| 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 dy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function uo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var vA={exports:{}},nx={};var YU;function wre(){if(YU)return nx;YU=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 nx.Fragment=e,nx.jsx=n,nx.jsxs=n,nx}var ZU;function Sre(){return ZU||(ZU=1,vA.exports=wre()),vA.exports}var l=Sre(),yA={exports:{}},Qt={};var QU;function Ere(){if(QU)return Qt;QU=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,ee){this.props=U,this.context=z,this.refs=v,this.updater=ee||x}b.prototype.isReactComponent={},b.prototype.setState=function(U,z){if(typeof U!="object"&&typeof U!="function"&&U!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,U,z,"setState")},b.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function E(){}E.prototype=b.prototype;function w(U,z,ee){this.props=U,this.context=z,this.refs=v,this.updater=ee||x}var A=w.prototype=new E;A.constructor=w,y(A,b.prototype),A.isPureReactComponent=!0;var T=Array.isArray;function k(){}var N={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function C(U,z,ee){var ae=ee.ref;return{$$typeof:t,type:U,key:z,ref:ae!==void 0?ae:null,props:ee}}function D(U,z){return C(U.type,z,U.props)}function F(U){return typeof U=="object"&&U!==null&&U.$$typeof===t}function j(U){var z={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(ee){return z[ee]})}var q=/\/+/g;function R(U,z){return typeof U=="object"&&U!==null&&U.key!=null?j(""+U.key):z.toString(36)}function W(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(k,k):(U.status="pending",U.then(function(z){U.status==="pending"&&(U.status="fulfilled",U.value=z)},function(z){U.status==="pending"&&(U.status="rejected",U.reason=z)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function K(U,z,ee,ae,fe){var de=typeof U;(de==="undefined"||de==="boolean")&&(U=null);var xe=!1;if(U===null)xe=!0;else switch(de){case"bigint":case"string":case"number":xe=!0;break;case"object":switch(U.$$typeof){case t:case e:xe=!0;break;case d:return xe=U._init,K(xe(U._payload),z,ee,ae,fe)}}if(xe)return fe=fe(U),xe=ae===""?"."+R(U,0):ae,T(fe)?(ee="",xe!=null&&(ee=xe.replace(q,"$&/")+"/"),K(fe,z,ee,"",function(ve){return ve})):fe!=null&&(F(fe)&&(fe=D(fe,ee+(fe.key==null||U&&U.key===fe.key?"":(""+fe.key).replace(q,"$&/")+"/")+xe)),z.push(fe)),1;xe=0;var ye=ae===""?".":ae+":";if(T(U))for(var re=0;re<U.length;re++)ae=U[re],de=ye+R(ae,re),xe+=K(ae,z,ee,de,fe);else if(re=m(U),typeof re=="function")for(U=re.call(U),re=0;!(ae=U.next()).done;)ae=ae.value,de=ye+R(ae,re++),xe+=K(ae,z,ee,de,fe);else if(de==="object"){if(typeof U.then=="function")return K(W(U),z,ee,ae,fe);throw z=String(U),Error("Objects are not valid as a React child (found: "+(z==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":z)+"). If you meant to render a collection of children, use an array instead.")}return xe}function V(U,z,ee){if(U==null)return U;var ae=[],fe=0;return K(U,ae,"","",function(de){return z.call(ee,de,fe++)}),ae}function te(U){if(U._status===-1){var z=U._result;z=z(),z.then(function(ee){(U._status===0||U._status===-1)&&(U._status=1,U._result=ee)},function(ee){(U._status===0||U._status===-1)&&(U._status=2,U._result=ee)}),U._status===-1&&(U._status=0,U._result=z)}if(U._status===1)return U._result.default;throw U._result}var Y=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof U=="object"&&U!==null&&typeof U.message=="string"?String(U.message):String(U),error:U});if(!window.dispatchEvent(z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",U);return}console.error(U)},Z={map:V,forEach:function(U,z,ee){V(U,function(){z.apply(this,arguments)},ee)},count:function(U){var z=0;return V(U,function(){z++}),z},toArray:function(U){return V(U,function(z){return z})||[]},only:function(U){if(!F(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return Qt.Activity=f,Qt.Children=Z,Qt.Component=b,Qt.Fragment=n,Qt.Profiler=i,Qt.PureComponent=w,Qt.StrictMode=r,Qt.Suspense=c,Qt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,Qt.__COMPILER_RUNTIME={__proto__:null,c:function(U){return N.H.useMemoCache(U)}},Qt.cache=function(U){return function(){return U.apply(null,arguments)}},Qt.cacheSignal=function(){return null},Qt.cloneElement=function(U,z,ee){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var ae=y({},U.props),fe=U.key;if(z!=null)for(de in z.key!==void 0&&(fe=""+z.key),z)!I.call(z,de)||de==="key"||de==="__self"||de==="__source"||de==="ref"&&z.ref===void 0||(ae[de]=z[de]);var de=arguments.length-2;if(de===1)ae.children=ee;else if(1<de){for(var xe=Array(de),ye=0;ye<de;ye++)xe[ye]=arguments[ye+2];ae.children=xe}return C(U.type,fe,ae)},Qt.createContext=function(U){return U={$$typeof:a,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:s,_context:U},U},Qt.createElement=function(U,z,ee){var ae,fe={},de=null;if(z!=null)for(ae in z.key!==void 0&&(de=""+z.key),z)I.call(z,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(fe[ae]=z[ae]);var xe=arguments.length-2;if(xe===1)fe.children=ee;else if(1<xe){for(var ye=Array(xe),re=0;re<xe;re++)ye[re]=arguments[re+2];fe.children=ye}if(U&&U.defaultProps)for(ae in xe=U.defaultProps,xe)fe[ae]===void 0&&(fe[ae]=xe[ae]);return C(U,de,fe)},Qt.createRef=function(){return{current:null}},Qt.forwardRef=function(U){return{$$typeof:o,render:U}},Qt.isValidElement=F,Qt.lazy=function(U){return{$$typeof:d,_payload:{_status:-1,_result:U},_init:te}},Qt.memo=function(U,z){return{$$typeof:u,type:U,compare:z===void 0?null:z}},Qt.startTransition=function(U){var z=N.T,ee={};N.T=ee;try{var ae=U(),fe=N.S;fe!==null&&fe(ee,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(k,Y)}catch(de){Y(de)}finally{z!==null&&ee.types!==null&&(z.types=ee.types),N.T=z}},Qt.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},Qt.use=function(U){return N.H.use(U)},Qt.useActionState=function(U,z,ee){return N.H.useActionState(U,z,ee)},Qt.useCallback=function(U,z){return N.H.useCallback(U,z)},Qt.useContext=function(U){return N.H.useContext(U)},Qt.useDebugValue=function(){},Qt.useDeferredValue=function(U,z){return N.H.useDeferredValue(U,z)},Qt.useEffect=function(U,z){return N.H.useEffect(U,z)},Qt.useEffectEvent=function(U){return N.H.useEffectEvent(U)},Qt.useId=function(){return N.H.useId()},Qt.useImperativeHandle=function(U,z,ee){return N.H.useImperativeHandle(U,z,ee)},Qt.useInsertionEffect=function(U,z){return N.H.useInsertionEffect(U,z)},Qt.useLayoutEffect=function(U,z){return N.H.useLayoutEffect(U,z)},Qt.useMemo=function(U,z){return N.H.useMemo(U,z)},Qt.useOptimistic=function(U,z){return N.H.useOptimistic(U,z)},Qt.useReducer=function(U,z,ee){return N.H.useReducer(U,z,ee)},Qt.useRef=function(U){return N.H.useRef(U)},Qt.useState=function(U){return N.H.useState(U)},Qt.useSyncExternalStore=function(U,z,ee){return N.H.useSyncExternalStore(U,z,ee)},Qt.useTransition=function(){return N.H.useTransition()},Qt.version="19.2.0",Qt}var JU;function $m(){return JU||(JU=1,yA.exports=Ere()),yA.exports}var M=$m();const mr=uo(M),Mre=_re({__proto__:null,default:mr},[M]);var _A={exports:{}},rx={},wA={exports:{}},SA={};var e5;function Are(){return e5||(e5=1,(function(t){function e(K,V){var te=K.length;K.push(V);e:for(;0<te;){var Y=te-1>>>1,Z=K[Y];if(0<i(Z,V))K[Y]=V,K[te]=Z,te=Y;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var V=K[0],te=K.pop();if(te!==V){K[0]=te;e:for(var Y=0,Z=K.length,U=Z>>>1;Y<U;){var z=2*(Y+1)-1,ee=K[z],ae=z+1,fe=K[ae];if(0>i(ee,te))ae<Z&&0>i(fe,ee)?(K[Y]=fe,K[ae]=te,Y=ae):(K[Y]=ee,K[z]=te,Y=z);else if(ae<Z&&0>i(fe,te))K[Y]=fe,K[ae]=te,Y=ae;else break e}}return V}function i(K,V){var te=K.sortIndex-V.sortIndex;return te!==0?te:K.id-V.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();t.unstable_now=function(){return a.now()-o}}var 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,w=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 te=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 Z=Y(f.expirationTime<=K);if(K=t.unstable_now(),typeof Z=="function"){f.callback=Z,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=te,m=!1}V=void 0}}finally{V?j():k=!1}}}var j;if(typeof w=="function")j=function(){w(F)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,R=q.port2;q.port1.onmessage=F,j=function(){R.postMessage(null)}}else j=function(){b(F,0)};function W(K,V){N=b(function(){K(t.unstable_now())},V)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(K){switch(g){case 1:case 2:case 3:var V=3;break;default:V=g}var te=g;g=V;try{return K()}finally{g=te}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function(K,V){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var te=g;g=K;try{return V()}finally{g=te}},t.unstable_scheduleCallback=function(K,V,te){var Y=t.unstable_now();switch(typeof te=="object"&&te!==null?(te=te.delay,te=typeof te=="number"&&0<te?Y+te:Y):te=Y,K){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=te+Z,K={id:d++,callback:V,priorityLevel:K,startTime:te,expirationTime:Z,sortIndex:-1},te>Y?(K.sortIndex=te,e(u,K),n(c)===null&&K===n(u)&&(y?(E(N),N=-1):y=!0,W(T,te-Y))):(K.sortIndex=Z,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 te=g;g=V;try{return K.apply(this,arguments)}finally{g=te}}}})(SA)),SA}var t5;function Tre(){return t5||(t5=1,wA.exports=Are()),wA.exports}var EA={exports:{}},rs={};var n5;function Cre(){if(n5)return rs;n5=1;var t=$m();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 rs.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,rs.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)},rs.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()}},rs.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))},rs.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},rs.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})}},rs.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)},rs.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})}},rs.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)},rs.requestFormReset=function(c){r.d.r(c)},rs.unstable_batchedUpdates=function(c,u){return c(u)},rs.useFormState=function(c,u,d){return a.H.useFormState(c,u,d)},rs.useFormStatus=function(){return a.H.useHostTransitionStatus()},rs.version="19.2.0",rs}var r5;function gG(){if(r5)return EA.exports;r5=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 i5;function Nre(){if(i5)return rx;i5=1;var t=Tre(),e=$m(),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,S=p;;){var P=_.return;if(P===null)break;var O=P.alternate;if(O===null){if(S=P.return,S!==null){_=S;continue}break}if(P.child===O.child){for(O=P.child;O;){if(O===_)return c(P),h;if(O===S)return c(P),p;O=O.sibling}throw Error(r(188))}if(_.return!==S.return)_=P,S=O;else{for(var X=!1,oe=P.child;oe;){if(oe===_){X=!0,_=P,S=O;break}if(oe===S){X=!0,S=P,_=O;break}oe=oe.sibling}if(!X){for(oe=O.child;oe;){if(oe===_){X=!0,_=O,S=P;break}if(oe===S){X=!0,S=O,_=P;break}oe=oe.sibling}if(!X)throw Error(r(189))}}if(_.alternate!==S)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h: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"),w=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 w:return h.displayName||"Context";case E:return(h._context.displayName||"Context")+".Consumer";case A:var p=h.render;return h=h.displayName,h||(h=p.displayName||p.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case N:return p=h.displayName||null,p!==null?p:R(h.type)||"Memo";case I:p=h._payload,h=h._init;try{return R(h(p))}catch{}}return null}var W=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te={pending:!1,data:null,method:null,action:null},Y=[],Z=-1;function U(h){return{current:h}}function z(h){0>Z||(h.current=Y[Z],Y[Z]=null,Z--)}function ee(h,p){Z++,Y[Z]=h.current,h.current=p}var ae=U(null),fe=U(null),de=U(null),xe=U(null);function ye(h,p){switch(ee(de,p),ee(fe,h),ee(ae,null),p.nodeType){case 9:case 11:h=(h=p.documentElement)&&(h=h.namespaceURI)?vU(h):0;break;default:if(h=p.tagName,p=p.namespaceURI)p=vU(p),h=yU(p,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}z(ae),ee(ae,h)}function re(){z(ae),z(fe),z(de)}function ve(h){h.memoizedState!==null&&ee(xe,h);var p=ae.current,_=yU(p,h.type);p!==_&&(ee(fe,h),ee(ae,_))}function je(h){fe.current===h&&(z(ae),z(fe)),xe.current===h&&(z(xe),Qg._currentValue=te)}var ue,ut;function $(h){if(ue===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);ue=p&&p[1]||"",ut=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+ue+h+ut}var H=!1;function ie(h,p){if(!h||H)return"";H=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var S={DetermineComponentFrameRoot:function(){try{if(p){var dt=function(){throw Error()};if(Object.defineProperty(dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(dt,[])}catch(it){var Qe=it}Reflect.construct(h,[],dt)}else{try{dt.call()}catch(it){Qe=it}h.call(dt.prototype)}}else{try{throw Error()}catch(it){Qe=it}(dt=h())&&typeof dt.catch=="function"&&dt.catch(function(){})}}catch(it){if(it&&Qe&&typeof it.stack=="string")return[it.stack,Qe.stack]}return[null,null]}};S.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(S.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(S.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var O=S.DetermineComponentFrameRoot(),X=O[0],oe=O[1];if(X&&oe){var Me=X.split(`
- `),Ke=oe.split(`
- `);for(P=S=0;S<Me.length&&!Me[S].includes("DetermineComponentFrameRoot");)S++;for(;P<Ke.length&&!Ke[P].includes("DetermineComponentFrameRoot");)P++;if(S===Me.length||P===Ke.length)for(S=Me.length-1,P=Ke.length-1;1<=S&&0<=P&&Me[S]!==Ke[P];)P--;for(;1<=S&&0<=P;S--,P--)if(Me[S]!==Ke[P]){if(S!==1||P!==1)do if(S--,P--,0>P||Me[S]!==Ke[P]){var lt=`
- `+Me[S].replace(" at new "," at ");return h.displayName&<.includes("<anonymous>")&&(lt=lt.replace("<anonymous>",h.displayName)),lt}while(1<=S&&0<=P);break}}}finally{H=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?$(_):""}function G(h,p){switch(h.tag){case 26:case 27:case 5:return $(h.type);case 16:return $("Lazy");case 13:return h.child!==p&&p!==null?$("Suspense Fallback"):$("Suspense");case 19:return $("SuspenseList");case 0:case 15:return ie(h.type,!1);case 11:return ie(h.type.render,!1);case 1:return ie(h.type,!0);case 31:return $("Activity");default:return""}}function J(h){try{var p="",_=null;do p+=G(h,_),_=h,h=h.return;while(h);return p}catch(S){return`
- Error generating stack: `+S.message+`
- `+S.stack}}var le=Object.prototype.hasOwnProperty,Pe=t.unstable_scheduleCallback,Ne=t.unstable_cancelCallback,Se=t.unstable_shouldYield,B=t.unstable_requestPaint,L=t.unstable_now,ne=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,we=t.unstable_UserBlockingPriority,ge=t.unstable_NormalPriority,me=t.unstable_LowPriority,Ae=t.unstable_IdlePriority,ze=t.log,st=t.unstable_setDisableYieldValue,Ve=null,ce=null;function Ye(h){if(typeof ze=="function"&&st(h),ce&&typeof ce.setStrictMode=="function")try{ce.setStrictMode(Ve,h)}catch{}}var $e=Math.clz32?Math.clz32:Q,Ze=Math.log,at=Math.LN2;function Q(h){return h>>>=0,h===0?32:31-(Ze(h)/at|0)|0}var Fe=256,pe=262144,Ue=4194304;function Ce(h){var p=h&42;if(p!==0)return p;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function _e(h,p,_){var S=h.pendingLanes;if(S===0)return 0;var P=0,O=h.suspendedLanes,X=h.pingedLanes;h=h.warmLanes;var oe=S&134217727;return oe!==0?(S=oe&~O,S!==0?P=Ce(S):(X&=oe,X!==0?P=Ce(X):_||(_=oe&~h,_!==0&&(P=Ce(_))))):(oe=S&~O,oe!==0?P=Ce(oe):X!==0?P=Ce(X):_||(_=S&~h,_!==0&&(P=Ce(_)))),P===0?0:p!==0&&p!==P&&(p&O)===0&&(O=P&-P,_=p&-p,O>=_||O===32&&(_&4194048)!==0)?p:P}function He(h,p){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&p)===0}function ht(h,p){switch(h){case 1:case 2:case 4:case 8:case 64:return p+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return p+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function wt(){var h=Ue;return Ue<<=1,(Ue&62914560)===0&&(Ue=4194304),h}function Ot(h){for(var p=[],_=0;31>_;_++)p.push(h);return p}function cn(h,p){h.pendingLanes|=p,p!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function It(h,p,_,S,P,O){var X=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var oe=h.entanglements,Me=h.expirationTimes,Ke=h.hiddenUpdates;for(_=X&~_;0<_;){var lt=31-$e(_),dt=1<<lt;oe[lt]=0,Me[lt]=-1;var Qe=Ke[lt];if(Qe!==null)for(Ke[lt]=null,lt=0;lt<Qe.length;lt++){var it=Qe[lt];it!==null&&(it.lane&=-536870913)}_&=~dt}S!==0&&Dn(h,S,0),O!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=O&~(X&~p))}function Dn(h,p,_){h.pendingLanes|=p,h.suspendedLanes&=~p;var S=31-$e(p);h.entangledLanes|=p,h.entanglements[S]=h.entanglements[S]|1073741824|_&261930}function Qn(h,p){var _=h.entangledLanes|=p;for(h=h.entanglements;_;){var S=31-$e(_),P=1<<S;P&p|h[S]&p&&(h[S]|=p),_&=~P}}function Si(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 Ei(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Fi(){var h=V.p;return h!==0?h:(h=window.event,h===void 0?32:$U(h.type))}function ns(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,fo="__reactContainer$"+Hr,Hc="__reactEvents$"+Hr,he="__reactListeners$"+Hr,Ge="__reactHandles$"+Hr,nt="__reactResources$"+Hr,rt="__reactMarker$"+Hr;function et(h){delete h[br],delete h[Or],delete h[Hc],delete h[he],delete h[Ge]}function St(h){var p=h[br];if(p)return p;for(var _=h.parentNode;_;){if(p=_[fo]||_[br]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(h=TU(h);h!==null;){if(_=h[br])return _;h=TU(h)}return p}h=_,_=h.parentNode}return null}function se(h){if(h=h[br]||h[fo]){var p=h.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return h}return null}function Ee(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h.stateNode;throw Error(r(33))}function Le(h){var p=h[nt];return p||(p=h[nt]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Oe(h){h[rt]=!0}var Te=new Set,ot={};function ft(h,p){bt(h,p),bt(h+"Capture",p)}function bt(h,p){for(ot[h]=p,h=0;h<p.length;h++)Te.add(p[h])}var xt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),jt={},Mt={};function mt(h){return le.call(Mt,h)?!0:le.call(jt,h)?!1:xt.test(h)?Mt[h]=!0:(jt[h]=!0,!1)}function Kt(h,p,_){if(mt(p))if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(p);return;case"boolean":var S=p.toLowerCase().slice(0,5);if(S!=="data-"&&S!=="aria-"){h.removeAttribute(p);return}}h.setAttribute(p,""+_)}}function Ft(h,p,_){if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(p);return}h.setAttribute(p,""+_)}}function nn(h,p,_,S){if(S===null)h.removeAttribute(_);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(p,_,""+S)}}function dn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function xn(h){var p=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Ut(h,p,_){var S=Object.getOwnPropertyDescriptor(h.constructor.prototype,p);if(!h.hasOwnProperty(p)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var P=S.get,O=S.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:S.enumerable}),{getValue:function(){return _},setValue:function(X){_=""+X},stopTracking:function(){h._valueTracker=null,delete h[p]}}}}function Zt(h){if(!h._valueTracker){var p=xn(h)?"checked":"value";h._valueTracker=Ut(h,p,""+h[p])}}function Jt(h){if(!h)return!1;var p=h._valueTracker;if(!p)return!0;var _=p.getValue(),S="";return h&&(S=xn(h)?h.checked?"true":"false":h.value),h=S,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 Pn(h){return h.replace(jr,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function po(h,p,_,S,P,O,X,oe){h.name="",X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?h.type=X:h.removeAttribute("type"),p!=null?X==="number"?(p===0&&h.value===""||h.value!=p)&&(h.value=""+dn(p)):h.value!==""+dn(p)&&(h.value=""+dn(p)):X!=="submit"&&X!=="reset"||h.removeAttribute("value"),p!=null?Mi(h,X,dn(p)):_!=null?Mi(h,X,dn(_)):S!=null&&h.removeAttribute("value"),P==null&&O!=null&&(h.defaultChecked=!!O),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),oe!=null&&typeof oe!="function"&&typeof oe!="symbol"&&typeof oe!="boolean"?h.name=""+dn(oe):h.removeAttribute("name")}function On(h,p,_,S,P,O,X,oe){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(h.type=O),p!=null||_!=null){if(!(O!=="submit"&&O!=="reset"||p!=null)){Zt(h);return}_=_!=null?""+dn(_):"",p=p!=null?""+dn(p):_,oe||p===h.value||(h.value=p),h.defaultValue=p}S=S??P,S=typeof S!="function"&&typeof S!="symbol"&&!!S,h.checked=oe?h.checked:!!S,h.defaultChecked=!!S,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(h.name=X),Zt(h)}function Mi(h,p,_){p==="number"&&Ar(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function oi(h,p,_,S){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&&S&&(h[_].defaultSelected=!0)}else{for(_=""+dn(_),p=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,S&&(h[P].defaultSelected=!0);return}p!==null||h[P].disabled||(p=h[P])}p!==null&&(p.selected=!0)}}function Ai(h,p,_){if(p!=null&&(p=""+dn(p),p!==h.value&&(h.value=p),_==null)){h.defaultValue!==p&&(h.defaultValue=p);return}h.defaultValue=_!=null?""+dn(_):""}function zi(h,p,_,S){if(p==null){if(S!=null){if(_!=null)throw Error(r(92));if(W(S)){if(1<S.length)throw Error(r(93));S=S[0]}_=S}_==null&&(_=""),p=_}_=dn(p),h.defaultValue=_,S=h.textContent,S===_&&S!==""&&S!==null&&(h.value=S),Zt(h)}function $o(h,p){if(p){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=p;return}}h.textContent=p}var Ml=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function gL(h,p,_){var S=p.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?S?h.setProperty(p,""):p==="float"?h.cssFloat="":h[p]="":S?h.setProperty(p,_):typeof _!="number"||_===0||Ml.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 S in _)!_.hasOwnProperty(S)||p!=null&&p.hasOwnProperty(S)||(S.indexOf("--")===0?h.setProperty(S,""):S==="float"?h.cssFloat="":h[S]="");for(var P in p)S=p[P],p.hasOwnProperty(P)&&_[P]!==S&&gL(h,P,S)}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 nv(h){return bte.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Al(){}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=se(h);if(p&&(h=p.stateNode)){var _=h[Or]||null;e:switch(h=p.stateNode,p.type){case"input":if(po(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Pn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var S=_[p];if(S!==h&&S.form===h.form){var P=S[Or]||null;if(!P)throw Error(r(90));po(S,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(p=0;p<_.length;p++)S=_[p],S.form===h.form&&Jt(S)}break e;case"textarea":Ai(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 S=h(p);return S}finally{if(bM=!1,(bf!==null||vf!==null)&&($v(),bf&&(p=bf,h=vf,vf=bf=null,bL(p),h)))for(p=0;p<h.length;p++)bL(h[p])}}function mg(h,p){var _=h.stateNode;if(_===null)return null;var S=_[Or]||null;if(S===null)return null;_=S[p];e:switch(p){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(S=!S.disabled)||(h=h.type,S=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!S;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,p,typeof _));return _}var Tl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vM=!1;if(Tl)try{var gg={};Object.defineProperty(gg,"passive",{get:function(){vM=!0}}),window.addEventListener("test",gg,gg),window.removeEventListener("test",gg,gg)}catch{vM=!1}var $c=null,yM=null,rv=null;function yL(){if(rv)return rv;var h,p=yM,_=p.length,S,P="value"in $c?$c.value:$c.textContent,O=P.length;for(h=0;h<_&&p[h]===P[h];h++);var X=_-h;for(S=1;S<=X&&p[_-S]===P[O-S];S++);return rv=P.slice(h,1<S?1-S:void 0)}function iv(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 sv(){return!0}function _L(){return!1}function js(h){function p(_,S,P,O,X){this._reactName=_,this._targetInst=P,this.type=S,this.nativeEvent=O,this.target=X,this.currentTarget=null;for(var oe in h)h.hasOwnProperty(oe)&&(_=h[oe],this[oe]=_?_(O):O[oe]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?sv:_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=sv)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=sv)},persist:function(){},isPersistent:sv}),p}var Ad={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},av=js(Ad),xg=f({},Ad,{view:0,detail:0}),vte=js(xg),_M,wM,bg,ov=f({},xg,{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!==bg&&(bg&&h.type==="mousemove"?(_M=h.screenX-bg.screenX,wM=h.screenY-bg.screenY):wM=_M=0,bg=h),_M)},movementY:function(h){return"movementY"in h?h.movementY:wM}}),wL=js(ov),yte=f({},ov,{dataTransfer:0}),_te=js(yte),wte=f({},xg,{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({},xg,{key:function(h){if(h.key){var p=Cte[h.key]||h.key;if(p!=="Unidentified")return p}return h.type==="keypress"?(h=iv(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"?iv(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?iv(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Dte=js(Rte),Ote=f({},ov,{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({},xg,{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({},ov,{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=Tl&&"CompositionEvent"in window,vg=null;Tl&&"documentMode"in document&&(vg=document.documentMode);var Vte=Tl&&"TextEvent"in window&&!vg,ML=Tl&&(!MM||vg&&8<vg&&11>=vg),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(),rv=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,_,S){bf?vf?vf.push(S):vf=[S]:bf=S,p=Yv(p,"onChange"),0<p.length&&(_=new av("onChange","change",null,_,S),h.push({event:_,listeners:p}))}var yg=null,_g=null;function Kte(h){fU(h,0)}function lv(h){var p=Ee(h);if(Jt(p))return h}function RL(h,p){if(h==="change")return p}var DL=!1;if(Tl){var AM;if(Tl){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(){yg&&(yg.detachEvent("onpropertychange",LL),_g=yg=null)}function LL(h){if(h.propertyName==="value"&&lv(_g)){var p=[];PL(p,_g,h,xM(h)),vL(Kte,p)}}function Xte(h,p,_){h==="focusin"?(jL(),yg=p,_g=_,yg.attachEvent("onpropertychange",LL)):h==="focusout"&&jL()}function Yte(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return lv(_g)}function Zte(h,p){if(h==="click")return lv(p)}function Qte(h,p){if(h==="input"||h==="change")return lv(p)}function Jte(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var ta=typeof Object.is=="function"?Object.is:Jte;function wg(h,p){if(ta(h,p))return!0;if(typeof h!="object"||h===null||typeof p!="object"||p===null)return!1;var _=Object.keys(h),S=Object.keys(p);if(_.length!==S.length)return!1;for(S=0;S<_.length;S++){var P=_[S];if(!le.call(p,P)||!ta(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 S;_;){if(_.nodeType===3){if(S=h+_.textContent.length,h<=p&&S>=p)return{node:_,offset:p-h};h=S}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=Tl&&"documentMode"in document&&11>=document.documentMode,_f=null,NM=null,Sg=null,kM=!1;function BL(h,p,_){var S=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;kM||_f==null||_f!==Ar(S)||(S=_f,"selectionStart"in S&&CM(S)?S={start:S.selectionStart,end:S.selectionEnd}:(S=(S.ownerDocument&&S.ownerDocument.defaultView||window).getSelection(),S={anchorNode:S.anchorNode,anchorOffset:S.anchorOffset,focusNode:S.focusNode,focusOffset:S.focusOffset}),Sg&&wg(Sg,S)||(Sg=S,S=Yv(NM,"onSelect"),0<S.length&&(p=new av("onSelect","select",null,p,_),h.push({event:p,listeners:S}),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={};Tl&&(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 mo(h,p){qL.set(h,p),ft(p,[h])}var cv=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)},Ta=[],Sf=0,DM=0;function uv(){for(var h=Sf,p=DM=Sf=0;p<h;){var _=Ta[p];Ta[p++]=null;var S=Ta[p];Ta[p++]=null;var P=Ta[p];Ta[p++]=null;var O=Ta[p];if(Ta[p++]=null,S!==null&&P!==null){var X=S.pending;X===null?P.next=P:(P.next=X.next,X.next=P),S.pending=P}O!==0&&KL(_,P,O)}}function dv(h,p,_,S){Ta[Sf++]=h,Ta[Sf++]=p,Ta[Sf++]=_,Ta[Sf++]=S,DM|=S,h.lanes|=S,h=h.alternate,h!==null&&(h.lanes|=S)}function OM(h,p,_,S){return dv(h,p,_,S),hv(h)}function Nd(h,p){return dv(h,null,null,p),hv(h)}function KL(h,p,_){h.lanes|=_;var S=h.alternate;S!==null&&(S.lanes|=_);for(var P=!1,O=h.return;O!==null;)O.childLanes|=_,S=O.alternate,S!==null&&(S.childLanes|=_),O.tag===22&&(h=O.stateNode,h===null||h._visibility&1||(P=!0)),h=O,O=O.return;return h.tag===3?(O=h.stateNode,P&&p!==null&&(P=31-$e(_),h=O.hiddenUpdates,S=h[P],S===null?h[P]=[p]:S.push(p),p.lane=_|536870912),O):null}function hv(h){if(50<Gg)throw Gg=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,_,S){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=S,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function na(h,p,_,S){return new ine(h,p,_,S)}function jM(h){return h=h.prototype,!(!h||!h.isReactComponent)}function Cl(h,p){var _=h.alternate;return _===null?(_=na(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 fv(h,p,_,S,P,O){var X=0;if(S=h,typeof h=="function")jM(h)&&(X=1);else if(typeof h=="string")X=cre(h,_,ae.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case C:return h=na(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=na(12,_,p,P|2),h.elementType=b,h.lanes=O,h;case T:return h=na(13,_,p,P),h.elementType=T,h.lanes=O,h;case k:return h=na(19,_,p,P),h.elementType=k,h.lanes=O,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case w:X=10;break e;case E:X=9;break e;case A:X=11;break e;case N:X=14;break e;case I:X=16,S=null;break e}X=29,_=Error(r(130,h===null?"null":typeof h,"")),S=null}return p=na(X,_,p,P),p.elementType=h,p.type=S,p.lanes=O,p}function kd(h,p,_,S){return h=na(7,h,S,p),h.lanes=_,h}function LM(h,p,_){return h=na(6,h,null,p),h.lanes=_,h}function YL(h){var p=na(18,null,null,0);return p.stateNode=h,p}function IM(h,p,_){return p=na(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 Ca(h,p){if(typeof h=="object"&&h!==null){var _=ZL.get(h);return _!==void 0?_:(p={value:h,source:p,stack:J(p)},ZL.set(h,p),p)}return{value:h,source:p,stack:J(p)}}var Mf=[],Af=0,pv=null,Eg=0,Na=[],ka=0,Vc=null,Vo=1,Go="";function Nl(h,p){Mf[Af++]=Eg,Mf[Af++]=pv,pv=h,Eg=p}function QL(h,p,_){Na[ka++]=Vo,Na[ka++]=Go,Na[ka++]=Vc,Vc=h;var S=Vo;h=Go;var P=32-$e(S)-1;S&=~(1<<P),_+=1;var O=32-$e(p)+P;if(30<O){var X=P-P%5;O=(S&(1<<X)-1).toString(32),S>>=X,P-=X,Vo=1<<32-$e(p)+P|_<<P|S,Go=O+h}else Vo=1<<O|_<<P|S,Go=h}function UM(h){h.return!==null&&(Nl(h,1),QL(h,1,0))}function FM(h){for(;h===pv;)pv=Mf[--Af],Mf[Af]=null,Eg=Mf[--Af],Mf[Af]=null;for(;h===Vc;)Vc=Na[--ka],Na[ka]=null,Go=Na[--ka],Na[ka]=null,Vo=Na[--ka],Na[ka]=null}function JL(h,p){Na[ka++]=Vo,Na[ka++]=Go,Na[ka++]=Vc,Vo=p.id,Go=p.overflow,Vc=h}var Bi=null,ar=null,_n=!1,Gc=null,Pa=!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 Mg(Ca(p,h)),zM}function eI(h){var p=h.stateNode,_=h.type,S=h.memoizedProps;switch(p[br]=h,p[Or]=S,_){case"dialog":pn("cancel",p),pn("close",p);break;case"iframe":case"object":case"embed":pn("load",p);break;case"video":case"audio":for(_=0;_<qg.length;_++)pn(qg[_],p);break;case"source":pn("error",p);break;case"img":case"image":case"link":pn("error",p),pn("load",p);break;case"details":pn("toggle",p);break;case"input":pn("invalid",p),On(p,S.value,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name,!0);break;case"select":pn("invalid",p);break;case"textarea":pn("invalid",p),zi(p,S.value,S.defaultValue,S.children)}_=S.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||S.suppressHydrationWarning===!0||xU(p.textContent,_)?(S.popover!=null&&(pn("beforetoggle",p),pn("toggle",p)),S.onScroll!=null&&pn("scroll",p),S.onScrollEnd!=null&&pn("scrollend",p),S.onClick!=null&&(p.onclick=Al),p=!0):p=!1,p||Wc(h,!0)}function tI(h){for(Bi=h.return;Bi;)switch(Bi.tag){case 5:case 31:case 13:Pa=!1;return;case 27:case 3:Pa=!0;return;default:Bi=Bi.return}}function Tf(h){if(h!==Bi)return!1;if(!_n)return tI(h),_n=!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=AU(h)}else if(p===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));ar=AU(h)}else p===27?(p=ar,au(h.type)?(h=cA,cA=null,ar=h):ar=p):ar=Bi?Da(h.stateNode.nextSibling):null;return!0}function Pd(){ar=Bi=null,_n=!1}function BM(){var h=Gc;return h!==null&&(Fs===null?Fs=h:Fs.push.apply(Fs,h),Gc=null),h}function Mg(h){Gc===null?Gc=[h]:Gc.push(h)}var HM=U(null),Rd=null,kl=null;function qc(h,p,_){ee(HM,p._currentValue),p._currentValue=_}function Pl(h){h._currentValue=HM.current,z(HM)}function $M(h,p,_){for(;h!==null;){var S=h.alternate;if((h.childLanes&p)!==p?(h.childLanes|=p,S!==null&&(S.childLanes|=p)):S!==null&&(S.childLanes&p)!==p&&(S.childLanes|=p),h===_)break;h=h.return}}function VM(h,p,_,S){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var O=P.dependencies;if(O!==null){var X=P.child;O=O.firstContext;e:for(;O!==null;){var oe=O;O=P;for(var Me=0;Me<p.length;Me++)if(oe.context===p[Me]){O.lanes|=_,oe=O.alternate,oe!==null&&(oe.lanes|=_),$M(O.return,_,h),S||(X=null);break e}O=oe.next}}else if(P.tag===18){if(X=P.return,X===null)throw Error(r(341));X.lanes|=_,O=X.alternate,O!==null&&(O.lanes|=_),$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,_,S){h=null;for(var P=p,O=!1;P!==null;){if(!O){if((P.flags&524288)!==0)O=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var X=P.alternate;if(X===null)throw Error(r(387));if(X=X.memoizedProps,X!==null){var oe=P.type;ta(P.pendingProps.value,X.value)||(h!==null?h.push(oe):h=[oe])}}else if(P===xe.current){if(X=P.alternate,X===null)throw Error(r(387));X.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Qg):h=[Qg])}P=P.return}h!==null&&VM(p,h,_,S),p.flags|=262144}function mv(h){for(h=h.firstContext;h!==null;){if(!ta(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Dd(h){Rd=h,kl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function Hi(h){return nI(Rd,h)}function gv(h,p){return Rd===null&&Dd(h),nI(h,p)}function nI(h,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},kl===null){if(h===null)throw Error(r(308));kl=p,h.dependencies={lanes:0,firstContext:p},h.flags|=524288}else kl=kl.next=p;return _}var sne=typeof AbortController<"u"?AbortController:function(){var h=[],p=this.signal={aborted:!1,addEventListener:function(_,S){h.push(S)}};this.abort=function(){p.aborted=!0,h.forEach(function(_){return _()})}},ane=t.unstable_scheduleCallback,one=t.unstable_NormalPriority,$r={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function GM(){return{controller:new sne,data:new Map,refCount:0}}function Ag(h){h.refCount--,h.refCount===0&&ane(one,function(){h.controller.abort()})}var Tg=null,WM=0,Nf=0,kf=null;function lne(h,p){if(Tg===null){var _=Tg=[];WM=0,Nf=X2(),kf={status:"pending",value:void 0,then:function(S){_.push(S)}}}return WM++,p.then(rI,rI),p}function rI(){if(--WM===0&&Tg!==null){kf!==null&&(kf.status="fulfilled");var h=Tg;Tg=null,Nf=0,kf=null;for(var p=0;p<h.length;p++)(0,h[p])()}}function cne(h,p){var _=[],S={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){S.status="fulfilled",S.value=p;for(var P=0;P<_.length;P++)(0,_[P])(p)},function(P){for(S.status="rejected",S.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),S}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 xv(h,p){p===null?ee(Od,Od.current):ee(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)),bv=Error(r(542)),vv={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(Al,Al),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(Al,Al);else{if(h=Jn,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=p,h.status="pending",h.then(function(S){if(p.status==="pending"){var P=p;P.status="fulfilled",P.value=S}},function(S){if(p.status==="pending"){var P=p;P.status="rejected",P.reason=S}})}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===bv)throw Error(r(483))}var Rf=null,Cg=0;function yv(h){var p=Cg;return Cg+=1,Rf===null&&(Rf=[]),oI(Rf,h,p)}function Ng(h,p){p=p.props.ref,h.ref=p!==void 0?p:null}function _v(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(Be,Re){if(h){var qe=Be.deletions;qe===null?(Be.deletions=[Re],Be.flags|=16):qe.push(Re)}}function _(Be,Re){if(!h)return null;for(;Re!==null;)p(Be,Re),Re=Re.sibling;return null}function S(Be){for(var Re=new Map;Be!==null;)Be.key!==null?Re.set(Be.key,Be):Re.set(Be.index,Be),Be=Be.sibling;return Re}function P(Be,Re){return Be=Cl(Be,Re),Be.index=0,Be.sibling=null,Be}function O(Be,Re,qe){return Be.index=qe,h?(qe=Be.alternate,qe!==null?(qe=qe.index,qe<Re?(Be.flags|=67108866,Re):qe):(Be.flags|=67108866,Re)):(Be.flags|=1048576,Re)}function X(Be){return h&&Be.alternate===null&&(Be.flags|=67108866),Be}function oe(Be,Re,qe,ct){return Re===null||Re.tag!==6?(Re=LM(qe,Be.mode,ct),Re.return=Be,Re):(Re=P(Re,qe),Re.return=Be,Re)}function Me(Be,Re,qe,ct){var zt=qe.type;return zt===y?lt(Be,Re,qe.props.children,ct,qe.key):Re!==null&&(Re.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&jd(zt)===Re.type)?(Re=P(Re,qe.props),Ng(Re,qe),Re.return=Be,Re):(Re=fv(qe.type,qe.key,qe.props,null,Be.mode,ct),Ng(Re,qe),Re.return=Be,Re)}function Ke(Be,Re,qe,ct){return Re===null||Re.tag!==4||Re.stateNode.containerInfo!==qe.containerInfo||Re.stateNode.implementation!==qe.implementation?(Re=IM(qe,Be.mode,ct),Re.return=Be,Re):(Re=P(Re,qe.children||[]),Re.return=Be,Re)}function lt(Be,Re,qe,ct,zt){return Re===null||Re.tag!==7?(Re=kd(qe,Be.mode,ct,zt),Re.return=Be,Re):(Re=P(Re,qe),Re.return=Be,Re)}function dt(Be,Re,qe){if(typeof Re=="string"&&Re!==""||typeof Re=="number"||typeof Re=="bigint")return Re=LM(""+Re,Be.mode,qe),Re.return=Be,Re;if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case m:return qe=fv(Re.type,Re.key,Re.props,null,Be.mode,qe),Ng(qe,Re),qe.return=Be,qe;case x:return Re=IM(Re,Be.mode,qe),Re.return=Be,Re;case I:return Re=jd(Re),dt(Be,Re,qe)}if(W(Re)||j(Re))return Re=kd(Re,Be.mode,qe,null),Re.return=Be,Re;if(typeof Re.then=="function")return dt(Be,yv(Re),qe);if(Re.$$typeof===w)return dt(Be,gv(Be,Re),qe);_v(Be,Re)}return null}function Qe(Be,Re,qe,ct){var zt=Re!==null?Re.key:null;if(typeof qe=="string"&&qe!==""||typeof qe=="number"||typeof qe=="bigint")return zt!==null?null:oe(Be,Re,""+qe,ct);if(typeof qe=="object"&&qe!==null){switch(qe.$$typeof){case m:return qe.key===zt?Me(Be,Re,qe,ct):null;case x:return qe.key===zt?Ke(Be,Re,qe,ct):null;case I:return qe=jd(qe),Qe(Be,Re,qe,ct)}if(W(qe)||j(qe))return zt!==null?null:lt(Be,Re,qe,ct,null);if(typeof qe.then=="function")return Qe(Be,Re,yv(qe),ct);if(qe.$$typeof===w)return Qe(Be,Re,gv(Be,qe),ct);_v(Be,qe)}return null}function it(Be,Re,qe,ct,zt){if(typeof ct=="string"&&ct!==""||typeof ct=="number"||typeof ct=="bigint")return Be=Be.get(qe)||null,oe(Re,Be,""+ct,zt);if(typeof ct=="object"&&ct!==null){switch(ct.$$typeof){case m:return Be=Be.get(ct.key===null?qe:ct.key)||null,Me(Re,Be,ct,zt);case x:return Be=Be.get(ct.key===null?qe:ct.key)||null,Ke(Re,Be,ct,zt);case I:return ct=jd(ct),it(Be,Re,qe,ct,zt)}if(W(ct)||j(ct))return Be=Be.get(qe)||null,lt(Re,Be,ct,zt,null);if(typeof ct.then=="function")return it(Be,Re,qe,yv(ct),zt);if(ct.$$typeof===w)return it(Be,Re,qe,gv(Re,ct),zt);_v(Re,ct)}return null}function Rt(Be,Re,qe,ct){for(var zt=null,Mn=null,Lt=Re,tn=Re=0,vn=null;Lt!==null&&tn<qe.length;tn++){Lt.index>tn?(vn=Lt,Lt=null):vn=Lt.sibling;var An=Qe(Be,Lt,qe[tn],ct);if(An===null){Lt===null&&(Lt=vn);break}h&&Lt&&An.alternate===null&&p(Be,Lt),Re=O(An,Re,tn),Mn===null?zt=An:Mn.sibling=An,Mn=An,Lt=vn}if(tn===qe.length)return _(Be,Lt),_n&&Nl(Be,tn),zt;if(Lt===null){for(;tn<qe.length;tn++)Lt=dt(Be,qe[tn],ct),Lt!==null&&(Re=O(Lt,Re,tn),Mn===null?zt=Lt:Mn.sibling=Lt,Mn=Lt);return _n&&Nl(Be,tn),zt}for(Lt=S(Lt);tn<qe.length;tn++)vn=it(Lt,Be,tn,qe[tn],ct),vn!==null&&(h&&vn.alternate!==null&&Lt.delete(vn.key===null?tn:vn.key),Re=O(vn,Re,tn),Mn===null?zt=vn:Mn.sibling=vn,Mn=vn);return h&&Lt.forEach(function(du){return p(Be,du)}),_n&&Nl(Be,tn),zt}function Vt(Be,Re,qe,ct){if(qe==null)throw Error(r(151));for(var zt=null,Mn=null,Lt=Re,tn=Re=0,vn=null,An=qe.next();Lt!==null&&!An.done;tn++,An=qe.next()){Lt.index>tn?(vn=Lt,Lt=null):vn=Lt.sibling;var du=Qe(Be,Lt,An.value,ct);if(du===null){Lt===null&&(Lt=vn);break}h&&Lt&&du.alternate===null&&p(Be,Lt),Re=O(du,Re,tn),Mn===null?zt=du:Mn.sibling=du,Mn=du,Lt=vn}if(An.done)return _(Be,Lt),_n&&Nl(Be,tn),zt;if(Lt===null){for(;!An.done;tn++,An=qe.next())An=dt(Be,An.value,ct),An!==null&&(Re=O(An,Re,tn),Mn===null?zt=An:Mn.sibling=An,Mn=An);return _n&&Nl(Be,tn),zt}for(Lt=S(Lt);!An.done;tn++,An=qe.next())An=it(Lt,Be,tn,An.value,ct),An!==null&&(h&&An.alternate!==null&&Lt.delete(An.key===null?tn:An.key),Re=O(An,Re,tn),Mn===null?zt=An:Mn.sibling=An,Mn=An);return h&&Lt.forEach(function(yre){return p(Be,yre)}),_n&&Nl(Be,tn),zt}function Vn(Be,Re,qe,ct){if(typeof qe=="object"&&qe!==null&&qe.type===y&&qe.key===null&&(qe=qe.props.children),typeof qe=="object"&&qe!==null){switch(qe.$$typeof){case m:e:{for(var zt=qe.key;Re!==null;){if(Re.key===zt){if(zt=qe.type,zt===y){if(Re.tag===7){_(Be,Re.sibling),ct=P(Re,qe.props.children),ct.return=Be,Be=ct;break e}}else if(Re.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&jd(zt)===Re.type){_(Be,Re.sibling),ct=P(Re,qe.props),Ng(ct,qe),ct.return=Be,Be=ct;break e}_(Be,Re);break}else p(Be,Re);Re=Re.sibling}qe.type===y?(ct=kd(qe.props.children,Be.mode,ct,qe.key),ct.return=Be,Be=ct):(ct=fv(qe.type,qe.key,qe.props,null,Be.mode,ct),Ng(ct,qe),ct.return=Be,Be=ct)}return X(Be);case x:e:{for(zt=qe.key;Re!==null;){if(Re.key===zt)if(Re.tag===4&&Re.stateNode.containerInfo===qe.containerInfo&&Re.stateNode.implementation===qe.implementation){_(Be,Re.sibling),ct=P(Re,qe.children||[]),ct.return=Be,Be=ct;break e}else{_(Be,Re);break}else p(Be,Re);Re=Re.sibling}ct=IM(qe,Be.mode,ct),ct.return=Be,Be=ct}return X(Be);case I:return qe=jd(qe),Vn(Be,Re,qe,ct)}if(W(qe))return Rt(Be,Re,qe,ct);if(j(qe)){if(zt=j(qe),typeof zt!="function")throw Error(r(150));return qe=zt.call(qe),Vt(Be,Re,qe,ct)}if(typeof qe.then=="function")return Vn(Be,Re,yv(qe),ct);if(qe.$$typeof===w)return Vn(Be,Re,gv(Be,qe),ct);_v(Be,qe)}return typeof qe=="string"&&qe!==""||typeof qe=="number"||typeof qe=="bigint"?(qe=""+qe,Re!==null&&Re.tag===6?(_(Be,Re.sibling),ct=P(Re,qe),ct.return=Be,Be=ct):(_(Be,Re),ct=LM(qe,Be.mode,ct),ct.return=Be,Be=ct),X(Be)):_(Be,Re)}return function(Be,Re,qe,ct){try{Cg=0;var zt=Vn(Be,Re,qe,ct);return Rf=null,zt}catch(Lt){if(Lt===Pf||Lt===bv)throw Lt;var Mn=na(29,Lt,null,Be.mode);return Mn.lanes=ct,Mn.return=Be,Mn}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 S=h.updateQueue;if(S===null)return null;if(S=S.shared,(Nn&2)!==0){var P=S.pending;return P===null?p.next=p:(p.next=P.next,P.next=p),S.pending=p,p=hv(h),KL(h,null,_),p}return dv(h,S,p,_),hv(h)}function kg(h,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var S=p.lanes;S&=h.pendingLanes,_|=S,p.lanes=_,Qn(h,_)}}function ZM(h,p){var _=h.updateQueue,S=h.alternate;if(S!==null&&(S=S.updateQueue,_===S)){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:S.baseState,firstBaseUpdate:P,lastBaseUpdate:O,shared:S.shared,callbacks:S.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=p:h.next=p,_.lastBaseUpdate=p}var QM=!1;function Pg(){if(QM){var h=kf;if(h!==null)throw h}}function Rg(h,p,_,S){QM=!1;var P=h.updateQueue;Kc=!1;var O=P.firstBaseUpdate,X=P.lastBaseUpdate,oe=P.shared.pending;if(oe!==null){P.shared.pending=null;var Me=oe,Ke=Me.next;Me.next=null,X===null?O=Ke:X.next=Ke,X=Me;var lt=h.alternate;lt!==null&&(lt=lt.updateQueue,oe=lt.lastBaseUpdate,oe!==X&&(oe===null?lt.firstBaseUpdate=Ke:oe.next=Ke,lt.lastBaseUpdate=Me))}if(O!==null){var dt=P.baseState;X=0,lt=Ke=Me=null,oe=O;do{var Qe=oe.lane&-536870913,it=Qe!==oe.lane;if(it?(bn&Qe)===Qe:(S&Qe)===Qe){Qe!==0&&Qe===Nf&&(QM=!0),lt!==null&&(lt=lt.next={lane:0,tag:oe.tag,payload:oe.payload,callback:null,next:null});e:{var Rt=h,Vt=oe;Qe=p;var Vn=_;switch(Vt.tag){case 1:if(Rt=Vt.payload,typeof Rt=="function"){dt=Rt.call(Vn,dt,Qe);break e}dt=Rt;break e;case 3:Rt.flags=Rt.flags&-65537|128;case 0:if(Rt=Vt.payload,Qe=typeof Rt=="function"?Rt.call(Vn,dt,Qe):Rt,Qe==null)break e;dt=f({},dt,Qe);break e;case 2:Kc=!0}}Qe=oe.callback,Qe!==null&&(h.flags|=64,it&&(h.flags|=8192),it=P.callbacks,it===null?P.callbacks=[Qe]:it.push(Qe))}else it={lane:Qe,tag:oe.tag,payload:oe.payload,callback:oe.callback,next:null},lt===null?(Ke=lt=it,Me=dt):lt=lt.next=it,X|=Qe;if(oe=oe.next,oe===null){if(oe=P.shared.pending,oe===null)break;it=oe,oe=it.next,it.next=null,P.lastBaseUpdate=it,P.shared.pending=null}}while(!0);lt===null&&(Me=dt),P.baseState=Me,P.firstBaseUpdate=Ke,P.lastBaseUpdate=lt,O===null&&(P.shared.lanes=0),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),wv=U(0);function pI(h,p){h=zl,ee(wv,h),ee(Df,p),zl=h|p.baseLanes}function JM(){ee(wv,zl),ee(Df,Df.current)}function e2(){zl=wv.current,z(Df),z(wv)}var ra=U(null),Ra=null;function Zc(h){var p=h.alternate;ee(Lr,Lr.current&1),ee(ra,h),Ra===null&&(p===null||Df.current!==null||p.memoizedState!==null)&&(Ra=h)}function t2(h){ee(Lr,Lr.current),ee(ra,h),Ra===null&&(Ra=h)}function mI(h){h.tag===22?(ee(Lr,Lr.current),ee(ra,h),Ra===null&&(Ra=h)):Qc()}function Qc(){ee(Lr,Lr.current),ee(ra,ra.current)}function ia(h){z(ra),Ra===h&&(Ra=null),z(Lr)}var Lr=U(0);function Sv(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 Rl=0,en=null,Hn=null,Vr=null,Ev=!1,Of=!1,Ud=!1,Mv=0,Dg=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(!ta(h[_],p[_]))return!1;return!0}function r2(h,p,_,S,P,O){return Rl=O,en=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,K.H=h===null||h.memoizedState===null?QI:b2,Ud=!1,O=_(S,P),Ud=!1,Of&&(O=xI(p,_,S,P)),gI(h),O}function gI(h){K.H=Lg;var p=Hn!==null&&Hn.next!==null;if(Rl=0,Vr=Hn=en=null,Ev=!1,Dg=0,jf=null,p)throw Error(r(300));h===null||Gr||(h=h.dependencies,h!==null&&mv(h)&&(Gr=!0))}function xI(h,p,_,S){en=h;var P=0;do{if(Of&&(jf=null),Dg=0,Of=!1,25<=P)throw Error(r(301));if(P+=1,Vr=Hn=null,h.updateQueue!=null){var O=h.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}K.H=JI,O=p(_,S)}while(Of);return O}function dne(){var h=K.H,p=h.useState()[0];return p=typeof p.then=="function"?Og(p):p,h=h.useState()[0],(Hn!==null?Hn.memoizedState:null)!==h&&(en.flags|=1024),p}function i2(){var h=Mv!==0;return Mv=0,h}function s2(h,p,_){p.updateQueue=h.updateQueue,p.flags&=-2053,h.lanes&=~_}function a2(h){if(Ev){for(h=h.memoizedState;h!==null;){var p=h.queue;p!==null&&(p.pending=null),h=h.next}Ev=!1}Rl=0,Vr=Hn=en=null,Of=!1,Dg=Mv=0,jf=null}function vs(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Vr===null?en.memoizedState=Vr=h:Vr=Vr.next=h,Vr}function Ir(){if(Hn===null){var h=en.alternate;h=h!==null?h.memoizedState:null}else h=Hn.next;var p=Vr===null?en.memoizedState:Vr.next;if(p!==null)Vr=p,Hn=h;else{if(h===null)throw en.alternate===null?Error(r(467)):Error(r(310));Hn=h,h={memoizedState:Hn.memoizedState,baseState:Hn.baseState,baseQueue:Hn.baseQueue,queue:Hn.queue,next:null},Vr===null?en.memoizedState=Vr=h:Vr=Vr.next=h}return Vr}function Av(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Og(h){var p=Dg;return Dg+=1,jf===null&&(jf=[]),h=oI(jf,h,p),p=en,(Vr===null?p.memoizedState:Vr.next)===null&&(p=p.alternate,K.H=p===null||p.memoizedState===null?QI:b2),h}function Tv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Og(h);if(h.$$typeof===w)return Hi(h)}throw Error(r(438,String(h)))}function o2(h){var p=null,_=en.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var S=en.alternate;S!==null&&(S=S.updateQueue,S!==null&&(S=S.memoCache,S!=null&&(p={data:S.data.map(function(P){return P.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=Av(),en.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(h),S=0;S<h;S++)_[S]=D;return p.index++,_}function Dl(h,p){return typeof p=="function"?p(h):p}function Cv(h){var p=Ir();return l2(p,Hn,h)}function l2(h,p,_){var S=h.queue;if(S===null)throw Error(r(311));S.lastRenderedReducer=_;var P=h.baseQueue,O=S.pending;if(O!==null){if(P!==null){var X=P.next;P.next=O.next,O.next=X}p.baseQueue=P=O,S.pending=null}if(O=h.baseState,P===null)h.memoizedState=O;else{p=P.next;var oe=X=null,Me=null,Ke=p,lt=!1;do{var dt=Ke.lane&-536870913;if(dt!==Ke.lane?(bn&dt)===dt:(Rl&dt)===dt){var Qe=Ke.revertLane;if(Qe===0)Me!==null&&(Me=Me.next={lane:0,revertLane:0,gesture:null,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null}),dt===Nf&&(lt=!0);else if((Rl&Qe)===Qe){Ke=Ke.next,Qe===Nf&&(lt=!0);continue}else dt={lane:0,revertLane:Ke.revertLane,gesture:null,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null},Me===null?(oe=Me=dt,X=O):Me=Me.next=dt,en.lanes|=Qe,tu|=Qe;dt=Ke.action,Ud&&_(O,dt),O=Ke.hasEagerState?Ke.eagerState:_(O,dt)}else Qe={lane:dt,revertLane:Ke.revertLane,gesture:Ke.gesture,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null},Me===null?(oe=Me=Qe,X=O):Me=Me.next=Qe,en.lanes|=dt,tu|=dt;Ke=Ke.next}while(Ke!==null&&Ke!==p);if(Me===null?X=O:Me.next=oe,!ta(O,h.memoizedState)&&(Gr=!0,lt&&(_=kf,_!==null)))throw _;h.memoizedState=O,h.baseState=X,h.baseQueue=Me,S.lastRenderedState=O}return P===null&&(S.lanes=0),[h.memoizedState,S.dispatch]}function c2(h){var p=Ir(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var S=_.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);ta(O,p.memoizedState)||(Gr=!0),p.memoizedState=O,p.baseQueue===null&&(p.baseState=O),_.lastRenderedState=O}return[O,S]}function bI(h,p,_){var S=en,P=Ir(),O=_n;if(O){if(_===void 0)throw Error(r(407));_=_()}else _=p();var X=!ta((Hn||P).memoizedState,_);if(X&&(P.memoizedState=_,Gr=!0),P=P.queue,h2(_I.bind(null,S,P,h),[h]),P.getSnapshot!==p||X||Vr!==null&&Vr.memoizedState.tag&1){if(S.flags|=2048,Lf(9,{destroy:void 0},yI.bind(null,S,P,_,p),null),Jn===null)throw Error(r(349));O||(Rl&127)!==0||vI(S,p,_)}return _}function vI(h,p,_){h.flags|=16384,h={getSnapshot:p,value:_},p=en.updateQueue,p===null?(p=Av(),en.updateQueue=p,p.stores=[h]):(_=p.stores,_===null?p.stores=[h]:_.push(h))}function yI(h,p,_,S){p.value=_,p.getSnapshot=S,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!ta(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){Ye(!0);try{_()}finally{Ye(!1)}}}return p.memoizedState=p.baseState=h,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Dl,lastRenderedState:h},p}function EI(h,p,_,S){return h.baseState=_,l2(h,Hn,typeof S=="function"?S:Dl)}function hne(h,p,_,S,P){if(Pv(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,S(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,S=p.payload,P=h.state;if(p.isTransition){var O=K.T,X={};K.T=X;try{var oe=_(P,S),Me=K.S;Me!==null&&Me(X,oe),AI(h,p,oe)}catch(Ke){d2(h,p,Ke)}finally{O!==null&&X.types!==null&&(O.types=X.types),K.T=O}}else try{O=_(P,S),AI(h,p,O)}catch(Ke){d2(h,p,Ke)}}function AI(h,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(S){TI(h,p,S)},function(S){return d2(h,p,S)}):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 S=h.pending;if(h.pending=null,S!==null){S=S.next;do p.status="rejected",p.reason=_,CI(p),p=p.next;while(p!==S)}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(_n){var _=Jn.formState;if(_!==null){e:{var S=en;if(_n){if(ar){t:{for(var P=ar,O=Pa;P.nodeType!==8;){if(!O){P=null;break t}if(P=Da(P.nextSibling),P===null){P=null;break t}}O=P.data,P=O==="F!"||O==="F"?P:null}if(P){ar=Da(P.nextSibling),S=P.data==="F!";break e}}Wc(S)}S=!1}S&&(p=_[0])}}return _=vs(),_.memoizedState=_.baseState=p,S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:NI,lastRenderedState:p},_.queue=S,_=XI.bind(null,en,S),S.dispatch=_,S=u2(!1),O=x2.bind(null,en,!1,S.queue),S=vs(),P={state:p,dispatch:null,action:h,pending:null},S.queue=P,_=hne.bind(null,en,P,O,_),P.dispatch=_,S.memoizedState=h,[p,_,!1]}function PI(h){var p=Ir();return RI(p,Hn,h)}function RI(h,p,_){if(p=l2(h,p,NI)[0],h=Cv(Dl)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var S=Og(p)}catch(X){throw X===Pf?bv:X}else S=p;p=Ir();var P=p.queue,O=P.dispatch;return _!==p.memoizedState&&(en.flags|=2048,Lf(9,{destroy:void 0},fne.bind(null,P,_),null)),[S,O,h]}function fne(h,p){h.action=p}function DI(h){var p=Ir(),_=Hn;if(_!==null)return RI(p,_,h);Ir(),p=p.memoizedState,_=Ir();var S=_.queue.dispatch;return _.memoizedState=h,[p,S,!1]}function Lf(h,p,_,S){return h={tag:h,create:_,deps:S,inst:p,next:null},p=en.updateQueue,p===null&&(p=Av(),en.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=h.next=h:(S=_.next,_.next=h,h.next=S,p.lastEffect=h),h}function OI(){return Ir().memoizedState}function Nv(h,p,_,S){var P=vs();en.flags|=h,P.memoizedState=Lf(1|p,{destroy:void 0},_,S===void 0?null:S)}function kv(h,p,_,S){var P=Ir();S=S===void 0?null:S;var O=P.memoizedState.inst;Hn!==null&&S!==null&&n2(S,Hn.memoizedState.deps)?P.memoizedState=Lf(p,O,_,S):(en.flags|=h,P.memoizedState=Lf(1|p,O,_,S))}function jI(h,p){Nv(8390656,8,h,p)}function h2(h,p){kv(2048,8,h,p)}function pne(h){en.flags|=4;var p=en.updateQueue;if(p===null)p=Av(),en.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((Nn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function II(h,p){return kv(4,2,h,p)}function UI(h,p){return kv(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,kv(4,4,FI.bind(null,p,h),_)}function f2(){}function BI(h,p){var _=Ir();p=p===void 0?null:p;var S=_.memoizedState;return p!==null&&n2(p,S[1])?S[0]:(_.memoizedState=[h,p],h)}function HI(h,p){var _=Ir();p=p===void 0?null:p;var S=_.memoizedState;if(p!==null&&n2(p,S[1]))return S[0];if(S=h(),Ud){Ye(!0);try{h()}finally{Ye(!1)}}return _.memoizedState=[S,p],S}function p2(h,p,_){return _===void 0||(Rl&1073741824)!==0&&(bn&261930)===0?h.memoizedState=p:(h.memoizedState=_,h=$4(),en.lanes|=h,tu|=h,_)}function $I(h,p,_,S){return ta(_,p)?_:Df.current!==null?(h=p2(h,_,S),ta(h,p)||(Gr=!0),h):(Rl&42)===0||(Rl&1073741824)!==0&&(bn&261930)===0?(Gr=!0,h.memoizedState=_):(h=$4(),en.lanes|=h,tu|=h,p)}function VI(h,p,_,S,P){var O=V.p;V.p=O!==0&&8>O?O:8;var X=K.T,oe={};K.T=oe,x2(h,!1,p,_);try{var Me=P(),Ke=K.S;if(Ke!==null&&Ke(oe,Me),Me!==null&&typeof Me=="object"&&typeof Me.then=="function"){var lt=cne(Me,S);jg(h,p,lt,oa(h))}else jg(h,p,S,oa(h))}catch(dt){jg(h,p,{then:function(){},status:"rejected",reason:dt},oa())}finally{V.p=O,X!==null&&oe.types!==null&&(X.types=oe.types),K.T=X}}function mne(){}function m2(h,p,_,S){if(h.tag!==5)throw Error(r(476));var P=GI(h).queue;VI(h,P,p,te,_===null?mne:function(){return WI(h),_(S)})}function GI(h){var p=h.memoizedState;if(p!==null)return p;p={memoizedState:te,baseState:te,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Dl,lastRenderedState:te},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Dl,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),jg(h,p.next.queue,{},oa())}function g2(){return Hi(Qg)}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 _=oa();h=Xc(_);var S=Yc(p,h,_);S!==null&&(zs(S,p,_),kg(S,p,_)),p={cache:GM()},h.payload=p;return}p=p.return}}function xne(h,p,_){var S=oa();_={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Pv(h)?YI(p,_):(_=OM(h,p,_,S),_!==null&&(zs(_,h,S),ZI(_,p,S)))}function XI(h,p,_){var S=oa();jg(h,p,_,S)}function jg(h,p,_,S){var P={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Pv(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,oe=O(X,_);if(P.hasEagerState=!0,P.eagerState=oe,ta(oe,X))return dv(h,p,P,0),Jn===null&&uv(),!1}catch{}finally{}if(_=OM(h,p,P,S),_!==null)return zs(_,h,S),ZI(_,p,S),!0}return!1}function x2(h,p,_,S){if(S={lane:2,revertLane:X2(),gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},Pv(h)){if(p)throw Error(r(479))}else p=OM(h,_,S,2),p!==null&&zs(p,h,2)}function Pv(h){var p=h.alternate;return h===en||p!==null&&p===en}function YI(h,p){Of=Ev=!0;var _=h.pending;_===null?p.next=p:(p.next=_.next,_.next=p),h.pending=p}function ZI(h,p,_){if((_&4194048)!==0){var S=p.lanes;S&=h.pendingLanes,_|=S,p.lanes=_,Qn(h,_)}}var Lg={readContext:Hi,use:Tv,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};Lg.useEffectEvent=Tr;var QI={readContext:Hi,use:Tv,useCallback:function(h,p){return vs().memoizedState=[h,p===void 0?null:p],h},useContext:Hi,useEffect:jI,useImperativeHandle:function(h,p,_){_=_!=null?_.concat([h]):null,Nv(4194308,4,FI.bind(null,p,h),_)},useLayoutEffect:function(h,p){return Nv(4194308,4,h,p)},useInsertionEffect:function(h,p){Nv(4,2,h,p)},useMemo:function(h,p){var _=vs();p=p===void 0?null:p;var S=h();if(Ud){Ye(!0);try{h()}finally{Ye(!1)}}return _.memoizedState=[S,p],S},useReducer:function(h,p,_){var S=vs();if(_!==void 0){var P=_(p);if(Ud){Ye(!0);try{_(p)}finally{Ye(!1)}}}else P=p;return S.memoizedState=S.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},S.queue=h,h=h.dispatch=xne.bind(null,en,h),[S.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,en,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,en,h.queue,!0,!1),vs().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,p,_){var S=en,P=vs();if(_n){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Jn===null)throw Error(r(349));(bn&127)!==0||vI(S,p,_)}P.memoizedState=_;var O={value:_,getSnapshot:p};return P.queue=O,jI(_I.bind(null,S,O,h),[h]),S.flags|=2048,Lf(9,{destroy:void 0},yI.bind(null,S,O,_,p),null),_},useId:function(){var h=vs(),p=Jn.identifierPrefix;if(_n){var _=Go,S=Vo;_=(S&~(1<<32-$e(S)-1)).toString(32)+_,p="_"+p+"R_"+_,_=Mv++,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,en,!0,_),_.dispatch=p,[h,p]},useMemoCache:o2,useCacheRefresh:function(){return vs().memoizedState=gne.bind(null,en)},useEffectEvent:function(h){var p=vs(),_={impl:h};return p.memoizedState=_,function(){if((Nn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},b2={readContext:Hi,use:Tv,useCallback:BI,useContext:Hi,useEffect:h2,useImperativeHandle:zI,useInsertionEffect:II,useLayoutEffect:UI,useMemo:HI,useReducer:Cv,useRef:OI,useState:function(){return Cv(Dl)},useDebugValue:f2,useDeferredValue:function(h,p){var _=Ir();return $I(_,Hn.memoizedState,h,p)},useTransition:function(){var h=Cv(Dl)[0],p=Ir().memoizedState;return[typeof h=="boolean"?h:Og(h),p]},useSyncExternalStore:bI,useId:qI,useHostTransitionStatus:g2,useFormState:PI,useActionState:PI,useOptimistic:function(h,p){var _=Ir();return EI(_,Hn,h,p)},useMemoCache:o2,useCacheRefresh:KI};b2.useEffectEvent=LI;var JI={readContext:Hi,use:Tv,useCallback:BI,useContext:Hi,useEffect:h2,useImperativeHandle:zI,useInsertionEffect:II,useLayoutEffect:UI,useMemo:HI,useReducer:c2,useRef:OI,useState:function(){return c2(Dl)},useDebugValue:f2,useDeferredValue:function(h,p){var _=Ir();return Hn===null?p2(_,h,p):$I(_,Hn.memoizedState,h,p)},useTransition:function(){var h=c2(Dl)[0],p=Ir().memoizedState;return[typeof h=="boolean"?h:Og(h),p]},useSyncExternalStore:bI,useId:qI,useHostTransitionStatus:g2,useFormState:DI,useActionState:DI,useOptimistic:function(h,p){var _=Ir();return Hn!==null?EI(_,Hn,h,p):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:o2,useCacheRefresh:KI};JI.useEffectEvent=LI;function v2(h,p,_,S){p=h.memoizedState,_=_(S,p),_=_==null?p:f({},p,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var y2={enqueueSetState:function(h,p,_){h=h._reactInternals;var S=oa(),P=Xc(S);P.payload=p,_!=null&&(P.callback=_),p=Yc(h,P,S),p!==null&&(zs(p,h,S),kg(p,h,S))},enqueueReplaceState:function(h,p,_){h=h._reactInternals;var S=oa(),P=Xc(S);P.tag=1,P.payload=p,_!=null&&(P.callback=_),p=Yc(h,P,S),p!==null&&(zs(p,h,S),kg(p,h,S))},enqueueForceUpdate:function(h,p){h=h._reactInternals;var _=oa(),S=Xc(_);S.tag=2,p!=null&&(S.callback=p),p=Yc(h,S,_),p!==null&&(zs(p,h,_),kg(p,h,_))}};function e4(h,p,_,S,P,O,X){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(S,O,X):p.prototype&&p.prototype.isPureReactComponent?!wg(_,S)||!wg(P,O):!0}function t4(h,p,_,S){h=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(_,S),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(_,S),p.state!==h&&y2.enqueueReplaceState(p,p.state,null)}function Fd(h,p){var _=p;if("ref"in p){_={};for(var S in p)S!=="ref"&&(_[S]=p[S])}if(h=h.defaultProps){_===p&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function n4(h){cv(h)}function r4(h){console.error(h)}function i4(h){cv(h)}function Rv(h,p){try{var _=h.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(S){setTimeout(function(){throw S})}}function s4(h,p,_){try{var S=h.onCaughtError;S(_.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(){Rv(h,p)},_}function a4(h){return h=Xc(h),h.tag=3,h}function o4(h,p,_,S){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var O=S.value;h.payload=function(){return P(O)},h.callback=function(){s4(p,_,S)}}var X=_.stateNode;X!==null&&typeof X.componentDidCatch=="function"&&(h.callback=function(){s4(p,_,S),typeof P!="function"&&(nu===null?nu=new Set([this]):nu.add(this));var oe=S.stack;this.componentDidCatch(S.value,{componentStack:oe!==null?oe:""})})}function bne(h,p,_,S,P){if(_.flags|=32768,S!==null&&typeof S=="object"&&typeof S.then=="function"){if(p=_.alternate,p!==null&&Cf(p,_,P,!0),_=ra.current,_!==null){switch(_.tag){case 31:case 13:return Ra===null?Vv():_.alternate===null&&Cr===0&&(Cr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,S===vv?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([S]):p.add(S),W2(h,S,P)),!1;case 22:return _.flags|=65536,S===vv?_.flags|=16384:(p=_.updateQueue,p===null?(p={transitions:null,markerInstances:null,retryQueue:new Set([S])},_.updateQueue=p):(_=p.retryQueue,_===null?p.retryQueue=new Set([S]):_.add(S)),W2(h,S,P)),!1}throw Error(r(435,_.tag))}return W2(h,S,P),Vv(),!1}if(_n)return p=ra.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=P,S!==zM&&(h=Error(r(422),{cause:S}),Mg(Ca(h,_)))):(S!==zM&&(p=Error(r(423),{cause:S}),Mg(Ca(p,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,S=Ca(S,_),P=_2(h.stateNode,S,P),ZM(h,P),Cr!==4&&(Cr=2)),!1;var O=Error(r(520),{cause:S});if(O=Ca(O,_),Vg===null?Vg=[O]:Vg.push(O),Cr!==4&&(Cr=2),p===null)return!0;S=Ca(S,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=_2(_.stateNode,S,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,_,S),ZM(_,P),!1}_=_.return}while(_!==null);return!1}var w2=Error(r(461)),Gr=!1;function $i(h,p,_,S){p.child=h===null?dI(p,null,_,S):Id(p,h.child,_,S)}function l4(h,p,_,S,P){_=_.render;var O=p.ref;if("ref"in S){var X={};for(var oe in S)oe!=="ref"&&(X[oe]=S[oe])}else X=S;return Dd(p),S=r2(h,p,_,X,O,P),oe=i2(),h!==null&&!Gr?(s2(h,p,P),Ol(h,p,P)):(_n&&oe&&UM(p),p.flags|=1,$i(h,p,S,P),p.child)}function c4(h,p,_,S,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,S,P)):(h=fv(_.type,null,S,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?_:wg,_(X,S)&&h.ref===p.ref)return Ol(h,p,P)}return p.flags|=1,h=Cl(O,S),h.ref=p.ref,h.return=p,p.child=h}function u4(h,p,_,S,P){if(h!==null){var O=h.memoizedProps;if(wg(O,S)&&h.ref===p.ref)if(Gr=!1,p.pendingProps=S=O,k2(h,P))(h.flags&131072)!==0&&(Gr=!0);else return p.lanes=h.lanes,Ol(h,p,P)}return S2(h,p,_,S,P)}function d4(h,p,_,S){var P=S.children,O=h!==null?h.memoizedState:null;if(h===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),S.mode==="hidden"){if((p.flags&128)!==0){if(O=O!==null?O.baseLanes|_:_,h!==null){for(S=p.child=h.child,P=0;S!==null;)P=P|S.lanes|S.childLanes,S=S.sibling;S=P&~O}else S=0,p.child=null;return h4(h,p,O,_,S)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},h!==null&&xv(p,O!==null?O.cachePool:null),O!==null?pI(p,O):JM(),mI(p);else return S=p.lanes=536870912,h4(h,p,O!==null?O.baseLanes|_:_,_,S)}else O!==null?(xv(p,O.cachePool),pI(p,O),Qc(),p.memoizedState=null):(h!==null&&xv(p,null),JM(),Qc());return $i(h,p,P,_),p.child}function Ig(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,_,S,P){var O=qM();return O=O===null?null:{parent:$r._currentValue,pool:O},p.memoizedState={baseLanes:_,cachePool:O},h!==null&&xv(p,null),JM(),mI(p),h!==null&&Cf(h,p,S,!0),p.childLanes=P,null}function Dv(h,p){return p=jv({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=Dv(p,p.pendingProps),h.flags|=2,ia(p),p.memoizedState=null,h}function vne(h,p,_){var S=p.pendingProps,P=(p.flags&128)!==0;if(p.flags&=-129,h===null){if(_n){if(S.mode==="hidden")return h=Dv(p,S),p.lanes=536870912,Ig(null,h);if(t2(p),(h=ar)?(h=MU(h,Pa),h=h!==null&&h.data==="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Vc!==null?{id:Vo,overflow:Go}:null,retryLane:536870912,hydrationErrors:null},_=YL(h),_.return=p,p.child=_,Bi=p,ar=null)):h=null,h===null)throw Wc(p);return p.lanes=536870912,null}return Dv(p,S)}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(S=Jn,S!==null&&(X=Si(S,_),X!==0&&X!==O.retryLane))throw O.retryLane=X,Nd(h,X),zs(S,h,X),w2;Vv(),p=f4(h,p,_)}else h=O.treeContext,ar=Da(X.nextSibling),Bi=p,_n=!0,Gc=null,Pa=!1,h!==null&&JL(p,h),p=Dv(p,S),p.flags|=4096;return p}return h=Cl(h.child,{mode:S.mode,children:S.children}),h.ref=p.ref,p.child=h,h.return=p,h}function Ov(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,_,S,P){return Dd(p),_=r2(h,p,_,S,void 0,P),S=i2(),h!==null&&!Gr?(s2(h,p,P),Ol(h,p,P)):(_n&&S&&UM(p),p.flags|=1,$i(h,p,_,P),p.child)}function p4(h,p,_,S,P,O){return Dd(p),p.updateQueue=null,_=xI(p,S,_,P),gI(h),S=i2(),h!==null&&!Gr?(s2(h,p,O),Ol(h,p,O)):(_n&&S&&UM(p),p.flags|=1,$i(h,p,_,O),p.child)}function m4(h,p,_,S,P){if(Dd(p),p.stateNode===null){var O=Ef,X=_.contextType;typeof X=="object"&&X!==null&&(O=Hi(X)),O=new _(S,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=S,O.state=p.memoizedState,O.refs={},XM(p),X=_.contextType,O.context=typeof X=="object"&&X!==null?Hi(X):Ef,O.state=p.memoizedState,X=_.getDerivedStateFromProps,typeof X=="function"&&(v2(p,_,X,S),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),Rg(p,S,O,P),Pg(),O.state=p.memoizedState),typeof O.componentDidMount=="function"&&(p.flags|=4194308),S=!0}else if(h===null){O=p.stateNode;var oe=p.memoizedProps,Me=Fd(_,oe);O.props=Me;var Ke=O.context,lt=_.contextType;X=Ef,typeof lt=="object"&<!==null&&(X=Hi(lt));var dt=_.getDerivedStateFromProps;lt=typeof dt=="function"||typeof O.getSnapshotBeforeUpdate=="function",oe=p.pendingProps!==oe,lt||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(oe||Ke!==X)&&t4(p,O,S,X),Kc=!1;var Qe=p.memoizedState;O.state=Qe,Rg(p,S,O,P),Pg(),Ke=p.memoizedState,oe||Qe!==Ke||Kc?(typeof dt=="function"&&(v2(p,_,dt,S),Ke=p.memoizedState),(Me=Kc||e4(p,_,Me,S,Qe,Ke,X))?(lt||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(p.flags|=4194308)):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=S,p.memoizedState=Ke),O.props=S,O.state=Ke,O.context=X,S=Me):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),S=!1)}else{O=p.stateNode,YM(h,p),X=p.memoizedProps,lt=Fd(_,X),O.props=lt,dt=p.pendingProps,Qe=O.context,Ke=_.contextType,Me=Ef,typeof Ke=="object"&&Ke!==null&&(Me=Hi(Ke)),oe=_.getDerivedStateFromProps,(Ke=typeof oe=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(X!==dt||Qe!==Me)&&t4(p,O,S,Me),Kc=!1,Qe=p.memoizedState,O.state=Qe,Rg(p,S,O,P),Pg();var it=p.memoizedState;X!==dt||Qe!==it||Kc||h!==null&&h.dependencies!==null&&mv(h.dependencies)?(typeof oe=="function"&&(v2(p,_,oe,S),it=p.memoizedState),(lt=Kc||e4(p,_,lt,S,Qe,it,Me)||h!==null&&h.dependencies!==null&&mv(h.dependencies))?(Ke||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(S,it,Me),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(S,it,Me)),typeof O.componentDidUpdate=="function"&&(p.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof O.componentDidUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=1024),p.memoizedProps=S,p.memoizedState=it),O.props=S,O.state=it,O.context=Me,S=lt):(typeof O.componentDidUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=1024),S=!1)}return O=S,Ov(h,p),S=(p.flags&128)!==0,O||S?(O=p.stateNode,_=S&&typeof _.getDerivedStateFromError!="function"?null:O.render(),p.flags|=1,h!==null&&S?(p.child=Id(p,h.child,null,P),p.child=Id(p,null,_,P)):$i(h,p,_,P),p.memoizedState=O.state,h=p.child):h=Ol(h,p,P),h}function g4(h,p,_,S){return Pd(),p.flags|=256,$i(h,p,_,S),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|=aa),h}function x4(h,p,_){var S=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(_n){if(P?Zc(p):Qc(),(h=ar)?(h=MU(h,Pa),h=h!==null&&h.data!=="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Vc!==null?{id:Vo,overflow:Go}:null,retryLane:536870912,hydrationErrors:null},_=YL(h),_.return=p,p.child=_,Bi=p,ar=null)):h=null,h===null)throw Wc(p);return lA(h)?p.lanes=32:p.lanes=536870912,null}var oe=S.children;return S=S.fallback,P?(Qc(),P=p.mode,oe=jv({mode:"hidden",children:oe},P),S=kd(S,P,_,null),oe.return=p,S.return=p,oe.sibling=S,p.child=oe,S=p.child,S.memoizedState=M2(_),S.childLanes=A2(h,X,_),p.memoizedState=E2,Ig(null,S)):(Zc(p),T2(p,oe))}var Me=h.memoizedState;if(Me!==null&&(oe=Me.dehydrated,oe!==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(),oe=S.fallback,P=p.mode,S=jv({mode:"visible",children:S.children},P),oe=kd(oe,P,_,null),oe.flags|=2,S.return=p,oe.return=p,S.sibling=oe,p.child=S,Id(p,h.child,null,_),S=p.child,S.memoizedState=M2(_),S.childLanes=A2(h,X,_),p.memoizedState=E2,p=Ig(null,S));else if(Zc(p),lA(oe)){if(X=oe.nextSibling&&oe.nextSibling.dataset,X)var Ke=X.dgst;X=Ke,S=Error(r(419)),S.stack="",S.digest=X,Mg({value:S,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&&(S=Si(X,_),S!==0&&S!==Me.retryLane))throw Me.retryLane=S,Nd(h,S),zs(X,h,S),w2;oA(oe)||Vv(),p=C2(h,p,_)}else oA(oe)?(p.flags|=192,p.child=h.child,p=null):(h=Me.treeContext,ar=Da(oe.nextSibling),Bi=p,_n=!0,Gc=null,Pa=!1,h!==null&&JL(p,h),p=T2(p,S.children),p.flags|=4096);return p}return P?(Qc(),oe=S.fallback,P=p.mode,Me=h.child,Ke=Me.sibling,S=Cl(Me,{mode:"hidden",children:S.children}),S.subtreeFlags=Me.subtreeFlags&65011712,Ke!==null?oe=Cl(Ke,oe):(oe=kd(oe,P,_,null),oe.flags|=2),oe.return=p,S.return=p,S.sibling=oe,p.child=S,Ig(null,S),S=p.child,oe=h.child.memoizedState,oe===null?oe=M2(_):(P=oe.cachePool,P!==null?(Me=$r._currentValue,P=P.parent!==Me?{parent:Me,pool:Me}:P):P=sI(),oe={baseLanes:oe.baseLanes|_,cachePool:P}),S.memoizedState=oe,S.childLanes=A2(h,X,_),p.memoizedState=E2,Ig(h.child,S)):(Zc(p),_=h.child,h=_.sibling,_=Cl(_,{mode:"visible",children:S.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=jv({mode:"visible",children:p},h.mode),p.return=h,h.child=p}function jv(h,p){return h=na(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 S=h.alternate;S!==null&&(S.lanes|=p),$M(h.return,p,_)}function N2(h,p,_,S,P,O){var X=h.memoizedState;X===null?h.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:S,tail:_,tailMode:P,treeForkCount:O}:(X.isBackwards=p,X.rendering=null,X.renderingStartTime=0,X.last=S,X.tail=_,X.tailMode=P,X.treeForkCount=O)}function v4(h,p,_){var S=p.pendingProps,P=S.revealOrder,O=S.tail;S=S.children;var X=Lr.current,oe=(X&2)!==0;if(oe?(X=X&1|2,p.flags|=128):X&=1,ee(Lr,X),$i(h,p,S,_),S=_n?Eg:0,!oe&&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&&Sv(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=p.child,p.child=null):(P=_.sibling,_.sibling=null),N2(p,!1,P,_,O,S);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=p.child,p.child=null;P!==null;){if(h=P.alternate,h!==null&&Sv(h)===null){p.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}N2(p,!0,_,null,O,S);break;case"together":N2(p,!1,null,null,void 0,S);break;default:p.memoizedState=null}return p.child}function Ol(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,_=Cl(h,h.pendingProps),p.child=_,_.return=p;h.sibling!==null;)h=h.sibling,_=_.sibling=Cl(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&&mv(h)))}function yne(h,p,_){switch(p.tag){case 3:ye(p,p.stateNode.containerInfo),qc(p,$r,h.memoizedState.cache),Pd();break;case 27:case 5:ve(p);break;case 4:ye(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 S=p.memoizedState;if(S!==null)return S.dehydrated!==null?(Zc(p),p.flags|=128,null):(_&p.child.childLanes)!==0?x4(h,p,_):(Zc(p),h=Ol(h,p,_),h!==null?h.sibling:null);Zc(p);break;case 19:var P=(h.flags&128)!==0;if(S=(_&p.childLanes)!==0,S||(Cf(h,p,_,!1),S=(_&p.childLanes)!==0),P){if(S)return v4(h,p,_);p.flags|=128}if(P=p.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ee(Lr,Lr.current),S)break;return null;case 22:return p.lanes=0,d4(h,p,_,p.pendingProps);case 24:qc(p,$r,h.memoizedState.cache)}return Ol(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,_n&&(p.flags&1048576)!==0&&QL(p,Eg,p.index);switch(p.lanes=0,p.tag){case 16:e:{var S=p.pendingProps;if(h=jd(p.elementType),p.type=h,typeof h=="function")jM(h)?(S=Fd(h,S),p.tag=1,p=m4(null,p,h,S,_)):(p.tag=0,p=S2(null,p,h,S,_));else{if(h!=null){var P=h.$$typeof;if(P===A){p.tag=11,p=l4(null,p,h,S,_);break e}else if(P===N){p.tag=14,p=c4(null,p,h,S,_);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 S=p.type,P=Fd(S,p.pendingProps),m4(h,p,S,P,_);case 3:e:{if(ye(p,p.stateNode.containerInfo),h===null)throw Error(r(387));S=p.pendingProps;var O=p.memoizedState;P=O.element,YM(h,p),Rg(p,S,null,_);var X=p.memoizedState;if(S=X.cache,qc(p,$r,S),S!==O.cache&&VM(p,[$r],_,!0),Pg(),S=X.element,O.isDehydrated)if(O={element:S,isDehydrated:!1,cache:X.cache},p.updateQueue.baseState=O,p.memoizedState=O,p.flags&256){p=g4(h,p,S,_);break e}else if(S!==P){P=Ca(Error(r(424)),p),Mg(P),p=g4(h,p,S,_);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=Da(h.firstChild),Bi=p,_n=!0,Gc=null,Pa=!0,_=dI(p,null,S,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Pd(),S===P){p=Ol(h,p,_);break e}$i(h,p,S,_)}p=p.child}return p;case 26:return Ov(h,p),h===null?(_=PU(p.type,null,p.pendingProps,null))?p.memoizedState=_:_n||(_=p.type,h=p.pendingProps,S=Zv(de.current).createElement(_),S[br]=p,S[Or]=h,Vi(S,_,h),Oe(S),p.stateNode=S):p.memoizedState=PU(p.type,h.memoizedProps,p.pendingProps,h.memoizedState),null;case 27:return ve(p),h===null&&_n&&(S=p.stateNode=CU(p.type,p.pendingProps,de.current),Bi=p,Pa=!0,P=ar,au(p.type)?(cA=P,ar=Da(S.firstChild)):ar=P),$i(h,p,p.pendingProps.children,_),Ov(h,p),h===null&&(p.flags|=4194304),p.child;case 5:return h===null&&_n&&((P=S=ar)&&(S=Yne(S,p.type,p.pendingProps,Pa),S!==null?(p.stateNode=S,Bi=p,ar=Da(S.firstChild),Pa=!1,P=!0):P=!1),P||Wc(p)),ve(p),P=p.type,O=p.pendingProps,X=h!==null?h.memoizedProps:null,S=O.children,iA(P,O)?S=null:X!==null&&iA(P,X)&&(p.flags|=32),p.memoizedState!==null&&(P=r2(h,p,dne,null,null,_),Qg._currentValue=P),Ov(h,p),$i(h,p,S,_),p.child;case 6:return h===null&&_n&&((h=_=ar)&&(_=Zne(_,p.pendingProps,Pa),_!==null?(p.stateNode=_,Bi=p,ar=null,h=!0):h=!1),h||Wc(p)),null;case 13:return x4(h,p,_);case 4:return ye(p,p.stateNode.containerInfo),S=p.pendingProps,h===null?p.child=Id(p,null,S,_):$i(h,p,S,_),p.child;case 11:return l4(h,p,p.type,p.pendingProps,_);case 7:return $i(h,p,p.pendingProps,_),p.child;case 8:return $i(h,p,p.pendingProps.children,_),p.child;case 12:return $i(h,p,p.pendingProps.children,_),p.child;case 10:return S=p.pendingProps,qc(p,p.type,S.value),$i(h,p,S.children,_),p.child;case 9:return P=p.type._context,S=p.pendingProps.children,Dd(p),P=Hi(P),S=S(P),p.flags|=1,$i(h,p,S,_),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),S=Hi($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:S,cache:P},XM(p),qc(p,$r,P)):((h.lanes&_)!==0&&(YM(h,p),Rg(p,null,null,_),Pg()),P=h.memoizedState,O=p.memoizedState,P.parent!==S?(P={parent:S,cache:S},p.memoizedState=P,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=P),qc(p,$r,S)):(S=O.cache,qc(p,$r,S),S!==P.cache&&VM(p,[$r],_,!0))),$i(h,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function jl(h){h.flags|=4}function P2(h,p,_,S,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=vv,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,!LU(p))if(q4())h.flags|=8192;else throw Ld=vv,KM}function Lv(h,p){p!==null&&(h.flags|=4),h.flags&16384&&(p=h.tag!==22?wt():536870912,h.lanes|=p,zf|=p)}function Ug(h,p){if(!_n)switch(h.tailMode){case"hidden":p=h.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var S=null;_!==null;)_.alternate!==null&&(S=_),_=_.sibling;S===null?p||h.tail===null?h.tail=null:h.tail.sibling=null:S.sibling=null}}function or(h){var p=h.alternate!==null&&h.alternate.child===h.child,_=0,S=0;if(p)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,S|=P.subtreeFlags&65011712,S|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,S|=P.subtreeFlags,S|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=S,h.childLanes=_,p}function _ne(h,p,_){var S=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,S=null,h!==null&&(S=h.memoizedState.cache),p.memoizedState.cache!==S&&(p.flags|=2048),Pl($r),re(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Tf(p)?jl(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?(jl(p),O!==null?(or(p),_4(p,O)):(or(p),P2(p,P,null,S,_))):O?O!==h.memoizedState?(jl(p),or(p),_4(p,O)):(or(p),p.flags&=-16777217):(h=h.memoizedProps,h!==S&&jl(p),or(p),P2(p,P,h,S,_)),null;case 27:if(je(p),_=de.current,P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==S&&jl(p);else{if(!S){if(p.stateNode===null)throw Error(r(166));return or(p),null}h=ae.current,Tf(p)?eI(p):(h=CU(P,S,_),p.stateNode=h,jl(p))}return or(p),null;case 5:if(je(p),P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==S&&jl(p);else{if(!S){if(p.stateNode===null)throw Error(r(166));return or(p),null}if(O=ae.current,Tf(p))eI(p);else{var X=Zv(de.current);switch(O){case 1:O=X.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:O=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":O=X.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":O=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":O=X.createElement("div"),O.innerHTML="<script><\/script>",O=O.removeChild(O.firstChild);break;case"select":O=typeof S.is=="string"?X.createElement("select",{is:S.is}):X.createElement("select"),S.multiple?O.multiple=!0:S.size&&(O.size=S.size);break;default:O=typeof S.is=="string"?X.createElement(P,{is:S.is}):X.createElement(P)}}O[br]=p,O[Or]=S;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(Vi(O,P,S),P){case"button":case"input":case"select":case"textarea":S=!!S.autoFocus;break e;case"img":S=!0;break e;default:S=!1}S&&jl(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!==S&&jl(p);else{if(typeof S!="string"&&p.stateNode===null)throw Error(r(166));if(h=de.current,Tf(p)){if(h=p.stateNode,_=p.memoizedProps,S=null,P=Bi,P!==null)switch(P.tag){case 27:case 5:S=P.memoizedProps}h[br]=p,h=!!(h.nodeValue===_||S!==null&&S.suppressHydrationWarning===!0||xU(h.nodeValue,_)),h||Wc(p,!0)}else h=Zv(h).createTextNode(S),h[br]=p,p.stateNode=h}return or(p),null;case 31:if(_=p.memoizedState,h===null||h.memoizedState!==null){if(S=Tf(p),_!==null){if(h===null){if(!S)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?(ia(p),p):(ia(p),null);if((p.flags&128)!==0)throw Error(r(558))}return or(p),null;case 13:if(S=p.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Tf(p),S!==null&&S.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?(ia(p),p):(ia(p),null)}return ia(p),(p.flags&128)!==0?(p.lanes=_,p):(_=S!==null,h=h!==null&&h.memoizedState!==null,_&&(S=p.child,P=null,S.alternate!==null&&S.alternate.memoizedState!==null&&S.alternate.memoizedState.cachePool!==null&&(P=S.alternate.memoizedState.cachePool.pool),O=null,S.memoizedState!==null&&S.memoizedState.cachePool!==null&&(O=S.memoizedState.cachePool.pool),O!==P&&(S.flags|=2048)),_!==h&&_&&(p.child.flags|=8192),Lv(p,p.updateQueue),or(p),null);case 4:return re(),h===null&&J2(p.stateNode.containerInfo),or(p),null;case 10:return Pl(p.type),or(p),null;case 19:if(z(Lr),S=p.memoizedState,S===null)return or(p),null;if(P=(p.flags&128)!==0,O=S.rendering,O===null)if(P)Ug(S,!1);else{if(Cr!==0||h!==null&&(h.flags&128)!==0)for(h=p.child;h!==null;){if(O=Sv(h),O!==null){for(p.flags|=128,Ug(S,!1),h=O.updateQueue,p.updateQueue=h,Lv(p,h),p.subtreeFlags=0,h=_,_=p.child;_!==null;)XL(_,h),_=_.sibling;return ee(Lr,Lr.current&1|2),_n&&Nl(p,S.treeForkCount),p.child}h=h.sibling}S.tail!==null&&L()>Bv&&(p.flags|=128,P=!0,Ug(S,!1),p.lanes=4194304)}else{if(!P)if(h=Sv(O),h!==null){if(p.flags|=128,P=!0,h=h.updateQueue,p.updateQueue=h,Lv(p,h),Ug(S,!0),S.tail===null&&S.tailMode==="hidden"&&!O.alternate&&!_n)return or(p),null}else 2*L()-S.renderingStartTime>Bv&&_!==536870912&&(p.flags|=128,P=!0,Ug(S,!1),p.lanes=4194304);S.isBackwards?(O.sibling=p.child,p.child=O):(h=S.last,h!==null?h.sibling=O:p.child=O,S.last=O)}return S.tail!==null?(h=S.tail,S.rendering=h,S.tail=h.sibling,S.renderingStartTime=L(),h.sibling=null,_=Lr.current,ee(Lr,P?_&1|2:_&1),_n&&Nl(p,S.treeForkCount),h):(or(p),null);case 22:case 23:return ia(p),e2(),S=p.memoizedState!==null,h!==null?h.memoizedState!==null!==S&&(p.flags|=8192):S&&(p.flags|=8192),S?(_&536870912)!==0&&(p.flags&128)===0&&(or(p),p.subtreeFlags&6&&(p.flags|=8192)):or(p),_=p.updateQueue,_!==null&&Lv(p,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),S=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(S=p.memoizedState.cachePool.pool),S!==_&&(p.flags|=2048),h!==null&&z(Od),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),Pl($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 Pl($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 je(p),null;case 31:if(p.memoizedState!==null){if(ia(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(ia(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 Pl(p.type),null;case 22:case 23:return ia(p),e2(),h!==null&&z(Od),h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 24:return Pl($r),null;case 25:return null;default:return null}}function w4(h,p){switch(FM(p),p.tag){case 3:Pl($r),re();break;case 26:case 27:case 5:je(p);break;case 4:re();break;case 31:p.memoizedState!==null&&ia(p);break;case 13:ia(p);break;case 19:z(Lr);break;case 10:Pl(p.type);break;case 22:case 23:ia(p),e2(),h!==null&&z(Od);break;case 24:Pl($r)}}function Fg(h,p){try{var _=p.updateQueue,S=_!==null?_.lastEffect:null;if(S!==null){var P=S.next;_=P;do{if((_.tag&h)===h){S=void 0;var O=_.create,X=_.inst;S=O(),X.destroy=S}_=_.next}while(_!==P)}}catch(oe){Ln(p,p.return,oe)}}function Jc(h,p,_){try{var S=p.updateQueue,P=S!==null?S.lastEffect:null;if(P!==null){var O=P.next;S=O;do{if((S.tag&h)===h){var X=S.inst,oe=X.destroy;if(oe!==void 0){X.destroy=void 0,P=p;var Me=_,Ke=oe;try{Ke()}catch(lt){Ln(P,Me,lt)}}}S=S.next}while(S!==O)}}catch(lt){Ln(p,p.return,lt)}}function S4(h){var p=h.updateQueue;if(p!==null){var _=h.stateNode;try{fI(p,_)}catch(S){Ln(h,h.return,S)}}}function E4(h,p,_){_.props=Fd(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(S){Ln(h,p,S)}}function zg(h,p){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var S=h.stateNode;break;case 30:S=h.stateNode;break;default:S=h.stateNode}typeof _=="function"?h.refCleanup=_(S):_.current=S}}catch(P){Ln(h,p,P)}}function Wo(h,p){var _=h.ref,S=h.refCleanup;if(_!==null)if(typeof S=="function")try{S()}catch(P){Ln(h,p,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Ln(h,p,P)}else _.current=null}function M4(h){var p=h.type,_=h.memoizedProps,S=h.stateNode;try{e:switch(p){case"button":case"input":case"select":case"textarea":_.autoFocus&&S.focus();break e;case"img":_.src?S.src=_.src:_.srcSet&&(S.srcset=_.srcSet)}}catch(P){Ln(h,h.return,P)}}function R2(h,p,_){try{var S=h.stateNode;Vne(S,h.type,_,p),S[Or]=p}catch(P){Ln(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 S=h.tag;if(S===5||S===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=Al));else if(S!==4&&(S===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 Iv(h,p,_){var S=h.tag;if(S===5||S===6)h=h.stateNode,p?_.insertBefore(h,p):_.appendChild(h);else if(S!==4&&(S===27&&au(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Iv(h,p,_),h=h.sibling;h!==null;)Iv(h,p,_),h=h.sibling}function T4(h){var p=h.stateNode,_=h.memoizedProps;try{for(var S=h.type,P=p.attributes;P.length;)p.removeAttributeNode(P[0]);Vi(p,S,_),p[br]=h,p[Or]=_}catch(O){Ln(h,h.return,O)}}var Ll=!1,Wr=!1,j2=!1,C4=typeof WeakSet=="function"?WeakSet:Set,Ti=null;function Sne(h,p){if(h=h.containerInfo,nA=iy,h=zL(h),CM(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var S=_.getSelection&&_.getSelection();if(S&&S.rangeCount!==0){_=S.anchorNode;var P=S.anchorOffset,O=S.focusNode;S=S.focusOffset;try{_.nodeType,O.nodeType}catch{_=null;break e}var X=0,oe=-1,Me=-1,Ke=0,lt=0,dt=h,Qe=null;t:for(;;){for(var it;dt!==_||P!==0&&dt.nodeType!==3||(oe=X+P),dt!==O||S!==0&&dt.nodeType!==3||(Me=X+S),dt.nodeType===3&&(X+=dt.nodeValue.length),(it=dt.firstChild)!==null;)Qe=dt,dt=it;for(;;){if(dt===h)break t;if(Qe===_&&++Ke===P&&(oe=X),Qe===O&&++lt===S&&(Me=X),(it=dt.nextSibling)!==null)break;dt=Qe,Qe=dt.parentNode}dt=it}_=oe===-1||Me===-1?null:{start:oe,end:Me}}else _=null}_=_||{start:0,end:0}}else _=null;for(rA={focusedElem:h,selectionRange:_},iy=!1,Ti=p;Ti!==null;)if(p=Ti,h=p.child,(p.subtreeFlags&1028)!==0&&h!==null)h.return=p,Ti=h;else for(;Ti!==null;){switch(p=Ti,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,S=_.stateNode;try{var Rt=Fd(_.type,P);h=S.getSnapshotBeforeUpdate(Rt,O),S.__reactInternalSnapshotBeforeUpdate=h}catch(Vt){Ln(_,_.return,Vt)}}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,Ti=h;break}Ti=p.return}}function N4(h,p,_){var S=_.flags;switch(_.tag){case 0:case 11:case 15:Ul(h,_),S&4&&Fg(5,_);break;case 1:if(Ul(h,_),S&4)if(h=_.stateNode,p===null)try{h.componentDidMount()}catch(X){Ln(_,_.return,X)}else{var P=Fd(_.type,p.memoizedProps);p=p.memoizedState;try{h.componentDidUpdate(P,p,h.__reactInternalSnapshotBeforeUpdate)}catch(X){Ln(_,_.return,X)}}S&64&&S4(_),S&512&&zg(_,_.return);break;case 3:if(Ul(h,_),S&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){Ln(_,_.return,X)}}break;case 27:p===null&&S&4&&T4(_);case 26:case 5:Ul(h,_),p===null&&S&4&&M4(_),S&512&&zg(_,_.return);break;case 12:Ul(h,_);break;case 31:Ul(h,_),S&4&&R4(h,_);break;case 13:Ul(h,_),S&4&&D4(h,_),S&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Rne.bind(null,_),Qne(h,_))));break;case 22:if(S=_.memoizedState!==null||Ll,!S){p=p!==null&&p.memoizedState!==null||Wr,P=Ll;var O=Wr;Ll=S,(Wr=p)&&!O?Fl(h,_,(_.subtreeFlags&8772)!==0):Ul(h,_),Ll=P,Wr=O}break;case 30:break;default:Ul(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 Il(h,p,_){for(_=_.child;_!==null;)P4(h,p,_),_=_.sibling}function P4(h,p,_){if(ce&&typeof ce.onCommitFiberUnmount=="function")try{ce.onCommitFiberUnmount(Ve,_)}catch{}switch(_.tag){case 26:Wr||Wo(_,p),Il(h,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Wr||Wo(_,p);var S=hr,P=Ls;au(_.type)&&(hr=_.stateNode,Ls=!1),Il(h,p,_),Xg(_.stateNode),hr=S,Ls=P;break;case 5:Wr||Wo(_,p);case 6:if(S=hr,P=Ls,hr=null,Il(h,p,_),hr=S,Ls=P,hr!==null)if(Ls)try{(hr.nodeType===9?hr.body:hr.nodeName==="HTML"?hr.ownerDocument.body:hr).removeChild(_.stateNode)}catch(O){Ln(_,p,O)}else try{hr.removeChild(_.stateNode)}catch(O){Ln(_,p,O)}break;case 18:hr!==null&&(Ls?(h=hr,SU(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Kf(h)):SU(hr,_.stateNode));break;case 4:S=hr,P=Ls,hr=_.stateNode.containerInfo,Ls=!0,Il(h,p,_),hr=S,Ls=P;break;case 0:case 11:case 14:case 15:Jc(2,_,p),Wr||Jc(4,_,p),Il(h,p,_);break;case 1:Wr||(Wo(_,p),S=_.stateNode,typeof S.componentWillUnmount=="function"&&E4(_,p,S)),Il(h,p,_);break;case 21:Il(h,p,_);break;case 22:Wr=(S=Wr)||_.memoizedState!==null,Il(h,p,_),Wr=S;break;default:Il(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(_){Ln(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(_){Ln(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 Uv(h,p){var _=Ene(h);p.forEach(function(S){if(!_.has(S)){_.add(S);var P=Dne.bind(null,h,S);S.then(P,P)}})}function Is(h,p){var _=p.deletions;if(_!==null)for(var S=0;S<_.length;S++){var P=_[S],O=h,X=p,oe=X;e:for(;oe!==null;){switch(oe.tag){case 27:if(au(oe.type)){hr=oe.stateNode,Ls=!1;break e}break;case 5:hr=oe.stateNode,Ls=!1;break e;case 3:case 4:hr=oe.stateNode.containerInfo,Ls=!0;break e}oe=oe.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 go=null;function O4(h,p){var _=h.alternate,S=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Is(p,h),Us(h),S&4&&(Jc(3,h,h.return),Fg(3,h),Jc(5,h,h.return));break;case 1:Is(p,h),Us(h),S&512&&(Wr||_===null||Wo(_,_.return)),S&64&&Ll&&(h=h.updateQueue,h!==null&&(S=h.callbacks,S!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?S:_.concat(S))));break;case 26:var P=go;if(Is(p,h),Us(h),S&512&&(Wr||_===null||Wo(_,_.return)),S&4){var O=_!==null?_.memoizedState:null;if(S=h.memoizedState,_===null)if(S===null)if(h.stateNode===null){e:{S=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(S){case"title":O=P.getElementsByTagName("title")[0],(!O||O[rt]||O[br]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=P.createElement(S),P.head.insertBefore(O,P.querySelector("head > title"))),Vi(O,S,_),O[br]=h,Oe(O),S=O;break e;case"link":var X=OU("link","href",P).get(S+(_.href||""));if(X){for(var oe=0;oe<X.length;oe++)if(O=X[oe],O.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&O.getAttribute("rel")===(_.rel==null?null:_.rel)&&O.getAttribute("title")===(_.title==null?null:_.title)&&O.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){X.splice(oe,1);break t}}O=P.createElement(S),Vi(O,S,_),P.head.appendChild(O);break;case"meta":if(X=OU("meta","content",P).get(S+(_.content||""))){for(oe=0;oe<X.length;oe++)if(O=X[oe],O.getAttribute("content")===(_.content==null?null:""+_.content)&&O.getAttribute("name")===(_.name==null?null:_.name)&&O.getAttribute("property")===(_.property==null?null:_.property)&&O.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&O.getAttribute("charset")===(_.charSet==null?null:_.charSet)){X.splice(oe,1);break t}}O=P.createElement(S),Vi(O,S,_),P.head.appendChild(O);break;default:throw Error(r(468,S))}O[br]=h,Oe(O),S=O}h.stateNode=S}else jU(P,h.type,h.stateNode);else h.stateNode=DU(P,S,h.memoizedProps);else O!==S?(O===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):O.count--,S===null?jU(P,h.type,h.stateNode):DU(P,S,h.memoizedProps)):S===null&&h.stateNode!==null&&R2(h,h.memoizedProps,_.memoizedProps)}break;case 27:Is(p,h),Us(h),S&512&&(Wr||_===null||Wo(_,_.return)),_!==null&&S&4&&R2(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Is(p,h),Us(h),S&512&&(Wr||_===null||Wo(_,_.return)),h.flags&32){P=h.stateNode;try{$o(P,"")}catch(Rt){Ln(h,h.return,Rt)}}S&4&&h.stateNode!=null&&(P=h.memoizedProps,R2(h,P,_!==null?_.memoizedProps:P)),S&1024&&(j2=!0);break;case 6:if(Is(p,h),Us(h),S&4){if(h.stateNode===null)throw Error(r(162));S=h.memoizedProps,_=h.stateNode;try{_.nodeValue=S}catch(Rt){Ln(h,h.return,Rt)}}break;case 3:if(ey=null,P=go,go=Qv(p.containerInfo),Is(p,h),go=P,Us(h),S&4&&_!==null&&_.memoizedState.isDehydrated)try{Kf(p.containerInfo)}catch(Rt){Ln(h,h.return,Rt)}j2&&(j2=!1,j4(h));break;case 4:S=go,go=Qv(h.stateNode.containerInfo),Is(p,h),Us(h),go=S;break;case 12:Is(p,h),Us(h);break;case 31:Is(p,h),Us(h),S&4&&(S=h.updateQueue,S!==null&&(h.updateQueue=null,Uv(h,S)));break;case 13:Is(p,h),Us(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(zv=L()),S&4&&(S=h.updateQueue,S!==null&&(h.updateQueue=null,Uv(h,S)));break;case 22:P=h.memoizedState!==null;var Me=_!==null&&_.memoizedState!==null,Ke=Ll,lt=Wr;if(Ll=Ke||P,Wr=lt||Me,Is(p,h),Wr=lt,Ll=Ke,Us(h),S&8192)e:for(p=h.stateNode,p._visibility=P?p._visibility&-2:p._visibility|1,P&&(_===null||Me||Ll||Wr||zd(h)),_=null,p=h;;){if(p.tag===5||p.tag===26){if(_===null){Me=_=p;try{if(O=Me.stateNode,P)X=O.style,typeof X.setProperty=="function"?X.setProperty("display","none","important"):X.display="none";else{oe=Me.stateNode;var dt=Me.memoizedProps.style,Qe=dt!=null&&dt.hasOwnProperty("display")?dt.display:null;oe.style.display=Qe==null||typeof Qe=="boolean"?"":(""+Qe).trim()}}catch(Rt){Ln(Me,Me.return,Rt)}}}else if(p.tag===6){if(_===null){Me=p;try{Me.stateNode.nodeValue=P?"":Me.memoizedProps}catch(Rt){Ln(Me,Me.return,Rt)}}}else if(p.tag===18){if(_===null){Me=p;try{var it=Me.stateNode;P?EU(it,!0):EU(Me.stateNode,!1)}catch(Rt){Ln(Me,Me.return,Rt)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===h)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break e;for(;p.sibling===null;){if(p.return===null||p.return===h)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}S&4&&(S=h.updateQueue,S!==null&&(_=S.retryQueue,_!==null&&(S.retryQueue=null,Uv(h,_))));break;case 19:Is(p,h),Us(h),S&4&&(S=h.updateQueue,S!==null&&(h.updateQueue=null,Uv(h,S)));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 _,S=h.return;S!==null;){if(A4(S)){_=S;break}S=S.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,O=D2(h);Iv(h,O,P);break;case 5:var X=_.stateNode;_.flags&32&&($o(X,""),_.flags&=-33);var oe=D2(h);Iv(h,oe,X);break;case 3:case 4:var Me=_.stateNode.containerInfo,Ke=D2(h);O2(h,Ke,Me);break;default:throw Error(r(161))}}catch(lt){Ln(h,h.return,lt)}h.flags&=-3}p&4096&&(h.flags&=-4097)}function 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 Ul(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:Wo(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&E4(p,p.return,_),zd(p);break;case 27:Xg(p.stateNode);case 26:case 5:Wo(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 Fl(h,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var S=p.alternate,P=h,O=p,X=O.flags;switch(O.tag){case 0:case 11:case 15:Fl(P,O,_),Fg(4,O);break;case 1:if(Fl(P,O,_),S=O,P=S.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(Ke){Ln(S,S.return,Ke)}if(S=O,P=S.updateQueue,P!==null){var oe=S.stateNode;try{var Me=P.shared.hiddenCallbacks;if(Me!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Me.length;P++)hI(Me[P],oe)}catch(Ke){Ln(S,S.return,Ke)}}_&&X&64&&S4(O),zg(O,O.return);break;case 27:T4(O);case 26:case 5:Fl(P,O,_),_&&S===null&&X&4&&M4(O),zg(O,O.return);break;case 12:Fl(P,O,_);break;case 31:Fl(P,O,_),_&&X&4&&R4(P,O);break;case 13:Fl(P,O,_),_&&X&4&&D4(P,O);break;case 22:O.memoizedState===null&&Fl(P,O,_),zg(O,O.return);break;case 30:break;default:Fl(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&&Ag(_))}function I2(h,p){h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&Ag(h))}function xo(h,p,_,S){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)L4(h,p,_,S),p=p.sibling}function L4(h,p,_,S){var P=p.flags;switch(p.tag){case 0:case 11:case 15:xo(h,p,_,S),P&2048&&Fg(9,p);break;case 1:xo(h,p,_,S);break;case 3:xo(h,p,_,S),P&2048&&(h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&Ag(h)));break;case 12:if(P&2048){xo(h,p,_,S),h=p.stateNode;try{var O=p.memoizedProps,X=O.id,oe=O.onPostCommit;typeof oe=="function"&&oe(X,p.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Me){Ln(p,p.return,Me)}}else xo(h,p,_,S);break;case 31:xo(h,p,_,S);break;case 13:xo(h,p,_,S);break;case 23:break;case 22:O=p.stateNode,X=p.alternate,p.memoizedState!==null?O._visibility&2?xo(h,p,_,S):Bg(h,p):O._visibility&2?xo(h,p,_,S):(O._visibility|=2,If(h,p,_,S,(p.subtreeFlags&10256)!==0||!1)),P&2048&&L2(X,p);break;case 24:xo(h,p,_,S),P&2048&&I2(p.alternate,p);break;default:xo(h,p,_,S)}}function If(h,p,_,S,P){for(P=P&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var O=h,X=p,oe=_,Me=S,Ke=X.flags;switch(X.tag){case 0:case 11:case 15:If(O,X,oe,Me,P),Fg(8,X);break;case 23:break;case 22:var lt=X.stateNode;X.memoizedState!==null?lt._visibility&2?If(O,X,oe,Me,P):Bg(O,X):(lt._visibility|=2,If(O,X,oe,Me,P)),P&&Ke&2048&&L2(X.alternate,X);break;case 24:If(O,X,oe,Me,P),P&&Ke&2048&&I2(X.alternate,X);break;default:If(O,X,oe,Me,P)}p=p.sibling}}function Bg(h,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=h,S=p,P=S.flags;switch(S.tag){case 22:Bg(_,S),P&2048&&L2(S.alternate,S);break;case 24:Bg(_,S),P&2048&&I2(S.alternate,S);break;default:Bg(_,S)}p=p.sibling}}var Hg=8192;function Uf(h,p,_){if(h.subtreeFlags&Hg)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&Hg&&h.memoizedState!==null&&ure(_,go,h.memoizedState,h.memoizedProps);break;case 5:Uf(h,p,_);break;case 3:case 4:var S=go;go=Qv(h.stateNode.containerInfo),Uf(h,p,_),go=S;break;case 22:h.memoizedState===null&&(S=h.alternate,S!==null&&S.memoizedState!==null?(S=Hg,Hg=16777216,Uf(h,p,_),Hg=S):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 $g(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var S=p[_];Ti=S,z4(S,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:$g(h),h.flags&2048&&Jc(9,h,h.return);break;case 3:$g(h);break;case 12:$g(h);break;case 22:var p=h.stateNode;h.memoizedState!==null&&p._visibility&2&&(h.return===null||h.return.tag!==13)?(p._visibility&=-3,Fv(h)):$g(h);break;default:$g(h)}}function Fv(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var S=p[_];Ti=S,z4(S,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),Fv(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,Fv(p));break;default:Fv(p)}h=h.sibling}}function z4(h,p){for(;Ti!==null;){var _=Ti;switch(_.tag){case 0:case 11:case 15:Jc(8,_,p);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var S=_.memoizedState.cachePool.pool;S!=null&&S.refCount++}break;case 24:Ag(_.memoizedState.cache)}if(S=_.child,S!==null)S.return=_,Ti=S;else e:for(_=h;Ti!==null;){S=Ti;var P=S.sibling,O=S.return;if(k4(S),S===_){Ti=null;break e}if(P!==null){P.return=O,Ti=P;break e}Ti=O}}}var Mne={getCacheForType:function(h){var p=Hi($r),_=p.data.get(h);return _===void 0&&(_=h(),p.data.set(h,_)),_},cacheSignal:function(){return Hi($r).controller.signal}},Ane=typeof WeakMap=="function"?WeakMap:Map,Nn=0,Jn=null,fn=null,bn=0,jn=0,sa=null,eu=!1,Ff=!1,U2=!1,zl=0,Cr=0,tu=0,Bd=0,F2=0,aa=0,zf=0,Vg=null,Fs=null,z2=!1,zv=0,B4=0,Bv=1/0,Hv=null,nu=null,li=0,ru=null,Bf=null,Bl=0,B2=0,H2=null,H4=null,Gg=0,$2=null;function oa(){return(Nn&2)!==0&&bn!==0?bn&-bn:K.T!==null?X2():Fi()}function $4(){if(aa===0)if((bn&536870912)===0||_n){var h=pe;pe<<=1,(pe&3932160)===0&&(pe=262144),aa=h}else aa=536870912;return h=ra.current,h!==null&&(h.flags|=32),aa}function zs(h,p,_){(h===Jn&&(jn===2||jn===9)||h.cancelPendingCommit!==null)&&(Hf(h,0),iu(h,bn,aa,!1)),cn(h,_),((Nn&2)===0||h!==Jn)&&(h===Jn&&((Nn&2)===0&&(Bd|=_),Cr===4&&iu(h,bn,aa,!1)),qo(h))}function V4(h,p,_){if((Nn&6)!==0)throw Error(r(327));var S=!_&&(p&127)===0&&(p&h.expiredLanes)===0||He(h,p),P=S?Nne(h,p):G2(h,p,!0),O=S;do{if(P===0){Ff&&!S&&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 oe=h;P=Vg;var Me=oe.current.memoizedState.isDehydrated;if(Me&&(Hf(oe,X).flags|=256),X=G2(oe,X,!1),X!==2){if(U2&&!Me){oe.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(S=h,O=P,O){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:iu(S,p,aa,!eu);break e;case 2:Fs=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(P=zv+300-L(),10<P)){if(iu(S,p,aa,!eu),_e(S,0,!0)!==0)break e;Bl=p,S.timeoutHandle=_U(G4.bind(null,S,_,Fs,Hv,z2,p,aa,Bd,zf,eu,O,"Throttled",-0,0),P);break e}G4(S,_,Fs,Hv,z2,p,aa,Bd,zf,eu,O,null,-0,0)}}break}while(!0);qo(h)}function G4(h,p,_,S,P,O,X,oe,Me,Ke,lt,dt,Qe,it){if(h.timeoutHandle=-1,dt=p.subtreeFlags,dt&8192||(dt&16785408)===16785408){dt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Al},I4(p,O,dt);var Rt=(O&62914560)===O?zv-L():(O&4194048)===O?B4-L():0;if(Rt=dre(dt,Rt),Rt!==null){Bl=O,h.cancelPendingCommit=Rt(J4.bind(null,h,p,O,_,S,P,X,oe,Me,lt,dt,null,Qe,it)),iu(h,O,X,!Ke);return}}J4(h,p,O,_,S,P,X,oe,Me)}function Tne(h){for(var p=h;;){var _=p.tag;if((_===0||_===11||_===15)&&p.flags&16384&&(_=p.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var S=0;S<_.length;S++){var P=_[S],O=P.getSnapshot;P=P.value;try{if(!ta(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,_,S){p&=~F2,p&=~Bd,h.suspendedLanes|=p,h.pingedLanes&=~p,S&&(h.warmLanes|=p),S=h.expirationTimes;for(var P=p;0<P;){var O=31-$e(P),X=1<<O;S[O]=-1,P&=~X}_!==0&&Dn(h,_,p)}function $v(){return(Nn&6)===0?(Wg(0),!1):!0}function V2(){if(fn!==null){if(jn===0)var h=fn.return;else h=fn,kl=Rd=null,a2(h),Rf=null,Cg=0,h=fn;for(;h!==null;)w4(h.alternate,h),h=h.return;fn=null}}function Hf(h,p){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,qne(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Bl=0,V2(),Jn=h,fn=_=Cl(h.current,null),bn=p,jn=0,sa=null,eu=!1,Ff=He(h,p),U2=!1,zf=aa=F2=Bd=tu=Cr=0,Fs=Vg=null,z2=!1,(p&8)!==0&&(p|=p&32);var S=h.entangledLanes;if(S!==0)for(h=h.entanglements,S&=p;0<S;){var P=31-$e(S),O=1<<P;p|=h[P],S&=~O}return zl=p,uv(),_}function W4(h,p){en=null,K.H=Lg,p===Pf||p===bv?(p=lI(),jn=3):p===KM?(p=lI(),jn=4):jn=p===w2?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,sa=p,fn===null&&(Cr=1,Rv(h,Ca(p,h.current)))}function q4(){var h=ra.current;return h===null?!0:(bn&4194048)===bn?Ra===null:(bn&62914560)===bn||(bn&536870912)!==0?h===Ra:!1}function K4(){var h=K.H;return K.H=Lg,h===null?Lg:h}function X4(){var h=K.A;return K.A=Mne,h}function Vv(){Cr=4,eu||(bn&4194048)!==bn&&ra.current!==null||(Ff=!0),(tu&134217727)===0&&(Bd&134217727)===0||Jn===null||iu(Jn,bn,aa,!1)}function G2(h,p,_){var S=Nn;Nn|=2;var P=K4(),O=X4();(Jn!==h||bn!==p)&&(Hv=null,Hf(h,p)),p=!1;var X=Cr;e:do try{if(jn!==0&&fn!==null){var oe=fn,Me=sa;switch(jn){case 8:V2(),X=6;break e;case 3:case 2:case 9:case 6:ra.current===null&&(p=!0);var Ke=jn;if(jn=0,sa=null,$f(h,oe,Me,Ke),_&&Ff){X=0;break e}break;default:Ke=jn,jn=0,sa=null,$f(h,oe,Me,Ke)}}Cne(),X=Cr;break}catch(lt){W4(h,lt)}while(!0);return p&&h.shellSuspendCounter++,kl=Rd=null,Nn=S,K.H=P,K.A=O,fn===null&&(Jn=null,bn=0,uv()),X}function Cne(){for(;fn!==null;)Y4(fn)}function Nne(h,p){var _=Nn;Nn|=2;var S=K4(),P=X4();Jn!==h||bn!==p?(Hv=null,Bv=L()+500,Hf(h,p)):Ff=He(h,p);e:do try{if(jn!==0&&fn!==null){p=fn;var O=sa;t:switch(jn){case 1:jn=0,sa=null,$f(h,p,O,1);break;case 2:case 9:if(aI(O)){jn=0,sa=null,Z4(p);break}p=function(){jn!==2&&jn!==9||Jn!==h||(jn=7),qo(h)},O.then(p,p);break e;case 3:jn=7;break e;case 4:jn=5;break e;case 7:aI(O)?(jn=0,sa=null,Z4(p)):(jn=0,sa=null,$f(h,p,O,7));break;case 5:var X=null;switch(fn.tag){case 26:X=fn.memoizedState;case 5:case 27:var oe=fn;if(X?LU(X):oe.stateNode.complete){jn=0,sa=null;var Me=oe.sibling;if(Me!==null)fn=Me;else{var Ke=oe.return;Ke!==null?(fn=Ke,Gv(Ke)):fn=null}break t}}jn=0,sa=null,$f(h,p,O,5);break;case 6:jn=0,sa=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 kl=Rd=null,K.H=S,K.A=P,Nn=_,fn!==null?0:(Jn=null,bn=0,uv(),Cr)}function kne(){for(;fn!==null&&!Se();)Y4(fn)}function Y4(h){var p=y4(h.alternate,h,zl);h.memoizedProps=h.pendingProps,p===null?Gv(h):fn=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,bn);break;case 11:p=p4(_,p,p.pendingProps,p.type.render,p.ref,bn);break;case 5:a2(p);default:w4(_,p),p=fn=XL(p,zl),p=y4(_,p,zl)}h.memoizedProps=h.pendingProps,p===null?Gv(h):fn=p}function $f(h,p,_,S){kl=Rd=null,a2(p),Rf=null,Cg=0;var P=p.return;try{if(bne(h,P,p,_,bn)){Cr=1,Rv(h,Ca(_,h.current)),fn=null;return}}catch(O){if(P!==null)throw fn=P,O;Cr=1,Rv(h,Ca(_,h.current)),fn=null;return}p.flags&32768?(_n||S===1?h=!0:Ff||(bn&536870912)!==0?h=!1:(eu=h=!0,(S===2||S===9||S===3||S===6)&&(S=ra.current,S!==null&&S.tag===13&&(S.flags|=16384))),Q4(p,h)):Gv(p)}function Gv(h){var p=h;do{if((p.flags&32768)!==0){Q4(p,eu);return}h=p.return;var _=_ne(p.alternate,p,zl);if(_!==null){fn=_;return}if(p=p.sibling,p!==null){fn=p;return}fn=p=h}while(p!==null);Cr===0&&(Cr=5)}function Q4(h,p){do{var _=wne(h.alternate,h);if(_!==null){_.flags&=32767,fn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(h=h.sibling,h!==null)){fn=h;return}fn=h=_}while(h!==null);Cr=6,fn=null}function J4(h,p,_,S,P,O,X,oe,Me){h.cancelPendingCommit=null;do Wv();while(li!==0);if((Nn&6)!==0)throw Error(r(327));if(p!==null){if(p===h.current)throw Error(r(177));if(O=p.lanes|p.childLanes,O|=DM,It(h,_,O,X,oe,Me),h===Jn&&(fn=Jn=null,bn=0),Bf=p,ru=h,Bl=_,B2=O,H2=P,H4=S,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,One(ge,function(){return iU(),null})):(h.callbackNode=null,h.callbackPriority=0),S=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||S){S=K.T,K.T=null,P=V.p,V.p=2,X=Nn,Nn|=4;try{Sne(h,p,_)}finally{Nn=X,V.p=P,K.T=S}}li=1,eU(),tU(),nU()}}function eU(){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 S=V.p;V.p=2;var P=Nn;Nn|=4;try{O4(p,h);var O=rA,X=zL(h.containerInfo),oe=O.focusedElem,Me=O.selectionRange;if(X!==oe&&oe&&oe.ownerDocument&&FL(oe.ownerDocument.documentElement,oe)){if(Me!==null&&CM(oe)){var Ke=Me.start,lt=Me.end;if(lt===void 0&&(lt=Ke),"selectionStart"in oe)oe.selectionStart=Ke,oe.selectionEnd=Math.min(lt,oe.value.length);else{var dt=oe.ownerDocument||document,Qe=dt&&dt.defaultView||window;if(Qe.getSelection){var it=Qe.getSelection(),Rt=oe.textContent.length,Vt=Math.min(Me.start,Rt),Vn=Me.end===void 0?Vt:Math.min(Me.end,Rt);!it.extend&&Vt>Vn&&(X=Vn,Vn=Vt,Vt=X);var Be=UL(oe,Vt),Re=UL(oe,Vn);if(Be&&Re&&(it.rangeCount!==1||it.anchorNode!==Be.node||it.anchorOffset!==Be.offset||it.focusNode!==Re.node||it.focusOffset!==Re.offset)){var qe=dt.createRange();qe.setStart(Be.node,Be.offset),it.removeAllRanges(),Vt>Vn?(it.addRange(qe),it.extend(Re.node,Re.offset)):(qe.setEnd(Re.node,Re.offset),it.addRange(qe))}}}}for(dt=[],it=oe;it=it.parentNode;)it.nodeType===1&&dt.push({element:it,left:it.scrollLeft,top:it.scrollTop});for(typeof oe.focus=="function"&&oe.focus(),oe=0;oe<dt.length;oe++){var ct=dt[oe];ct.element.scrollLeft=ct.left,ct.element.scrollTop=ct.top}}iy=!!nA,rA=nA=null}finally{Nn=P,V.p=S,K.T=_}}h.current=p,li=2}}function tU(){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 S=V.p;V.p=2;var P=Nn;Nn|=4;try{N4(h,p.alternate,p)}finally{Nn=P,V.p=S,K.T=_}}li=3}}function nU(){if(li===4||li===3){li=0,B();var h=ru,p=Bf,_=Bl,S=H4;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?li=5:(li=0,Bf=ru=null,rU(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(nu=null),Ei(_),p=p.stateNode,ce&&typeof ce.onCommitFiberRoot=="function")try{ce.onCommitFiberRoot(Ve,p,void 0,(p.current.flags&128)===128)}catch{}if(S!==null){p=K.T,P=V.p,V.p=2,K.T=null;try{for(var O=h.onRecoverableError,X=0;X<S.length;X++){var oe=S[X];O(oe.value,{componentStack:oe.stack})}}finally{K.T=p,V.p=P}}(Bl&3)!==0&&Wv(),qo(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===$2?Gg++:(Gg=0,$2=h):Gg=0,Wg(0)}}function rU(h,p){(h.pooledCacheLanes&=p)===0&&(p=h.pooledCache,p!=null&&(h.pooledCache=null,Ag(p)))}function Wv(){return eU(),tU(),nU(),iU()}function iU(){if(li!==5)return!1;var h=ru,p=B2;B2=0;var _=Ei(Bl),S=K.T,P=V.p;try{V.p=32>_?32:_,K.T=null,_=H2,H2=null;var O=ru,X=Bl;if(li=0,Bf=ru=null,Bl=0,(Nn&6)!==0)throw Error(r(331));var oe=Nn;if(Nn|=4,F4(O.current),L4(O,O.current,X,_),Nn=oe,Wg(0,!1),ce&&typeof ce.onPostCommitFiberRoot=="function")try{ce.onPostCommitFiberRoot(Ve,O)}catch{}return!0}finally{V.p=P,K.T=S,rU(h,p)}}function sU(h,p,_){p=Ca(_,p),p=_2(h.stateNode,p,2),h=Yc(h,p,2),h!==null&&(cn(h,2),qo(h))}function Ln(h,p,_){if(h.tag===3)sU(h,h,_);else for(;p!==null;){if(p.tag===3){sU(p,h,_);break}else if(p.tag===1){var S=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof S.componentDidCatch=="function"&&(nu===null||!nu.has(S))){h=Ca(_,h),_=a4(2),S=Yc(p,_,2),S!==null&&(o4(_,S,p,h),cn(S,2),qo(S));break}}p=p.return}}function W2(h,p,_){var S=h.pingCache;if(S===null){S=h.pingCache=new Ane;var P=new Set;S.set(p,P)}else P=S.get(p),P===void 0&&(P=new Set,S.set(p,P));P.has(_)||(U2=!0,P.add(_),h=Pne.bind(null,h,p,_),p.then(h,h))}function Pne(h,p,_){var S=h.pingCache;S!==null&&S.delete(p),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,Jn===h&&(bn&_)===_&&(Cr===4||Cr===3&&(bn&62914560)===bn&&300>L()-zv?(Nn&2)===0&&Hf(h,0):F2|=_,zf===bn&&(zf=0)),qo(h)}function aU(h,p){p===0&&(p=wt()),h=Nd(h,p),h!==null&&(cn(h,p),qo(h))}function Rne(h){var p=h.memoizedState,_=0;p!==null&&(_=p.retryLane),aU(h,_)}function Dne(h,p){var _=0;switch(h.tag){case 31:case 13:var S=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:S=h.stateNode;break;case 22:S=h.stateNode._retryCache;break;default:throw Error(r(314))}S!==null&&S.delete(p),aU(h,_)}function One(h,p){return Pe(h,p)}var qv=null,Vf=null,q2=!1,Kv=!1,K2=!1,su=0;function qo(h){h!==Vf&&h.next===null&&(Vf===null?qv=Vf=h:Vf=Vf.next=h),Kv=!0,q2||(q2=!0,Lne())}function Wg(h,p){if(!K2&&Kv){K2=!0;do for(var _=!1,S=qv;S!==null;){if(h!==0){var P=S.pendingLanes;if(P===0)var O=0;else{var X=S.suspendedLanes,oe=S.pingedLanes;O=(1<<31-$e(42|h)+1)-1,O&=P&~(X&~oe),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(_=!0,uU(S,O))}else O=bn,O=_e(S,S===Jn?O:0,S.cancelPendingCommit!==null||S.timeoutHandle!==-1),(O&3)===0||He(S,O)||(_=!0,uU(S,O));S=S.next}while(_);K2=!1}}function jne(){oU()}function oU(){Kv=q2=!1;var h=0;su!==0&&Wne()&&(h=su);for(var p=L(),_=null,S=qv;S!==null;){var P=S.next,O=lU(S,p);O===0?(S.next=null,_===null?qv=P:_.next=P,P===null&&(Vf=_)):(_=S,(h!==0||(O&3)!==0)&&(Kv=!0)),S=P}li!==0&&li!==5||Wg(h),su!==0&&(su=0)}function lU(h,p){for(var _=h.suspendedLanes,S=h.pingedLanes,P=h.expirationTimes,O=h.pendingLanes&-62914561;0<O;){var X=31-$e(O),oe=1<<X,Me=P[X];Me===-1?((oe&_)===0||(oe&S)!==0)&&(P[X]=ht(oe,p)):Me<=p&&(h.expiredLanes|=oe),O&=~oe}if(p=Jn,_=bn,_=_e(h,h===p?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),S=h.callbackNode,_===0||h===p&&(jn===2||jn===9)||h.cancelPendingCommit!==null)return S!==null&&S!==null&&Ne(S),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||He(h,_)){if(p=_&-_,p===h.callbackPriority)return p;switch(S!==null&&Ne(S),Ei(_)){case 2:case 8:_=we;break;case 32:_=ge;break;case 268435456:_=Ae;break;default:_=ge}return S=cU.bind(null,h),_=Pe(_,S),h.callbackPriority=p,h.callbackNode=_,p}return S!==null&&S!==null&&Ne(S),h.callbackPriority=2,h.callbackNode=null,2}function cU(h,p){if(li!==0&&li!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Wv()&&h.callbackNode!==_)return null;var S=bn;return S=_e(h,h===Jn?S:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),S===0?null:(V4(h,S,p),lU(h,L()),h.callbackNode!=null&&h.callbackNode===_?cU.bind(null,h):null)}function uU(h,p){if(Wv())return null;V4(h,p,!0)}function Lne(){Kne(function(){(Nn&6)!==0?Pe(be,jne):oU()})}function X2(){if(su===0){var h=Nf;h===0&&(h=Fe,Fe<<=1,(Fe&261888)===0&&(Fe=256)),su=h}return su}function dU(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:nv(""+h)}function hU(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,_,S,P){if(p==="submit"&&_&&_.stateNode===P){var O=dU((P[Or]||null).action),X=S.submitter;X&&(p=(p=X[Or]||null)?dU(p.formAction):X.getAttribute("formAction"),p!==null&&(O=p,X=null));var oe=new av("action","action",null,S,P);h.push({event:oe,listeners:[{instance:null,listener:function(){if(S.defaultPrevented){if(su!==0){var Me=X?hU(P,X):new FormData(P);m2(_,{pending:!0,data:Me,method:P.method,action:O},null,Me)}}else typeof O=="function"&&(oe.preventDefault(),Me=X?hU(P,X):new FormData(P),m2(_,{pending:!0,data:Me,method:P.method,action:O},O,Me))},currentTarget:P}]})}}for(var Y2=0;Y2<RM.length;Y2++){var Z2=RM[Y2],Une=Z2.toLowerCase(),Fne=Z2[0].toUpperCase()+Z2.slice(1);mo(Une,"on"+Fne)}mo($L,"onAnimationEnd"),mo(VL,"onAnimationIteration"),mo(GL,"onAnimationStart"),mo("dblclick","onDoubleClick"),mo("focusin","onFocus"),mo("focusout","onBlur"),mo(tne,"onTransitionRun"),mo(nne,"onTransitionStart"),mo(rne,"onTransitionCancel"),mo(WL,"onTransitionEnd"),bt("onMouseEnter",["mouseout","mouseover"]),bt("onMouseLeave",["mouseout","mouseover"]),bt("onPointerEnter",["pointerout","pointerover"]),bt("onPointerLeave",["pointerout","pointerover"]),ft("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ft("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ft("onBeforeInput",["compositionend","keypress","textInput","paste"]),ft("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var qg="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(qg));function fU(h,p){p=(p&4)!==0;for(var _=0;_<h.length;_++){var S=h[_],P=S.event;S=S.listeners;e:{var O=void 0;if(p)for(var X=S.length-1;0<=X;X--){var oe=S[X],Me=oe.instance,Ke=oe.currentTarget;if(oe=oe.listener,Me!==O&&P.isPropagationStopped())break e;O=oe,P.currentTarget=Ke;try{O(P)}catch(lt){cv(lt)}P.currentTarget=null,O=Me}else for(X=0;X<S.length;X++){if(oe=S[X],Me=oe.instance,Ke=oe.currentTarget,oe=oe.listener,Me!==O&&P.isPropagationStopped())break e;O=oe,P.currentTarget=Ke;try{O(P)}catch(lt){cv(lt)}P.currentTarget=null,O=Me}}}}function pn(h,p){var _=p[Hc];_===void 0&&(_=p[Hc]=new Set);var S=h+"__bubble";_.has(S)||(pU(p,h,2,!1),_.add(S))}function Q2(h,p,_){var S=0;p&&(S|=4),pU(_,h,S,p)}var Xv="_reactListening"+Math.random().toString(36).slice(2);function J2(h){if(!h[Xv]){h[Xv]=!0,Te.forEach(function(_){_!=="selectionchange"&&(zne.has(_)||Q2(_,!1,h),Q2(_,!0,h))});var p=h.nodeType===9?h:h.ownerDocument;p===null||p[Xv]||(p[Xv]=!0,Q2("selectionchange",!1,p))}}function pU(h,p,_,S){switch($U(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),S?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,_,S,P){var O=S;if((p&1)===0&&(p&2)===0&&S!==null)e:for(;;){if(S===null)return;var X=S.tag;if(X===3||X===4){var oe=S.stateNode.containerInfo;if(oe===P)break;if(X===4)for(X=S.return;X!==null;){var Me=X.tag;if((Me===3||Me===4)&&X.stateNode.containerInfo===P)return;X=X.return}for(;oe!==null;){if(X=St(oe),X===null)return;if(Me=X.tag,Me===5||Me===6||Me===26||Me===27){S=O=X;continue e}oe=oe.parentNode}}S=S.return}vL(function(){var Ke=O,lt=xM(_),dt=[];e:{var Qe=qL.get(h);if(Qe!==void 0){var it=av,Rt=h;switch(h){case"keypress":if(iv(_)===0)break e;case"keydown":case"keyup":it=Dte;break;case"focusin":Rt="focus",it=SM;break;case"focusout":Rt="blur",it=SM;break;case"beforeblur":case"afterblur":it=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":it=wL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":it=_te;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":it=Lte;break;case $L:case VL:case GL:it=Ete;break;case WL:it=Ute;break;case"scroll":case"scrollend":it=vte;break;case"wheel":it=zte;break;case"copy":case"cut":case"paste":it=Ate;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":it=EL;break;case"toggle":case"beforetoggle":it=Hte}var Vt=(p&4)!==0,Vn=!Vt&&(h==="scroll"||h==="scrollend"),Be=Vt?Qe!==null?Qe+"Capture":null:Qe;Vt=[];for(var Re=Ke,qe;Re!==null;){var ct=Re;if(qe=ct.stateNode,ct=ct.tag,ct!==5&&ct!==26&&ct!==27||qe===null||Be===null||(ct=mg(Re,Be),ct!=null&&Vt.push(Kg(Re,ct,qe))),Vn)break;Re=Re.return}0<Vt.length&&(Qe=new it(Qe,Rt,null,_,lt),dt.push({event:Qe,listeners:Vt}))}}if((p&7)===0){e:{if(Qe=h==="mouseover"||h==="pointerover",it=h==="mouseout"||h==="pointerout",Qe&&_!==gM&&(Rt=_.relatedTarget||_.fromElement)&&(St(Rt)||Rt[fo]))break e;if((it||Qe)&&(Qe=lt.window===lt?lt:(Qe=lt.ownerDocument)?Qe.defaultView||Qe.parentWindow:window,it?(Rt=_.relatedTarget||_.toElement,it=Ke,Rt=Rt?St(Rt):null,Rt!==null&&(Vn=s(Rt),Vt=Rt.tag,Rt!==Vn||Vt!==5&&Vt!==27&&Vt!==6)&&(Rt=null)):(it=null,Rt=Ke),it!==Rt)){if(Vt=wL,ct="onMouseLeave",Be="onMouseEnter",Re="mouse",(h==="pointerout"||h==="pointerover")&&(Vt=EL,ct="onPointerLeave",Be="onPointerEnter",Re="pointer"),Vn=it==null?Qe:Ee(it),qe=Rt==null?Qe:Ee(Rt),Qe=new Vt(ct,Re+"leave",it,_,lt),Qe.target=Vn,Qe.relatedTarget=qe,ct=null,St(lt)===Ke&&(Vt=new Vt(Be,Re+"enter",Rt,_,lt),Vt.target=qe,Vt.relatedTarget=Vn,ct=Vt),Vn=ct,it&&Rt)t:{for(Vt=Bne,Be=it,Re=Rt,qe=0,ct=Be;ct;ct=Vt(ct))qe++;ct=0;for(var zt=Re;zt;zt=Vt(zt))ct++;for(;0<qe-ct;)Be=Vt(Be),qe--;for(;0<ct-qe;)Re=Vt(Re),ct--;for(;qe--;){if(Be===Re||Re!==null&&Be===Re.alternate){Vt=Be;break t}Be=Vt(Be),Re=Vt(Re)}Vt=null}else Vt=null;it!==null&&mU(dt,Qe,it,Vt,!1),Rt!==null&&Vn!==null&&mU(dt,Vn,Rt,Vt,!0)}}e:{if(Qe=Ke?Ee(Ke):window,it=Qe.nodeName&&Qe.nodeName.toLowerCase(),it==="select"||it==="input"&&Qe.type==="file")var Mn=RL;else if(kL(Qe))if(DL)Mn=Qte;else{Mn=Yte;var Lt=Xte}else it=Qe.nodeName,!it||it.toLowerCase()!=="input"||Qe.type!=="checkbox"&&Qe.type!=="radio"?Ke&&mM(Ke.elementType)&&(Mn=RL):Mn=Zte;if(Mn&&(Mn=Mn(h,Ke))){PL(dt,Mn,_,lt);break e}Lt&&Lt(h,Qe,Ke),h==="focusout"&&Ke&&Qe.type==="number"&&Ke.memoizedProps.value!=null&&Mi(Qe,"number",Qe.value)}switch(Lt=Ke?Ee(Ke):window,h){case"focusin":(kL(Lt)||Lt.contentEditable==="true")&&(_f=Lt,NM=Ke,Sg=null);break;case"focusout":Sg=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 tn;if(MM)e:{switch(h){case"compositionstart":var vn="onCompositionStart";break e;case"compositionend":vn="onCompositionEnd";break e;case"compositionupdate":vn="onCompositionUpdate";break e}vn=void 0}else yf?CL(h,_)&&(vn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(vn="onCompositionStart");vn&&(ML&&_.locale!=="ko"&&(yf||vn!=="onCompositionStart"?vn==="onCompositionEnd"&&yf&&(tn=yL()):($c=lt,yM="value"in $c?$c.value:$c.textContent,yf=!0)),Lt=Yv(Ke,vn),0<Lt.length&&(vn=new SL(vn,h,null,_,lt),dt.push({event:vn,listeners:Lt}),tn?vn.data=tn:(tn=NL(_),tn!==null&&(vn.data=tn)))),(tn=Vte?Gte(h,_):Wte(h,_))&&(vn=Yv(Ke,"onBeforeInput"),0<vn.length&&(Lt=new SL("onBeforeInput","beforeinput",null,_,lt),dt.push({event:Lt,listeners:vn}),Lt.data=tn)),Ine(dt,h,Ke,_,lt)}fU(dt,p)})}function Kg(h,p,_){return{instance:h,listener:p,currentTarget:_}}function Yv(h,p){for(var _=p+"Capture",S=[];h!==null;){var P=h,O=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||O===null||(P=mg(h,_),P!=null&&S.unshift(Kg(h,P,O)),P=mg(h,p),P!=null&&S.push(Kg(h,P,O))),h.tag===3)return S;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 mU(h,p,_,S,P){for(var O=p._reactName,X=[];_!==null&&_!==S;){var oe=_,Me=oe.alternate,Ke=oe.stateNode;if(oe=oe.tag,Me!==null&&Me===S)break;oe!==5&&oe!==26&&oe!==27||Ke===null||(Me=Ke,P?(Ke=mg(_,O),Ke!=null&&X.unshift(Kg(_,Ke,Me))):P||(Ke=mg(_,O),Ke!=null&&X.push(Kg(_,Ke,Me)))),_=_.return}X.length!==0&&h.push({event:p,listeners:X})}var Hne=/\r\n?/g,$ne=/\u0000|\uFFFD/g;function gU(h){return(typeof h=="string"?h:""+h).replace(Hne,`
- `).replace($ne,"")}function xU(h,p){return p=gU(p),gU(h)===p}function $n(h,p,_,S,P,O){switch(_){case"children":typeof S=="string"?p==="body"||p==="textarea"&&S===""||$o(h,S):(typeof S=="number"||typeof S=="bigint")&&p!=="body"&&$o(h,""+S);break;case"className":Ft(h,"class",S);break;case"tabIndex":Ft(h,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":Ft(h,_,S);break;case"style":xL(h,S,O);break;case"data":if(p!=="object"){Ft(h,"data",S);break}case"src":case"href":if(S===""&&(p!=="a"||_!=="href")){h.removeAttribute(_);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){h.removeAttribute(_);break}S=nv(""+S),h.setAttribute(_,S);break;case"action":case"formAction":if(typeof S=="function"){h.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof O=="function"&&(_==="formAction"?(p!=="input"&&$n(h,p,"name",P.name,P,null),$n(h,p,"formEncType",P.formEncType,P,null),$n(h,p,"formMethod",P.formMethod,P,null),$n(h,p,"formTarget",P.formTarget,P,null)):($n(h,p,"encType",P.encType,P,null),$n(h,p,"method",P.method,P,null),$n(h,p,"target",P.target,P,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){h.removeAttribute(_);break}S=nv(""+S),h.setAttribute(_,S);break;case"onClick":S!=null&&(h.onclick=Al);break;case"onScroll":S!=null&&pn("scroll",h);break;case"onScrollEnd":S!=null&&pn("scrollend",h);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":h.muted=S&&typeof S!="function"&&typeof S!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(S==null||typeof S=="function"||typeof S=="boolean"||typeof S=="symbol"){h.removeAttribute("xlink:href");break}_=nv(""+S),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":S!=null&&typeof S!="function"&&typeof S!="symbol"?h.setAttribute(_,""+S):h.removeAttribute(_);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":S&&typeof S!="function"&&typeof S!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":S===!0?h.setAttribute(_,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?h.setAttribute(_,S):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?h.setAttribute(_,S):h.removeAttribute(_);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?h.removeAttribute(_):h.setAttribute(_,S);break;case"popover":pn("beforetoggle",h),pn("toggle",h),Kt(h,"popover",S);break;case"xlinkActuate":nn(h,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":nn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":nn(h,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":nn(h,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":nn(h,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":nn(h,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":nn(h,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":nn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":nn(h,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":Kt(h,"is",S);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=xte.get(_)||_,Kt(h,_,S))}}function tA(h,p,_,S,P,O){switch(_){case"style":xL(h,S,O);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof S=="string"?$o(h,S):(typeof S=="number"||typeof S=="bigint")&&$o(h,""+S);break;case"onScroll":S!=null&&pn("scroll",h);break;case"onScrollEnd":S!=null&&pn("scrollend",h);break;case"onClick":S!=null&&(h.onclick=Al);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 S=="function")){typeof O!="function"&&O!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(p,S,P);break e}_ in h?h[_]=S:S===!0?h.setAttribute(_,""):Kt(h,_,S)}}}function Vi(h,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":pn("error",h),pn("load",h);var S=!1,P=!1,O;for(O in _)if(_.hasOwnProperty(O)){var X=_[O];if(X!=null)switch(O){case"src":S=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:$n(h,p,O,X,_,null)}}P&&$n(h,p,"srcSet",_.srcSet,_,null),S&&$n(h,p,"src",_.src,_,null);return;case"input":pn("invalid",h);var oe=O=X=P=null,Me=null,Ke=null;for(S in _)if(_.hasOwnProperty(S)){var lt=_[S];if(lt!=null)switch(S){case"name":P=lt;break;case"type":X=lt;break;case"checked":Me=lt;break;case"defaultChecked":Ke=lt;break;case"value":O=lt;break;case"defaultValue":oe=lt;break;case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(r(137,p));break;default:$n(h,p,S,lt,_,null)}}On(h,O,oe,Me,Ke,X,P,!1);return;case"select":pn("invalid",h),S=X=O=null;for(P in _)if(_.hasOwnProperty(P)&&(oe=_[P],oe!=null))switch(P){case"value":O=oe;break;case"defaultValue":X=oe;break;case"multiple":S=oe;default:$n(h,p,P,oe,_,null)}p=O,_=X,h.multiple=!!S,p!=null?oi(h,!!S,p,!1):_!=null&&oi(h,!!S,_,!0);return;case"textarea":pn("invalid",h),O=P=S=null;for(X in _)if(_.hasOwnProperty(X)&&(oe=_[X],oe!=null))switch(X){case"value":S=oe;break;case"defaultValue":P=oe;break;case"children":O=oe;break;case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(91));break;default:$n(h,p,X,oe,_,null)}zi(h,S,P,O);return;case"option":for(Me in _)if(_.hasOwnProperty(Me)&&(S=_[Me],S!=null))switch(Me){case"selected":h.selected=S&&typeof S!="function"&&typeof S!="symbol";break;default:$n(h,p,Me,S,_,null)}return;case"dialog":pn("beforetoggle",h),pn("toggle",h),pn("cancel",h),pn("close",h);break;case"iframe":case"object":pn("load",h);break;case"video":case"audio":for(S=0;S<qg.length;S++)pn(qg[S],h);break;case"image":pn("error",h),pn("load",h);break;case"details":pn("toggle",h);break;case"embed":case"source":case"link":pn("error",h),pn("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Ke in _)if(_.hasOwnProperty(Ke)&&(S=_[Ke],S!=null))switch(Ke){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:$n(h,p,Ke,S,_,null)}return;default:if(mM(p)){for(lt in _)_.hasOwnProperty(lt)&&(S=_[lt],S!==void 0&&tA(h,p,lt,S,_,void 0));return}}for(oe in _)_.hasOwnProperty(oe)&&(S=_[oe],S!=null&&$n(h,p,oe,S,_,null))}function Vne(h,p,_,S){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,O=null,X=null,oe=null,Me=null,Ke=null,lt=null;for(it in _){var dt=_[it];if(_.hasOwnProperty(it)&&dt!=null)switch(it){case"checked":break;case"value":break;case"defaultValue":Me=dt;default:S.hasOwnProperty(it)||$n(h,p,it,null,S,dt)}}for(var Qe in S){var it=S[Qe];if(dt=_[Qe],S.hasOwnProperty(Qe)&&(it!=null||dt!=null))switch(Qe){case"type":O=it;break;case"name":P=it;break;case"checked":Ke=it;break;case"defaultChecked":lt=it;break;case"value":X=it;break;case"defaultValue":oe=it;break;case"children":case"dangerouslySetInnerHTML":if(it!=null)throw Error(r(137,p));break;default:it!==dt&&$n(h,p,Qe,it,S,dt)}}po(h,X,oe,Me,Ke,lt,O,P);return;case"select":it=X=oe=Qe=null;for(O in _)if(Me=_[O],_.hasOwnProperty(O)&&Me!=null)switch(O){case"value":break;case"multiple":it=Me;default:S.hasOwnProperty(O)||$n(h,p,O,null,S,Me)}for(P in S)if(O=S[P],Me=_[P],S.hasOwnProperty(P)&&(O!=null||Me!=null))switch(P){case"value":Qe=O;break;case"defaultValue":oe=O;break;case"multiple":X=O;default:O!==Me&&$n(h,p,P,O,S,Me)}p=oe,_=X,S=it,Qe!=null?oi(h,!!_,Qe,!1):!!S!=!!_&&(p!=null?oi(h,!!_,p,!0):oi(h,!!_,_?[]:"",!1));return;case"textarea":it=Qe=null;for(oe in _)if(P=_[oe],_.hasOwnProperty(oe)&&P!=null&&!S.hasOwnProperty(oe))switch(oe){case"value":break;case"children":break;default:$n(h,p,oe,null,S,P)}for(X in S)if(P=S[X],O=_[X],S.hasOwnProperty(X)&&(P!=null||O!=null))switch(X){case"value":Qe=P;break;case"defaultValue":it=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==O&&$n(h,p,X,P,S,O)}Ai(h,Qe,it);return;case"option":for(var Rt in _)if(Qe=_[Rt],_.hasOwnProperty(Rt)&&Qe!=null&&!S.hasOwnProperty(Rt))switch(Rt){case"selected":h.selected=!1;break;default:$n(h,p,Rt,null,S,Qe)}for(Me in S)if(Qe=S[Me],it=_[Me],S.hasOwnProperty(Me)&&Qe!==it&&(Qe!=null||it!=null))switch(Me){case"selected":h.selected=Qe&&typeof Qe!="function"&&typeof Qe!="symbol";break;default:$n(h,p,Me,Qe,S,it)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Vt in _)Qe=_[Vt],_.hasOwnProperty(Vt)&&Qe!=null&&!S.hasOwnProperty(Vt)&&$n(h,p,Vt,null,S,Qe);for(Ke in S)if(Qe=S[Ke],it=_[Ke],S.hasOwnProperty(Ke)&&Qe!==it&&(Qe!=null||it!=null))switch(Ke){case"children":case"dangerouslySetInnerHTML":if(Qe!=null)throw Error(r(137,p));break;default:$n(h,p,Ke,Qe,S,it)}return;default:if(mM(p)){for(var Vn in _)Qe=_[Vn],_.hasOwnProperty(Vn)&&Qe!==void 0&&!S.hasOwnProperty(Vn)&&tA(h,p,Vn,void 0,S,Qe);for(lt in S)Qe=S[lt],it=_[lt],!S.hasOwnProperty(lt)||Qe===it||Qe===void 0&&it===void 0||tA(h,p,lt,Qe,S,it);return}}for(var Be in _)Qe=_[Be],_.hasOwnProperty(Be)&&Qe!=null&&!S.hasOwnProperty(Be)&&$n(h,p,Be,null,S,Qe);for(dt in S)Qe=S[dt],it=_[dt],!S.hasOwnProperty(dt)||Qe===it||Qe==null&&it==null||$n(h,p,dt,Qe,S,it)}function bU(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"),S=0;S<_.length;S++){var P=_[S],O=P.transferSize,X=P.initiatorType,oe=P.duration;if(O&&oe&&bU(X)){for(X=0,oe=P.responseEnd,S+=1;S<_.length;S++){var Me=_[S],Ke=Me.startTime;if(Ke>oe)break;var lt=Me.transferSize,dt=Me.initiatorType;lt&&bU(dt)&&(Me=Me.responseEnd,X+=lt*(Me<oe?1:(oe-Ke)/(Me-Ke)))}if(--S,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 Zv(h){return h.nodeType===9?h:h.ownerDocument}function vU(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 yU(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 _U=typeof setTimeout=="function"?setTimeout:void 0,qne=typeof clearTimeout=="function"?clearTimeout:void 0,wU=typeof Promise=="function"?Promise:void 0,Kne=typeof queueMicrotask=="function"?queueMicrotask:typeof wU<"u"?function(h){return wU.resolve(null).then(h).catch(Xne)}:_U;function Xne(h){setTimeout(function(){throw h})}function au(h){return h==="head"}function SU(h,p){var _=p,S=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(S===0){h.removeChild(P),Kf(p);return}S--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")S++;else if(_==="html")Xg(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Xg(_);for(var O=_.firstChild;O;){var X=O.nextSibling,oe=O.nodeName;O[rt]||oe==="SCRIPT"||oe==="STYLE"||oe==="LINK"&&O.rel.toLowerCase()==="stylesheet"||_.removeChild(O),O=X}}else _==="body"&&Xg(h.ownerDocument.body);_=P}while(_);Kf(p)}function EU(h,p){var _=h;h=0;do{var S=_.nextSibling;if(_.nodeType===1?p?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(p?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),S&&S.nodeType===8)if(_=S.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=S}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,_,S){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==p.toLowerCase()){if(!S&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(S){if(!h[rt])switch(p){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(O=h.getAttribute("rel"),O==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(O!==P.rel||h.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||h.getAttribute("title")!==(P.title==null?null:P.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(O=h.getAttribute("src"),(O!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&O&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(p==="input"&&h.type==="hidden"){var O=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===O)return h}else return h;if(h=Da(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=Da(h.nextSibling),h===null))return null;return h}function MU(h,p){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!p||(h=Da(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 S=function(){p(),_.removeEventListener("DOMContentLoaded",S)};_.addEventListener("DOMContentLoaded",S),h._reactRetry=S}}function Da(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 AU(h){h=h.nextSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(p===0)return Da(h.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}h=h.nextSibling}return null}function TU(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 CU(h,p,_){switch(p=Zv(_),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 Xg(h){for(var p=h.attributes;p.length;)h.removeAttributeNode(p[0]);et(h)}var Oa=new Map,NU=new Set;function Qv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Hl=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=Hl.f(),p=$v();return h||p}function ere(h){var p=se(h);p!==null&&p.tag===5&&p.type==="form"?WI(p):Hl.r(h)}var Gf=typeof document>"u"?null:document;function kU(h,p,_){var S=Gf;if(S&&typeof p=="string"&&p){var P=Pn(p);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),NU.has(P)||(NU.add(P),h={rel:h,crossOrigin:_,href:p},S.querySelector(P)===null&&(p=S.createElement("link"),Vi(p,"link",h),Oe(p),S.head.appendChild(p)))}}function tre(h){Hl.D(h),kU("dns-prefetch",h,null)}function nre(h,p){Hl.C(h,p),kU("preconnect",h,p)}function rre(h,p,_){Hl.L(h,p,_);var S=Gf;if(S&&h&&p){var P='link[rel="preload"][as="'+Pn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+Pn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+Pn(_.imageSizes)+'"]')):P+='[href="'+Pn(h)+'"]';var O=P;switch(p){case"style":O=Wf(h);break;case"script":O=qf(h)}Oa.has(O)||(h=f({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:h,as:p},_),Oa.set(O,h),S.querySelector(P)!==null||p==="style"&&S.querySelector(Yg(O))||p==="script"&&S.querySelector(Zg(O))||(p=S.createElement("link"),Vi(p,"link",h),Oe(p),S.head.appendChild(p)))}}function ire(h,p){Hl.m(h,p);var _=Gf;if(_&&h){var S=p&&typeof p.as=="string"?p.as:"script",P='link[rel="modulepreload"][as="'+Pn(S)+'"][href="'+Pn(h)+'"]',O=P;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=qf(h)}if(!Oa.has(O)&&(h=f({rel:"modulepreload",href:h},p),Oa.set(O,h),_.querySelector(P)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Zg(O)))return}S=_.createElement("link"),Vi(S,"link",h),Oe(S),_.head.appendChild(S)}}}function sre(h,p,_){Hl.S(h,p,_);var S=Gf;if(S&&h){var P=Le(S).hoistableStyles,O=Wf(h);p=p||"default";var X=P.get(O);if(!X){var oe={loading:0,preload:null};if(X=S.querySelector(Yg(O)))oe.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":p},_),(_=Oa.get(O))&&uA(h,_);var Me=X=S.createElement("link");Oe(Me),Vi(Me,"link",h),Me._p=new Promise(function(Ke,lt){Me.onload=Ke,Me.onerror=lt}),Me.addEventListener("load",function(){oe.loading|=1}),Me.addEventListener("error",function(){oe.loading|=2}),oe.loading|=4,Jv(X,p,S)}X={type:"stylesheet",instance:X,count:1,state:oe},P.set(O,X)}}}function are(h,p){Hl.X(h,p);var _=Gf;if(_&&h){var S=Le(_).hoistableScripts,P=qf(h),O=S.get(P);O||(O=_.querySelector(Zg(P)),O||(h=f({src:h,async:!0},p),(p=Oa.get(P))&&dA(h,p),O=_.createElement("script"),Oe(O),Vi(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},S.set(P,O))}}function ore(h,p){Hl.M(h,p);var _=Gf;if(_&&h){var S=Le(_).hoistableScripts,P=qf(h),O=S.get(P);O||(O=_.querySelector(Zg(P)),O||(h=f({src:h,async:!0,type:"module"},p),(p=Oa.get(P))&&dA(h,p),O=_.createElement("script"),Oe(O),Vi(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},S.set(P,O))}}function PU(h,p,_,S){var P=(P=de.current)?Qv(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),_=Le(P).hoistableStyles,S=_.get(p),S||(S={type:"style",instance:null,count:0,state:null},_.set(p,S)),S):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Wf(_.href);var O=Le(P).hoistableStyles,X=O.get(h);if(X||(P=P.ownerDocument||P,X={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(h,X),(O=P.querySelector(Yg(h)))&&!O._p&&(X.instance=O,X.state.loading=5),Oa.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Oa.set(h,_),O||lre(P,h,_,X.state))),p&&S===null)throw Error(r(528,""));return X}if(p&&S!==null)throw Error(r(529,""));return null;case"script":return p=_.async,_=_.src,typeof _=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=qf(_),_=Le(P).hoistableScripts,S=_.get(p),S||(S={type:"script",instance:null,count:0,state:null},_.set(p,S)),S):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Wf(h){return'href="'+Pn(h)+'"'}function Yg(h){return'link[rel="stylesheet"]['+h+"]"}function RU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function lre(h,p,_,S){h.querySelector('link[rel="preload"][as="style"]['+p+"]")?S.loading=1:(p=h.createElement("link"),S.preload=p,p.addEventListener("load",function(){return S.loading|=1}),p.addEventListener("error",function(){return S.loading|=2}),Vi(p,"link",_),Oe(p),h.head.appendChild(p))}function qf(h){return'[src="'+Pn(h)+'"]'}function Zg(h){return"script[async]"+h}function DU(h,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var S=h.querySelector('style[data-href~="'+Pn(_.href)+'"]');if(S)return p.instance=S,Oe(S),S;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return S=(h.ownerDocument||h).createElement("style"),Oe(S),Vi(S,"style",P),Jv(S,_.precedence,h),p.instance=S;case"stylesheet":P=Wf(_.href);var O=h.querySelector(Yg(P));if(O)return p.state.loading|=4,p.instance=O,Oe(O),O;S=RU(_),(P=Oa.get(P))&&uA(S,P),O=(h.ownerDocument||h).createElement("link"),Oe(O);var X=O;return X._p=new Promise(function(oe,Me){X.onload=oe,X.onerror=Me}),Vi(O,"link",S),p.state.loading|=4,Jv(O,_.precedence,h),p.instance=O;case"script":return O=qf(_.src),(P=h.querySelector(Zg(O)))?(p.instance=P,Oe(P),P):(S=_,(P=Oa.get(O))&&(S=f({},_),dA(S,P)),h=h.ownerDocument||h,P=h.createElement("script"),Oe(P),Vi(P,"link",S),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&&(S=p.instance,p.state.loading|=4,Jv(S,_.precedence,h));return p.instance}function Jv(h,p,_){for(var S=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=S.length?S[S.length-1]:null,O=P,X=0;X<S.length;X++){var oe=S[X];if(oe.dataset.precedence===p)O=oe;else if(O!==P)break}O?O.parentNode.insertBefore(h,O.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(h,p.firstChild))}function 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 ey=null;function OU(h,p,_){if(ey===null){var S=new Map,P=ey=new Map;P.set(_,S)}else P=ey,S=P.get(_),S||(S=new Map,P.set(_,S));if(S.has(h))return S;for(S.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var O=_[P];if(!(O[rt]||O[br]||h==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var X=O.getAttribute(p)||"";X=h+X;var oe=S.get(X);oe?oe.push(O):S.set(X,[O])}}return S}function jU(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 LU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function ure(h,p,_,S){if(_.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Wf(S.href),O=p.querySelector(Yg(P));if(O){p=O._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(h.count++,h=ty.bind(h),p.then(h,h)),_.state.loading|=4,_.instance=O,Oe(O);return}O=p.ownerDocument||p,S=RU(S),(P=Oa.get(P))&&uA(S,P),O=O.createElement("link"),Oe(O);var X=O;X._p=new Promise(function(oe,Me){X.onload=oe,X.onerror=Me}),Vi(O,"link",S),_.instance=O}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=ty.bind(h),p.addEventListener("load",_),p.addEventListener("error",_))}}var hA=0;function dre(h,p){return h.stylesheets&&h.count===0&&ry(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var S=setTimeout(function(){if(h.stylesheets&&ry(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&&ry(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(S),clearTimeout(P)}}:null}function ty(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ry(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var ny=null;function ry(h,p){h.stylesheets=null,h.unsuspend!==null&&(h.count++,ny=new Map,p.forEach(hre,h),ny=null,ty.call(h))}function hre(h,p){if(!(p.state.loading&4)){var _=ny.get(h);if(_)var S=_.get(null);else{_=new Map,ny.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),S=X)}S&&_.set(null,S)}P=p.instance,X=P.getAttribute("data-precedence"),O=_.get(X)||S,O===S&&_.set(null,P),_.set(X,P),this.count++,S=ty.bind(this),P.addEventListener("load",S),P.addEventListener("error",S),O?O.parentNode.insertBefore(P,O.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),p.state.loading|=4}}var Qg={$$typeof:w,Provider:null,Consumer:null,_currentValue:te,_currentValue2:te,_threadCount:0};function fre(h,p,_,S,P,O,X,oe,Me){this.tag=1,this.containerInfo=h,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ot(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ot(0),this.hiddenUpdates=Ot(null),this.identifierPrefix=S,this.onUncaughtError=P,this.onCaughtError=O,this.onRecoverableError=X,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Me,this.incompleteTransitions=new Map}function IU(h,p,_,S,P,O,X,oe,Me,Ke,lt,dt){return h=new fre(h,p,_,X,Me,Ke,lt,dt,oe),p=1,O===!0&&(p|=24),O=na(3,null,null,p),h.current=O,O.stateNode=h,p=GM(),p.refCount++,h.pooledCache=p,p.refCount++,O.memoizedState={element:S,isDehydrated:_,cache:p},XM(O),h}function UU(h){return h?(h=Ef,h):Ef}function FU(h,p,_,S,P,O){P=UU(P),S.context===null?S.context=P:S.pendingContext=P,S=Xc(p),S.payload={element:_},O=O===void 0?null:O,O!==null&&(S.callback=O),_=Yc(h,S,p),_!==null&&(zs(_,h,p),kg(_,h,p))}function zU(h,p){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<p?_:p}}function fA(h,p){zU(h,p),(h=h.alternate)&&zU(h,p)}function BU(h){if(h.tag===13||h.tag===31){var p=Nd(h,67108864);p!==null&&zs(p,h,67108864),fA(h,67108864)}}function HU(h){if(h.tag===13||h.tag===31){var p=oa();p=ai(p);var _=Nd(h,p);_!==null&&zs(_,h,p),fA(h,p)}}var iy=!0;function pre(h,p,_,S){var P=K.T;K.T=null;var O=V.p;try{V.p=2,pA(h,p,_,S)}finally{V.p=O,K.T=P}}function mre(h,p,_,S){var P=K.T;K.T=null;var O=V.p;try{V.p=8,pA(h,p,_,S)}finally{V.p=O,K.T=P}}function pA(h,p,_,S){if(iy){var P=mA(S);if(P===null)eA(h,p,S,sy,_),VU(h,S);else if(xre(P,h,p,_,S))S.stopPropagation();else if(VU(h,S),p&4&&-1<gre.indexOf(h)){for(;P!==null;){var O=se(P);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var X=Ce(O.pendingLanes);if(X!==0){var oe=O;for(oe.pendingLanes|=2,oe.entangledLanes|=2;X;){var Me=1<<31-$e(X);oe.entanglements[1]|=Me,X&=~Me}qo(O),(Nn&6)===0&&(Bv=L()+500,Wg(0))}}break;case 31:case 13:oe=Nd(O,2),oe!==null&&zs(oe,O,2),$v(),fA(O,2)}if(O=mA(S),O===null&&eA(h,p,S,sy,_),O===P)break;P=O}P!==null&&S.stopPropagation()}else eA(h,p,S,null,_)}}function mA(h){return h=xM(h),gA(h)}var sy=null;function gA(h){if(sy=null,h=St(h),h!==null){var p=s(h);if(p===null)h=null;else{var _=p.tag;if(_===13){if(h=a(p),h!==null)return h;h=null}else if(_===31){if(h=o(p),h!==null)return h;h=null}else if(_===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;h=null}else p!==h&&(h=null)}}return sy=h,null}function $U(h){switch(h){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ne()){case be:return 2;case we:return 8;case ge:case me:return 32;case Ae:return 268435456;default:return 32}default:return 32}}var xA=!1,ou=null,lu=null,cu=null,Jg=new Map,ex=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 VU(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":Jg.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":ex.delete(p.pointerId)}}function tx(h,p,_,S,P,O){return h===null||h.nativeEvent!==O?(h={blockedOn:p,domEventName:_,eventSystemFlags:S,nativeEvent:O,targetContainers:[P]},p!==null&&(p=se(p),p!==null&&BU(p)),h):(h.eventSystemFlags|=S,p=h.targetContainers,P!==null&&p.indexOf(P)===-1&&p.push(P),h)}function xre(h,p,_,S,P){switch(p){case"focusin":return ou=tx(ou,h,p,_,S,P),!0;case"dragenter":return lu=tx(lu,h,p,_,S,P),!0;case"mouseover":return cu=tx(cu,h,p,_,S,P),!0;case"pointerover":var O=P.pointerId;return Jg.set(O,tx(Jg.get(O)||null,h,p,_,S,P)),!0;case"gotpointercapture":return O=P.pointerId,ex.set(O,tx(ex.get(O)||null,h,p,_,S,P)),!0}return!1}function GU(h){var p=St(h.target);if(p!==null){var _=s(p);if(_!==null){if(p=_.tag,p===13){if(p=a(_),p!==null){h.blockedOn=p,ns(h.priority,function(){HU(_)});return}}else if(p===31){if(p=o(_),p!==null){h.blockedOn=p,ns(h.priority,function(){HU(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function ay(h){if(h.blockedOn!==null)return!1;for(var p=h.targetContainers;0<p.length;){var _=mA(h.nativeEvent);if(_===null){_=h.nativeEvent;var S=new _.constructor(_.type,_);gM=S,_.target.dispatchEvent(S),gM=null}else return p=se(_),p!==null&&BU(p),h.blockedOn=_,!1;p.shift()}return!0}function WU(h,p,_){ay(h)&&_.delete(p)}function bre(){xA=!1,ou!==null&&ay(ou)&&(ou=null),lu!==null&&ay(lu)&&(lu=null),cu!==null&&ay(cu)&&(cu=null),Jg.forEach(WU),ex.forEach(WU)}function oy(h,p){h.blockedOn===p&&(h.blockedOn=null,xA||(xA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,bre)))}var ly=null;function qU(h){ly!==h&&(ly=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){ly===h&&(ly=null);for(var p=0;p<h.length;p+=3){var _=h[p],S=h[p+1],P=h[p+2];if(typeof S!="function"){if(gA(S||_)===null)continue;break}var O=se(_);O!==null&&(h.splice(p,3),p-=3,m2(O,{pending:!0,data:P,method:_.method,action:S},S,P))}}))}function Kf(h){function p(Me){return oy(Me,h)}ou!==null&&oy(ou,h),lu!==null&&oy(lu,h),cu!==null&&oy(cu,h),Jg.forEach(p),ex.forEach(p);for(var _=0;_<uu.length;_++){var S=uu[_];S.blockedOn===h&&(S.blockedOn=null)}for(;0<uu.length&&(_=uu[0],_.blockedOn===null);)GU(_),_.blockedOn===null&&uu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(S=0;S<_.length;S+=3){var P=_[S],O=_[S+1],X=P[Or]||null;if(typeof O=="function")X||qU(_);else if(X){var oe=null;if(O&&O.hasAttribute("formAction")){if(P=O,X=O[Or]||null)oe=X.formAction;else if(gA(P)!==null)continue}else oe=X.action;typeof oe=="function"?_[S+1]=oe:(_.splice(S,3),S-=3),qU(_)}}}function KU(){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),S||setTimeout(_,20)}function _(){if(!S&&!navigation.transition){var O=navigation.currentEntry;O&&O.url!=null&&navigation.navigate(O.url,{state:O.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(_,100),function(){S=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),P!==null&&(P(),P=null)}}}function bA(h){this._internalRoot=h}cy.prototype.render=bA.prototype.render=function(h){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,S=oa();FU(_,S,h,p,null,null)},cy.prototype.unmount=bA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var p=h.containerInfo;FU(h.current,2,null,h,null,null),$v(),p[fo]=null}};function cy(h){this._internalRoot=h}cy.prototype.unstable_scheduleHydration=function(h){if(h){var p=Fi();h={blockedOn:null,target:h,priority:p};for(var _=0;_<uu.length&&p!==0&&p<uu[_].priority;_++);uu.splice(_,0,h),_===0&&GU(h)}};var XU=e.version;if(XU!=="19.2.0")throw Error(r(527,XU,"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 uy=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!uy.isDisabled&&uy.supportsFiber)try{Ve=uy.inject(vre),ce=uy}catch{}}return rx.createRoot=function(h,p){if(!i(h))throw Error(r(299));var _=!1,S="",P=n4,O=r4,X=i4;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(S=p.identifierPrefix),p.onUncaughtError!==void 0&&(P=p.onUncaughtError),p.onCaughtError!==void 0&&(O=p.onCaughtError),p.onRecoverableError!==void 0&&(X=p.onRecoverableError)),p=IU(h,1,!1,null,null,_,S,null,P,O,X,KU),h[fo]=p.current,J2(h),new bA(p)},rx.hydrateRoot=function(h,p,_){if(!i(h))throw Error(r(299));var S=!1,P="",O=n4,X=r4,oe=i4,Me=null;return _!=null&&(_.unstable_strictMode===!0&&(S=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(O=_.onUncaughtError),_.onCaughtError!==void 0&&(X=_.onCaughtError),_.onRecoverableError!==void 0&&(oe=_.onRecoverableError),_.formState!==void 0&&(Me=_.formState)),p=IU(h,1,!0,p,_??null,S,P,Me,O,X,oe,KU),p.context=UU(null),_=p.current,S=oa(),S=ai(S),P=Xc(S),P.callback=null,Yc(_,P,S),_=S,p.current.lanes=_,cn(p,_),qo(p),h[fo]=p.current,J2(h),new cy(p)},rx.version="19.2.0",rx}var s5;function kre(){if(s5)return _A.exports;s5=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 Wt=t=>typeof t=="string",ix=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},a5=t=>t==null?"":""+t,Rre=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Dre=/###/g,o5=t=>t&&t.indexOf("###")>-1?t.replace(Dre,"."):t,l5=t=>!t||Wt(t),Vx=(t,e,n)=>{const r=Wt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(l5(t))return{};const s=o5(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return l5(t)?{}:{obj:t,k:o5(r[i])}},c5=(t,e,n)=>{const{obj:r,k:i}=Vx(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=Vx(t,a,Object);for(;o.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),o=Vx(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}=Vx(t,e,Object);i[s]=i[s]||[],i[s].push(n)},y1=(t,e)=>{const{obj:n,k:r}=Vx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},jre=(t,e,n)=>{const r=y1(t,n);return r!==void 0?r:y1(e,n)},xG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Wt(t[r])||t[r]instanceof String||Wt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):xG(t[r],e[r],n):t[r]=e[r]);return t},Xf=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Lre={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Ire=t=>Wt(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},f0=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 _1{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:(Wt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new _1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new _1(this.logger,e)}}var il=new _1;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 u5 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):Wt(r)&&s?o.push(...r.split(s)):o.push(r)));const c=y1(this.data,o);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),c||!a||!Wt(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),c5(this.data,o,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(Wt(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s,a={silent:!1,skipCopy:!1}){let o=[e,n];e.indexOf(".")>-1&&(o=e.split("."),i=r,r=n,n=o[1]),this.addNamespaces(n);let c=y1(this.data,o)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?xG(c,r,s):c={...c,...r},c5(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 d5={},MA=t=>!Wt(t)&&typeof t!="boolean"&&typeof t!="number";class w1 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=il.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:Wt(s)?[s]:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return{key:e,namespaces:Wt(s)?[s]:s}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=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,w=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!Wt(i.count),T=w1.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;w&&!x&&T&&(D=C);const F=MA(D),j=Object.prototype.toString.apply(D);if(w&&D&&F&&b.indexOf(j)<0&&!(Wt(E)&&Array.isArray(D))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,D,{...i,ns: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(w&&Wt(E)&&Array.isArray(x))x=x.join(E),x&&(x=this.extendTranslation(x,e,i,r));else{let q=!1,R=!1;!this.isValidLookup(x)&&T&&(q=!0,x=C),this.isValidLookup(x)||(R=!0,x=o);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:x,V=T&&C!==x&&this.options.updateMissing;if(R||q||V){if(this.logger.log(V?"updateKey":"missingKey",f,u,o,V?C:x),a){const U=this.resolve(o,{...i,keySeparator:!1});U&&U.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let te=[];const Y=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Y&&Y[0])for(let U=0;U<Y.length;U++)te.push(Y[U]);else this.options.saveMissingTo==="all"?te=this.languageUtils.toResolveHierarchy(i.lng||this.language):te.push(i.lng||this.language);const Z=(U,z,ee)=>{const ae=T&&ee!==x?ee:K;this.options.missingKeyHandler?this.options.missingKeyHandler(U,u,z,ae,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(U,u,z,ae,V,i),this.emit("missingKey",U,u,z,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?te.forEach(U=>{const z=this.pluralResolver.getSuffixes(U,i);I&&i[`defaultValue${this.options.pluralSeparator}zero`]&&z.indexOf(`${this.options.pluralSeparator}zero`)<0&&z.push(`${this.options.pluralSeparator}zero`),z.forEach(ee=>{Z([U],o+ee,i[`defaultValue${ee}`]||C)})}):Z(te,o,C))}x=this.extendTranslation(x,e,i,m,r),R&&x===o&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${o}`),(R||q)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${o}`:o,q?x:void 0,i))}return s?(m.res=x,m.usedParams=this.getUsedParamsDetails(i),m):x}extendTranslation(e,n,r,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=Wt(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&&!Wt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),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=Wt(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 Wt(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&&!Wt(n.count),m=g&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(Wt(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{this.isValidLookup(r)||(o=v,!d5[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(d5[`${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 w;for(;w=E.pop();)this.isValidLookup(r)||(s=w,r=this.getResource(b,v,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!Wt(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class h5{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=il.create("languageUtils")}getScriptPartFromCode(e){if(e=f0(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=f0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Wt(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(a=>{if(a===s)return a;if(!(a.indexOf("-")<0&&s.indexOf("-")<0)&&(a.indexOf("-")>0&&s.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===s||a.indexOf(s)===0&&s.length>1))return a})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),Wt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],s=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return Wt(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):Wt(e)&&s(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const f5={zero:0,one:1,two:2,few:3,many:4,other:5},p5={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Vre{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=il.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=f0(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!"),p5;if(!e.match(/-|_/))return p5;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)=>f5[i]-f5[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 m5=(t,e,n,r=".",i=!0)=>{let s=jre(t,e,n);return!s&&i&&Wt(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=il.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=m5(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(m5(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=Wt(v)?v:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))a="";else if(f){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),a="";else!Wt(a)&&!this.useRawValueToEscape&&(a=a5(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&&!Wt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(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&&!Wt(s))return s;Wt(s)||(s=a5(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}},g5=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(f0(r),i),e[a]=o),o(n)}},qre=t=>(e,n,r)=>t(f0(n),r)(e);class Kre{constructor(e={}){this.logger=il.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?g5: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()]=g5(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=il.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();Wt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Wt(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(a,o)=>{a&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,a),!a&&o&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,o),this.loaded(e,a,o)})}saveMissing(e,n,r,i,s,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const 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 x5=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),Wt(t[1])&&(e.defaultValue=t[1]),Wt(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),b5=t=>(Wt(t.ns)&&(t.ns=[t.ns]),Wt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Wt(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),hy=()=>{},Zre=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Gx extends OS{constructor(e={},n){if(super(),this.options=b5(e),this.services={},this.logger=il,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&&(Wt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=x5();this.options={...r,...this.options,...b5(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?il.init(i(this.modules.logger),this.options):il.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Kre;const d=new h5(this.options);this.store=new u5(this.options.resources,this.options);const f=this.services;f.logger=il,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 w1(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=hy),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=ix(),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=hy){let r=n;const i=Wt(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],a=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(u=>{u!=="cimode"&&s.indexOf(u)<0&&s.push(u)})};i?a(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(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=ix();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=hy),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=ix();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=Wt(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Wt(o)?[o]:o);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{s(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),r}getFixedT(e,n,r){const i=(s,a,...o)=>{let 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 Wt(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(o,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=ix();return this.options.ns?(Wt(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=ix();Wt(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return s.length?(this.options.preload=i.concat(s),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const s=i.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new h5(x5());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 Gx(e,n);return r.createInstance=Gx.createInstance,r}cloneInstance(e={},n=hy){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Gx(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 u5(o,i),s.services.resourceStore=s.store}return s.translator=new w1(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=Gx.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)},v5={},yG=(t,e,n,r)=>{Ih(n)&&v5[n]||(Ih(n)&&(v5[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))},y5=(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 _5;function hie(){if(_5)return CA;_5=1;var t=$m();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 w5;function SG(){return w5||(w5=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=()=>()=>{},Vm=(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:w}=ER.useSyncExternalStore(m,y,y);M.useEffect(()=>{if(s&&!w&&!o){const C=()=>b(D=>D+1);e.lng?y5(s,e.lng,f,C):x3(s,f,C)}},[s,e.lng,f,w,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,w];return j.t=E,j.i18n=F,j.ready=w,j},[E,A,w,A.resolvedLanguage,A.language,A.languages]);if(s&&o&&!w)throw new Promise(C=>{const D=()=>C();e.lng?y5(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 S5=/^[\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(!S5.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!S5.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},E5={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 E5.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&E5.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 M5=()=>{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&&M5())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&M5()&&window.localStorage.setItem(n,t)}};let Zf=null;const A5=()=>{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&&A5())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&A5()&&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",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",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 T5=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var C5="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:p0(i)}return Lie(e,n,null,t)}function yr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Lo(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 N5(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"?Gm(e):e,state:n,key:e&&e.key||r||jie()}}function p0({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 Gm(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 w=N5(E,u),A=y.createHref(E);try{a.pushState(w,"",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 w=N5(E,u),A=y.createHref(E);a.replaceState(w,"",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(C5,f),c=v,()=>{i.removeEventListener(C5,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:p0(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"?Gm(e):e,s=Ac(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=bc([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,k5=t=>t==="*";function Wie(t,e){let n=t.split("/"),r=n.length;return n.some(k5)&&(r+=Gie),e&&(r+=Hie),n.filter(i=>!k5(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=S1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),g=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=S1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),a.push({params:i,pathname:bc([s,f.pathname]),pathnameBase:tse(bc([s,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(s=bc([s,f.pathnameBase]))}return a}function S1(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){Lo(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 Lo(!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 Ac(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"?Gm(t):t,s;if(n)if(Qie(n))s=n;else{if(n.includes("//")){let a=n;n=n.replace(/\/\/+/g,"/"),Lo(!1,`Pathnames cannot have embedded double slashes - normalizing ${a} -> ${n}`)}n.startsWith("/")?s=P5(n.substring(1),"/"):s=P5(n,e)}else s=e;return{pathname:s,search:nse(r),hash:rse(i)}}function P5(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=Gm(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 bc=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 Wm=M.createContext(null);Wm.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 yl=M.createContext(null);yl.displayName="Navigation";var hb=M.createContext(null);hb.displayName="Location";var zo=M.createContext({outlet:null,matches:[],isDataRoute:!1});zo.displayName="Route";var MR=M.createContext(null);MR.displayName="RouteError";function lse(t,{relative:e}={}){yr(fb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=M.useContext(yl),{hash:i,pathname:s,search:a}=pb(t,{relative:e}),o=s;return n!=="/"&&(o=s==="/"?n:bc([n,s])),r.createHref({pathname:o,search:a,hash:i})}function fb(){return M.useContext(hb)!=null}function xd(){return yr(fb(),"useLocation() may be used only in the context of a <Router> component."),M.useContext(hb).location}var OG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function jG(t){M.useContext(yl).static||M.useLayoutEffect(t)}function AR(){let{isDataRoute:t}=M.useContext(zo);return t?Sse():cse()}function cse(){yr(fb(),"useNavigate() may be used only in the context of a <Router> component.");let t=M.useContext(Wm),{basename:e,navigator:n}=M.useContext(yl),{matches:r}=M.useContext(zo),{pathname:i}=xd(),s=JSON.stringify(kG(r)),a=M.useRef(!1);return jG(()=>{a.current=!0}),M.useCallback((c,u={})=>{if(Lo(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:bc([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(zo).outlet;return M.useMemo(()=>e&&M.createElement(use.Provider,{value:t},e),[e,t])}function LG(){let{matches:t}=M.useContext(zo),e=t[t.length-1];return e?e.params:{}}function pb(t,{relative:e}={}){let{matches:n}=M.useContext(zo),{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(fb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=M.useContext(yl),{matches:a}=M.useContext(zo),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"?Gm(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});Lo(f||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Lo(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:bc([d,s.encodeLocation?s.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?d:bc([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(hb.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(zo.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(Wm);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),M.createElement(zo.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 w;return m?w=y:x?w=v:f.route.Component?w=M.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=d,M.createElement(gse,{match:f,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:w})};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(Wm);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(zo);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={})=>{Lo(n.current,OG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var R5={};function UG(t,e,n){!e&&!R5[t]&&(R5[t]=!0,Lo(!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 ha(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(!fb(),"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=Gm(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,m=M.useMemo(()=>{let x=Ac(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 Lo(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(yl.Provider,{value:o},M.createElement(hb.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===ha,`[${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 Y_="get",Z_="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 fy=null;function Dse(){if(fy===null)try{new FormData(document.createElement("form"),0),fy=!1}catch{fy=!0}return fy}var Ose=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function kA(t){return t!=null&&!Ose.has(t)?(Lo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Z_}"`),null):t}function jse(t,e){let n,r,i,s,a;if(Nse(t)){let o=t.getAttribute("action");r=o?Ac(o,e):null,n=t.getAttribute("method")||Y_,i=kA(t.getAttribute("enctype"))||Z_,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?Ac(c,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||Y_,i=kA(t.getAttribute("formenctype"))||kA(o.getAttribute("enctype"))||Z_,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=Y_,r=null,i=Z_,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&&Ac(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 D5(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(Wm);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:sx(o,m),onBlur:sx(c,x),onMouseEnter:sx(u,m),onMouseLeave:sx(d,x),onTouchStart:sx(f,m)}]:[!1,g,{}]}function sx(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(()=>D5(t,e,c,i,r,"data"),[t,e,c,i,r]),d=M.useMemo(()=>D5(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(w=>w.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(yl),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=Ac(D.pathname,x);D.origin===C.origin&&F!=null?u=F+D.search+D.hash:b=!0}catch{Lo(!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}),[w,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 w&&!y?M.createElement(M.Fragment,null,I,M.createElement(Wse,{page:E})):I});IS.displayName="Link";var Px=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=pb(a,{relative:u.relative}),g=xd(),m=M.useContext(jS),{navigator:x,basename:y}=M.useContext(yl),v=m!=null&&iae(f)&&o===!0,b=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,E=g.pathname,w=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(E=E.toLowerCase(),w=w?w.toLowerCase():null,b=b.toLowerCase()),w&&y&&(w=Ac(w,y)||w);const A=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let T=E===b||!i&&E.startsWith(b)&&E.charAt(A)==="/",k=w!=null&&(w===b||!i&&w.startsWith(b)&&w.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)});Px.displayName="NavLink";var Zse=M.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:a=Y_,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=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let A=w.nativeEvent.submitter,T=A?.getAttribute("formmethod")||a;x(A||w.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(Wm);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=pb(t,{relative:s});return M.useCallback(d=>{if(Rse(d,e)){d.preventDefault();let f=n!==void 0?n:p0(c)===p0(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(yl),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(yl),r=M.useContext(zo);yr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...pb(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:bc([n,s.pathname])),p0(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=pb(t,{relative:e});if(!n.isTransitioning)return!1;let s=Ac(n.currentLocation.pathname,r)||n.currentLocation.pathname,a=Ac(n.nextLocation.pathname,r)||n.nextLocation.pathname;return S1(i.pathname,a)!=null||S1(i.pathname,s)!=null}var dc=gG();const sae=uo(dc);var qm=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 Va(t,e){return typeof t=="function"?t(e):t}function O5(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(!m0(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 j5(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(!m0(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 m0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>m0(t[n],e[n])):!1}var uae=Object.prototype.hasOwnProperty;function GG(t,e){if(t===e)return t;const n=L5(t)&&L5(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 E1(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 L5(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function w3(t){if(!I5(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!I5(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function I5(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 qm{#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 qm{#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}},M1=new xae;function bae(t){return Math.min(1e3*2**t,3e4)}function KG(t){return(t??"online")==="online"?M1.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"||M1.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),w=t.retryDelay??bae,A=typeof w=="function"?w(n,b):w,T=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,b);if(e||!T){g(b);return}n++,t.onFail?.(n,b),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=F5(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=F5(this.options);e.data!==void 0&&(this.setState(U5(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=>Va(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,...U5(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 U5(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function F5(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 qm{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),z5(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 Va(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&&!E1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&B5(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Va(this.options.enabled,this.#t)!==Va(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||Va(this.options.enabled,this.#t)!==Va(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||Va(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&&z5(t,e),D=I&&B5(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",w=y==="error",A=E&&b,T=g!==void 0,N={status:y,fetchStatus:d.fetchStatus,isPending:E,isSuccess:y==="success",isError:w,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:w&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&T,isStale:OR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Va(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),E1(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 Va(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function z5(t,e){return _ae(t,e)||t.state.data!==void 0&&A3(t,e,e.refetchOnMount)}function A3(t,e,n){if(Va(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 B5(t,e,n,r){return(t!==e||Va(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&OR(t,n)}function OR(t,e){return Va(e.enabled,t)!==!1&&t.isStaleByTime(Wu(e.staleTime,t))}function wae(t,e){return!E1(t.getCurrentResult(),e)}function H5(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})(),w=await g(E),{maxPages:A}=e.options,T=v?fae:hae;return{pages:T(x.pages,w,A),pageParams:T(x.pageParams,y,A)}};if(i&&s.length){const x=i==="backward",y=x?Sae:$5,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:$5(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 $5(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 qm{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=py(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=py(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=py(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=py(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=>j5(e,n))}findAll(t={}){return this.getAll().filter(e=>j5(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 py(t){return t.options.scope?.id}var Aae=class extends qm{#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),E1(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 qm{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=>O5(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>O5(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=M1.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=H5(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ss).catch(Ss)}ensureInfiniteQueryData(t){return t.behavior=H5(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return M1.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=>{m0(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=>{m0(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),En=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,V5=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function zae(t,e,n){const r=kae(),i=Dae(),s=En(),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 V5(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?V5(a,c,i):s.getQueryCache().get(a.queryHash)?.promise)?.catch(Ss).finally(()=>{c.updateResult()}),a.notifyOnChangeProps?u:c.trackResult(u)}function vt(t,e){return zae(t,yae)}function _t(t,e){const n=En(),[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()),G5=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 Xe=(t,e)=>{const n=M.forwardRef(({className:r,...i},s)=>M.createElement(Gae,{ref:s,iconNode:e,className:t7(`lucide-${Bae(G5(t))}`,`lucide-${t}`,r),...i}));return n.displayName=G5(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=Xe("archive",Wae);const qae=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],g0=Xe("arrow-down",qae);const Kae=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],T3=Xe("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=Xe("arrow-up-down",Xae);const Zae=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],hm=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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"}]],x0=Xe("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=Xe("chart-column",hoe);const poe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],zh=Xe("check",poe);const moe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],uf=Xe("chevron-down",moe);const goe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],df=Xe("chevron-right",goe);const xoe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Bh=Xe("chevron-left",xoe);const boe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],US=Xe("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"}]],Io=Xe("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=Xe("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"}]],ps=Xe("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=Xe("circle-check",woe);const Eoe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Moe=Xe("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=Xe("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"}]],Lc=Xe("circle-x",Coe);const Noe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_r=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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"}]],my=Xe("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=Xe("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=Xe("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"}]],Sa=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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"}]],ao=Xe("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=Xe("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"}]],b0=Xe("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=Xe("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=Xe("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"}]],W5=Xe("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=Xe("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"}]],A1=Xe("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"}]],Ja=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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"}]],q5=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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"}]],mb=Xe("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"}]],T1=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("list",Wle);const qle=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],At=Xe("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"}]],K5=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("memory-stick",sce);const oce=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],lce=Xe("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=Xe("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=Xe("minimize",dce);const fce=[["path",{d:"M5 12h14",key:"1ays0h"}]],R3=Xe("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=Xe("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=Xe("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"}]],_0=Xe("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=Xe("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=Xe("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"}]],w0=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("plug",Tce);const Cce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pr=Xe("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=Xe("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=Xe("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"}]],Ea=Xe("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=Xe("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=Xe("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"}]],Km=Xe("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=Xe("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"}]],ko=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("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=Xe("settings",Gce);const Wce=[["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"}]],qce=Xe("shopping-cart",Wce);const Kce=[["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"}]],Xce=Xe("signal",Kce);const Yce=[["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"}]],Zce=Xe("skip-back",Yce);const Qce=[["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=Xe("skip-forward",Qce);const Jce=[["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"}]],X5=Xe("sliders-vertical",Jce);const eue=[["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"}]],S0=Xe("sparkles",eue);const tue=[["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=Xe("square-check-big",tue);const nue=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],mm=Xe("square",nue);const rue=[["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"}]],gm=Xe("star",rue);const iue=[["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=Xe("sticky-note",iue);const sue=[["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"}]],Y5=Xe("sun",sue);const aue=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],E0=Xe("tag",aue);const oue=[["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=Xe("target",oue);const lue=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],h7=Xe("terminal",lue);const cue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],uue=Xe("text-align-center",cue);const due=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],hue=Xe("text-align-end",due);const fue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],pue=Xe("text-align-start",fue);const mue=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Sh=Xe("thermometer",mue);const gue=[["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=Xe("timer",gue);const xue=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],kn=Xe("trash-2",xue);const bue=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],f7=Xe("trending-down",bue);const vue=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],p7=Xe("trending-up",vue);const yue=[["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=Xe("triangle-alert",yue);const _ue=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],wue=Xe("underline",_ue);const Sue=[["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=Xe("unlink",Sue);const Eue=[["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"}]],ba=Xe("upload",Eue);const Mue=[["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=Xe("user",Mue);const Aue=[["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"}]],Tue=Xe("users",Aue);const Cue=[["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=Xe("video",Cue);const Nue=[["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=Xe("wifi-off",Nue);const kue=[["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=Xe("wifi",kue);const Pue=[["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"}]],Rue=Xe("wind",Pue);const Due=[["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=Xe("wrench",Due);const Oue=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gt=Xe("x",Oue);const jue=[["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"}]],Lue=Xe("zoom-in",jue);const Iue=[["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"}]],xm=Xe("zap",Iue);const Uue=[["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"}]],Fue=Xe("zoom-out",Uue),b7=M.createContext(void 0);function zue({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 gb(){const t=M.useContext(b7);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function kt({children:t,className:e="",onClick:n,onContextMenu:r}){return l.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function $a({children:t,className:e=""}){return l.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Dt({children:t,className:e=""}){return l.jsx("div",{className:`p-6 ${e}`,children:t})}function Bue(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 Z5({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 Hue({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Vm(),i=Bue(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(kt,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:l.jsxs(Dt,{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(Gt,{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(ao,{className:"w-3 h-3 text-bambu-gray"})]}),l.jsx("div",{className:"flex gap-1",children:a.keys.map(o=>l.jsx(Z5,{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(Z5,{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:ao},{name:"book",icon:noe},{name:"file-text",icon:Ja},{name:"home",icon:Cle},{name:"star",icon:gm},{name:"heart",icon:Mle},{name:"bookmark",icon:ioe},{name:"shopping-cart",icon:qce},{name:"music",icon:gce},{name:"video",icon:g7},{name:"image",icon:mb},{name:"camera",icon:x0},{name:"map",icon:ece},{name:"compass",icon:Foe},{name:"coffee",icon:joe},{name:"gift",icon:ble},{name:"wrench",icon:sd},{name:"zap",icon:xm},{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:Tue},{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 $ue({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 Q5=768;function y7(){const[t,e]=M.useState(()=>typeof window<"u"?window.innerWidth<Q5:!1);return M.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Q5-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const M0=[{id:"printers",to:"/",icon:Ea,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 Vue(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return M0.map(e=>e.id)}return M0.map(e=>e.id)}function Gue(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function DA(t){return t.startsWith("ext-")}function _7(){return localStorage.getItem("defaultView")||"/"}function Wue(t){localStorage.setItem("defaultView",t)}function que(){const t=AR(),e=xd(),{theme:n,toggleTheme:r}=gb(),{t:i}=Vm(),s=y7(),[a,o]=M.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=M.useState(!1),[d,f]=M.useState(!1),[g,m]=M.useState(Vue),[x,y]=M.useState(null),[v,b]=M.useState(null),E=M.useRef(!1),[w,A]=M.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:T}=vt({queryKey:["version"],queryFn:ke.getVersion,staleTime:1/0}),{data:k}=vt({queryKey:["settings"],queryFn:ke.getSettings,staleTime:300*1e3}),{data:N}=vt({queryKey:["updateCheck"],queryFn:ke.checkForUpdates,enabled:k?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:I}=vt({queryKey:["external-links"],queryFn:ke.getExternalLinks}),C=new Map(M0.map(Z=>[Z.id,Z])),D=new Map((I||[]).map(Z=>[`ext-${Z.id}`,Z])),F=(()=>{const Z=[],U=new Set;for(const z of g)(C.has(z)||D.has(z))&&(Z.push(z),U.add(z));for(const z of M0)U.has(z.id)||(Z.push(z.id),U.add(z.id));for(const z of I||[]){const ee=`ext-${z.id}`;U.has(ee)||(Z.push(ee),U.add(ee))}return Z})(),j=(Z,U)=>{y(U),Z.dataTransfer.effectAllowed="move",Z.dataTransfer.setData("text/plain",U)},q=(Z,U)=>{Z.preventDefault(),Z.dataTransfer.dropEffect="move",b(U)},R=()=>{b(null)},W=(Z,U)=>{if(Z.preventDefault(),x===null||x===U){y(null),b(null);return}const z=[...F],ee=z.indexOf(x),ae=z.indexOf(U);if(ee===-1||ae===-1){y(null),b(null);return}z.splice(ee,1),z.splice(ae,0,x),m(z),Gue(z),y(null),b(null)},K=()=>{y(null),b(null)},V=N?.update_available&&N.latest_version&&N.latest_version!==w,te=()=>{N?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",N.latest_version),A(N.latest_version))};M.useEffect(()=>{if(!E.current&&e.pathname==="/"){const Z=_7();Z!=="/"&&(E.current=!0,t(Z,{replace:!0}))}},[e.pathname,t]),M.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(a))},[a]),M.useEffect(()=>{s&&u(!1)},[e.pathname,s]);const Y=M.useCallback(Z=>{const U=Z.target;if(!(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable)&&!Z.metaKey&&!Z.ctrlKey&&!Z.altKey){const z=parseInt(Z.key);if(z>=1&&z<=F.length&&z<=9){const ee=F[z-1];if(Z.preventDefault(),DA(ee)){const ae=ee.replace("ext-","");t(`/external/${ae}`)}else{const ae=C.get(ee);ae&&t(ae.to)}return}switch(Z.key){case"?":Z.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,F,C]);return M.useEffect(()=>(document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)),[Y]),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(Z=>{if(DA(Z)){const z=D.get(Z);if(!z)return null;const ee=z.custom_icon?null:$S(z.icon);return l.jsx("li",{draggable:!0,onDragStart:ae=>j(ae,Z),onDragOver:ae=>q(ae,Z),onDragLeave:R,onDrop:ae=>W(ae,Z),onDragEnd:K,className:`relative ${x===Z?"opacity-50":""} ${v===Z&&x!==Z?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:l.jsxs(Px,{to:`/external/${z.id}`,className:({isActive:ae})=>`flex items-center ${s||a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ae?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!a?z.name:void 0,children:[a&&!s&&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"}`}):ee&&l.jsx(ee,{className:"w-5 h-5 flex-shrink-0"}),(s||a)&&l.jsx("span",{children:z.name})]})},Z)}else{const z=C.get(Z);if(!z)return null;const{to:ee,icon:ae,labelKey:fe}=z;return l.jsx("li",{draggable:!0,onDragStart:de=>j(de,Z),onDragOver:de=>q(de,Z),onDragLeave:R,onDrop:de=>W(de,Z),onDragEnd:K,className:`relative ${x===Z?"opacity-50":""} ${v===Z&&x!==Z?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:l.jsxs(Px,{to:ee,className:({isActive:de})=>`flex items-center ${s||a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${de?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!a?i(fe):void 0,children:[a&&!s&&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(ae,{className:"w-5 h-5 flex-shrink-0"}),(s||a)&&l.jsx("span",{children:i(fe)})]})},Z)}})})}),!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(Px,{to:"/system",className:({isActive:Z})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${Z?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:l.jsx(T1,{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(q5,{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(Y5,{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(Px,{to:"/system",className:({isActive:Z})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${Z?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:l.jsx(T1,{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(q5,{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(Y5,{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:te,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:l.jsx(Gt,{className:"w-4 h-4"})})]}),l.jsx(Mse,{})]}),d&&l.jsx(Hue,{onClose:()=>f(!1),sidebarItems:F.map(Z=>{if(DA(Z)){const U=D.get(Z);return U?{type:"external",label:U.name}:null}else{const U=C.get(Z);return U?{type:"nav",label:U.labelKey,labelKey:U.labelKey}:null}}).filter(Boolean)})]})}function Ie({variant:t="primary",size:e="md",className:n="",children:r,...i}){const s="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",a={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},o={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return 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(kt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:l.jsxs(Dt,{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(Ie,{variant:"secondary",onClick:a,className:"flex-1",children:r}),l.jsx(Ie,{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 Kue={success:l.jsx(ps,{className:"w-5 h-5 text-green-400"}),error:l.jsx(Lc,{className:"w-5 h-5 text-red-400"}),warning:l.jsx(Io,{className:"w-5 h-5 text-yellow-400"}),info:l.jsx(T1,{className:"w-5 h-5 text-blue-400"})},Xue={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30"};function Yue({children:t}){const[e,n]=M.useState([]),r=M.useCallback((s,a="success")=>{const o=Math.random().toString(36).substr(2,9);n(c=>[...c,{id:o,message:s,type:a}]),setTimeout(()=>{n(c=>c.filter(u=>u.id!==o))},3e3)},[]),i=M.useCallback(s=>{n(a=>a.filter(o=>o.id!==s))},[]);return l.jsxs(w7.Provider,{value:{showToast:r},children:[t,l.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(s=>l.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Xue[s.type]}`,children:[Kue[s.type],l.jsx("span",{className:"text-white text-sm",children:s.message}),l.jsx("button",{onClick:()=>i(s.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:l.jsx(Gt,{className:"w-4 h-4"})})]},s.id))})]})}function Zue(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 J5(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 Que(t,e){if(e)return a7;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return tle;case"gcode":return Ja;case"mp4":case"avi":return Zp;case"png":case"jpg":case"jpeg":return mb;default:return s7}}function Jue({printerId:t,printerName:e,onClose:n}){const{showToast:r}=si(),i=En(),[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}=vt({queryKey:["printerFiles",t,s],queryFn:()=>ke.getPrinterFiles(t,s)}),{data:v}=vt({queryKey:["printerStorage",t],queryFn:()=>ke.getPrinterStorage(t),staleTime:3e4}),b=_t({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)},w=()=>{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: ",J5(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: ",J5(v.free_bytes)]})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Gt,{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(Ie,{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:w,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=Que(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:Zue(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(Ie,{variant:"secondary",disabled:!o,onClick:()=>o&&A(o),children:[l.jsx(Sa,{className:"w-4 h-4"}),"Download"]}),l.jsxs(Ie,{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(kn,{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 ede({printerId:t,printerName:e,onClose:n}){const r=En(),[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}=vt({queryKey:["mqtt-logs",t],queryFn:()=>ke.getMQTTLogs(t),refetchInterval:1e3}),v=_t({mutationFn:()=>ke.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),b=_t({mutationFn:()=>ke.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=_t({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 w=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(Gt,{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(Ie,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,children:[l.jsx(mm,{className:"w-4 h-4"}),"Stop"]}):l.jsxs(Ie,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[l.jsx(BS,{className:"w-4 h-4"}),"Start Logging"]}),l.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||N.length===0,children:[l.jsx(kn,{className:"w-4 h-4"}),"Clear"]}),l.jsx(Ie,{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(Gt,{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(g0,{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:()=>w(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(g0,{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(Ie,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const tde={"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 nde(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:Io};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:T1}}}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 rde(t,e,n){const r=S7(t,e);return`https://wiki.bambulab.com/en/${n.toLowerCase().includes("h2")?"h2":"x1"}/troubleshooting/hmscode/${r}`}function ide({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(Gt,{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(Io,{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}=nde(r.severity),u=parseInt(r.code.replace("0x",""),16)||0,d=S7(r.attr,u),f=tde[d]||"Unknown error. Click the link below for details.",g=rde(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(ao,{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 sde(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 ade({printerId:t}){const{data:e}=vt({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"}),sde(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 Sn(){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 ode=["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=ode;return e.includes(t)}var lde=["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"],cde=new Set(lde);function M7(t){return typeof t!="string"?!1:cde.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 ts(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 ude(t){return t==null?null:M.isValidElement(t)?ts(t.props):typeof t=="object"&&!Array.isArray(t)?ts(t):null}var dde=["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 hde(t,e){if(t==null)return{};var n,r,i=fde(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 fde(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=hde(t,dde),f=s||{width:r,height:i,x:0,y:0},g=Sn("recharts-surface",a);return M.createElement("svg",O3({},ts(d),{className:g,width:r,height:i,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),M.createElement("title",null,c),M.createElement("desc",null,u),n)}),pde=["children","className"];function 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 mde(t,e){if(t==null)return{};var n,r,i=gde(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 gde(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=mde(t,pde),s=Sn("recharts-layer",r);return M.createElement("g",j3({className:s},ts(i),{ref:e}),n)}),T7=M.createContext(null),xde=()=>M.useContext(T7);function ir(t){return function(){return t}}const C7=Math.cos,k1=Math.sin,Bo=Math.sqrt,P1=Math.PI,VS=2*P1,L3=Math.PI,I3=2*L3,nh=1e-6,bde=I3-nh;function N7(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function vde(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 yde{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?N7:vde(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),w=s*Math.tan((L3-Math.acos((y+g-v)/(2*b*E)))/2),A=w/E,T=w/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>bde?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 yde(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 gy(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,w=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(w[x],A[x]);o.lineEnd(),o.areaEnd()}b&&(w[g]=+t(v,g,f),A[g]=+e(v,g,f),o.point(r?+r(v,g,f):w[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 _de(t){return new O7(t,!0)}function wde(t){return new O7(t,!1)}const YR={draw(t,e){const n=Bo(e/P1);t.moveTo(n,0),t.arc(0,0,n,0,VS)}},Sde={draw(t,e){const n=Bo(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=Bo(1/3),Ede=j7*2,Mde={draw(t,e){const n=Bo(e/Ede),r=n*j7;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Ade={draw(t,e){const n=Bo(e),r=-n/2;t.rect(r,r,n,n)}},Tde=.8908130915292852,L7=k1(P1/10)/k1(7*P1/10),Cde=k1(VS/10)*L7,Nde=-C7(VS/10)*L7,kde={draw(t,e){const n=Bo(e*Tde),r=Cde*n,i=Nde*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=Bo(3),Pde={draw(t,e){const n=-Bo(e/(OA*3));t.moveTo(0,n*2),t.lineTo(-OA*n,-n),t.lineTo(OA*n,-n),t.closePath()}},ja=-.5,La=Bo(3)/2,U3=1/Bo(12),Rde=(U3/2+1)*3,Dde={draw(t,e){const n=Bo(e/Rde),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(ja*r-La*i,La*r+ja*i),t.lineTo(ja*s-La*a,La*s+ja*a),t.lineTo(ja*o-La*c,La*o+ja*c),t.lineTo(ja*r+La*i,ja*i-La*r),t.lineTo(ja*s+La*a,ja*a-La*s),t.lineTo(ja*o+La*c,ja*c-La*o),t.closePath()}};function Ode(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 jde(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 Lde(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 Ide(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 Ude(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 Fde(t){return new O1(t)}function zde(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 Bde(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 Hde(t){return new WS(t,.5)}function $de(t){return new WS(t,0)}function Vde(t){return new WS(t,1)}function bm(t,e){if((a=t.length)>1)for(var n=1,r,i,s=t[e[0]],a,o=s.length;n<a;++n)for(i=s,s=t[e[n]],r=0;r<o;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function F3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Gde(t,e){return t[e]}function Wde(t){const e=[];return e.key=t,e}function qde(){var t=ir([]),e=F3,n=bm,r=Gde;function i(s){var a=Array.from(t.apply(this,arguments),Wde),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??bm,i):n},i}function Kde(t,e){if((r=t.length)>0){for(var n,r,i=0,s=t[0].length,a;i<s;++i){for(a=n=0;n<r;++n)a+=t[n][i][1]||0;if(a)for(n=0;n<r;++n)t[n][i][1]/=a}bm(t,e)}}function Xde(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,s=r.length;n<s;++n){for(var a=0,o=0;a<i;++a)o+=t[a][n][1]||0;r[n][1]+=r[n][0]=-o/2}bm(t,e)}}function Yde(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,bm(t,e)}}var LA={},IA={},iF;function Zde(){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 Qde(){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=Qde(),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=Zde(),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 Jde(){return uF||(uF=1,HA=JR().get),HA}var ehe=Jde();const Wh=uo(ehe);var ji=t=>t===0?0:t>0?1:-1,Zs=t=>typeof t=="number"&&t!=+t,Tc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Nt=t=>(typeof t=="number"||t instanceof Number)&&!Zs(t),oo=t=>Nt(t)||typeof t=="string",the=0,A0=t=>{var e=++the;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(!Nt(e)&&typeof e!="string")return r;var s;if(Tc(e)){if(n==null)return r;var a=e.indexOf("%");s=n*parseFloat(e.slice(0,a))/100}else s=+e;return Zs(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 Rn(t,e,n){return Nt(t)&&Nt(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",xb=t=>dr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function nhe(t){return t!=null}function bb(){}var rhe=["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){ihe(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 ihe(t,e,n){return(e=she(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function she(t){var e=ahe(t,"string");return typeof e=="symbol"?e:e+""}function ahe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ohe(t,e){if(t==null)return{};var n,r,i=lhe(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 lhe(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:Sde,symbolDiamond:Mde,symbolSquare:Ade,symbolStar:kde,symbolTriangle:Pde,symbolWye:Dde},che=Math.PI/180,uhe=t=>{var e="symbol".concat(xb(t));return q7[e]||YR},dhe=(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*che;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}},hhe=(t,e)=>{q7["symbol".concat(xb(t))]=e},eD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=ohe(t,rhe),s=hF(hF({},i),{},{type:e,size:n,sizeType:r}),a="circle";typeof e=="string"&&(a=e);var o=()=>{var g=uhe(a),m=Ode().type(g).size(dhe(n,r,a)),x=m();if(x!==null)return x},{className:c,cx:u,cy:d}=s,f=ts(s);return Nt(u)&&Nt(d)&&Nt(n)?M.createElement("path",z3({},f,{className:Sn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:o()})):null};eD.registerSymbol=hhe;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},fhe=(t,e,n)=>r=>(t(e,n,r),null),vb=(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]=fhe(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 phe(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){mhe(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 mhe(t,e,n){return(e=ghe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ghe(t){var e=xhe(t,"string");return typeof e=="symbol"?e:e+""}function xhe(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=phe({},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 bhe(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){vhe(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 vhe(t,e,n){return(e=yhe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yhe(t){var e=_he(t,"string");return typeof e=="symbol"?e:e+""}function _he(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 Ba=32,whe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function She(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Ba/2,s=Ba/6,a=Ba/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:Ba,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(Ba,"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(Ba/8,"h").concat(Ba,"v").concat(Ba*3/4,"h").concat(-Ba,"z"),className:"recharts-legend-icon"});if(M.isValidElement(e.legendIcon)){var d=bhe({},e);return delete d.legendIcon,M.cloneElement(e.legendIcon,d)}return M.createElement(eD,{fill:o,cx:i,cy:i,size:Ba,sizeType:"diameter",type:c})}function Ehe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:a}=t,o={x:0,y:0,width:Ba,height:Ba},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=Sn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?s:d.color,y=g?g(d.value,d,f):d.value;return M.createElement("li",j1({className:m,style:c,key:"legend-item-".concat(f)},vb(t,d,f)),M.createElement(qR,{width:n,height:n,viewBox:o,style:u,"aria-label":"".concat(y," legend icon")},M.createElement(She,{data:d,iconType:a,inactiveColor:s})),M.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var Mhe=t=>{var e=Sr(t,whe),{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(Ehe,j1({},e,{payload:n})))},$A={},VA={},mF;function Ahe(){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 The(){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=The();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(qA)),qA}var XA={},vF;function Che(){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 Nhe(){return yF||(yF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nD(),n=Che();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(WA)),WA}var YA={},ZA={},_F;function khe(){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 Phe(){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,w){const A=g(x,y,v,b,E,w);return A!==void 0?!!A:s(x,y,m,w)},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 w=d[E];let A=!1;if(g(w,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=Phe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(JA)),JA}var iT={},sT={},aT={},TF;function Rhe(){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]",w="[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=w,t.uint8ArrayTag=v,t.uint8ClampedArrayTag=b})(lT)),lT}var cT={},kF;function Dhe(){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=Rhe(),n=eW(),r=tW(),i=Z7(),s=Dhe();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 Ohe(){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 jhe(){return DF||(DF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=J7(),n=Ohe();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(QA)),QA}var uT={},dT={},hT={},OF;function Lhe(){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 Ihe(){return jF||(jF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Lhe();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 Uhe(){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 Fhe(){return UF||(UF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=V7(),n=rW(),r=Uhe(),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 zhe(){return FF||(FF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=J7(),n=ZR(),r=Ihe(),i=JR(),s=Fhe();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 Bhe(){return zF||(zF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=X7(),n=khe(),r=jhe(),i=zhe();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 Hhe(){return BF||(BF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ahe(),n=X7(),r=Nhe(),i=Bhe();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 $he(){return HF||(HF=1,gT=Hhe().uniqBy),gT}var Vhe=$he();const $F=uo(Vhe);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 Ghe(){if(VF)return bT;VF=1;var t=$m(),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,w=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(w,k))return N;var I=g(k);return m!==void 0&&m(N,I)?(w=k,N):(w=k,A=I)}var E=!1,w,A,T=f===void 0?null:f;return[function(){return b(d())},T===null?void 0:function(){return b(T())}]},[d,f,g,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 Whe(){return GF||(GF=1,xT.exports=Ghe()),xT.exports}var sW=Whe(),rD=M.createContext(null),qhe=t=>t,rr=()=>{var t=M.useContext(rD);return t?t.store.dispatch:qhe},Q_=()=>{},Khe=()=>Q_,Xhe=(t,e)=>t===e;function Tt(t){var e=M.useContext(rD);return sW.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Khe,e?e.store.getState:Q_,e?e.store.getState:Q_,e?t:Q_,Xhe)}function Yhe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Zhe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function Qhe(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 Jhe(t){const e=Array.isArray(t[0])?t[0]:t;return Qhe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function efe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var tfe=class{constructor(t){this.value=t}deref(){return this.value}},nfe=typeof WeakRef<"u"?WeakRef:tfe,rfe=0,qF=1;function xy(){return{s:rfe,v:void 0,o:null,p:null}}function aW(t,e={}){let n=xy();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=xy(),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=xy(),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 nfe(d):d}return u.s=qF,u.v=d,d}return a.clearCache=()=>{n=xy(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function ife(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()),Yhe(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=Jhe(i),E=f(function(){return s++,u.apply(null,arguments)},...y),w=m(function(){a++;const T=efe(b,arguments);return o=E.apply(null,T),o},...v);return Object.assign(w,{resultFunc:u,memoizedResultFunc:E,dependencies:b,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>o,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var We=ife(aW),sfe=Object.assign((t,e=We)=>{Zhe(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:()=>sfe}),vT={},yT={},_T={},KF;function afe(){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 ofe(){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 lfe(){return ZF||(ZF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=afe(),n=ofe(),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 cfe(){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 ufe(){return ez||(ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lfe(),n=cfe(),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 dfe(){return tz||(tz=1,AT=ufe().sortBy),AT}var hfe=dfe();const qS=uo(hfe);var cW=t=>t.legend.settings,ffe=t=>t.legend.size,pfe=t=>t.legend.payload,mfe=We([pfe,cW],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?qS(r,n):r});function gfe(){return Tt(mfe)}var by=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)>by||Math.abs(a.left-e.left)>by||Math.abs(a.top-e.top)>by||Math.abs(a.width-e.width)>by)&&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 Ki(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 xfe=typeof Symbol=="function"&&Symbol.observable||"@@observable",nz=xfe,TT=()=>Math.random().toString(36).substring(7).split("").join("."),bfe={INIT:`@@redux/INIT${TT()}`,REPLACE:`@@redux/REPLACE${TT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${TT()}`},L1=bfe;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(Ki(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Ki(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Ki(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(Ki(3));return i}function f(v){if(typeof v!="function")throw new Error(Ki(4));if(c)throw new Error(Ki(5));let b=!0;u();const E=o++;return a.set(E,v),function(){if(b){if(c)throw new Error(Ki(6));b=!1,u(),a.delete(E),s=null}}}function g(v){if(!iD(v))throw new Error(Ki(7));if(typeof v.type>"u")throw new Error(Ki(8));if(typeof v.type!="string")throw new Error(Ki(17));if(c)throw new Error(Ki(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(Ki(10));r=v,g({type:L1.REPLACE})}function x(){const v=f;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(Ki(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 vfe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:L1.INIT})>"u")throw new Error(Ki(12));if(typeof n(void 0,{type:L1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Ki(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{vfe(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(Ki(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 yfe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(Ki(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 Mo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var xa=Object,vm=xa.getPrototypeOf,U1="constructor",KS="prototype",B3="configurable",F1="enumerable",J_="writable",T0="value",Cc=t=>!!t&&!!t[ks];function Uo(t){return t?mW(t)||XS(t)||!!t[rz]||!!t[U1]?.[rz]||YS(t)||ZS(t):!1}var _fe=xa[KS][U1].toString(),iz=new WeakMap;function mW(t){if(!t||!sD(t))return!1;const e=vm(t);if(e===null||e===xa[KS])return!0;const n=xa.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===_fe}function yb(t,e,n=!0){_b(t)===0?(n?Reflect.ownKeys(t):xa.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function _b(t){const e=t[ks];return e?e.type_:XS(t)?1:YS(t)?2:ZS(t)?3:0}var sz=(t,e,n=_b(t))=>n===2?t.has(e):xa[KS].hasOwnProperty.call(t,e),H3=(t,e,n=_b(t))=>n===2?t.get(e):t[e],z1=(t,e,n,r=_b(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function wfe(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",oc=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=xa.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[J_]===!1&&(o[J_]=!0,o[B3]=!0),(o.get||o.set)&&(r[a]={[B3]:!0,[J_]:!0,[F1]:o[F1],[T0]:t[a]})}return xa.create(vm(t),r)}else{const r=vm(t);if(r!==null&&n)return{...t};const i=xa.create(r);return xa.assign(i,t)}}function oD(t,e=!1){return QS(t)||Cc(t)||!Uo(t)||(_b(t)>1&&xa.defineProperties(t,{set:vy,add:vy,clear:vy,delete:vy}),xa.freeze(t),e&&yb(t,(n,r)=>{oD(r,!0)},!1)),t}function Sfe(){Mo(2)}var vy={[T0]:Sfe};function QS(t){return t===null||!sD(t)?!0:xa.isFrozen(t)}var B1="MapSet",V3="Patches",gW={};function ym(t){const e=gW[t];return e||Mo(0,t),e}var Efe=t=>!!gW[t],C0,xW=()=>C0,Mfe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Efe(B1)?ym(B1):void 0});function az(t,e){e&&(t.patchPlugin_=ym(V3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function G3(t){W3(t),t.drafts_.forEach(Afe),t.drafts_=null}function W3(t){t===C0&&(C0=t.parent_)}var oz=t=>C0=Mfe(C0,t);function Afe(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),Mo(4)),Uo(t)&&(t=cz(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[ks].base_,t,e)}else t=cz(e,n);return Tfe(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 Tfe(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,Cfe=[];function vW(t,e,n,r){const i=oc(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;yb(i,(c,u)=>{if(Cc(u)){const d=o.get(u)||[];d.push(c),o.set(u,d)}})}const a=t.draftLocations_.get(e)??Cfe;for(const o of a)z1(i,o,n,s)}function Nfe(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 kfe(t,e,n){const{scope_:r}=t;if(Cc(n)){const i=n[ks];JS(i,r)&&i.callbacks_.push(function(){e1(t);const a=aD(i);vW(t,n,a,e)})}else Uo(n)&&t.callbacks_.push(function(){const s=oc(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||Cc(t)||e.has(t)||!Uo(t)||QS(t)||(e.add(t),yb(t,(r,i)=>{if(Cc(i)){const s=i[ks];if(JS(s,n)){const a=aD(s);z1(t,r,a,t.type_),bW(s)}}else Uo(i)&&lD(i,e,n)})),t}function Pfe(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=N0);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=oc(t);if(!sz(n,e,t.type_))return Rfe(t,n,e);const r=n[e];if(t.finalized_||!Uo(r))return r;if(r===NT(t.base_,e)){e1(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 oc(t)},ownKeys(t){return Reflect.ownKeys(oc(t))},set(t,e,n){const r=_W(oc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=NT(oc(t),e),s=i?.[ks];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(wfe(n,i)&&(n!==void 0||sz(t.base_,e,t.type_)))return!0;e1(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),kfe(t,e,n)),!0},deleteProperty(t,e){return e1(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=oc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[J_]:!0,[B3]:t.type_!==1||e!=="length",[F1]:r[F1],[T0]:n[e]}},defineProperty(){Mo(11)},getPrototypeOf(t){return vm(t.base_)},setPrototypeOf(){Mo(12)}},N0={};yb(cD,(t,e)=>{N0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});N0.deleteProperty=function(t,e){return N0.set.call(this,t,e,void 0)};N0.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?oc(n):t)[e]}function Rfe(t,e,n){const r=_W(e,n);return r?T0 in r?r[T0]:r.get?.call(t.draft_):void 0}function _W(t,e){if(!(e in t))return;let n=vm(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=vm(n)}}function q3(t){t.modified_||(t.modified_=!0,t.parent_&&q3(t.parent_))}function e1(t){t.copy_||(t.assigned_=new Map,t.copy_=$3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Dfe=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)||Mo(6),i!==void 0&&!Up(i)&&Mo(7);let s;if(Uo(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=[];ym(V3).generateReplacementPatches_(n,s,{patches_:a,inversePatches_:o}),i(a,o)}return s}else Mo(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){Uo(e)||Mo(8),Cc(e)&&(e=Oo(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_)&&Mo(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=ym(V3).applyPatches_;return Cc(e)?i(e,n):this.produce(e,s=>i(s,n))}};function K3(t,e,n,r){const[i,s]=YS(e)?ym(B1).proxyMap_(e,n):ZS(e)?ym(B1).proxySet_(e,n):Pfe(e,n);return(n?.scope_??xW()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?Nfe(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 Oo(t){return Cc(t)||Mo(10,t),wW(t)}function wW(t){if(!Uo(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 yb(n,(i,s)=>{z1(n,i,wW(s))},r),e&&(e.finalized_=!1),n}var Ofe=new Dfe,SW=Ofe.produce;function EW(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var jfe=EW(),Lfe=EW,Ife=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 lo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(va(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 Rx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Rx.prototype)}static get[Symbol.species](){return Rx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Rx(...e[0].concat(this)):new Rx(...e.concat(this))}};function uz(t){return Uo(t)?SW(t,()=>{}):t}function yy(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Ufe(t){return typeof t=="boolean"}var Ffe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let a=new MW;return n&&(Ufe(n)?a.push(jfe):a.push(Lfe(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}}})},zfe=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 Bfe(t){const e=Ffe(),{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(va(1));let c;typeof r=="function"?c=r(e):c=e();let u=I1;i&&(u=Ife({trace:!1,...typeof i=="object"&&i}));const d=yfe(...c),f=zfe(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(va(28));if(o in e)throw new Error(va(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 Hfe(t){return typeof t=="function"}function $fe(t,e){let[n,r,i]=CW(e),s;if(Hfe(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(Cc(d)){const m=f(d,c);return m===void 0?d:m}else{if(Uo(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 Vfe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Gfe=(t=21)=>{let e="",n=t;for(;n--;)e+=Vfe[Math.random()*64|0];return e},Wfe=Symbol.for("rtk-slice-createasyncthunk");function qfe(t,e){return`${t}/${e}`}function Kfe({creators:t}={}){const e=t?.asyncThunk?.[Wfe];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(va(11));const a=(typeof r.reducers=="function"?r.reducers(Yfe()):r.reducers)||{},o=Object.keys(a),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,A){const T=typeof w=="string"?w:w.type;if(!T)throw new Error(va(12));if(T in c.sliceCaseReducersByType)throw new Error(va(13));return c.sliceCaseReducersByType[T]=A,u},addMatcher(w,A){return c.sliceMatchers.push({matcher:w,reducer:A}),u},exposeAction(w,A){return c.actionCreators[w]=A,u},exposeCaseReducer(w,A){return c.sliceCaseReducersByName[w]=A,u}};o.forEach(w=>{const A=a[w],T={reducerName:w,type:qfe(i,w),createNotation:typeof r.reducers=="function"};Qfe(A)?epe(T,A,u,e):Zfe(T,A,u)});function d(){const[w={},A=[],T=void 0]=typeof r.extraReducers=="function"?CW(r.extraReducers):[r.extraReducers],k={...w,...c.sliceCaseReducersByType};return $fe(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=w=>w,g=new Map,m=new WeakMap;let x;function y(w,A){return x||(x=d()),x(w,A)}function v(){return x||(x=d()),x.getInitialState()}function b(w,A=!1){function T(N){let I=N[w];return typeof I>"u"&&A&&(I=yy(m,T,v)),I}function k(N=f){const I=yy(g,A,()=>new WeakMap);return yy(I,N,()=>{const C={};for(const[D,F]of Object.entries(r.selectors??{}))C[D]=Xfe(F,N,()=>yy(m,N,v),A);return C})}return{reducerPath:w,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(w,{reducerPath:A,...T}={}){const k=A??s;return w.inject({reducerPath:k,reducer:y},T),{...E,...b(k,!0)}}};return E}}function Xfe(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 Qs=Kfe();function Yfe(){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 Zfe({type:t,reducerName:e,createNotation:n},r,i){let s,a;if("reducer"in r){if(n&&!Jfe(r))throw new Error(va(17));s=r.reducer,a=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,a?lo(t,a):lo(t))}function Qfe(t){return t._reducerDefinitionType==="asyncThunk"}function Jfe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function epe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(va(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||_y,pending:o||_y,rejected:c||_y,settled:u||_y})}function _y(){}var tpe="task",NW="listener",kW="completed",uD="cancelled",npe=`task-${uD}`,rpe=`task-${kW}`,X3=`${NW}-${uD}`,ipe=`${NW}-${kW}`,eE=class{constructor(t){this.code=t,this.message=`${tpe} ${uD} (reason: ${t})`}name="TaskAbortError";message},dD=(t,e)=>{if(typeof t!="function")throw new TypeError(va(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 spe=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",ape=(t,e)=>{const n=r=>RW(t,()=>Eh(r,t.reason));return(r,i)=>{dD(r);const s=new AbortController;n(s);const a=spe(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,rpe));return i?.autoJoin&&e.push(a.catch(H1)),{result:$1(t)(a),cancel(){Eh(s,npe)}}}},ope=(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=lo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(va(21));return dD(s),{predicate:i,type:e,effect:s}},LW=em(t=>{const{type:e,predicate:n,effect:r}=jW(t);return{id:Gfe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(va(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)})},lpe=(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(lo(`${tE}/add`),{withTypes:()=>IW}),cpe=lo(`${tE}/removeAll`),UW=em(lo(`${tE}/remove`),{withTypes:()=>UW}),upe=(...t)=>{console.error(`${tE}/error`,...t)},wb=(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=upe}=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=ope(c,b.signal),w=[];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:ape(b.signal,w),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(w),Eh(b,ipe),i(m),m.pending.delete(b)}},f=lpe(e,n);return{middleware:m=>x=>y=>{if(!fW(y))return x(y);if(IW.match(y))return c(y.payload);if(cpe.match(y)){f();return}if(UW.match(y))return u(y.payload);let v=m.getState();const b=()=>{if(v===hz)throw new Error(va(23));return v};let E;try{if(E=x(y),e.size>0){const w=m.getState(),A=Array.from(e.values());for(const T of A){let k=!1;try{k=T.predicate(y,w,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 va(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 dpe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},FW=Qs({name:"chartLayout",initialState:dpe,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:hpe,setLayout:fpe,setChartSize:ppe,setScale:mpe}=FW.actions,gpe=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){xpe(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 xpe(t,e,n){return(e=bpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bpe(t){var e=vpe(t,"string");return typeof e=="symbol"?e:e+""}function vpe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function zn(t,e,n){return dr(t)||dr(e)?n:oo(e)?Wh(t,e,n):typeof e=="function"?e(t):n}var ype=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:s,verticalAlign:a,layout:o}=e;if((o==="vertical"||o==="horizontal"&&a==="middle")&&s!=="center"&&Nt(t[s]))return Gp(Gp({},t),{},{[s]:t[s]+(r||0)});if((o==="horizontal"||o==="vertical"&&s==="center")&&a!=="middle"&&Nt(t[a]))return Gp(Gp({},t),{},{[a]:t[a]+(i||0)})}return t},_l=(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?ji(s[0]-s[1])*2*y:y,f||g){var v=(f||g||[]).map((b,E)=>{var w=r?r.indexOf(b):b;return{coordinate:a(w)+y,value:b,offset:y,index:E}});return v.filter(b=>!Zs(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,_pe=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]])}},wpe=(t,e)=>{if(!e||e.length!==2||!Nt(e[0])||!Nt(e[1]))return t;var n=Math.min(e[0],e[1]),r=Math.max(e[0],e[1]),i=[t[0],t[1]];return(!Nt(t[0])||t[0]<n)&&(i[0]=n),(!Nt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},Spe=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=Zs(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])}},Epe=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=Zs(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)}},Mpe={sign:Spe,expand:Kde,none:bm,silhouette:Xde,wiggle:Yde,positive:Epe},Ape=(t,e,n)=>{var r=Mpe[n],i=qde().keys(e).value((s,a)=>Number(zn(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=zn(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=zn(s,e.dataKey,e.scale.domain()[a]);return dr(o)?null:e.scale(o)-i/2+r},Tpe=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]},Cpe=t=>{var e=t.flat(2).filter(Nt);return[Math.min(...e),Math.max(...e)]},Npe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],kpe=(t,e,n)=>{if(t!=null)return Npe(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=Cpe(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 Ppe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Rpe=(t,e)=>e==="centric"?t.angle:t.radius,Ic=t=>t.layout.width,Uc=t=>t.layout.height,Dpe=t=>t.layout.scale,VW=t=>t.layout.margin,nE=We(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),rE=We(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),GW="data-recharts-item-index",WW="data-recharts-item-data-key",Sb=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 wy(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){Ope(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 Ope(t,e,n){return(e=jpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jpe(t){var e=Lpe(t,"string");return typeof e=="symbol"?e:e+""}function Lpe(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 Ipe=t=>t.brush.height;function Upe(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:Sb;return n+i}return n},0)}function Fpe(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:Sb;return n+i}return n},0)}function zpe(t){var e=nE(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Bpe(t){var e=nE(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var xi=We([Ic,Uc,VW,Ipe,Upe,Fpe,zpe,Bpe,cW,ffe],(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=wy(wy({},f),d),m=g.bottom;g.bottom+=r,g=ype(g,c,u);var x=t-g.left-g.right,y=e-g.top-g.bottom;return wy(wy({brushBottom:m},g),{},{width:Math.max(x,0),height:Math.max(y,0)})}),Hpe=We(xi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),hD=We(Ic,Uc,(t,e)=>({x:0,y:0,width:t,height:e})),$pe=M.createContext(null),bi=()=>M.useContext($pe)!=null,iE=t=>t.brush,sE=We([iE,xi,VW],(t,e,n)=>({height:t.height,x:Nt(t.x)?t.x:e.left,y:Nt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Nt(t.width)?t.width:e.width})),kT={},PT={},RT={},wz;function Vpe(){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 w=g==null;m(),c&&w&&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 Gpe(){return Sz||(Sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Vpe();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 Wpe(){return Ez||(Ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Gpe();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 qpe(){return Mz||(Mz=1,DT=Wpe().throttle),DT}var Kpe=qpe();const Xpe=uo(Kpe);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=Tc(r)?t:Number(r),c=Tc(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}},Ype={width:0,height:0,overflow:"visible"},Zpe={width:0,overflowX:"visible"},Qpe={height:0,overflowY:"visible"},Jpe={},eme=t=>{var{width:e,height:n}=t,r=Tc(e),i=Tc(n);return r&&i?Ype:r?Zpe:i?Qpe:Jpe};function tme(t){var{width:e,height:n,aspect:r}=t,i=e,s=n;return i===void 0&&s===void 0?(i="100%",s="100%"):i===void 0?i=r&&r>0?void 0:"100%":s===void 0&&(s=r&&r>0?void 0:"100%"),{width:i,height:s}}function Bn(t){return Number.isFinite(t)}function dl(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){nme(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 nme(t,e,n){return(e=rme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rme(t){var e=ime(t,"string");return typeof e=="symbol"?e:e+""}function ime(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 sme(t){return dl(t.width)&&dl(t.height)}function XW(t){var{children:e,width:n,height:r}=t,i=M.useMemo(()=>({width:n,height:r}),[n,r]);return sme(i)?M.createElement(KW.Provider,{value:i},e):null}var fD=()=>M.useContext(KW),ame=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}),w=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 bb;var I=j=>{var q,{width:R,height:W}=j[0].contentRect;w(R,W),(q=v.current)===null||q===void 0||q.call(v,R,W)};d>0&&(I=Xpe(I,d,{trailing:!0,leading:!1}));var C=new ResizeObserver(I),{width:D,height:F}=y.current.getBoundingClientRect();return w(D,F),C.observe(y.current),()=>{C.disconnect()}},[w,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:Sn("recharts-responsive-container",g),style:Tz(Tz({},x),{},{width:i,height:s,minWidth:a,minHeight:o,maxHeight:c}),ref:y},M.createElement("div",{style:eme({width:i,height:s})},M.createElement(XW,{width:k,height:N},u)))}),t1=M.forwardRef((t,e)=>{var n=fD();if(dl(n.width)&&dl(n.height))return t.children;var{width:r,height:i}=tme({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 Nt(s)&&Nt(a)?M.createElement(XW,{width:s,height:a},t.children):M.createElement(ame,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 Eb=()=>{var t,e=bi(),n=Tt(Hpe),r=Tt(sE),i=(t=Tt(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}},ome={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},ZW=()=>{var t;return(t=Tt(xi))!==null&&t!==void 0?t:ome},pD=()=>Tt(Ic),mD=()=>Tt(Uc),lme=()=>Tt(t=>t.layout.margin),gn=t=>t.layout.layoutType,hf=()=>Tt(gn),cme=()=>{var t=hf();if(t==="horizontal"||t==="vertical")return t},ume=()=>{var t=hf();return t!==void 0},aE=t=>{var e=rr(),n=bi(),{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&&dl(a)&&dl(o)&&e(ppe({width:a,height:o}))},[e,n,a,o]),null},QW=Symbol.for("immer-nothing"),Cz=Symbol.for("immer-draftable"),Ma=Symbol.for("immer-state");function Ao(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var k0=Object.getPrototypeOf;function _m(t){return!!t&&!!t[Ma]}function qh(t){return t?JW(t)||Array.isArray(t)||!!t[Cz]||!!t.constructor?.[Cz]||Mb(t)||lE(t):!1}var dme=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===dme}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[Ma];return e?e.type_:Array.isArray(t)?1:Mb(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 hme(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Mb(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(Mb(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[Ma];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(k0(t),r)}else{const r=k0(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)||_m(t)||!qh(t)||(oE(t)>1&&Object.defineProperties(t,{set:Sy,add:Sy,clear:Sy,delete:Sy}),Object.freeze(t),e&&Object.values(t).forEach(n=>gD(n,!0))),t}function fme(){Ao(2)}var Sy={value:fme};function cE(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var pme={};function Kh(t){const e=pme[t];return e||Ao(0,t),e}var P0;function tq(){return P0}function mme(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(gme),t.drafts_=null}function tk(t){t===P0&&(P0=t.parent_)}function Pz(t){return P0=mme(P0,t)}function gme(t){const e=t[Ma];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[Ma].modified_&&(ek(e),Ao(4)),qh(t)&&(t=q1(e,t),e.parent_||K1(e,t)),e.patches_&&Kh("Patches").generateReplacementPatches_(n[Ma].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[Ma];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(_m(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),_m(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"&&(Mb(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 xme(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=R0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,o}var xD={get(t,e){if(e===Ma)return t;const n=rh(t);if(!Q3(n,e))return bme(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?.[Ma];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(hme(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(){Ao(11)},getPrototypeOf(t){return k0(t.base_)},setPrototypeOf(){Ao(12)}},R0={};W1(xD,(t,e)=>{R0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});R0.deleteProperty=function(t,e){return R0.set.call(this,t,e,void 0)};R0.set=function(t,e,n){return xD.set.call(this,t[0],e,n,t[0])};function OT(t,e){const n=t[Ma];return(n?rh(n):t)[e]}function bme(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=k0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=k0(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 vme=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"&&Ao(6),r!==void 0&&typeof r!="function"&&Ao(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 Ao(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)||Ao(8),_m(t)&&(t=yme(t));const e=Pz(this),n=rk(t,void 0);return n[Ma].isManual_=!0,tk(e),n}finishDraft(t,e){const n=t&&t[Ma];(!n||!n.isManual_)&&Ao(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 _m(t)?r(t,e):this.produce(t,i=>r(i,e))}};function rk(t,e){const n=Mb(t)?Kh("MapSet").proxyMap_(t,e):lE(t)?Kh("MapSet").proxySet_(t,e):xme(t,e);return(e?e.scope_:tq()).drafts_.push(n),n}function yme(t){return _m(t)||Ao(10,t),rq(t)}function rq(t){if(!qh(t)||cE(t))return t;const e=t[Ma];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 _me=new vme;_me.produce;var wme={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},iq=Qs({name:"legend",initialState:wme,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=Oo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:fr()},removeLegendPayload:{reducer(t,e){var n=Oo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:fr()}}}),{setLegendSize:Oz,setLegendSettings:Sme,addLegendPayload:sq,replaceLegendPayload:aq,removeLegendPayload:oq}=iq.actions,Eme=iq.reducer,Mme=["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 wm(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){Ame(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 Ame(t,e,n){return(e=Tme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Tme(t){var e=Cme(t,"string");return typeof e=="symbol"?e:e+""}function Cme(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 Nme(t,e){if(t==null)return{};var n,r,i=kme(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 kme(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Pme(t){return t.value}function Rme(t){var{contextPayload:e}=t,n=Nme(t,Mme),r=iW(e,t.payloadUniqBy,Pme),i=wm(wm({},n),{},{payload:r});return M.isValidElement(t.content)?M.cloneElement(t.content,i):typeof t.content=="function"?M.createElement(t.content,i):M.createElement(Mhe,i)}function Dme(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}),wm(wm({},u),d)}function Ome(t){var e=rr();return M.useEffect(()=>{e(Sme(t))},[e,t]),null}function jme(t){var e=rr();return M.useEffect(()=>(e(Oz(t)),()=>{e(Oz({width:0,height:0}))}),[e,t]),null}function Lme(t,e,n,r){return t==="vertical"&&Nt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var Ime={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function bD(t){var e=Sr(t,Ime),n=gfe(),r=xde(),i=lme(),{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=Lme(e.layout,a,s,m),y=c?o:wm(wm({position:"absolute",width:x?.width||s||"auto",height:x?.height||a||"auto"},Dme(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(Ome,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&M.createElement(jme,{width:u.width,height:u.height}),M.createElement(Rme,ik({},e,x,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return dc.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){Ume(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 Ume(t,e,n){return(e=Fme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Fme(t){var e=zme(t,"string");return typeof e=="symbol"?e:e+""}function zme(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 Bme(t){return Array.isArray(t)&&oo(t[0])&&oo(t[1])?t.join(" ~ "):t}var Hme=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||Bme,{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},oo(q)?M.createElement("span",{className:"recharts-tooltip-item-name"},q):null,oo(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=Sn("recharts-default-tooltip",c),w=Sn("recharts-tooltip-label",u);v&&f&&s!==void 0&&s!==null&&(b=f(d,s));var A=g?{role:"status","aria-live":"assertive"}:{};return M.createElement("div",sk({className:E,style:x},A),M.createElement("p",{className:w,style:y},M.isValidElement(b)?b:"".concat(b)),m())},ax="recharts-tooltip-wrapper",$me={visibility:"hidden"};function Vme(t){var{coordinate:e,translateX:n,translateY:r}=t;return Sn(ax,{["".concat(ax,"-right")]:Nt(n)&&e&&Nt(e.x)&&n>=e.x,["".concat(ax,"-left")]:Nt(n)&&e&&Nt(e.x)&&n<e.x,["".concat(ax,"-bottom")]:Nt(r)&&e&&Nt(e.y)&&r>=e.y,["".concat(ax,"-top")]:Nt(r)&&e&&Nt(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&&Nt(s[r]))return s[r];var d=n[r]-o-(i>0?i:0),f=n[r]+i;if(e[r])return a[r]?d:f;var g=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 Gme(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 Wme(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=Gme({translateX:d,translateY:f,useTranslate3d:o})):u=$me,{cssProperties:u,cssClasses:Vme({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 Ey(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=qme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qme(t){var e=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)}class Xme 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:w}=Wme({allowEscapeViewBox:n,coordinate:a,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:g,viewBox:m}),A=b?{}:Ey(Ey({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&o?"visible":"hidden",position:"absolute",top:0,left:0}),T=Ey(Ey({},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=Tt(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){Yme(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 Yme(t,e,n){return(e=Zme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Zme(t){var e=Qme(t,"string");return typeof e=="symbol"?e:e+""}function Qme(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:Lde,curveBasisOpen:Ide,curveBasis:jde,curveBumpX:_de,curveBumpY:wde,curveLinearClosed:Ude,curveLinear:GS,curveMonotoneX:Fde,curveMonotoneY:zde,curveNatural:Bde,curveStep:Hde,curveStepAfter:Vde,curveStepBefore:$de},X1=t=>Bn(t.x)&&Bn(t.y),Hz=t=>t.base!=null&&X1(t.base)&&X1(t),ox=t=>t.x,lx=t=>t.y,Jme=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(xb(t));return(n==="curveMonotone"||n==="curveBump")&&e?Bz["".concat(n).concat(e==="vertical"?"Y":"X")]:Bz[n]||GS},ege=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,a=Jme(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=gy().y(lx).x1(ox).x0(m=>m.base.x):c=gy().x(ox).y1(lx).y0(m=>m.base.y);var d=c.defined(Hz).curve(a),f=s?u.filter(Hz):u;return d(f)}i==="vertical"&&Nt(r)?c=gy().y(lx).x1(ox).x0(r):Nt(r)?c=gy().x(ox).y1(lx).y0(r):c=D7().x(ox).y(lx);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?ege(t):r;return M.createElement("path",ok({},Ns(t),tD(t),{className:Sn("recharts-curve",e),d:s===null?void 0:s,ref:i}))},tge=["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 nge(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){rge(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 rge(t,e,n){return(e=ige(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ige(t){var e=sge(t,"string");return typeof e=="symbol"?e:e+""}function sge(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 age(t,e){if(t==null)return{};var n,r,i=oge(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 oge(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 lge=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),cge=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:a=0,className:o}=t,c=age(t,tge),u=nge({x:e,y:n,top:r,left:i,width:s,height:a},c);return!Nt(e)||!Nt(n)||!Nt(s)||!Nt(a)||!Nt(r)||!Nt(i)?null:M.createElement("path",lk({},ts(u),{className:Sn("recharts-cross",o),d:lge(e,n,s,a,r,i)}))};function uge(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){dge(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 dge(t,e,n){return(e=hge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hge(t){var e=fge(t,"string");return typeof e=="symbol"?e:e+""}function fge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var pge=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),cq=(t,e,n)=>t.map(r=>"".concat(pge(r)," ").concat(e,"ms ").concat(n)).join(","),mge=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),D0=(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){gge(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 gge(t,e,n){return(e=xge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xge(t){var e=bge(t,"string");return typeof e=="symbol"?e:e+""}function bge(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=D0((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?D0((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 vge(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=()=>D0((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 yge(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=D0((y,v)=>Y1(...v,n(g)),c);if(s(ui(ui(ui({},t),e),m)),g<1)o=a.setTimeout(d);else{var x=D0((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 _ge=(t,e,n,r,i,s)=>{var a=mge(t,e);return n==null?()=>(i(ui(ui({},t),e)),()=>{}):n.isStepper===!0?vge(t,e,n,a,i,s):yge(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)},wge=(t,e)=>n=>{var r=dq(t,e),i=[...r.map((s,a)=>s*a).slice(1),0];return hq(i,n)},Sge=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]},Ege=(t,e,n,r)=>{var i=qz(t,n),s=qz(e,r),a=wge(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 Ege(...Sge(...arguments))},Mge=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},Age=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 Mge();default:if(t.split("(")[0]==="cubic-bezier")return Kz(t)}return typeof t=="function"?t:null};function Tge(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 Cge{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 Nge(){return Tge(new Cge)}var kge=M.createContext(Nge);function Pge(t,e){var n=M.useContext(kge);return M.useMemo(()=>e??n(t),[t,e,n])}var Rge=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Xm={devToolsEnabled:!1,isSsr:Rge()},Dge={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},Xz={t:0},IT={t:1};function Ym(t){var e=Sr(t,Dge),{isActive:n,canBegin:r,duration:i,easing:s,begin:a,onAnimationEnd:o,onAnimationStart:c,children:u}=e,d=n==="auto"?!Xm.isSsr:n,f=Pge(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 bb;var y=_ge(Xz,IT,Age(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 Zm(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=M.useRef(A0(e)),r=M.useRef(t);return r.current!==t&&(n.current=A0(e),r.current=t),n.current}var Oge=["radius"],jge=["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){Lge(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 Lge(t,e,n){return(e=Ige(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ige(t){var e=Uge(t,"string");return typeof e=="symbol"?e:e+""}function Uge(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=Fge(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 Fge(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),w=M.useRef(a),A=M.useMemo(()=>({x:s,y:a,width:o,height:c,radius:u}),[s,a,o,c,u]),T=Zm(A,"rectangle-");if(s!==+s||a!==+a||o!==+o||c!==+c||o===0||c===0)return null;var k=Sn("recharts-rectangle",d);if(!y){var N=ts(e),{radius:I}=N,C=Qz(N,Oge);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=w.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(Ym,{animationId:T,key:T,canBegin:r>0,duration:g,easing:f,isActive:y,begin:m},V=>{var te=Rn(D,o,V),Y=Rn(F,c,V),Z=Rn(j,s,V),U=Rn(q,a,V);n.current&&(v.current=te,b.current=Y,E.current=Z,w.current=U);var z;x?V>0?z={transition:K,strokeDasharray:W}:z={strokeDasharray:R}:z={strokeDasharray:W};var ee=ts(e),{radius:ae}=ee,fe=Qz(ee,jge);return M.createElement("path",Q1({},fe,{radius:typeof u=="number"?u:void 0,className:k,d:Jz(Z,U,te,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){zge(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 zge(t,e,n){return(e=Bge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Bge(t){var e=Hge(t,"string");return typeof e=="symbol"?e:e+""}function Hge(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,$ge=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},Vge=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},Gge=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,a=Vge({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:$ge(c),angleInRadian:c}},Wge=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}},qge=(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},Kge=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=Gge({x:n,y:r},e),{innerRadius:a,outerRadius:o}=e;if(i<a||i>o||i===0)return null;var{startAngle:c,endAngle:u}=Wge(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:qge(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 Xge=(t,e)=>{var n=ji(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},My=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=Xge(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},Yge=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:a,cornerIsExternal:o,startAngle:c,endAngle:u}=t,d=ji(u-c),{circleTangency:f,lineTangency:g,theta:m}=My({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:s,cornerIsExternal:o}),{circleTangency:x,lineTangency:y,theta:v}=My({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:w,lineTangency:A,theta:T}=My({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),{circleTangency:k,lineTangency:N,theta:I}=My({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(w.x,",").concat(w.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},Zge={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},xq=t=>{var e=Sr(t,Zge),{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=Sn("recharts-sector",f),m=s-i,x=ms(a,m,0,!0),y;return x>0&&Math.abs(u-d)<360?y=Yge({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({},ts(e),{className:g,d:y}))};function Qge(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 Jge(){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 exe(){return iB||(iB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Jge();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 txe(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lW(),n=exe();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 nxe(){return aB||(aB=1,BT=txe().range),BT}var rxe=nxe();const bq=uo(rxe);function Ku(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ixe(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===ixe?t:sxe,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 sxe(){return 0}function vq(t){return t===null?NaN:+t}function*axe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const oxe=vD(Ku),Ab=oxe.right;vD(vq).center;class oB extends Map{constructor(e,n=uxe){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(lxe(this,e),n)}delete(e){return super.delete(cxe(this,e))}}function lB({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function lxe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function cxe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function uxe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function dxe(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 hxe=Math.sqrt(50),fxe=Math.sqrt(10),pxe=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>=hxe?10:s>=fxe?5:s>=pxe?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:dxe(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(cx(t,n,e),i(t[r],s)>0&&cx(t,n,r);a<o;){for(cx(t,a,o),++a,--o;i(t[a],s)<0;)++a;for(;i(t[o],s)>0;)--o}i(t[n],s)===0?cx(t,n,o):(++o,cx(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function cx(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function mxe(t,e,n){if(t=Float64Array.from(axe(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 gxe(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 xxe(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 ho(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)},ho.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=xxe(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)},ho.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 bxe(){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 Tb(){}var O0=.7,tw=1/O0,nm="\\s*([+-]?\\d+)\\s*",j0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ll="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vxe=/^#([0-9a-f]{3,8})$/,yxe=new RegExp(`^rgb\\(${nm},${nm},${nm}\\)$`),_xe=new RegExp(`^rgb\\(${ll},${ll},${ll}\\)$`),wxe=new RegExp(`^rgba\\(${nm},${nm},${nm},${j0}\\)$`),Sxe=new RegExp(`^rgba\\(${ll},${ll},${ll},${j0}\\)$`),Exe=new RegExp(`^hsl\\(${j0},${ll},${ll}\\)$`),Mxe=new RegExp(`^hsla\\(${j0},${ll},${ll},${j0}\\)$`),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(Tb,L0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:hB,formatHex:hB,formatHex8:Axe,formatHsl:Txe,formatRgb:fB,toString:fB});function hB(){return this.rgb().formatHex()}function Axe(){return this.rgb().formatHex8()}function Txe(){return Eq(this).formatHsl()}function fB(){return this.rgb().formatRgb()}function L0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=vxe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?pB(e):n===3?new Ws(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Ay(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Ay(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=yxe.exec(t))?new Ws(e[1],e[2],e[3],1):(e=_xe.exec(t))?new Ws(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=wxe.exec(t))?Ay(e[1],e[2],e[3],e[4]):(e=Sxe.exec(t))?Ay(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Exe.exec(t))?xB(e[1],e[2]/100,e[3]/100,1):(e=Mxe.exec(t))?xB(e[1],e[2]/100,e[3]/100,e[4]):dB.hasOwnProperty(t)?pB(dB[t]):t==="transparent"?new Ws(NaN,NaN,NaN,0):null}function pB(t){return new Ws(t>>16&255,t>>8&255,t&255,1)}function Ay(t,e,n,r){return r<=0&&(t=e=n=NaN),new Ws(t,e,n,r)}function Cxe(t){return t instanceof Tb||(t=L0(t)),t?(t=t.rgb(),new Ws(t.r,t.g,t.b,t.opacity)):new Ws}function mk(t,e,n,r){return arguments.length===1?Cxe(t):new Ws(t,e,n,r??1)}function Ws(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}wD(Ws,mk,Sq(Tb,{brighter(t){return t=t==null?tw:Math.pow(tw,t),new Ws(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?O0:Math.pow(O0,t),new Ws(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ws(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:Nxe,formatRgb:gB,toString:gB}));function mB(){return`#${fh(this.r)}${fh(this.g)}${fh(this.b)}`}function Nxe(){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 To(t,e,n,r)}function Eq(t){if(t instanceof To)return new To(t.h,t.s,t.l,t.opacity);if(t instanceof Tb||(t=L0(t)),!t)return new To;if(t instanceof To)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 To(a,o,c,t.opacity)}function kxe(t,e,n,r){return arguments.length===1?Eq(t):new To(t,e,n,r??1)}function To(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}wD(To,kxe,Sq(Tb,{brighter(t){return t=t==null?tw:Math.pow(tw,t),new To(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?O0:Math.pow(O0,t),new To(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 Ws(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 To(bB(this.h),Ty(this.s),Ty(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)}, ${Ty(this.s)*100}%, ${Ty(this.l)*100}%${t===1?")":`, ${t})`}`}}));function bB(t){return t=(t||0)%360,t<0?t+360:t}function Ty(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 Pxe(t,e){return function(n){return t+n*e}}function Rxe(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 Dxe(t){return(t=+t)==1?Mq:function(e,n){return n-e?Rxe(e,n,t):SD(isNaN(e)?n:e)}}function Mq(t,e){var n=e-t;return n?Pxe(t,n):SD(isNaN(t)?e:t)}const vB=(function t(e){var n=Dxe(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 Oxe(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 jxe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Lxe(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]=Qm(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 Ixe(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 Uxe(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]=Qm(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 Fxe(t){return function(){return t}}function zxe(t){return function(e){return t(e)+""}}function Bxe(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]?zxe(c[0].x):Fxe(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 Qm(t,e){var n=typeof e,r;return e==null||n==="boolean"?SD(e):(n==="number"?rw:n==="string"?(r=L0(e))?(e=r,vB):Bxe:e instanceof L0?vB:e instanceof Date?Ixe:jxe(e)?Oxe:Array.isArray(e)?Lxe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Uxe:rw)(t,e)}function ED(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Hxe(t,e){e===void 0&&(e=t,t=Qm);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 $xe(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}:$xe(isNaN(e)?NaN:.5)}function Vxe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Gxe(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 Wxe(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=Ab(t,o,1,r)-1;return s[c](i[c](o))}}function Cb(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=Qm,r,i,s,a=Ms,o,c,u;function d(){var g=Math.min(t.length,e.length);return a!==Ms&&(a=Vxe(t[0],t[g-1])),o=g>2?Wxe:Gxe,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 qxe(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 Sm(t){return t=sw(Math.abs(t)),t?t[1]:NaN}function Kxe(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 Xxe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Yxe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function I0(t){if(!(e=Yxe.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]})}I0.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 Zxe(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 Qxe(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:qxe,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:Qxe,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 Jxe(t){var e=t.grouping===void 0||t.thousands===void 0?SB:Kxe(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:Xxe(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=I0(f);var g=f.fill,m=f.align,x=f.sign,y=f.symbol,v=f.zero,b=f.width,E=f.comma,w=f.precision,A=f.trim,T=f.type;T==="n"?(E=!0,T="g"):wB[T]||(w===void 0&&(w=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);w=w===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));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),w),A&&(F=Zxe(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 te=j.length+F.length+q.length,Y=te<b?new Array(b-te+1).join(g):"";switch(E&&v&&(F=e(Y+F,Y.length?b-q.length:1/0),Y=""),m){case"<":F=j+F+q+Y;break;case"=":F=j+Y+F+q;break;case"^":F=Y.slice(0,te=Y.length>>1)+j+F+q+Y.slice(te);break;default:F=Y+j+F+q;break}return s(F)}return D.toString=function(){return f+""},D}function d(f,g){var m=u((f=I0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Sm(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 Cy,TD,Tq;e0e({thousands:",",grouping:[3],currency:["$",""]});function e0e(t){return Cy=Jxe(t),TD=Cy.format,Tq=Cy.formatPrefix,Cy}function t0e(t){return Math.max(0,-Sm(Math.abs(t)))}function n0e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Sm(e)/3)))*3-Sm(Math.abs(t)))}function r0e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Sm(e)-Sm(t))+1}function Cq(t,e,n,r){var i=fk(t,e,n),s;switch(r=I0(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=n0e(i,a))&&(r.precision=s),Tq(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=r0e(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=t0e(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 Cb(t,Nq())},ho.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 i0e(t){return-Math.log(-t)}function s0e(t){return-Math.exp(-t)}function a0e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function o0e(t){return t===10?a0e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function l0e(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=l0e(r),s=o0e(r),n()[0]<0?(i=CB(i),s=CB(s),t(i0e,s0e)):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=I0(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=()=>Cb(t,Rq()).base(t.base()),ho.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 Cb(t,Dq()).constant(t.constant())},ho.apply(t,arguments)}function PB(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function c0e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function u0e(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(c0e,u0e):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 Cb(t,PD()).exponent(t.exponent())},ho.apply(t,arguments),t}function d0e(){return PD.apply(null,arguments).exponent(.5)}function RB(t){return Math.sign(t)*t*t}function h0e(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=h0e(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)},ho.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]=gxe(t,a/o);return s}function s(a){return a==null||isNaN(a=+a)?r:e[Ab(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)},ho.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[Ab(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)},ho.apply(yd(a),arguments)}function Iq(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[Ab(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)},ho.apply(i,arguments)}const VT=new Date,GT=new Date;function vi(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=>vi(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=vi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);aw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?vi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):aw);aw.range;const hc=1e3,eo=hc*60,fc=eo*60,Nc=fc*24,RD=Nc*7,DB=Nc*30,WT=Nc*365,ph=vi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*hc)},(t,e)=>(e-t)/hc,t=>t.getUTCSeconds());ph.range;const DD=vi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*hc)},(t,e)=>{t.setTime(+t+e*eo)},(t,e)=>(e-t)/eo,t=>t.getMinutes());DD.range;const OD=vi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*eo)},(t,e)=>(e-t)/eo,t=>t.getUTCMinutes());OD.range;const jD=vi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*hc-t.getMinutes()*eo)},(t,e)=>{t.setTime(+t+e*fc)},(t,e)=>(e-t)/fc,t=>t.getHours());jD.range;const LD=vi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*fc)},(t,e)=>(e-t)/fc,t=>t.getUTCHours());LD.range;const Nb=vi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*eo)/Nc,t=>t.getDate()-1);Nb.range;const dE=vi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Nc,t=>t.getUTCDate()-1);dE.range;const Uq=vi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Nc,t=>Math.floor(t/Nc));Uq.range;function ff(t){return vi(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*eo)/RD)}const hE=ff(0),ow=ff(1),f0e=ff(2),p0e=ff(3),Em=ff(4),m0e=ff(5),g0e=ff(6);hE.range;ow.range;f0e.range;p0e.range;Em.range;m0e.range;g0e.range;function pf(t){return vi(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/RD)}const fE=pf(0),lw=pf(1),x0e=pf(2),b0e=pf(3),Mm=pf(4),v0e=pf(5),y0e=pf(6);fE.range;lw.range;x0e.range;b0e.range;Mm.range;v0e.range;y0e.range;const ID=vi(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());ID.range;const UD=vi(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());UD.range;const kc=vi(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());kc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:vi(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});kc.range;const Pc=vi(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());Pc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:vi(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});Pc.range;function Fq(t,e,n,r,i,s){const a=[[ph,1,hc],[ph,5,5*hc],[ph,15,15*hc],[ph,30,30*hc],[s,1,eo],[s,5,5*eo],[s,15,15*eo],[s,30,30*eo],[i,1,fc],[i,3,3*fc],[i,6,6*fc],[i,12,12*fc],[r,1,Nc],[r,2,2*Nc],[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[_0e,w0e]=Fq(Pc,UD,fE,Uq,LD,OD),[S0e,E0e]=Fq(kc,ID,hE,Nb,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 ux(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function M0e(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=dx(i),d=hx(i),f=dx(s),g=hx(s),m=dx(a),x=hx(a),y=dx(o),v=hx(o),b=dx(c),E=hx(c),w={a:V,A:te,b:Y,B:Z,c:null,d:FB,e:FB,f:K0e,g:ibe,G:abe,H:G0e,I:W0e,j:q0e,L:zq,m:X0e,M:Y0e,p:U,q:z,Q:HB,s:$B,S:Z0e,u:Q0e,U:J0e,V:ebe,w:tbe,W:nbe,x:null,X:null,y:rbe,Y:sbe,Z:obe,"%":BB},A={a:ee,A:ae,b:fe,B:de,c:null,d:zB,e:zB,f:dbe,g:_be,G:Sbe,H:lbe,I:cbe,j:ube,L:Hq,m:hbe,M:fbe,p:xe,q:ye,Q:HB,s:$B,S:pbe,u:mbe,U:gbe,V:xbe,w:bbe,W:vbe,x:null,X:null,y:ybe,Y:wbe,Z:Ebe,"%":BB},T={a:D,A:F,b:j,B:q,c:R,d:IB,e:IB,f:B0e,g:LB,G:jB,H:UB,I:UB,j:I0e,L:z0e,m:L0e,M:U0e,p:C,q:j0e,Q:$0e,s:V0e,S:F0e,u:k0e,U:P0e,V:R0e,w:N0e,W:D0e,x:W,X:K,y:LB,Y:jB,Z:O0e,"%":H0e};w.x=k(n,w),w.X=k(r,w),w.c=k(e,w),A.x=k(n,A),A.X=k(r,A),A.c=k(e,A);function k(re,ve){return function(je){var ue=[],ut=-1,$=0,H=re.length,ie,G,J;for(je instanceof Date||(je=new Date(+je));++ut<H;)re.charCodeAt(ut)===37&&(ue.push(re.slice($,ut)),(G=OB[ie=re.charAt(++ut)])!=null?ie=re.charAt(++ut):G=ie==="e"?" ":"0",(J=ve[ie])&&(ie=J(je,G)),ue.push(ie),$=ut+1);return ue.push(re.slice($,ut)),ue.join("")}}function N(re,ve){return function(je){var ue=ux(1900,void 0,1),ut=I(ue,re,je+="",0),$,H;if(ut!=je.length)return null;if("Q"in ue)return new Date(ue.Q);if("s"in ue)return new Date(ue.s*1e3+("L"in ue?ue.L:0));if(ve&&!("Z"in ue)&&(ue.Z=0),"p"in ue&&(ue.H=ue.H%12+ue.p*12),ue.m===void 0&&(ue.m="q"in ue?ue.q:0),"V"in ue){if(ue.V<1||ue.V>53)return null;"w"in ue||(ue.w=1),"Z"in ue?($=KT(ux(ue.y,0,1)),H=$.getUTCDay(),$=H>4||H===0?lw.ceil($):lw($),$=dE.offset($,(ue.V-1)*7),ue.y=$.getUTCFullYear(),ue.m=$.getUTCMonth(),ue.d=$.getUTCDate()+(ue.w+6)%7):($=qT(ux(ue.y,0,1)),H=$.getDay(),$=H>4||H===0?ow.ceil($):ow($),$=Nb.offset($,(ue.V-1)*7),ue.y=$.getFullYear(),ue.m=$.getMonth(),ue.d=$.getDate()+(ue.w+6)%7)}else("W"in ue||"U"in ue)&&("w"in ue||(ue.w="u"in ue?ue.u%7:"W"in ue?1:0),H="Z"in ue?KT(ux(ue.y,0,1)).getUTCDay():qT(ux(ue.y,0,1)).getDay(),ue.m=0,ue.d="W"in ue?(ue.w+6)%7+ue.W*7-(H+5)%7:ue.w+ue.U*7-(H+6)%7);return"Z"in ue?(ue.H+=ue.Z/100|0,ue.M+=ue.Z%100,KT(ue)):qT(ue)}}function I(re,ve,je,ue){for(var ut=0,$=ve.length,H=je.length,ie,G;ut<$;){if(ue>=H)return-1;if(ie=ve.charCodeAt(ut++),ie===37){if(ie=ve.charAt(ut++),G=T[ie in OB?ve.charAt(ut++):ie],!G||(ue=G(re,je,ue))<0)return-1}else if(ie!=je.charCodeAt(ue++))return-1}return ue}function C(re,ve,je){var ue=u.exec(ve.slice(je));return ue?(re.p=d.get(ue[0].toLowerCase()),je+ue[0].length):-1}function D(re,ve,je){var ue=m.exec(ve.slice(je));return ue?(re.w=x.get(ue[0].toLowerCase()),je+ue[0].length):-1}function F(re,ve,je){var ue=f.exec(ve.slice(je));return ue?(re.w=g.get(ue[0].toLowerCase()),je+ue[0].length):-1}function j(re,ve,je){var ue=b.exec(ve.slice(je));return ue?(re.m=E.get(ue[0].toLowerCase()),je+ue[0].length):-1}function q(re,ve,je){var ue=y.exec(ve.slice(je));return ue?(re.m=v.get(ue[0].toLowerCase()),je+ue[0].length):-1}function R(re,ve,je){return I(re,e,ve,je)}function W(re,ve,je){return I(re,n,ve,je)}function K(re,ve,je){return I(re,r,ve,je)}function V(re){return a[re.getDay()]}function te(re){return s[re.getDay()]}function Y(re){return c[re.getMonth()]}function Z(re){return o[re.getMonth()]}function U(re){return i[+(re.getHours()>=12)]}function z(re){return 1+~~(re.getMonth()/3)}function ee(re){return a[re.getUTCDay()]}function ae(re){return s[re.getUTCDay()]}function fe(re){return c[re.getUTCMonth()]}function de(re){return o[re.getUTCMonth()]}function xe(re){return i[+(re.getUTCHours()>=12)]}function ye(re){return 1+~~(re.getUTCMonth()/3)}return{format:function(re){var ve=k(re+="",w);return ve.toString=function(){return re},ve},parse:function(re){var ve=N(re+="",!1);return ve.toString=function(){return re},ve},utcFormat:function(re){var ve=k(re+="",A);return ve.toString=function(){return re},ve},utcParse:function(re){var ve=N(re+="",!0);return ve.toString=function(){return re},ve}}}var OB={"-":"",_:" ",0:"0"},Ui=/^\s*\d+/,A0e=/^%/,T0e=/[\\^$*+?|[\]().{}]/g;function Cn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s<n?new Array(n-s+1).join(e)+i:i)}function C0e(t){return t.replace(T0e,"\\$&")}function dx(t){return new RegExp("^(?:"+t.map(C0e).join("|")+")","i")}function hx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function N0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function k0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function P0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function R0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function D0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function jB(t,e,n){var r=Ui.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function LB(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function O0e(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 j0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function L0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function IB(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function I0e(t,e,n){var r=Ui.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function UB(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function U0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function F0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function z0e(t,e,n){var r=Ui.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function B0e(t,e,n){var r=Ui.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function H0e(t,e,n){var r=A0e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function $0e(t,e,n){var r=Ui.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function V0e(t,e,n){var r=Ui.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function FB(t,e){return Cn(t.getDate(),e,2)}function G0e(t,e){return Cn(t.getHours(),e,2)}function W0e(t,e){return Cn(t.getHours()%12||12,e,2)}function q0e(t,e){return Cn(1+Nb.count(kc(t),t),e,3)}function zq(t,e){return Cn(t.getMilliseconds(),e,3)}function K0e(t,e){return zq(t,e)+"000"}function X0e(t,e){return Cn(t.getMonth()+1,e,2)}function Y0e(t,e){return Cn(t.getMinutes(),e,2)}function Z0e(t,e){return Cn(t.getSeconds(),e,2)}function Q0e(t){var e=t.getDay();return e===0?7:e}function J0e(t,e){return Cn(hE.count(kc(t)-1,t),e,2)}function Bq(t){var e=t.getDay();return e>=4||e===0?Em(t):Em.ceil(t)}function ebe(t,e){return t=Bq(t),Cn(Em.count(kc(t),t)+(kc(t).getDay()===4),e,2)}function tbe(t){return t.getDay()}function nbe(t,e){return Cn(ow.count(kc(t)-1,t),e,2)}function rbe(t,e){return Cn(t.getFullYear()%100,e,2)}function ibe(t,e){return t=Bq(t),Cn(t.getFullYear()%100,e,2)}function sbe(t,e){return Cn(t.getFullYear()%1e4,e,4)}function abe(t,e){var n=t.getDay();return t=n>=4||n===0?Em(t):Em.ceil(t),Cn(t.getFullYear()%1e4,e,4)}function obe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Cn(e/60|0,"0",2)+Cn(e%60,"0",2)}function zB(t,e){return Cn(t.getUTCDate(),e,2)}function lbe(t,e){return Cn(t.getUTCHours(),e,2)}function cbe(t,e){return Cn(t.getUTCHours()%12||12,e,2)}function ube(t,e){return Cn(1+dE.count(Pc(t),t),e,3)}function Hq(t,e){return Cn(t.getUTCMilliseconds(),e,3)}function dbe(t,e){return Hq(t,e)+"000"}function hbe(t,e){return Cn(t.getUTCMonth()+1,e,2)}function fbe(t,e){return Cn(t.getUTCMinutes(),e,2)}function pbe(t,e){return Cn(t.getUTCSeconds(),e,2)}function mbe(t){var e=t.getUTCDay();return e===0?7:e}function gbe(t,e){return Cn(fE.count(Pc(t)-1,t),e,2)}function $q(t){var e=t.getUTCDay();return e>=4||e===0?Mm(t):Mm.ceil(t)}function xbe(t,e){return t=$q(t),Cn(Mm.count(Pc(t),t)+(Pc(t).getUTCDay()===4),e,2)}function bbe(t){return t.getUTCDay()}function vbe(t,e){return Cn(lw.count(Pc(t)-1,t),e,2)}function ybe(t,e){return Cn(t.getUTCFullYear()%100,e,2)}function _be(t,e){return t=$q(t),Cn(t.getUTCFullYear()%100,e,2)}function wbe(t,e){return Cn(t.getUTCFullYear()%1e4,e,4)}function Sbe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Mm(t):Mm.ceil(t),Cn(t.getUTCFullYear()%1e4,e,4)}function Ebe(){return"+0000"}function BB(){return"%"}function HB(t){return+t}function $B(t){return Math.floor(+t/1e3)}var Qf,Vq,Gq;Mbe({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 Mbe(t){return Qf=M0e(t),Vq=Qf.format,Qf.parse,Gq=Qf.utcFormat,Qf.utcParse,Qf}function Abe(t){return new Date(t)}function Tbe(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"),w=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?w:A)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?g(Array.from(k,Tbe)):g().map(Abe)},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 Cb(d,FD(t,e,n,r,i,s,a,o,c,u))},d}function Cbe(){return ho.apply(FD(S0e,E0e,kc,ID,hE,Nb,jD,DD,ph,Vq).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Nbe(){return ho.apply(FD(_0e,w0e,Pc,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(Qm),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 kbe(){return zD.apply(null,arguments).exponent(.5)}function Xq(){var t=[],e=Ms;function n(r){if(r!=null&&!isNaN(r=+r))return e((Ab(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)=>mxe(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,w;return arguments.length?([b,E,w]=v,u=Hxe(y,[b,E,w]),m):[u(0),u(.5),u(1)]}}return m.range=x(Qm),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 Pbe(){return BD.apply(null,arguments).exponent(.5)}const Dx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:_D,scaleDiverging:Yq,scaleDivergingLog:Zq,scaleDivergingPow:BD,scaleDivergingSqrt:Pbe,scaleDivergingSymlog:Qq,scaleIdentity:kq,scaleImplicit:pk,scaleLinear:Nq,scaleLog:Rq,scaleOrdinal:yD,scalePoint:bxe,scalePow:PD,scaleQuantile:jq,scaleQuantize:Lq,scaleRadial:Oq,scaleSequential:Wq,scaleSequentialLog:qq,scaleSequentialPow:zD,scaleSequentialQuantile:Xq,scaleSequentialSqrt:kbe,scaleSequentialSymlog:Kq,scaleSqrt:d0e,scaleSymlog:Dq,scaleThreshold:Iq,scaleTime:Cbe,scaleUtc:Nbe,tickFormat:Cq},Symbol.toStringTag,{value:"Module"}));var wd=t=>t.chartData,HD=We([wd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),kb=(t,e,n,r)=>r?HD(t):wd(t);function od(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(Bn(e)&&Bn(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(Bn(n))i=n;else if(typeof n=="function")return;if(Bn(r))s=r;else if(typeof r=="function")return;var a=[i,s];if(od(a))return a}}function Rbe(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(Nt(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(Nt(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 Jm=1e9,Dbe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},VD,gr=!0,co="[DecimalError] ",Th=co+"Invalid argument: ",$D=co+"Exponent out of range: ",eg=Math.floor,ih=Math.pow,Obe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ma,Ri=1e7,ur=7,eK=9007199254740991,cw=eg(eK/ur),Pt={};Pt.absoluteValue=Pt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Pt.comparedTo=Pt.cmp=function(t){var e,n,r,i,s=this;if(t=new s.constructor(t),s.s!==t.s)return s.s||-t.s;if(s.e!==t.e)return s.e>t.e^s.s<0?1:-1;for(r=s.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(s.d[e]!==t.d[e])return s.d[e]>t.d[e]^s.s<0?1:-1;return r===i?0:r>i^s.s<0?1:-1};Pt.decimalPlaces=Pt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*ur;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Pt.dividedBy=Pt.div=function(t){return vc(this,new this.constructor(t))};Pt.dividedToIntegerBy=Pt.idiv=function(t){var e=this,n=e.constructor;return nr(vc(e,new n(t),0,1),n.precision)};Pt.equals=Pt.eq=function(t){return!this.cmp(t)};Pt.exponent=function(){return ni(this)};Pt.greaterThan=Pt.gt=function(t){return this.cmp(t)>0};Pt.greaterThanOrEqualTo=Pt.gte=function(t){return this.cmp(t)>=0};Pt.isInteger=Pt.isint=function(){return this.e>this.d.length-2};Pt.isNegative=Pt.isneg=function(){return this.s<0};Pt.isPositive=Pt.ispos=function(){return this.s>0};Pt.isZero=function(){return this.s===0};Pt.lessThan=Pt.lt=function(t){return this.cmp(t)<0};Pt.lessThanOrEqualTo=Pt.lte=function(t){return this.cmp(t)<1};Pt.logarithm=Pt.log=function(t){var e,n=this,r=n.constructor,i=r.precision,s=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(ma))throw Error(co+"NaN");if(n.s<1)throw Error(co+(n.s?"NaN":"-Infinity"));return n.eq(ma)?new r(0):(gr=!1,e=vc(U0(n,s),U0(t,s),s),gr=!0,nr(e,i))};Pt.minus=Pt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?rK(e,t):tK(e,(t.s=-t.s,t))};Pt.modulo=Pt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(co+"NaN");return n.s?(gr=!1,e=vc(n,t,0,1).times(t),gr=!0,n.minus(e)):nr(new r(n),i)};Pt.naturalExponential=Pt.exp=function(){return nK(this)};Pt.naturalLogarithm=Pt.ln=function(){return U0(this)};Pt.negated=Pt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Pt.plus=Pt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?tK(e,t):rK(e,(t.s=-t.s,t))};Pt.precision=Pt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(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};Pt.squareRoot=Pt.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(co+"NaN")}for(t=ni(o),gr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=sl(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=eg((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(vc(o,s,a+2)).times(.5),sl(s.d).slice(0,a)===(e=sl(r.d)).slice(0,a)){if(e=e.slice(a-3,a+1),i==a&&e=="4999"){if(nr(s,n+1,0),s.times(s).eq(o)){r=s;break}}else if(e!="9999")break;a+=4}return gr=!0,nr(r,n)};Pt.times=Pt.mul=function(t){var e,n,r,i,s,a,o,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%Ri|0,e=o/Ri|0;s[i]=(s[i]+e)%Ri|0}for(;!s[--a];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,gr?nr(t,f.precision):t};Pt.toDecimalPlaces=Pt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(hl(t,0,Jm),e===void 0?e=r.rounding:hl(e,0,8),nr(n,t+ni(n)+1,e))};Pt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Xh(r,!0):(hl(t,0,Jm),e===void 0?e=i.rounding:hl(e,0,8),r=nr(new i(r),t+1,e),n=Xh(r,!0,t+1)),n};Pt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Xh(i):(hl(t,0,Jm),e===void 0?e=s.rounding:hl(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)};Pt.toInteger=Pt.toint=function(){var t=this,e=t.constructor;return nr(new e(t),ni(t)+1,e.rounding)};Pt.toNumber=function(){return+this};Pt.toPower=Pt.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(ma);if(o=new c(o),!o.s){if(t.s<1)throw Error(co+"Infinity");return o}if(o.eq(ma))return o;if(r=c.precision,t.eq(ma))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(ma),e=Math.ceil(r/ur+4),gr=!1;n%2&&(i=i.times(o),WB(i.d,e)),n=eg(n/2),n!==0;)o=o.times(o),WB(o.d,e);return gr=!0,t.s<0?new c(ma).div(i):nr(i,r)}}else if(s<0)throw Error(co+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,gr=!1,i=t.times(U0(o,r+u)),gr=!0,i=nK(i),i.s=s,i};Pt.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)):(hl(t,1,Jm),e===void 0?e=s.rounding:hl(e,0,8),i=nr(new s(i),t,e),n=ni(i),r=Xh(i,t<=n||n<=s.toExpNeg,t)),r};Pt.toSignificantDigits=Pt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(hl(t,1,Jm),e===void 0?e=r.rounding:hl(e,0,8)),nr(new r(n),t,e)};Pt.toString=Pt.valueOf=Pt.val=Pt.toJSON=Pt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=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)/Ri|0,c[s]%=Ri;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 hl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Th+t)}function sl(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 vc=(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%Ri|0,a=s/Ri|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*Ri+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,w,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(co+"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++)w=d*Ri+(F[u]||0),x[u]=w/j|0,d=w%j|0;else{for(d=Ri/(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]>=Ri/2&&++k;do d=0,o=e(j,y,N,v),o<0?(b=y[0],N!=v&&(b=b*Ri+(y[1]||0)),d=b/k|0,d>1?(d>=Ri&&(d=Ri-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(ma);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(ma),d.precision=o;;){if(i=nr(i.times(t),o),n=n.times(++c),a=s.plus(vc(i,n,o)),sl(a.d).slice(0,o)===sl(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(co+"LN10 precision limit exceeded");return nr(new t(t.LN10),e)}function Tu(t){for(var e="";t--;)e+="0";return e}function U0(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(co+(m.s?"NaN":"-Infinity"));if(m.eq(ma))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=sl(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=sl(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=U0(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=vc(m.minus(ma),m.plus(ma),u),d=nr(m.times(m),u),i=3;;){if(a=nr(a.times(d),u),c=o.plus(vc(a,new y(i),u)),sl(c.d).slice(0,u)===sl(o.d).slice(0,u))return o=o.times(2),s!==0&&(o=o.plus(XT(y,u+2,v).times(s+""))),o=vc(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=eg(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=eg(-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)==Ri&&(f[0]=1,++t.e);break}else{if(f[d]+=s,f[d]!=Ri)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]=Ri-1;--c[s],c[i]+=Ri}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=sl(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,Obe.test(s))GB(a,s);else throw Error(Th+s)}if(i.prototype=Pt,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=iK,i.config=i.set=jbe,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 jbe(t){if(!t||typeof t!="object")throw Error(co+"Object expected");var e,n,r,i=["precision",1,Jm,"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(eg(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(Dbe);ma=new VD(1);const Fn=VD;var Lbe=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)}))}),Ibe=t=>oK(t.length,t),bk=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Ube=Ibe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Fbe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Lbe;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 Fn(t).abs().log(10).toNumber())+1,e}function cK(t,e,n){for(var r=new Fn(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var 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 Fn(0);var r=lK(t.toNumber()),i=new Fn(10).pow(r),s=t.div(i),a=r!==1?.05:.1,o=new Fn(Math.ceil(s.div(a).toNumber())).add(n).mul(a),c=o.mul(i);return e?new Fn(c.toNumber()):new Fn(Math.ceil(c.toNumber()))},zbe=(t,e,n)=>{var r=new Fn(1),i=new Fn(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new Fn(10).pow(lK(t)-1),i=new Fn(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new Fn(Math.floor(t)))}else t===0?i=new Fn(Math.floor((e-1)/2)):n||(i=new Fn(Math.floor(t)));var a=Math.floor((e-1)/2),o=Fbe(Ube(c=>i.add(new Fn(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 Fn(0),tickMin:new Fn(0),tickMax:new Fn(0)};var a=dK(new Fn(n).sub(e).div(r-1),i,s),o;e<=0&&n>=0?o=new Fn(0):(o=new Fn(e).add(n).div(2),o=o.sub(new Fn(o).mod(a)));var c=Math.ceil(o.sub(e).div(a).toNumber()),u=Math.ceil(new Fn(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 Fn(c).mul(a)),tickMax:o.add(new Fn(u).mul(a))})},Bbe=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 zbe(o,i,s);var{step:d,tickMin:f,tickMax:g}=hK(o,c,a,s,0),m=cK(f,g.add(new Fn(.1).mul(d)),d);return n>r?vk(m):m},Hbe=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 Fn(o).sub(a).div(c-1),s,0),d=[...cK(new Fn(a),new Fn(o),u),o];return s===!1&&(d=d.map(f=>Math.round(f))),r>i?vk(d):d},fK=t=>t.rootProps.maxBarSize,$be=t=>t.rootProps.barGap,pK=t=>t.rootProps.barCategoryGap,Vbe=t=>t.rootProps.barSize,Pb=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,Gbe=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},lc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},fa={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},Wbe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:lc.angleAxisId,includeHidden:!1,name:void 0,reversed:lc.reversed,scale:lc.scale,tick:lc.tick,tickCount:void 0,ticks:void 0,type:lc.type,unit:void 0},qbe={allowDataOverflow:fa.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:fa.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:fa.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:fa.scale,tick:fa.tick,tickCount:fa.tickCount,ticks:void 0,type:fa.type,unit:void 0},Kbe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:lc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:lc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:lc.scale,tick:lc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},Xbe={allowDataOverflow:fa.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:fa.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:fa.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:fa.scale,tick:fa.tick,tickCount:fa.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"?Kbe:Wbe,XD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Xbe:qbe,xE=t=>t.polarOptions,YD=We([Ic,Uc,xi],pq),xK=We([xE,YD],(t,e)=>{if(t!=null)return ms(t.innerRadius,e,0)}),bK=We([xE,YD],(t,e)=>{if(t!=null)return ms(t.outerRadius,e,e*.8)}),Ybe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},vK=We([xE],Ybe);We([KD,vK],gE);var yK=We([YD,xK,bK],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});We([XD,yK],gE);var _K=We([gn,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,Rb=(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(zn(f,s,null)),x=zn(f,o.dataKey,0),y;a.has(m)?y=a.get(m):y={},Object.assign(y,{[d]:x}),a.set(m,y)})}}),Array.from(a.values())}function 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 Zbe(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 yi=t=>{var e=gn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},tg=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){Qbe(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 Qbe(t,e,n){return(e=Jbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Jbe(t){var e=eve(t,"string");return typeof e=="symbol"?e:e+""}function eve(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var yk=[0,"auto"],ki={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],wl=(t,e)=>{var n=SK(t,e);return n??ki},Pi={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:Sb},EK=(t,e)=>t.cartesianAxis.yAxis[e],Sl=(t,e)=>{var n=EK(t,e);return n??Pi},tve={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??tve},Er=(t,e,n)=>{switch(e){case"xAxis":return wl(t,n);case"yAxis":return Sl(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))}},nve=(t,e,n)=>{switch(e){case"xAxis":return wl(t,n);case"yAxis":return Sl(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Db=(t,e,n)=>{switch(e){case"xAxis":return wl(t,n);case"yAxis":return Sl(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 Ob=t=>t.graphicalItems.cartesianItems,rve=We([xr,Rb],QD),JD=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),jb=We([Ob,Er,rve],JD,{memoizeOptions:{resultEqualityCheck:_E}}),AK=We([jb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(vE)),TK=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),ive=We([jb],TK),eO=t=>t.map(e=>e.data).filter(Boolean).flat(1),sve=We([jb],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=We([sve,kb],tO),rO=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:zn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:zn(i,r)}))):t.map(r=>({value:r})),wE=We([nO,Er,jb],rO);function CK(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function n1(t){if(oo(t)||t instanceof Date){var e=Number(t);if(Bn(e))return e}}function XB(t){if(Array.isArray(t)){var e=[n1(t[0]),n1(t[1])];return od(e)?e:void 0}var n=n1(t);if(n!=null)return[n,n]}function Rc(t){return t.map(n1).filter(nhe)}function ave(t,e,n){return!n||typeof e!="number"||Zs(e)?[]:n.length?Rc(n.flatMap(r=>{var i=zn(t,r.dataKey),s,a;if(Array.isArray(i)?[s,a]=i:s=a=i,!(!Bn(s)||!Bn(a)))return[e-s,e+a]})):[]}var _i=t=>{var e=yi(t),n=tg(t);return Db(t,e,n)},Lb=We([_i],t=>t?.dataKey),ove=We([AK,kb,_i],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:Ape(t,d,n),graphicalItems:u}]}))},F0=We([ove,AK,Pb,mK],NK),kK=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var a=kpe(t,i,s);if(!(a!=null&&a[0]===0&&a[1]===0))return a}},lve=We([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=Rc(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=We([Er],iO),aO=We([sO,lve],Jq),cve=We([F0,wd,xr,aO],kK,{memoizeOptions:{resultEqualityCheck:yE}}),SE=t=>t.errorBars,uve=(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=zn(o,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),m=ave(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(zn(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]))}),Bn(s)&&Bn(a))return[s,a]},dve=We([nO,Er,ive,SE,xr],oO,{memoizeOptions:{resultEqualityCheck:yE}});function hve(t){var{value:e}=t;if(oo(e)||e instanceof Date)return e}var fve=(t,e,n)=>{var r=t.map(hve).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,ng=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),pve=We([PK,xr,Rb],ng),RK=t=>t.referenceElements.areas,mve=We([RK,xr,Rb],ng),DK=t=>t.referenceElements.lines,gve=We([DK,xr,Rb],ng),OK=(t,e)=>{var n=Rc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},xve=We(pve,xr,OK),jK=(t,e)=>{var n=Rc(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)]},bve=We([mve,xr],jK);function vve(t){var e;if(t.x!=null)return Rc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Rc(n)}function yve(t){var e;if(t.y!=null)return Rc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Rc(n)}var LK=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?vve(r):yve(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},_ve=We([gve,xr],LK),wve=We(xve,_ve,bve,(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 Rbe(e,u,t.allowDataOverflow)},Sve=We([Er,sO,aO,cve,dve,wve,gn,xr],lO,{memoizeOptions:{resultEqualityCheck:yE}}),Eve=[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=_l(e,s);if(u&&o==null){var d;return bq(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?fve(r,t,u):i==="expand"?Eve:a}},uO=We([Er,gn,nO,wE,Pb,xr,Sve],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(xb(s));return o in Dx?o:"point"}}},rg=We([Er,gn,MK,GD,xr],IK);function Mve(t){if(t!=null){if(t in Dx)return Dx[t]();var e="scale".concat(xb(t));if(e in Dx)return Dx[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=Mve(e);if(i!=null){var s=i.domain(n).range(r);return _pe(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 Bbe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&od(t))return Hbe(t,e.tickCount,e.allowDecimals)}},fO=We([uO,Db,rg],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},Ave=We([Er,uO,fO,xr],pO),Tve=We(wE,Er,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Rc(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=We(Tve,gn,pK,xi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!Bn(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var a=ms(n,t*s),o=t*s/2;return o-a-(o-a)/s*a}return 0}),Cve=(t,e)=>{var n=wl(t,e);return n==null||typeof n.padding!="string"?0:UK(t,"xAxis",e,n.padding)},Nve=(t,e)=>{var n=Sl(t,e);return n==null||typeof n.padding!="string"?0:UK(t,"yAxis",e,n.padding)},kve=We(wl,Cve,(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}}),Pve=We(Sl,Nve,(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}}),Rve=We([xi,kve,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]}),Dve=We([xi,gn,Pve,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]}),Ib=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Rve(t,n,r);case"yAxis":return Dve(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=We([Er,Ib],gE),ld=We([Er,rg,Ave,FK],dO);We([jb,SE,xr],uve);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,Ove=We(nE,EE,ME,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(zK)),jve=We(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}),Lve=(t,e)=>{var n=typeof e.width=="number"?e.width:Sb;return{width:n,height:t.height}},HK=We(xi,wl,BK),Ive=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},Uve=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},Fve=We(Uc,xi,Ove,EE,ME,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var c=BK(e,o);a==null&&(a=Ive(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}),zve=We(Ic,xi,jve,EE,ME,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var c=Lve(e,o);a==null&&(a=Uve(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}),Bve=(t,e)=>{var n=wl(t,e);if(n!=null)return Fve(t,n.orientation,n.mirror)},Hve=We([xi,wl,Bve,(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}}}),$ve=(t,e)=>{var n=Sl(t,e);if(n!=null)return zve(t,n.orientation,n.mirror)},Vve=We([xi,Sl,$ve,(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=We(xi,Sl,(t,e)=>{var n=typeof e.width=="number"?e.width:Sb;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=_l(t,r),c=e.map(u=>u.value);if(a&&o&&s==="category"&&i&&G7(c))return c}},mO=We([gn,wE,Er,xr],VK),GK=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,a=_l(t,r);if(a&&(i==="number"||s!=="auto"))return e.map(o=>o.value)}},gO=We([gn,wE,Db,xr],GK),ZB=We([gn,nve,rg,ld,mO,gO,Ib,fO,xr],(t,e,n,r,i,s,a,o,c)=>{if(e!=null){var u=_l(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}}}),Gve=(t,e,n,r,i,s,a,o,c)=>{if(!(e==null||r==null)){var u=_l(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?ji(s[0]-s[1])*2*x:x;var y=f||i;if(y){var v=y.map((b,E)=>{var w=a?a.indexOf(b):b;return{index:E,coordinate:r(w)+x,value:b,offset:x}});return v.filter(b=>Bn(b.coordinate))}return u&&o?o.map((b,E)=>({coordinate:r(b)+x,value:b,index:E,offset:x})).filter(b=>Bn(b.coordinate)):r.ticks?r.ticks(g).map(b=>({coordinate:r(b)+x,value:b,offset:x})):r.domain().map((b,E)=>({coordinate:r(b)+x,value:a?a[b]:b,index:E,offset:x}))}},WK=We([gn,Db,rg,ld,fO,Ib,mO,gO,xr],Gve),Wve=(t,e,n,r,i,s,a)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=_l(t,a),{tickCount:c}=e,u=0;return u=a==="angleAxis"&&r?.length>=2?ji(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}))}},fl=We([gn,Db,ld,Ib,mO,gO,xr],Wve),pl=We(Er,ld,(t,e)=>{if(!(t==null||e==null))return uw(uw({},t),{},{scale:e})}),qve=We([Er,rg,uO,FK],dO);We((t,e,n)=>ZD(t,n),qve,(t,e)=>{if(!(t==null||e==null))return uw(uw({},t),{},{scale:e})});var Kve=We([gn,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 Xve(t){return Tt(e=>xO(e,t))}var YK=(t,e)=>{var n,r=Number(e);if(!(Zs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},Yve=t=>t.tooltip.settings,ju={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},Zve={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=Qs({name:"tooltip",initialState:Zve,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:fr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Oo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:fr()},removeTooltipEntrySettings:{reducer(t,e){var n=Oo(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:Qve,replaceTooltipEntrySettings:Jve,removeTooltipEntrySettings:eye,setTooltipSettingsState:tye,setActiveMouseOverItemIndex:QK,mouseLeaveItem:nye,mouseLeaveChart:JK,setActiveClickItemIndex:rye,setMouseOverAxisIndex:eX,setMouseClickAxisIndex:iye,setSyncInteraction:_k,setKeyboardInteraction:wk}=ZK.actions,sye=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 Ny(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){aye(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 aye(t,e,n){return(e=oye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oye(t){var e=lye(t,"string");return typeof e=="symbol"?e:e+""}function lye(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 cye(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function uye(t){return t.index!=null}var tX=(t,e,n,r)=>{if(e==null)return ju;var i=cye(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(uye(i)){if(s)return Ny(Ny({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return Ny(Ny({},ju),{},{coordinate:i.coordinate})};function dye(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 hye(t,e){var n=dye(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 fye(t,e,n){if(n==null||e==null)return!0;var r=zn(t,e);return r==null||!od(n)?!0:hye(r,n)}var bO=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!Bn(s))return i;var a=0,o=1/0;e.length>0&&(o=e.length-1);var c=Math.max(a,Math.min(s,o)),u=e[c];return u==null||fye(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})},Ub=t=>t.options.tooltipPayloadSearcher,ig=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){pye(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 pye(t,e,n){return(e=mye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mye(t){var e=gye(t,"string");return typeof e=="symbol"?e:e+""}function gye(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 xye(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=xye(y,o),E=Array.isArray(b)?zW(b,u,d):b,w=(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:zn(N.payload,N.dataKey),name:N.name}))});else{var k;g.push(yz({tooltipEntrySettings:v,dataKey:w,payload:T,value:zn(T,w),name:(k=zn(T,A))!==null&&k!==void 0?k:v?.name}))}return g},f)}},vO=We([_i,gn,MK,GD,yi],IK),bye=We([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),vye=We([yi,tg],QD),Fb=We([bye,_i,vye],JD,{memoizeOptions:{resultEqualityCheck:_E}}),yye=We([Fb],t=>t.filter(vE)),_ye=We([Fb],eO,{memoizeOptions:{resultEqualityCheck:_E}}),sg=We([_ye,wd],tO),wye=We([yye,wd,_i],wK),yO=We([sg,_i,Fb],rO),sX=We([_i],iO),Sye=We([_i],t=>t.allowDataOverflow),aX=We([sX,Sye],Jq),Eye=We([Fb],t=>t.filter(vE)),Mye=We([wye,Eye,Pb,mK],NK),Aye=We([Mye,wd,yi,aX],kK),Tye=We([Fb],TK),Cye=We([sg,_i,Tye,SE,yi],oO,{memoizeOptions:{resultEqualityCheck:yE}}),Nye=We([PK,yi,tg],ng),kye=We([Nye,yi],OK),Pye=We([RK,yi,tg],ng),Rye=We([Pye,yi],jK),Dye=We([DK,yi,tg],ng),Oye=We([Dye,yi],LK),jye=We([kye,Oye,Rye],dw),Lye=We([_i,sX,aX,Aye,Cye,jye,gn,yi],lO),zb=We([_i,gn,sg,yO,Pb,yi,Lye],cO),Iye=We([zb,_i,vO],hO),Uye=We([_i,zb,Iye,yi],pO),oX=t=>{var e=yi(t),n=tg(t),r=!1;return Ib(t,e,n,r)},lX=We([_i,oX],gE),cX=We([_i,vO,Uye,lX],dO),Fye=We([gn,yO,_i,yi],VK),zye=We([gn,yO,_i,yi],GK),Bye=(t,e,n,r,i,s,a,o)=>{if(e){var{type:c}=e,u=_l(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?ji(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=We([gn,_i,vO,cX,oX,Fye,zye,yi],Bye),_O=We([qK,KK,Yve],(t,e,n)=>XK(n.shared,t,e)),uX=t=>t.tooltip.settings.trigger,wO=t=>t.tooltip.settings.defaultIndex,Bb=We([ig,_O,uX,wO],tX),cd=We([Bb,sg,Lb,zb],bO),dX=We([zc,cd],YK),SO=We([Bb],t=>{if(t)return t.dataKey}),Hye=We([Bb],t=>{if(t)return t.graphicalItemId}),hX=We([ig,_O,uX,wO],rX),$ye=We([Ic,Uc,gn,xi,zc,wO,hX,Ub],nX),Vye=We([Bb,$ye],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),Gye=We([Bb],t=>t.active),Wye=We([hX,cd,wd,Lb,dX,Ub,_O],iX),qye=We([Wye],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){Kye(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 Kye(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=Yye(t,"string");return typeof e=="symbol"?e:e+""}function Yye(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 Zye=()=>Tt(_i),Qye=()=>{var t=Zye(),e=Tt(zc),n=Tt(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){Jye(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 Jye(t,e,n){return(e=e_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e_e(t){var e=t_e(t,"string");return typeof e=="symbol"?e:e+""}function t_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 n_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}},r_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 i_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(ji(d-u)!==ji(f-d)){var m=[];if(ji(f-d)===ji(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 w=0;w<o;w++)if(w===0&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w>0&&w<o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:a}=e[w]);break}}return a},pX=()=>Tt(GD),EO=(t,e)=>e,mX=(t,e,n)=>n,MO=(t,e,n,r)=>r,s_e=We(zc,t=>qS(t,e=>e.coordinate)),AO=We([ig,EO,mX,MO],tX),TO=We([AO,sg,Lb,zb],bO),a_e=(t,e,n)=>{if(e!=null){var r=ig(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=We([ig,EO,mX,MO],rX),hw=We([Ic,Uc,gn,xi,zc,MO,gX,Ub],nX),o_e=We([AO,hw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),xX=We([zc,TO],YK),l_e=We([gX,TO,wd,Lb,xX,Ub,EO],iX),c_e=We([AO,TO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),u_e=(t,e,n,r,i,s,a)=>{if(!(!t||!n||!r||!i)&&i_e(t,a)){var o=Ppe(t,e),c=fX(o,s,i,n,r),u=n_e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},d_e=(t,e,n,r,i,s,a)=>{if(!(!t||!r||!i||!s||!n)){var o=Kge(t,n);if(o){var c=Rpe(o,e),u=fX(c,a,s,r,i),d=r_e(e,s,u,o);return{activeIndex:String(u),activeCoordinate:d}}}},h_e=(t,e,n,r,i,s,a,o)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?u_e(t,e,r,i,s,a,o):d_e(t,e,n,r,i,s,a)},f_e=We(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),p_e=We(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:Zbe}});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){m_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 m_e(t,e,n){return(e=g_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function g_e(t){var e=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)}var b_e={},v_e={zIndexMap:Object.values(Rr).reduce((t,e)=>s6(s6({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),b_e)},y_e=new Set(Object.values(Rr));function __e(t){return y_e.has(t)}var bX=Qs({name:"zIndex",initialState:v_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&&!__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:w_e,unregisterZIndexPortal:S_e,registerZIndexPortalId:E_e,unregisterZIndexPortalId:M_e}=bX.actions,A_e=bX.reducer;function gs(t){var{zIndex:e,children:n}=t,r=ume(),i=r&&e!==void 0&&e!==0,s=bi(),a=rr();M.useLayoutEffect(()=>i?(a(w_e({zIndex:e})),()=>{a(S_e({zIndex:e}))}):bb,[a,e,i]);var o=Tt(u=>f_e(u,e,s));if(!i)return n;if(!o)return null;var c=document.getElementById(o);return c?dc.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 ky(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){T_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 T_e(t,e,n){return(e=C_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function C_e(t){var e=N_e(t,"string");return typeof e=="symbol"?e:e+""}function N_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function k_e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return M.isValidElement(e)?M.cloneElement(e,r):M.createElement(n,r)}function P_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=cge,v=Rr.cursorLine;else if(d==="BarChart")x=uge(o,f,s,a),y=fq,v=Rr.cursorRectangle;else if(o==="radial"&&K7(f)){var{cx:b,cy:E,radius:w,startAngle:A,endAngle:T}=mq(f);x={cx:b,cy:E,startAngle:A,endAngle:T,innerRadius:w,outerRadius:w},y=xq,v=Rr.cursorLine}else x={points:Qge(o,f,s)},y=tm,v=Rr.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,N=ky(ky(ky(ky({stroke:"#ccc",pointerEvents:"none"},s),x),Gh(c)),{},{payload:g,payloadIndex:m,className:Sn("recharts-tooltip-cursor",k)});return M.createElement(gs,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},M.createElement(k_e,{cursor:c,cursorComp:y,cursorProps:N}))}function R_e(t){var e=Qye(),n=ZW(),r=hf(),i=pX();return e==null||n==null||r==null||i==null?null:M.createElement(P_e,Sk({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var vX=M.createContext(null),D_e=()=>M.useContext(vX),YT={exports:{}},o6;function O_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,w;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(w=1,E=new Array(b-1);w<b;w++)E[w-1]=arguments[w];v.fn.apply(v.context,E)}else{var A=v.length,T;for(w=0;w<A;w++)switch(v[w].once&&this.removeListener(u,v[w].fn,void 0,!0),b){case 1:v[w].fn.call(v[w].context);break;case 2:v[w].fn.call(v[w].context,d);break;case 3:v[w].fn.call(v[w].context,d,f);break;case 4:v[w].fn.call(v[w].context,d,f,g);break;default:if(!E)for(T=1,E=new Array(b-1);T<b;T++)E[T-1]=arguments[T];v[w].fn.apply(v[w].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 j_e=O_e();const L_e=uo(j_e);var z0=new L_e,Ek="recharts.syncEvent.tooltip",l6="recharts.syncEvent.brush";function AE(t,e){if(e){var n=Number.parseInt(e,10);if(!Zs(n))return t?.[n]}}var I_e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},yX=Qs({name:"options",initialState:I_e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),U_e=yX.reducer,{createEventEmitter:F_e}=yX.actions;function z_e(t){return t.tooltip.syncInteraction}var B_e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},_X=Qs({name:"chartData",initialState:B_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:H_e,setComputedData:I7e}=_X.actions,$_e=_X.reducer,V_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){G_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 G_e(t,e,n){return(e=W_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function W_e(t){var e=q_e(t,"string");return typeof e=="symbol"?e:e+""}function q_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function K_e(t,e){if(t==null)return{};var n,r,i=X_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 X_e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Y_e(){var t=Tt(WD),e=Tt(qD),n=rr(),r=Tt(gK),i=Tt(zc),s=hf(),a=Eb(),o=Tt(c=>c.rootProps.className);M.useEffect(()=>{if(t==null)return bb;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=K_e(m,V_e),{x:b,y:E,width:w,height:A}=d.payload.sourceViewBox,T=ep(ep({},v),{},{x:a.x+(w?(x-b)/w: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 z0.on(Ek,c),()=>{z0.off(Ek,c)}},[o,n,e,t,r,i,s,a])}function Z_e(){var t=Tt(WD),e=Tt(qD),n=rr();M.useEffect(()=>{if(t==null)return bb;var r=(i,s,a)=>{e!==a&&t===i&&n(H_e(s))};return z0.on(l6,r),()=>{z0.off(l6,r)}},[n,e,t])}function Q_e(){var t=rr();M.useEffect(()=>{t(F_e())},[t]),Y_e(),Z_e()}function J_e(t,e,n,r,i,s){var a=Tt(m=>a_e(m,t,e)),o=Tt(qD),c=Tt(WD),u=Tt(gK),d=Tt(z_e),f=d?.active,g=Eb();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});z0.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){e1e(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 e1e(t,e,n){return(e=t1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function t1e(t){var e=n1e(t,"string");return typeof e=="symbol"?e:e+""}function n1e(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 r1e(t){return t.dataKey}function i1e(t,e){return M.isValidElement(t)?M.cloneElement(t,e):typeof t=="function"?M.createElement(t,e):M.createElement(Hme,e)}var f6=[],s1e={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 r1(t){var e,n,r=Sr(t,s1e),{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:w,defaultIndex:A,portal:T,axisId:k}=r,N=rr(),I=typeof A=="number"?String(A):A;M.useEffect(()=>{N(tye({shared:E,trigger:w,axisId:k,active:i,defaultIndex:I}))},[N,E,w,k,i,I]);var C=Eb(),D=lq(),F=Xve(E),{activeIndex:j,isActive:q}=(e=Tt(xe=>c_e(xe,F,w,I)))!==null&&e!==void 0?e:{},R=Tt(xe=>l_e(xe,F,w,I)),W=Tt(xe=>xX(xe,F,w,I)),K=Tt(xe=>o_e(xe,F,w,I)),V=R,te=D_e(),Y=(n=i??q)!==null&&n!==void 0?n:!1,[Z,U]=uW([V,Y]),z=F==="axis"?W:void 0;J_e(F,w,K,z,j,Y);var ee=T??te;if(ee==null||C==null||F==null)return null;var ae=V??f6;Y||(ae=f6),u&&ae.length&&(ae=iW(ae.filter(xe=>xe.value!=null&&(xe.hide!==!0||r.includeHidden)),g,r1e));var fe=ae.length>0,de=M.createElement(Xme,{allowEscapeViewBox:s,animationDuration:a,animationEasing:o,isAnimationActive:d,active:Y,coordinate:K,hasPayload:fe,offset:f,position:m,reverseDirection:x,useTranslate3d:y,viewBox:C,wrapperStyle:v,lastBoundingBox:Z,innerRef:U,hasPortalFromProps:!!T},i1e(c,h6(h6({},r),{},{payload:ae,label:z,active:Y,activeIndex:j,coordinate:K,accessibilityLayer:D})));return M.createElement(M.Fragment,null,dc.createPortal(de,ee),Y&&M.createElement(R_e,{cursor:b,tooltipEventType:F,coordinate:K,payload:ae,index:j}))}var Hb=t=>null;Hb.displayName="Cell";function a1e(t,e,n){return(e=o1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o1e(t){var e=l1e(t,"string");return typeof e=="symbol"?e:e+""}function l1e(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 c1e{constructor(e){a1e(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 u1e(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){d1e(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 d1e(t,e,n){return(e=h1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h1e(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)}var p1e={cacheSize:2e3,enableCache:!0},wX=u1e({},p1e),m6=new c1e(wX.cacheSize),m1e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},g6="recharts_measurement_span";function g1e(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,m1e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Wx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Xm.isSsr)return{width:0,height:0};if(!wX.enableCache)return x6(e,n);var r=g1e(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%]*)/,x1e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,b1e=/(-?\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},v1e=Object.keys(SX),Wp="NaN";function y1e(t,e){return t*SX[e]}class $s{static parse(e){var n,[,r,i]=(n=b1e.exec(e))!==null&&n!==void 0?n:[];return new $s(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Zs(e)&&(this.unit=""),n!==""&&!x1e.test(n)&&(this.num=NaN,this.unit=""),v1e.includes(n)&&(this.num=y1e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new $s(NaN,""):new $s(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new $s(NaN,""):new $s(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new $s(NaN,""):new $s(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new $s(NaN,""):new $s(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Zs(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=$s.parse(r??""),o=$s.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=$s.parse(d??""),x=$s.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 _1e(t){for(var e=t,n;(n=y6.exec(e))!=null;){var[,r]=n;e=e.replace(y6,EX(r))}return e}function w1e(t){var e=t.replace(/\s+/g,"");return e=_1e(e),e=EX(e),e}function S1e(t){try{return w1e(t)}catch{return Wp}}function ZT(t){var e=S1e(t.slice(5,-1));return e===Wp?"":e}var E1e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],M1e=["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=A1e(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 A1e(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:Wx(o,r).width})),a=n?0:Wx(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:a}}catch{return null}};function T1e(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),C1e="…",w6=(t,e,n,r,i,s,a,o)=>{var c=t.slice(0,e),u=AX({breakAll:n,style:r,children:c+C1e});if(!u)return[!1,[]];var d=TX(u.wordsWithComputedWidth,s,a,o),f=d.length>i||CX(d).width>Number(s);return[f,d]},N1e=(t,e,n,r,i)=>{var{maxLines:s,children:a,style:o,breakAll:c}=t,u=Nt(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,[w,A]=w6(d,E,c,o,s,r,n,i),[T]=w6(d,b,c,o,s,r,n,i);if(!w&&!T&&(m=b+1),w&&T&&(x=b-1),!w&&T){v=A;break}y++}return v||f},S6=t=>{var e=dr(t)?[]:t.toString().split(MX);return[{words:e,width:void 0}]},k1e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:a}=t;if((e||n)&&!Xm.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 N1e({breakAll:s,children:r,maxLines:a,style:i},o,c,e,!!n)}return S6(r)},NX="#808080",P1e={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,P1e),{x:r,y:i,lineHeight:s,capHeight:a,fill:o,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=_6(n,E1e),g=M.useMemo(()=>k1e({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,M1e);if(!oo(r)||!oo(i)||g.length===0)return null;var w=Number(r)+(Nt(m)?m:0),A=Number(i)+(Nt(x)?x:0);if(!Bn(w)||!Bn(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(Nt(I)&&Nt(N)?I/N:1,")"))}return y&&k.push("rotate(".concat(y,", ").concat(w,", ").concat(A,")")),k.length&&(E.transform=k.join(" ")),M.createElement("text",Mk({},ts(E),{ref:e,x:w,y:A,className:Sn("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:w,dy:D===0?T:s,key:"".concat(F,"-").concat(D)},F)}))});TE.displayName="Text";var R1e=["labelRef"];function D1e(t,e){if(t==null)return{};var n,r,i=O1e(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 O1e(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){j1e(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 j1e(t,e,n){return(e=L1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function L1e(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 cc(){return cc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},cc.apply(null,arguments)}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=Eb();return t||YW(e)},U1e=M.createContext(null),F1e=()=>{var t=M.useContext(U1e),e=Tt(_K);return t||e},z1e=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",B1e=(t,e)=>{var n=ji(e-t),r=Math.min(Math.abs(e-t),360);return n*r},H1e=(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=B1e(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 w=Jr(o,c,x,b),A=Jr(o,c,x,b+(E?1:-1)*359),T="M".concat(w.x,",").concat(w.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(E?0:1,`,
- `).concat(A.x,",").concat(A.y),k=dr(t.id)?A0("recharts-radial-line-"):t.id;return M.createElement("text",cc({},r,{dominantBaseline:"central",className:Sn("recharts-radial-bar-label",a)}),M.createElement("defs",null,M.createElement("path",{id:k,d:T})),M.createElement("textPath",{xlinkHref:"#".concat(k)},n))},$1e=(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&&Nt(t.cx),V1e=(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",w=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:w};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:w},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:w},j):i==="insideTopRight"?Fr({x:f+c-T,y:o+b,textAnchor:k,verticalAnchor:w},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"&&(Nt(i.x)||Tc(i.x))&&(Nt(i.y)||Tc(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)},G1e={angle:0,offset:5,zIndex:Rr.label,position:"middle",textBreakAll:!1};function Cu(t){var e=Sr(t,G1e),{viewBox:n,position:r,value:i,children:s,content:a,className:o="",textBreakAll:c,labelRef:u}=e,d=F1e(),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=D1e(v,R1e);return M.cloneElement(a,E)}if(typeof a=="function"){if(x=M.createElement(a,v),M.isValidElement(x))return x}else x=z1e(e);var w=ts(e);if(Ak(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return H1e(e,r,x,w,m);y=$1e(m,e.offset,e.position)}else y=V1e(e,m);return M.createElement(gs,{zIndex:e.zIndex},M.createElement(TE,cc({ref:u,className:Sn("recharts-label",o)},w,y,{textAnchor:T1e(w.textAnchor)?w.textAnchor:y.textAnchor,breakAll:c}),x))}Cu.displayName="Label";var W1e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?M.createElement(Cu,cc({key:"label-implicit"},r)):oo(t)?M.createElement(Cu,cc({key:"label-implicit",value:t},r)):M.isValidElement(t)?t.type===Cu?M.cloneElement(t,Fr({key:"label-implicit"},r)):M.createElement(Cu,cc({key:"label-implicit",content:t},r)):CO(t)?M.createElement(Cu,cc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?M.createElement(Cu,cc({},t,{key:"label-implicit"},r)):null};function DX(t){var{label:e,labelRef:n}=t,r=RX();return W1e(e,r,n)||null}var QT={},JT={},M6;function q1e(){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 K1e(){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 X1e(){return T6||(T6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=q1e(),n=K1e(),r=nD();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(QT)),QT}var tC,C6;function Y1e(){return C6||(C6=1,tC=X1e().last),tC}var Z1e=Y1e();const Q1e=uo(Z1e);var J1e=["valueAccessor"],ewe=["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=twe(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 twe(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 nwe=t=>Array.isArray(t.value)?Q1e(t.value):t.value,OX=M.createContext(void 0),NO=OX.Provider,jX=M.createContext(void 0),rwe=jX.Provider;function iwe(){return M.useContext(OX)}function swe(){return M.useContext(jX)}function i1(t){var{valueAccessor:e=nwe}=t,n=N6(t,J1e),{dataKey:r,clockWise:i,id:s,textBreakAll:a,zIndex:o}=n,c=N6(n,ewe),u=iwe(),d=swe(),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):zn(g&&g.payload,r),v=dr(s)?{}:{id:"".concat(s,"-").concat(m)};return M.createElement(Cu,fw({key:"label-".concat(m)},ts(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}))})))}i1.displayName="LabelList";function CE(t){var{label:e}=t;return e?e===!0?M.createElement(i1,{key:"labelList-implicit"}):M.isValidElement(e)||CO(e)?M.createElement(i1,{key:"labelList-implicit",content:e}):typeof e=="object"?M.createElement(i1,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=Sn("recharts-dot",i);return Nt(e)&&Nt(n)&&Nt(r)?M.createElement("circle",Tk({},Ns(t),tD(t),{className:s,cx:e,cy:n,r})):null},IX=t=>t.graphicalItems.polarItems,awe=We([xr,Rb],QD),NE=We([IX,Er,awe],JD),owe=We([NE],eO),kE=We([owe,HD],tO),lwe=We([kE,Er,NE],rO);We([kE,Er,NE],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,a=zn(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:a,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:zn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var k6=()=>{},cwe=We([kE,Er,NE,SE,xr],oO),uwe=We([Er,sO,aO,k6,cwe,k6,gn,xr],lO),UX=We([Er,gn,kE,lwe,Pb,xr,uwe],cO),dwe=We([UX,Er,rg],hO);We([Er,UX,dwe,xr],pO);var hwe={radiusAxis:{},angleAxis:{}},FX=Qs({name:"polarAxis",initialState:hwe,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:U7e,removeRadiusAxis:F7e,addAngleAxis:z7e,removeAngleAxis:B7e}=FX.actions,fwe=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){pwe(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 pwe(t,e,n){return(e=mwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mwe(t){var e=gwe(t,"string");return typeof e=="symbol"?e:e+""}function gwe(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 xwe=(t,e)=>e,kO=We([IX,xwe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),bwe=[],PO=(t,e,n)=>n?.length===0?bwe:n,zX=We([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}}),vwe=We([zX,kO,PO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,a=zn(r,e.nameKey,e.name),o;return n!=null&&(s=n[i])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:vd(a,e.dataKey),color:o,payload:r,type:e.legendType}})}),ywe=We([zX,kO,PO,xi],(t,e,n,r)=>{if(!(e==null||t==null))return _Se({offset:r,pieSettings:e,displayedData:t,cells:n})}),nC={exports:{}},Gn={};var D6;function _we(){if(D6)return Gn;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 Gn.ContextConsumer=s,Gn.ContextProvider=a,Gn.Element=t,Gn.ForwardRef=o,Gn.Fragment=n,Gn.Lazy=f,Gn.Memo=d,Gn.Portal=e,Gn.Profiler=i,Gn.StrictMode=r,Gn.Suspense=c,Gn.SuspenseList=u,Gn.isContextConsumer=function(y){return x(y)===s},Gn.isContextProvider=function(y){return x(y)===a},Gn.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},Gn.isForwardRef=function(y){return x(y)===o},Gn.isFragment=function(y){return x(y)===n},Gn.isLazy=function(y){return x(y)===f},Gn.isMemo=function(y){return x(y)===d},Gn.isPortal=function(y){return x(y)===e},Gn.isProfiler=function(y){return x(y)===i},Gn.isStrictMode=function(y){return x(y)===r},Gn.isSuspense=function(y){return x(y)===c},Gn.isSuspenseList=function(y){return x(y)===u},Gn.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===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)},Gn.typeOf=x,Gn}var O6;function wwe(){return O6||(O6=1,nC.exports=_we()),nC.exports}var Swe=wwe(),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)||(Swe.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 Ewe(){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 Mwe(){return U6||(U6=1,sC=Ewe().isPlainObject),sC}var Awe=Mwe();const Twe=uo(Awe);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){Cwe(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 Cwe(t,e,n){return(e=Nwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nwe(t){var e=kwe(t,"string");return typeof e=="symbol"?e:e+""}function kwe(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},Pwe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Rwe=t=>{var e=Sr(t,Pwe),{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),w=M.useRef(r),A=Zm(t,"trapezoid-");if(M.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var R=g.current.getTotalLength();R&&x(R)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||a!==+a||i===0&&s===0||a===0)return null;var T=Sn("recharts-trapezoid",o);if(!f)return M.createElement("g",null,M.createElement("path",pw({},ts(e),{className:T,d:B6(n,r,i,s,a)})));var k=y.current,N=v.current,I=b.current,C=E.current,D=w.current,F="0px ".concat(m===-1?1:m,"px"),j="".concat(m,"px 0px"),q=cq(["strokeDasharray"],u,c);return M.createElement(Ym,{animationId:A,key:A,canBegin:m>0,duration:u,easing:c,isActive:f,begin:d},R=>{var W=Rn(k,i,R),K=Rn(N,s,R),V=Rn(I,a,R),te=Rn(C,n,R),Y=Rn(D,r,R);g.current&&(y.current=W,v.current=K,b.current=V,E.current=te,w.current=Y);var Z=R>0?{transition:q,strokeDasharray:j}:{strokeDasharray:F};return M.createElement("path",pw({},ts(e),{className:T,d:B6(te,Y,W,K,V),ref:g,style:z6(z6({},Z),e.style)}))})},Dwe=["option","shapeType","propTransformer","activeClassName"];function Owe(t,e){if(t==null)return{};var n,r,i=jwe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function jwe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function 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){Lwe(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 Lwe(t,e,n){return(e=Iwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Iwe(t){var e=Uwe(t,"string");return typeof e=="symbol"?e:e+""}function Uwe(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 Fwe(t,e){return mw(mw({},e),t)}function zwe(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(Rwe,n);case"sector":return M.createElement(xq,n);case"symbols":if(zwe(e))return M.createElement(eD,n);break;case"curve":return M.createElement(tm,n);default:return null}}function Bwe(t){return M.isValidElement(t)?t.props:t}function OO(t){var{option:e,shapeType:n,propTransformer:r=Fwe,activeClassName:i="recharts-active-shape"}=t,s=Owe(t,Dwe),a;if(M.isValidElement(e))a=M.cloneElement(e,mw(mw({},s),Bwe(e)));else if(typeof e=="function")a=e(s,s.index);else if(Twe(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(nye())}},IO=(t,e,n)=>{var r=rr();return(i,s)=>a=>{t?.(i,s,a),r(rye({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function PE(t){var{tooltipEntrySettings:e}=t,n=rr(),r=bi(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n(Qve(e)):i.current!==e&&n(Jve({prev:i.current,next:e})),i.current=e)},[e,n,r]),M.useLayoutEffect(()=>()=>{i.current&&(n(eye(i.current)),i.current=null)},[n]),null}function UO(t){var{legendPayload:e}=t,n=rr(),r=bi(),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 Hwe(t){var{legendPayload:e}=t,n=rr(),r=Tt(gn),i=M.useRef(null);return M.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(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,$we=()=>{var[t]=M.useState(()=>A0("uid-"));return t},Vwe=(aC=Mre.useId)!==null&&aC!==void 0?aC:$we;function HX(t,e){var n=Vwe();return e||(t?"".concat(t,"-").concat(n):n)}var Gwe=M.createContext(void 0),RE=t=>{var{id:e,type:n,children:r}=t,i=HX("recharts-".concat(n),e);return M.createElement(Gwe.Provider,{value:i},r(i))},Wwe={cartesianItems:[],polarItems:[]},$X=Qs({name:"graphicalItems",initialState:Wwe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:fr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Oo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:fr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Oo(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=Oo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:fr()}}}),{addCartesianGraphicalItem:qwe,replaceCartesianGraphicalItem:Kwe,removeCartesianGraphicalItem:Xwe,addPolarGraphicalItem:Ywe,removePolarGraphicalItem:Zwe}=$X.actions,Qwe=$X.reducer,Jwe=t=>{var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(qwe(t)):n.current!==t&&e(Kwe({prev:n.current,next:t})),n.current=t},[e,t]),M.useLayoutEffect(()=>()=>{n.current&&(e(Xwe(n.current)),n.current=null)},[e]),null},FO=M.memo(Jwe);function eSe(t){var e=rr();return M.useLayoutEffect(()=>(e(Ywe(t)),()=>{e(Zwe(t))}),[e,t]),null}var tSe=["key"],nSe=["onMouseEnter","onClick","onMouseLeave"],rSe=["id"],iSe=["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){sSe(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 sSe(t,e,n){return(e=aSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aSe(t){var e=oSe(t,"string");return typeof e=="symbol"?e:e+""}function oSe(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=lSe(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 lSe(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 cSe(t){var e=M.useMemo(()=>RO(t.children,Hb),[t.children]),n=Tt(r=>vwe(r,t.id,e));return n==null?null:M.createElement(Hwe,{legendPayload:n})}var uSe=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})}),dSe=(t,e)=>t>e?"start":t<e?"end":"middle",hSe=(t,e,n)=>ms(typeof e=="function"?e(t):e,n,n*.8),fSe=(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=hSe(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}},pSe=(t,e)=>{var n=ji(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function mSe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var gSe=(t,e)=>{if(M.isValidElement(t))return M.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Sn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=DE(e,tSe);return M.createElement(tm,ud({},i,{type:"linear",className:n}))},xSe=(t,e,n)=>{if(M.isValidElement(t))return M.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),M.isValidElement(r)))return r;var i=Sn("recharts-pie-label-text",mSe(t));return M.createElement(TE,ud({},e,{alignmentBaseline:"middle",className:i}),r)};function bSe(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:dSe(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&&gSe(s,b),xSe(i,v,zn(g,a))))});return M.createElement(wr,{className:"recharts-pie-labels"},f)}function vSe(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(bSe,{sectors:e,props:n,showLabels:r})}function ySe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:a}=t,o=Tt(cd),c=Tt(SO),u=Tt(Hye),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,m=DE(i,nSe),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 w=u==null||u===a,A=String(E)===o&&(c==null||i.dataKey===c)&&w,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"},vb(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 _Se(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=pSe(o,c),x=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=r.filter(k=>zn(k,u,0)!==0).length,b=(x>=360?v:v-1)*y,E=x-v*g-b,w=r.reduce((k,N)=>{var I=zn(N,u,0);return k+(Nt(I)?I:0)},0),A;if(w>0){var T;A=r.map((k,N)=>{var I=zn(k,u,0),C=zn(k,d,N),D=fSe(n,s,k),F=(Nt(I)?I:0)/w,j,q=kr(kr({},k),i&&i[N]&&i[N].props);N?j=T.endAngle+ji(m)*y*(I!==0?1:0):j=o;var R=j+ji(m)*((I!==0?g:0)+F*E),W=(j+R)/2,K=(D.innerRadius+D.outerRadius)/2,V=[{name:C,value:I,payload:q,dataKey:u,type:f}],te=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:te},q),D),{},{value:I,dataKey:u,startAngle:j,endAngle:R,payload:q,paddingAngle:ji(m)*y}),T})}return A}function wSe(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(rwe,{value:e?i:void 0},r)}function SSe(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=Zm(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(wSe,{showLabels:!y,sectors:i},M.createElement(Ym,{animationId:m,begin:a,duration:o,isActive:s,easing:c,onAnimationStart:E,onAnimationEnd:b,key:m},w=>{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=Rn(C.endAngle-C.startAngle,N.endAngle-N.startAngle,w),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=Rn(0,q-R,w),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(ySe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),M.createElement(vSe,{showLabels:!y,sectors:i,props:e}),e.children)}var ESe={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 MSe(t){var{id:e}=t,n=DE(t,rSe),{hide:r,className:i,rootTabIndex:s}=t,a=M.useMemo(()=>RO(t.children,Hb),[t.children]),o=Tt(d=>ywe(d,e,a)),c=M.useRef(null),u=Sn("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(uSe,{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(SSe,{props:kr(kr({},n),{},{sectors:o}),previousSectorsRef:c,id:e})))}function VX(t){var e=Sr(t,ESe),{id:n}=e,r=DE(e,iSe),i=Ns(r);return M.createElement(RE,{id:n,type:"pie"},s=>M.createElement(M.Fragment,null,M.createElement(eSe,{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(cSe,ud({},r,{id:s})),M.createElement(MSe,ud({},r,{id:s}))))}VX.displayName="Pie";var ASe=["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){TSe(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 TSe(t,e,n){return(e=CSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function CSe(t){var e=NSe(t,"string");return typeof e=="symbol"?e:e+""}function NSe(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 kSe(t,e){if(t==null)return{};var n,r,i=PSe(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 PSe(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 RSe(t){var{option:e,dotProps:n,className:r}=t;if(M.isValidElement(e))return M.cloneElement(e,n);if(typeof e=="function")return e(n);var i=Sn(r,typeof e!="boolean"?e.className:""),s=n??{},{points:a}=s,o=kSe(s,ASe);return M.createElement(LX,gw({},o,{className:i}))}function DSe(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(!DSe(e,n))return null;var d=DO(n),f=ude(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(RSe,{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){OSe(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 OSe(t,e,n){return(e=jSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jSe(t){var e=LSe(t,"string");return typeof e=="symbol"?e:e+""}function LSe(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 ISe={xAxis:{},yAxis:{},zAxis:{}},WX=Qs({name:"cartesianAxis",initialState:ISe,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:USe,replaceXAxis:FSe,removeXAxis:zSe,addYAxis:BSe,replaceYAxis:HSe,removeYAxis:$Se,addZAxis:H7e,replaceZAxis:$7e,removeZAxis:V7e,updateYAxisWidth:VSe}=WX.actions,GSe=WX.reducer,WSe=We([xi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),qSe=We([WSe,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=()=>Tt(qSe),KSe=()=>Tt(qye);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){XSe(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 XSe(t,e,n){return(e=YSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YSe(t){var e=ZSe(t,"string");return typeof e=="symbol"?e:e+""}function ZSe(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 QSe=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=Tt(cd),c=KSe();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(QSe,{point:u,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var JSe="Invariant failed";function eEe(t,e){throw new Error(JSe)}var tEe=["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 fx(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){nEe(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 nEe(t,e,n){return(e=rEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rEe(t){var e=iEe(t,"string");return typeof e=="symbol"?e:e+""}function iEe(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 sEe(t,e){if(t==null)return{};var n,r,i=aEe(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 aEe(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 oEe(t,e){var{x:n,y:r}=t,i=sEe(t,tEe),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 fx(fx(fx(fx(fx({},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:oEe,activeClassName:"recharts-active-bar"},t))}var lEe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Nt(e))return e;var s=Nt(r)||dr(r);return s?e(r,i):(s||eEe(),n)}},cEe={},qX=Qs({name:"errorBars",initialState:cEe,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:G7e,replaceErrorBar:W7e,removeErrorBar:q7e}=qX.actions,uEe=qX.reducer,dEe=["children"];function hEe(t,e){if(t==null)return{};var n,r,i=fEe(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 fEe(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 pEe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},mEe=M.createContext(pEe);function KX(t){var{children:e}=t,n=hEe(t,dEe);return M.createElement(mEe.Provider,{value:n},e)}function jE(t,e){var n,r,i=Tt(u=>wl(u,t)),s=Tt(u=>Sl(u,e)),a=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:ki.allowDataOverflow,o=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:Pi.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 gEe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&Bn(t.zIndex)?t.zIndex:e}var cC={exports:{}},uC={};var Y6;function xEe(){if(Y6)return uC;Y6=1;var t=$m();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 w=k}return w=T}if(k=w,n(E,T))return k;var N=f(T);return g!==void 0&&g(k,N)?(E=T,k):(E=T,w=N)}var b=!1,E,w,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 bEe(){return Z6||(Z6=1,cC.exports=xEe()),cC.exports}bEe();function vEe(t){t()}function yEe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){vEe(()=>{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 _Ee(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=yEe())}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 wEe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",SEe=wEe(),EEe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",MEe=EEe(),AEe=()=>SEe||MEe?M.useLayoutEffect:M.useEffect,TEe=AEe();function J6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function CEe(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 NEe=Symbol.for("react-redux-context"),kEe=typeof globalThis<"u"?globalThis:{};function PEe(){if(!M.createContext)return{};const t=kEe[NEe]??=new Map;let e=t.get(M.createContext);return e||(e=M.createContext(null),t.set(M.createContext,e)),e}var REe=PEe();function DEe(t){const{children:e,context:n,serverState:r,store:i}=t,s=M.useMemo(()=>{const c=_Ee(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),a=M.useMemo(()=>i.getState(),[i]);TEe(()=>{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||REe;return M.createElement(o.Provider,{value:s},e)}var OEe=DEe,jEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function LEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function $b(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(jEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!CEe(t[r],e[r]))return!1}else if(!LEe(t[r],e[r]))return!1;return!0}var IEe=["onMouseEnter","onMouseLeave","onClick"],UEe=["value","background","tooltipPosition"],FEe=["id"],zEe=["onMouseEnter","onClick","onMouseLeave"];function Dc(){return Dc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Dc.apply(null,arguments)}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){BEe(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 BEe(t,e,n){return(e=HEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HEe(t){var e=$Ee(t,"string");return typeof e=="symbol"?e:e+""}function $Ee(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=VEe(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 VEe(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=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}]},WEe=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 qEe(t){var e=Tt(cd),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:a,onMouseLeave:o,onClick:c}=s,u=bw(s,IEe),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:gEe(i,Rr.barBackground)},n.map((x,y)=>{var{value:v,background:b,tooltipPosition:E}=x,w=bw(x,UEe);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},w),{},{fill:"#eee"},b),m),vb(u,x,y)),{},{onMouseEnter:A,onMouseLeave:T,onClick:k,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return M.createElement(xw,Dc({key:"background-bar-".concat(y)},N))}))}function KEe(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 XEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:a}=t,o=Tt(cd),c=Tt(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,Dc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:a}))):M.createElement(xw,Dc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:a}))}function YEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return M.createElement(xw,Dc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function ZEe(t){var e,{data:n,props:r}=t,i=(e=Ns(r))!==null&&e!==void 0?e:{},{id:s}=i,a=bw(i,FEe),{shape:o,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,m=bw(r,zEe),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,Dc({key:"rectangle-".concat(b?.x,"-").concat(b?.y,"-").concat(b?.value,"-").concat(E),className:"recharts-bar-rectangle"},vb(m,b,E),{onMouseEnter:x(b,E),onMouseLeave:y(b,E),onClick:v(b,E)}),u?M.createElement(XEe,{shape:o,activeBar:u,baseProps:a,entry:b,index:E,dataKey:c}):M.createElement(YEe,{shape:o,baseProps:a,entry:b,index:E,dataKey:c})))):null}function QEe(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=Zm(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(KEe,{showLabels:y,rects:r},M.createElement(Ym,{animationId:g,begin:a,duration:o,isActive:s,easing:c,onAnimationEnd:v,onAnimationStart:b,key:g},E=>{var w=E===1?r:r?.map((A,T)=>{var k=f&&f[T];if(k)return Es(Es({},A),{},{x:Rn(k.x,A.x,E),y:Rn(k.y,A.y,E),width:Rn(k.width,A.width,E),height:Rn(k.height,A.height,E)});if(i==="horizontal"){var N=Rn(0,A.height,E),I=Rn(A.stackedBarStart,A.y,E);return Es(Es({},A),{},{y:I,height:N})}var C=Rn(0,A.width,E),D=Rn(A.stackedBarStart,A.x,E);return Es(Es({},A),{},{width:C,x:D})});return E>0&&(n.current=w??null),w==null?null:M.createElement(wr,null,M.createElement(ZEe,{props:e,data:w}))}),M.createElement(CE,{label:e.label}),e.children)}function JEe(t){var e=M.useRef(null);return M.createElement(QEe,{previousRectanglesRef:e,props:t})}var XX=0,eMe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:zn(t,e)}};class tMe 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=Sn("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(qEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),M.createElement(JEe,this.props)))}}var nMe={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 rMe(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=bi(),x=RO(t.children,Hb),y=Tt(E=>PMe(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:eMe,errorBarOffset:v},M.createElement(tMe,Dc({},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 iMe(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=Tpe({numericAxis:v}),w=v.scale(E);return f.map((A,T)=>{var k,N,I,C,D,F;d?k=wpe(d[T+y],b):(k=zn(A,n),Array.isArray(k)||(k=[E,k]));var j=lEe(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=Zs(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=ji(D||j)*(Math.abs(j)-Math.abs(D));I-=V,D+=V}}else{var[te,Y]=[a.scale(k[0]),a.scale(k[1])];if(N=te,I=xz({axis:o,ticks:u,bandSize:s,offset:i.offset,entry:A,index:T}),C=Y-te,D=i.size,F={x:g.left,y:I,width:g.width,height:D},Math.abs(j)>0&&Math.abs(C)<Math.abs(j)){var Z=ji(C||j)*(Math.abs(j)-Math.abs(C));C+=Z}}if(N==null||I==null||C==null||D==null)return null;var U=Es(Es({},A),{},{stackedBarStart:w,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 sMe(t){var e=Sr(t,nMe),n=bi();return M.createElement(RE,{id:e.id,type:"bar"},r=>M.createElement(M.Fragment,null,M.createElement(UO,{legendPayload:GEe(e)}),M.createElement(WEe,{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(rMe,Dc({},e,{id:r})))))}var YX=M.memo(sMe,$b);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 Py(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){aMe(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 aMe(t,e,n){return(e=oMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oMe(t){var e=lMe(t,"string");return typeof e=="symbol"?e:e+""}function lMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var cMe=(t,e)=>e,uMe=(t,e,n)=>n,dMe=(t,e,n,r)=>r,hMe=(t,e,n,r,i)=>i,Vb=We([Ob,hMe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),fMe=We([Vb],t=>t?.maxBarSize),pMe=(t,e,n,r,i,s)=>s,n8=(t,e,n)=>{var r=n??t;if(!dr(r))return ms(r,e,0)},mMe=We([gn,Ob,cMe,uMe,dMe],(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")),gMe=(t,e,n,r)=>{var i=gn(t);return i==="horizontal"?F0(t,"yAxis",n,r):F0(t,"xAxis",e,r)},xMe=(t,e,n)=>{var r=gn(t);return r==="horizontal"?YB(t,"xAxis",e):YB(t,"yAxis",n)},bMe=(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]},vMe=We([mMe,Vbe,xMe],bMe),yMe=(t,e,n,r,i)=>{var s,a,o=Vb(t,e,n,r,i);if(o!=null){var c=gn(t),u=fK(t),{maxBarSize:d}=o,f=dr(d)?u:d,g,m;return c==="horizontal"?(g=pl(t,"xAxis",e,r),m=fl(t,"xAxis",e,r)):(g=pl(t,"yAxis",n,r),m=fl(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=gn(t),s,a;return i==="horizontal"?(s=pl(t,"xAxis",e,r),a=fl(t,"xAxis",e,r)):(s=pl(t,"yAxis",n,r),a=fl(t,"yAxis",n,r)),ad(s,a)};function _Me(t,e,n,r,i){var s=r.length;if(!(s<1)){var a=ms(t,n,0,!0),o,c=[];if(Bn(r[0].barSize)){var u=!1,d=n/s,f=r.reduce((b,E)=>b+(E.barSize||0),0);f+=(s-1)*a,f>=n&&(f-=(s-1)*a,a=0),f>=n&&d>0&&(u=!0,d*=.9,f=s*d);var g=(n-f)/2>>0,m={offset:g-a,size:0};o=r.reduce((b,E)=>{var w,A={stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:m.offset+m.size+a,size:u?d:(w=E.barSize)!==null&&w!==void 0?w: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=Bn(i)?Math.min(y,i):y;o=r.reduce((b,E,w)=>[...b,{stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:x+(y+a)*w+(y-v)/2,size:v}}],c)}return o}}var wMe=(t,e,n,r,i,s,a)=>{var o=dr(a)?e:a,c=_Me(n,r,i!==s?i:s,t,o);return i!==s&&c!=null&&(c=c.map(u=>Py(Py({},u),{},{position:Py(Py({},u.position),{},{offset:u.position.offset-i/2})}))),c},SMe=We([vMe,fK,$be,pK,yMe,ZX,fMe],wMe),EMe=(t,e,n,r)=>pl(t,"xAxis",e,r),MMe=(t,e,n,r)=>pl(t,"yAxis",n,r),AMe=(t,e,n,r)=>fl(t,"xAxis",e,r),TMe=(t,e,n,r)=>fl(t,"yAxis",n,r),CMe=We([SMe,Vb],(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}}),NMe=(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)}}}},kMe=We([gMe,Vb],NMe),PMe=We([xi,hD,EMe,MMe,AMe,TMe,CMe,gn,kb,ZX,kMe,Vb,pMe],(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 iMe({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=bi();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=Qs({name:"brush",initialState:r8,reducers:{setBrushSettings(t,e){return e.payload==null?r8:e.payload}}}),{setBrushSettings:K7e}=JX.actions,RMe=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 Ry(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=DMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DMe(t){var e=OMe(t,"string");return typeof e=="symbol"?e:e+""}function OMe(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 jMe=(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)}},LMe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return jMe({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 IMe=t=>{var e=Object.keys(t).reduce((n,r)=>Ry(Ry({},n),{},{[r]:LE.create(t[r])}),{});return Ry(Ry({},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 UMe(t){return(t%180+180)%180}var FMe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=UMe(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)},zMe={dots:[],areas:[],lines:[]},tY=Qs({name:"referenceElements",initialState:zMe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Oo(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=Oo(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=Oo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:X7e,removeDot:Y7e,addArea:Z7e,removeArea:Q7e,addLine:BMe,removeLine:HMe}=tY.actions,$Me=tY.reducer,nY=M.createContext(void 0),VMe=t=>{var{children:e}=t,[n]=M.useState("".concat(A0("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)},GMe=()=>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){WMe(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 WMe(t,e,n){return(e=qMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qMe(t){var e=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 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 XMe=(t,e)=>{var n;if(M.isValidElement(t))n=M.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!Bn(e.x1)||!Bn(e.y1)||!Bn(e.x2)||!Bn(e.y2))return null;n=M.createElement("line",vw({},e,{className:"recharts-reference-line-line"}))}return n},YMe=(t,e,n,r,i,s)=>{var{x:a,width:o}=s,c=i.y.apply(t,{position:n});if(Zs(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},ZMe=(t,e,n,r,i,s)=>{var{y:a,height:o}=s,c=i.x.apply(t,{position:n});if(Zs(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},QMe=(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},JMe=(t,e,n,r,i,s)=>{var{x:a,y:o,segment:c,ifOverflow:u}=s,d=oo(a),f=oo(o);return f?YMe(o,u,n,i,t,e):d?ZMe(a,u,n,r,t,e):c!=null&&c.length===2?QMe(c,u,n,t):null};function e2e(t){var e=rr();return M.useEffect(()=>(e(BMe(t)),()=>{e(HMe(t))})),null}function t2e(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:s}=t,a=bi(),o=GMe(),c=Tt(k=>wl(k,e)),u=Tt(k=>Sl(k,n)),d=Tt(k=>ld(k,"xAxis",e,a)),f=Tt(k=>ld(k,"yAxis",n,a)),g=Eb();if(!o||!g||c==null||u==null||d==null||f==null)return null;var m=IMe({x:d,y:f}),x=JMe(m,g,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:y,y:v},{x:b,y:E}]=x,w=s==="hidden"?"url(#".concat(o,")"):void 0,A=a8(a8({clipPath:w},ts(t)),{},{x1:y,y1:v,x2:b,y2:E}),T=LMe({x1:y,y1:v,x2:b,y2:E});return M.createElement(gs,{zIndex:t.zIndex},M.createElement(wr,{className:Sn("recharts-reference-line",i)},XMe(r,A),M.createElement(PX,vw({},T,{lowerWidth:T.width,upperWidth:T.width}),M.createElement(DX,{label:t.label}),t.children)))}var n2e={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Rr.line};function Ox(t){var e=Sr(t,n2e);return M.createElement(M.Fragment,null,M.createElement(e2e,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),M.createElement(t2e,e))}Ox.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 r2e(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return FMe(r,n)}function i2e(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 s2e(t,e){return rY(t,e+1)}function a2e(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,w=c===0||yw(t,E,b,d,o);w||(c=0,d=a,u+=1),w&&(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 us(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){o2e(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 o2e(t,e,n){return(e=l2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l2e(t){var e=c2e(t,"string");return typeof e=="symbol"?e:e+""}function c2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function u2e(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=us(us({},m),{},{tickCoord:v>0?m.coordinate-v*t:m.coordinate})}else s[g]=m=us(us({},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]=us(us({},m),{},{isShow:!0}))}},d=a-1;d>=0;d--)u(d);return s}function d2e(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=us(us({},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]=us(us({},d),{},{isShow:!0}))}}for(var x=s?o-1:o,y=function(E){var w=a[E],A,T=()=>(A===void 0&&(A=n(w,E)),A);if(E===0){var k=t*(w.coordinate-t*T()/2-c);a[E]=w=us(us({},w),{},{tickCoord:k<0?w.coordinate-k*t:w.coordinate})}else a[E]=w=us(us({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var N=yw(t,w.tickCoord,T,c,u);N&&(c=w.tickCoord+t*(T()/2+i),a[E]=us(us({},w),{},{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(Nt(c)||Xm.isSsr){var g;return(g=s2e(i,Nt(c)?c:0))!==null&&g!==void 0?g:[]}var m=[],x=o==="top"||o==="bottom"?"width":"height",y=d&&x==="width"?Wx(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},v=(w,A)=>{var T=typeof u=="function"?u(w.value,A):w.value;return x==="width"?r2e(Wx(T,{fontSize:e,letterSpacing:n}),y,f):Wx(T,{fontSize:e,letterSpacing:n})[x]},b=i.length>=2?ji(i[1].coordinate-i[0].coordinate):1,E=i2e(s,b,x);return c==="equidistantPreserveStart"?a2e(b,E,v,i,a):(c==="preserveStart"||c==="preserveStartEnd"?m=d2e(b,E,v,i,a,c==="preserveStartEnd"):m=u2e(b,E,v,i,a),m.filter(w=>w.isShow))}var h2e=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},f2e=["axisLine","width","height","className","hide","ticks","axisType"];function p2e(t,e){if(t==null)return{};var n,r,i=m2e(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 m2e(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){g2e(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 g2e(t,e,n){return(e=x2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x2e(t){var e=b2e(t,"string");return typeof e=="symbol"?e:e+""}function b2e(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 yc={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 v2e(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:Sn("recharts-cartesian-axis-line",Wh(o,"className"))}))}function y2e(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=Nt(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":u=d=t.coordinate,g=n+ +!o*i,f=g-y*v,x=f-y*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 _2e(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function w2e(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function S2e(t){var{option:e,tickProps:n,value:r}=t,i,s=Sn(n.className,"recharts-cartesian-axis-tick-value");if(M.isValidElement(e))i=M.cloneElement(e,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=Sn(a,e?.className)),i=M.createElement(TE,Yh({},n,{className:a}),r)}return i}var E2e=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:w,getTicksConfig:A,events:T,axisType:k}=t,N=BO(Xr(Xr({},A),{},{ticks:n}),E,w),I=_2e(d,f),C=w2e(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},y2e(V,g,m,x,y,d,v,f,b))),W=R.map(V=>{var{entry:te,line:Y}=V;return M.createElement(wr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(te.value,"-").concat(te.coordinate,"-").concat(te.tickCoord)},i&&M.createElement("line",Yh({},q,Y,{className:Sn("recharts-cartesian-axis-tick-line",Wh(i,"className"))})))}),K=R.map((V,te)=>{var{entry:Y,tick:Z}=V,U=Xr(Xr(Xr(Xr({textAnchor:I,verticalAnchor:C},D),{},{stroke:"none",fill:s},F),Z),{},{index:te,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)},vb(T,Y,te)),r&&M.createElement(S2e,{option:r,tickProps:U,value:"".concat(typeof a=="function"?a(Y.value,te):Y.value).concat(o||"")}))});return M.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},K.length>0&&M.createElement(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))}),M2e=M.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:a,ticks:o,axisType:c}=t,u=p2e(t,f2e),[d,f]=M.useState(""),[g,m]=M.useState(""),x=M.useRef(null);M.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return h2e({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 w=window.getComputedStyle(E),A=w.fontSize,T=w.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:Sn("recharts-cartesian-axis",s)},M.createElement(v2e,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ns(t)}),M.createElement(E2e,{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,yc);return M.createElement(M2e,Yh({},n,{ref:e}))});HO.displayName="CartesianAxis";var A2e=["x1","y1","x2","y2","key"],T2e=["offset"],C2e=["xAxisId","yAxisId"],N2e=["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 hs(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){k2e(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 k2e(t,e,n){return(e=P2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function P2e(t){var e=R2e(t,"string");return typeof e=="symbol"?e:e+""}function R2e(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=D2e(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 D2e(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 O2e=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,A2e),f=(i=Ns(d))!==null&&i!==void 0?i:{},{offset:g}=f,m=_w(f,T2e);r=M.createElement("line",mh({},m,{x1:s,y1:a,x2:o,y2:c,fill:"none",key:u}))}return r}function j2e(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,C2e),c=i.map((u,d)=>{var f=hs(hs({},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 L2e(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,N2e),c=i.map((u,d)=>{var f=hs(hs({},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 I2e(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 U2e(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 F2e=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return BW(BO(hs(hs(hs({},yc),n),{},{ticks:HW(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},z2e=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return BW(BO(hs(hs(hs({},yc),n),{},{ticks:HW(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},B2e={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=hs(hs({},Sr(t,B2e)),{},{x:Nt(t.x)?t.x:r.left,y:Nt(t.y)?t.y:r.top,width:Nt(t.width)?t.width:r.width,height:Nt(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:a,x:o,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:m}=i,x=bi(),y=Tt(C=>ZB(C,"xAxis",s,x)),v=Tt(C=>ZB(C,"yAxis",a,x));if(!dl(u)||!dl(d)||!Nt(o)||!Nt(c))return null;var b=i.verticalCoordinatesGenerator||F2e,E=i.horizontalCoordinatesGenerator||z2e,{horizontalPoints:w,verticalPoints:A}=i;if((!w||!w.length)&&typeof E=="function"){var T=g&&g.length,k=E({yAxis:v?hs(hs({},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)&&(w=k)}if((!A||!A.length)&&typeof b=="function"){var N=m&&m.length,I=b({xAxis:y?hs(hs({},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(O2e,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),M.createElement(I2e,mh({},i,{horizontalPoints:w})),M.createElement(U2e,mh({},i,{verticalPoints:A})),M.createElement(j2e,mh({},i,{offset:r,horizontalPoints:w,xAxis:y,yAxis:v})),M.createElement(L2e,mh({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:v}))))}ww.displayName="CartesianGrid";var sY=(t,e,n,r)=>pl(t,"xAxis",e,r),aY=(t,e,n,r)=>fl(t,"xAxis",e,r),oY=(t,e,n,r)=>pl(t,"yAxis",n,r),lY=(t,e,n,r)=>fl(t,"yAxis",n,r),H2e=We([gn,sY,oY,aY,lY],(t,e,n,r,i)=>_l(t,"xAxis")?ad(e,r,!1):ad(n,i,!1)),$2e=(t,e,n,r,i)=>i;function V2e(t){return t.type==="line"}var G2e=We([Ob,$2e],(t,e)=>t.filter(V2e).find(n=>n.id===e)),W2e=We([gn,sY,oY,aY,lY,G2e,H2e,kb],(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 hAe({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 q2e=["id"],K2e=["type","layout","connectNulls","needClip","shape"],X2e=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function B0(){return B0=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},B0.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 el(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){Y2e(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 Y2e(t,e,n){return(e=Z2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z2e(t){var e=Q2e(t,"string");return typeof e=="symbol"?e:e+""}function Q2e(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=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 eAe=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}]},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:r,unit:c}};return M.createElement(PE,{tooltipEntrySettings:d})}),uY=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function nAe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var rAe=(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[...nAe(n,i),...o,...d].map(f=>"".concat(f,"px")).join(", ")};function iAe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:s,needClip:a}=r,{id:o}=r,c=$O(r,q2e),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 sAe(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 el(el({},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,K2e),g=el(el({},ts(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,B0({shapeType:"curve",option:d},g,{pathRef:n})),M.createElement(iAe,{points:r,clipPathId:e,props:s}))}function aAe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function oAe(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=Zm(a,"recharts-line-"),w=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=aAe(r.current),D=M.useRef(0);w.current!==E&&(D.current=s.current,w.current=E);var F=D.current;return M.createElement(sAe,{points:a,showLabels:k},n.children,M.createElement(Ym,{animationId:E,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:N,onAnimationStart:I,key:E},j=>{var q=Rn(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=rAe(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,te=j===1?a:a.map((Y,Z)=>{var U=Math.floor(Z*V);if(b[U]){var z=b[U];return el(el({},Y),{},{x:Rn(z.x,Y.x,j),y:Rn(z.y,Y.y,j)})}return g?el(el({},Y),{},{x:Rn(m*2,Y.x,j),y:Rn(x/2,Y.y,j)}):el(el({},Y),{},{x:Y.x,y:Y.y})});return i.current=te,M.createElement(d8,{props:n,points:te,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 lAe(t){var{clipPathId:e,props:n}=t,r=M.useRef(null),i=M.useRef(0),s=M.useRef(null);return M.createElement(oAe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:s})}var cAe=(t,e)=>{var n,r;return{x:(n=t.x)!==null&&n!==void 0?n:void 0,y:(r=t.y)!==null&&r!==void 0?r:void 0,value:t.value,errorVal:zn(t.payload,e)}};class uAe 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=Sn("recharts-line",i),y=f,{r:v,strokeWidth:b}=cY(n),E=DO(n),w=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-w/2,y:o-w/2,width:u+w,height:d+w}))),M.createElement(KX,{xAxisId:s,yAxisId:a,data:r,dataPointFormatter:cAe,errorBarOffset:0},M.createElement(lAe,{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 dAe(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,X2e),{needClip:b}=jE(m,x),E=OE(),w=hf(),A=bi(),T=Tt(D=>W2e(D,m,x,A,y));if(w!=="horizontal"&&w!=="vertical"||T==null||E==null)return null;var{height:k,width:N,x:I,y:C}=E;return M.createElement(uAe,B0({},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:w,height:k,width:N,left:I,top:C,needClip:b}))}function hAe(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=zn(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 fAe(t){var e=Sr(t,dY),n=bi();return M.createElement(RE,{id:e.id,type:"line"},r=>M.createElement(M.Fragment,null,M.createElement(UO,{legendPayload:eAe(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:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),M.createElement(dAe,B0({},e,{id:r}))))}var hY=M.memo(fAe,$b);hY.displayName="Line";var fY=(t,e,n,r)=>pl(t,"xAxis",e,r),pY=(t,e,n,r)=>fl(t,"xAxis",e,r),mY=(t,e,n,r)=>pl(t,"yAxis",n,r),gY=(t,e,n,r)=>fl(t,"yAxis",n,r),pAe=We([gn,fY,mY,pY,gY],(t,e,n,r,i)=>_l(t,"xAxis")?ad(e,r,!1):ad(n,i,!1)),mAe=(t,e,n,r,i)=>i,xY=We([Ob,mAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),gAe=(t,e,n,r,i)=>{var s,a=xY(t,e,n,r,i);if(a!=null){var o=gn(t),c=_l(o,"xAxis"),u;if(c?u=F0(t,"yAxis",n,r):u=F0(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)}}}},xAe=We([gn,fY,mY,pY,gY,gAe,kb,pAe,xY,Gbe],(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 LAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:s,displayedData:x,chartBaseValue:u,bandSize:o})}}),bAe=["id"],vAe=["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=yAe(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 yAe(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){_Ae(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 _Ae(t,e,n){return(e=wAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wAe(t){var e=SAe(t,"string");return typeof e=="symbol"?e:e+""}function SAe(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 EAe=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}]},MAe=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 AAe(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 TAe(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,bAe),m=Ns(g),x=ts(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(AAe,{points:e,props:g,clipPathId:i}))}function CAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,a=r[r.length-1].y;if(!Bn(s)||!Bn(a))return null;var o=e*Math.abs(s-a),c=Math.max(...r.map(u=>u.x||0));return Nt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Nt(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 NAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,a=r[r.length-1].x;if(!Bn(s)||!Bn(a))return null;var o=e*Math.abs(s-a),c=Math.max(...r.map(u=>u.y||0));return Nt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Nt(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 kAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?M.createElement(CAe,{alpha:e,points:r,baseLine:i,strokeWidth:s}):M.createElement(NAe,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function PAe(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=Zm(x,"recharts-area-"),v=cme(),[b,E]=M.useState(!1),w=!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(TAe,{showLabels:w,points:a},r.children,M.createElement(Ym,{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:Rn(W.x,j.x,I),y:Rn(W.y,j.y,I)})}return j}),F;return Nt(o)?F=Rn(N,o,I):dr(o)||Zs(o)?F=Rn(N,0,I):F=o.map((j,q)=>{var R=Math.floor(q*C);if(Array.isArray(N)&&N[R]){var W=N[R];return qp(qp({},j),{},{x:Rn(W.x,j.x,I),y:Rn(W.y,j.y,I)})}return j}),I>0&&(i.current=D,s.current=F),M.createElement(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(kAe,{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 RAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=M.useRef(null),s=M.useRef();return M.createElement(PAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class DAe 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=Sn("recharts-area",i),v=g,{r:b,strokeWidth:E}=cY(n),w=DO(n),A=b*2+E,T=o?"url(#clipPath-".concat(w?"":"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}),!w&&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(RAe,{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 OAe(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,vAe),E=hf(),w=pX(),{needClip:A}=jE(y,v),T=bi(),{points:k,isRange:N,baseLine:I}=(e=Tt(R=>xAe(R,y,v,T,t.id)))!==null&&e!==void 0?e:{},C=OE();if(E!=="horizontal"&&E!=="vertical"||C==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:D,width:F,x:j,y:q}=C;return!k||!k.length?null:M.createElement(DAe,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"?!Xm.isSsr:g,isRange:N,legendType:m,needClip:A,points:k,stroke:x,width:F,left:j,top:q,xAxisId:y,yAxisId:v}))}var jAe=(t,e,n,r,i)=>{var s=n??e;if(Nt(s))return s;var a=t==="horizontal"?i:r,o=a.scale.domain();if(a.type==="number"){var 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 LAe(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=jAe(s,a,n,o,c),v=s==="horizontal",b=!1,E=u.map((A,T)=>{var k;x?k=i[d+T]:(k=zn(A,r),Array.isArray(k)?b=!0:k=[y,k]);var N=k[1]==null||x&&!e&&zn(A,r)==null;return v?{x: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}}),w;return x||b?w=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}}):w=v?c.scale(y):o.scale(y),{points:E,baseLine:w,isRange:b}}function IAe(t){var e=Sr(t,vY),n=bi();return M.createElement(RE,{id:e.id,type:"area"},r=>M.createElement(M.Fragment,null,M.createElement(UO,{legendPayload:EAe(e)}),M.createElement(MAe,{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(OAe,Ch({},e,{id:r}))))}var yY=M.memo(IAe,$b);yY.displayName="Area";var UAe=["domain","range"],FAe=["domain","range"];function p8(t,e){if(t==null)return{};var n,r,i=zAe(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 zAe(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,UAe),{domain:s,range:a}=e,o=p8(e,FAe);return!m8(n,s)||!m8(r,a)?!1:$b(i,o)}var BAe=["dangerouslySetInnerHTML","ticks"],HAe=["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=$Ae(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 $Ae(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 VAe(t){var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(USe(t)):n.current!==t&&e(FSe({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(zSe(n.current)),n.current=null)},[e]),null}var GAe=t=>{var{xAxisId:e,className:n}=t,r=Tt(hD),i=bi(),s="xAxis",a=Tt(v=>ld(v,s,e,i)),o=Tt(v=>WK(v,s,e,i)),c=Tt(v=>HK(v,e)),u=Tt(v=>Hve(v,e)),d=Tt(v=>SK(v,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,m=g8(t,BAe),{id:x}=d,y=g8(d,HAe);return M.createElement(HO,kk({},m,y,{scale:a,x:u.x,y:u.y,width:c.width,height:c.height,className:Sn("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:o,axisType:s}))},WAe={allowDataOverflow:ki.allowDataOverflow,allowDecimals:ki.allowDecimals,allowDuplicatedCategory:ki.allowDuplicatedCategory,angle:ki.angle,axisLine:yc.axisLine,height:ki.height,hide:!1,includeHidden:ki.includeHidden,interval:ki.interval,minTickGap:ki.minTickGap,mirror:ki.mirror,orientation:ki.orientation,padding:ki.padding,reversed:ki.reversed,scale:ki.scale,tick:ki.tick,tickCount:ki.tickCount,tickLine:yc.tickLine,tickSize:yc.tickSize,type:ki.type,xAxisId:0},qAe=t=>{var e=Sr(t,WAe);return M.createElement(M.Fragment,null,M.createElement(VAe,{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(GAe,e))},Ew=M.memo(qAe,_Y);Ew.displayName="XAxis";var KAe=["dangerouslySetInnerHTML","ticks"],XAe=["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=YAe(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 YAe(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 ZAe(t){var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(BSe(t)):n.current!==t&&e(HSe({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e($Se(n.current)),n.current=null)},[e]),null}var QAe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=M.useRef(null),a=M.useRef(null),o=Tt(hD),c=bi(),u=rr(),d="yAxis",f=Tt(T=>ld(T,d,e,c)),g=Tt(T=>$K(T,e)),m=Tt(T=>Vve(T,e)),x=Tt(T=>WK(T,d,e,c)),y=Tt(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(VSe({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,KAe),{id:w}=y,A=x8(y,XAe);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:Sn("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:x,axisType:d}))},JAe={allowDataOverflow:Pi.allowDataOverflow,allowDecimals:Pi.allowDecimals,allowDuplicatedCategory:Pi.allowDuplicatedCategory,angle:Pi.angle,axisLine:yc.axisLine,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:yc.tickLine,tickSize:yc.tickSize,type:Pi.type,width:Pi.width,yAxisId:0},eTe=t=>{var e=Sr(t,JAe);return M.createElement(M.Fragment,null,M.createElement(ZAe,{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(QAe,e))},Mw=M.memo(eTe,_Y);Mw.displayName="YAxis";var tTe=(t,e)=>e,VO=We([tTe,gn,_K,yi,lX,zc,s_e,xi],h_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=lo("mouseClick"),SY=wb();SY.startListening({actionCreator:wY,effect:(t,e)=>{var n=t.payload,r=VO(e.getState(),GO(n));r?.activeIndex!=null&&e.dispatch(iye({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var Rk=lo("mouseMove"),EY=wb(),Dy=null;EY.startListening({actionCreator:Rk,effect:(t,e)=>{var n=t.payload;Dy!==null&&cancelAnimationFrame(Dy);var r=GO(n);Dy=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())}Dy=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=Qs({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}}}),nTe=MY.reducer,{updateOptions:rTe}=MY.actions,AY=Qs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:iTe}=AY.actions,sTe=AY.reducer,TY=lo("keyDown"),CY=lo("focus"),WO=wb();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,sg(n),Lb(n),zb(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=Kve(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 za=lo("externalEvent"),NY=wb(),dC=new Map;NY.startListening({actionCreator:za,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:Vye(o),activeDataKey:SO(o),activeIndex:cd(o),activeLabel:dX(o),activeTooltipIndex:cd(o),isTooltipActive:Gye(o)};n(c,r)}finally{dC.delete(i)}});dC.set(i,a)}}});var aTe=We([ig],t=>t.tooltipItemPayloads),oTe=We([aTe,Ub,(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=lo("touchMove"),PY=wb();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=oTe(e.getState(),u,d);e.dispatch(QK({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var lTe=hW({brush:RMe,cartesianAxis:GSe,chartData:$_e,errorBars:uEe,graphicalItems:Qwe,layout:gpe,legend:Eme,options:U_e,polarAxis:fwe,polarOptions:sTe,referenceElements:$Me,rootProps:nTe,tooltip:sye,zIndex:A_e}),cTe=function(e){return Bfe({reducer:lTe,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:Xm.devToolsEnabled})};function RY(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=bi(),s=M.useRef(null);if(i)return n;s.current==null&&(s.current=cTe(e));var a=rD;return M.createElement(OEe,{context:a,store:s.current},n)}function uTe(t){var{layout:e,margin:n}=t,r=rr(),i=bi();return M.useEffect(()=>{i||(r(fpe(e)),r(hpe(n)))},[r,i,e,n]),null}var DY=M.memo(uTe,$b);function OY(t){var e=rr();return M.useEffect(()=>{e(rTe(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(E_e({zIndex:e,elementId:i,isPanorama:n})),()=>{s(M_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=Tt(p_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 dTe=["children"];function hTe(t,e){if(t==null)return{};var n,r,i=fTe(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 fTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function 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 pTe={width:"100%",height:"100%",display:"block"},mTe=M.forwardRef((t,e)=>{var n=pD(),r=mD(),i=lq();if(!dl(n)||!dl(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:pTe,ref:e}),s)}),gTe=t=>{var{children:e}=t,n=Tt(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=hTe(t,dTe),i=bi();return i?M.createElement(gTe,null,M.createElement(y8,{isPanorama:!0},n)):M.createElement(mTe,Aw({ref:e},r),M.createElement(y8,{isPanorama:!1},n))});function xTe(){var t=rr(),[e,n]=M.useState(null),r=Tt(Dpe);return M.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;Bn(s)&&s!==r&&t(mpe(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 bTe(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){vTe(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 vTe(t,e,n){return(e=yTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yTe(t){var e=_Te(t,"string");return typeof e=="symbol"?e:e+""}function _Te(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 wTe=()=>(Q_e(),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 STe=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)))}),ETe=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)))}),MTe=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)))}),ATe=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return Tc(n)||Tc(r)?M.createElement(ETe,Zh({},t,{ref:e})):M.createElement(MTe,Zh({},t,{ref:e}))});function TTe(t){return t===!0?STe:ATe}var CTe=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:w=!0}=t,A=M.useRef(null),T=rr(),[k,N]=M.useState(null),[I,C]=M.useState(null),D=xTe(),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(za({handler:s,reactEvent:re}))},[T,s]),K=M.useCallback(re=>{T(Rk(re)),T(za({handler:u,reactEvent:re}))},[T,u]),V=M.useCallback(re=>{T(JK()),T(za({handler:d,reactEvent:re}))},[T,d]),te=M.useCallback(re=>{T(Rk(re)),T(za({handler:f,reactEvent:re}))},[T,f]),Y=M.useCallback(()=>{T(CY())},[T]),Z=M.useCallback(re=>{T(TY(re.key))},[T]),U=M.useCallback(re=>{T(za({handler:a,reactEvent:re}))},[T,a]),z=M.useCallback(re=>{T(za({handler:o,reactEvent:re}))},[T,o]),ee=M.useCallback(re=>{T(za({handler:c,reactEvent:re}))},[T,c]),ae=M.useCallback(re=>{T(za({handler:g,reactEvent:re}))},[T,g]),fe=M.useCallback(re=>{T(za({handler:y,reactEvent:re}))},[T,y]),de=M.useCallback(re=>{w&&T(kY(re)),T(za({handler:x,reactEvent:re}))},[T,w,x]),xe=M.useCallback(re=>{T(za({handler:m,reactEvent:re}))},[T,m]),ye=TTe(E);return M.createElement(vX.Provider,{value:k},M.createElement(T7.Provider,{value:I},M.createElement(ye,{width:j??v?.width,height:q??v?.height,className:Sn("recharts-wrapper",r),style:bTe({position:"relative",cursor:"default",width:j,height:q},v),onClick:W,onContextMenu:U,onDoubleClick:z,onFocus:Y,onKeyDown:Z,onMouseDown:ee,onMouseEnter:K,onMouseLeave:V,onMouseMove:te,onMouseUp:ae,onTouchEnd:xe,onTouchMove:de,onTouchStart:fe,ref:R},M.createElement(wTe,null),n)))}),NTe=["width","height","responsive","children","className","style","compact","title","desc"];function kTe(t,e){if(t==null)return{};var n,r,i=PTe(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 PTe(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=kTe(t,NTe),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(CTe,{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(VMe,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 RTe={top:5,right:5,bottom:5,left:5},DTe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:RTe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},qO=M.forwardRef(function(e,n){var r,i=Sr(e.categoricalChartProps,DTe),{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})))}),OTe=["axis"],jTe=M.forwardRef((t,e)=>M.createElement(qO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:OTe,tooltipPayloadSearcher:AE,categoricalChartProps:t,ref:e})),LTe=["axis","item"],ITe=M.forwardRef((t,e)=>M.createElement(qO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:LTe,tooltipPayloadSearcher:AE,categoricalChartProps:t,ref:e}));function UTe(t){var e=rr();return M.useEffect(()=>{e(iTe(t))},[e,t]),null}var FTe=["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 zTe(t,e){if(t==null)return{};var n,r,i=BTe(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 BTe(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 HTe={top:5,right:5,bottom:5,left:5},LY={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:HTe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},$Te=M.forwardRef(function(e,n){var r,i=Sr(e.categoricalChartProps,LY),{layout:s}=i,a=zTe(i,FTe),{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(UTe,{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){VTe(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 VTe(t,e,n){return(e=GTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GTe(t){var e=WTe(t,"string");return typeof e=="symbol"?e:e+""}function WTe(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 qTe=["item"],KTe=E8(E8({},LY),{},{layout:"centric",startAngle:0,endAngle:360}),XTe=M.forwardRef((t,e)=>{var n=Sr(t,KTe);return M.createElement($Te,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:qTe,tooltipPayloadSearcher:AE,categoricalChartProps:n,ref:e})}),YTe=["axis"],ZTe=M.forwardRef((t,e)=>M.createElement(qO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:YTe,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 QTe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:s,initialMode:a="humidity",thresholds:o}){const{t:c}=Vm(),{theme:u}=gb(),[d,f]=M.useState("24h"),[g,m]=M.useState(a),x=u==="dark";M.useEffect(()=>{if(!t)return;const z=ee=>{ee.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[t,e]);const y=M8.find(z=>z.value===d)?.hours||24,{data:v,isLoading:b,error:E}=vt({queryKey:["ams-history",n,i,y],queryFn:()=>ke.getAMSHistory(n,i,y),enabled:t,refetchInterval:6e4});if(!t)return null;const w=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=w[w.length-1],C=I?.humidity,D=I?.temperature,F=z=>{const ee=z.filter(re=>re!=null);if(ee.length<4)return"stable";const ae=ee.slice(0,Math.floor(ee.length/4)),fe=ee.slice(-Math.floor(ee.length/4)),de=ae.reduce((re,ve)=>re+ve,0)/ae.length,ye=fe.reduce((re,ve)=>re+ve,0)/fe.length-de;return Math.abs(ye)<2?"stable":ye>0?"up":"down"},j=F(w.map(z=>z.humidity)),q=F(w.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",te=x?"#1d1d1d":"#f3f4f6",Y=x?"#3d3d3d":"#e5e7eb",Z=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:Z},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(Gt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:te},children:[l.jsxs("button",{onClick:()=>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:te},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:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.current","Current")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-2xl font-bold",style:{color:W(C)},children:C!=null?`${C}%`:"—"}),l.jsx(R,{trend:j})]})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.average","Average")}),l.jsx("p",{className:"text-2xl font-bold",style:{color:Z},children:v?.avg_humidity!=null?`${v.avg_humidity}%`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.min","Min")}),l.jsx("p",{className:"text-2xl font-bold text-green-500",children:v?.min_humidity!=null?`${v.min_humidity}%`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.max","Max")}),l.jsx("p",{className:"text-2xl font-bold text-red-500",children:v?.max_humidity!=null?`${v.max_humidity}%`:"—"})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.current","Current")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-2xl font-bold",style:{color:K(D)},children:D!=null?`${D}°C`:"—"}),l.jsx(R,{trend:q})]})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.average","Average")}),l.jsx("p",{className:"text-2xl font-bold",style:{color:Z},children:v?.avg_temperature!=null?`${v.avg_temperature}°C`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.min","Min")}),l.jsx("p",{className:"text-2xl font-bold text-blue-500",children:v?.min_temperature!=null?`${v.min_temperature}°C`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.max","Max")}),l.jsx("p",{className:"text-2xl font-bold text-red-500",children:v?.max_temperature!=null?`${v.max_temperature}°C`:"—"})]})]})}),l.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:b?l.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:c("common.loading","Loading...")}):E?l.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):w.length===0?l.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:c("common.noData","No data available for this time range")}):l.jsx(t1,{width:"100%",height:300,children:l.jsxs(jTe,{data:w,children:[l.jsx(ww,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),l.jsx(Ew,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:z=>{const ee=new Date(z);return y>24?ee.toLocaleDateString([],{day:"numeric",month:"short"}):ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),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(r1,{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(Ox,{y:A,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),l.jsx(Ox,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):l.jsxs(l.Fragment,{children:[l.jsx(Ox,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),l.jsx(Ox,{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 JTe({side:t}){const{theme:e}=gb(),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 eCe({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 tCe({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 nCe({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 rCe({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 iCe({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 sCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("rect",{x:"4.5",y:"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 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("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 oCe({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=nCe:u=rCe,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 lCe({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=iCe):t<=s?(a="#d4a017",o="Fair",c=sCe):(a="#c62828",o="Bad",c=aCe),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 cCe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function uCe(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 dCe(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 hCe(t){return t==null?{label:"",color:"text-bambu-gray",bars:0}:t>=-50?{label:"Excellent",color:"text-bambu-green",bars:4}:t>=-60?{label:"Good",color:"text-bambu-green",bars:3}:t>=-70?{label:"Fair",color:"text-yellow-400",bars:2}:t>=-80?{label:"Weak",color:"text-orange-400",bars:1}:{label:"Very weak",color:"text-red-400",bars:1}}function fCe({url:t,printName:e}){const[n,r]=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 pCe({printers:t}){const e=En(),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(()=>{const i=e.getQueryCache().subscribe(()=>{r(s=>s+1)});return()=>i()},[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=En(),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),[w,A]=M.useState(!1),[T,k]=M.useState(!1),[N,I]=M.useState(null),{data:C}=vt({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}=vt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ke.getSmartPlugByPrinter(t.id)}),{data:te}=vt({queryKey:["smartPlugStatus",V?.id],queryFn:()=>V?ke.getSmartPlugStatus(V.id):null,enabled:!!V,refetchInterval:1e4}),{data:Y}=vt({queryKey:["queue",t.id,"pending"],queryFn:()=>ke.getQueue(t.id,"pending")}),Z=Y?.length||0,{data:U}=vt({queryKey:["archives",t.id,"last"],queryFn:()=>ke.getArchives(t.id,1,0),enabled:C?.connected&&C?.state!=="RUNNING"}),z=U?.[0],ee=e&&C&&!C.connected,ae=_t({mutationFn:()=>ke.deletePrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printers"]})}}),fe=_t({mutationFn:()=>ke.connectPrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printerStatus",t.id]})}}),de=_t({mutationFn:ye=>V?ke.controlSmartPlug(V.id,ye):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugStatus",V?.id]})}}),xe=_t({mutationFn:ye=>V?ke.updateSmartPlug(V.id,{auto_off:ye}):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),s.invalidateQueries({queryKey:["smart-plugs"]})}});return ee?null:l.jsxs(kt,{className:"relative",children:[l.jsxs(Dt,{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:dCe(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(Ie,{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:()=>{fe.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(kn,{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 - ${hCe(j).label}`,children:[l.jsx(Xce,{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(ye=>ye.severity<=2)?"bg-red-500/20 text-red-400":"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:"Click to view HMS errors",children:[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"]}),Z>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:`${Z} print${Z>1?"s":""} in queue`,children:[l.jsx($h,{className:"w-3 h-3"}),Z]})]})]}),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:()=>{ae.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(fCe,{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"}),cCe(C.remaining_time*60)]}),l.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",uCe(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(ade,{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(ye=>{const re=R[String(ye.id)],ve=ye.id>=128?ye.id-128:ye.id,je=re!==void 0?re:ve,ue=t.nozzle_count===2||C?.temperatures?.nozzle_2!==void 0,ut=je===1,$=je===0,H=ye.tray.map(G=>G.tray_color?`#${G.tray_color}`:G.tray_type?"#333":null),ie=ye.tray.length===1;return 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:[ue&&(ut||$)&&l.jsx(JTe,{side:ut?"L":"R"}),ie?l.jsx(tCe,{color:H[0],className:"flex-shrink-0"}):l.jsx(eCe,{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(ye.id,ye.tray.length)}),l.jsx("div",{className:"mt-0.5 text-[10px] flex items-start",children:ye.tray.map((G,J)=>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}%`:"—"})]}),J<ye.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:"·"})]})]},J))})]}),(ye.humidity!=null||ye.temp!=null)&&l.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[ye.humidity!=null&&l.jsx(oCe,{humidity:ye.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair,onClick:()=>I({amsId:ye.id,amsLabel:hC(ye.id,ye.tray.length),mode:"humidity"})}),ye.temp!=null&&l.jsx(lCe,{temp:ye.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair,onClick:()=>I({amsId:ye.id,amsLabel:hC(ye.id,ye.tray.length),mode:"temperature"})})]})]})},ye.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(xm,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),l.jsx("span",{className:"text-sm text-white truncate",children:V.name}),te&&l.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${te.state==="ON"?"bg-bambu-green/20 text-bambu-green":te.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:te.state||"?"}),te?.energy?.power!=null&&te.state==="ON"&&l.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[te.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:de.isPending||te?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${te?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[l.jsx(bd,{className:"w-3 h-3"}),"On"]}),l.jsxs("button",{onClick:()=>A(!0),disabled:de.isPending||te?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${te?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[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(Ie,{variant:"secondary",size:"sm",onClick:()=>{window.open(`/camera/${t.id}`,`camera-${t.id}`,"width=640,height=400,menubar=no,toolbar=no,location=no,status=no")},disabled:!C?.connected,title:"Open camera in new window",children:l.jsx(g7,{className:"w-4 h-4"})}),l.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>x(!0),title:"Browse printer files",children:[l.jsx(FR,{className:"w-4 h-4"}),"Files"]})]})]})]}),m&&l.jsx(Jue,{printerId:t.id,printerName:t.name,onClose:()=>x(!1)}),y&&l.jsx(ede,{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:()=>{de.mutate("on"),E(!1)},onCancel:()=>E(!1)}),w&&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:()=>{de.mutate("off"),A(!1)},onCancel:()=>A(!1)}),T&&l.jsx(ide,{printerName:t.name,errors:C?.hms_errors||[],onClose:()=>k(!1)}),N&&l.jsx(QTe,{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(gCe,{printer:t,onClose:()=>g(!1)})]})}function mCe({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(kt,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:l.jsxs(Dt,{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(Ie,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),l.jsx(Ie,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function gCe({printer:t,onClose:e}){const n=En(),[r,i]=M.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),s=_t({mutationFn:o=>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(kt,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:l.jsxs(Dt,{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(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsx(Ie,{type:"submit",className:"flex-1",disabled:s.isPending,children:s.isPending?"Saving...":"Save Changes"})]})]})]})})})}function xCe(t){const{data:e}=vt({queryKey:["printerStatus",t],queryFn:()=>ke.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function bCe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=xCe(t.id),{data:s}=vt({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 vCe(){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=En(),{data:y,isLoading:v}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:b}=vt({queryKey:["settings"],queryFn:ke.getSettings}),{data:E}=vt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs}),{data:w}=vt({queryKey:["maintenanceOverview"],queryFn:ke.getMaintenanceOverview,staleTime:60*1e3}),A=w?.reduce((R,W)=>(R[W.printer_id]={due_count:W.due_count,warning_count:W.warning_count,total_print_hours:W.total_print_hours},R),{})||{},T=E?.reduce((R,W)=>(W.printer_id&&(R[W.printer_id]=W),R),{})||{},k=_t({mutationFn:ke.createPrinter,onSuccess:()=>{x.invalidateQueries({queryKey:["printers"]}),e(!1)}}),N=_t({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||"",te=K.location||"";return!V&&te?1:V&&!te?-1:V.localeCompare(te)||W.name.localeCompare(K.name)});break;case"status":R.sort((W,K)=>{const V=x.getQueryData(["printerStatus",W.id]),te=x.getQueryData(["printerStatus",K.id]),Y=Z=>Z?.connected?Z.state==="RUNNING"?0:1:2;return Y(V)-Y(te)});break}return d||R.reverse(),R},[y,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(pCe,{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(g0,{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(bCe,{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(Ie,{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(kt,{children:l.jsxs(Dt,{className:"text-center py-12",children:[l.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),l.jsxs(Ie,{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(mCe,{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},yCe=0,C8=1,_Ce=2,IY=1,wCe=2,rc=3,dd=0,qs=1,nl=2,_c=0,im=1,N8=2,k8=3,P8=4,SCe=5,ah=100,ECe=101,MCe=102,ACe=103,TCe=104,CCe=200,NCe=201,kCe=202,PCe=203,jk=204,Lk=205,RCe=206,DCe=207,OCe=208,jCe=209,LCe=210,ICe=211,UCe=212,FCe=213,zCe=214,Ik=0,Uk=1,Fk=2,Am=3,zk=4,Bk=5,Hk=6,$k=7,XO=0,BCe=1,HCe=2,Xu=0,$Ce=1,VCe=2,GCe=3,WCe=4,qCe=5,KCe=6,XCe=7,UY=300,Tm=301,Cm=302,Vk=303,Gk=304,IE=306,Wk=1e3,pc=1001,qk=1002,ya=1003,YCe=1004,Oy=1005,to=1006,fC=1007,gh=1008,ml=1009,FY=1010,zY=1011,H0=1012,YO=1013,Qh=1014,mc=1015,ag=1016,ZO=1017,QO=1018,$0=1020,BY=35902,HY=35899,$Y=1021,VY=1022,Po=1023,V0=1026,G0=1027,GY=1028,JO=1029,ej=1030,tj=1031,nj=1033,s1=33776,a1=33777,o1=33778,l1=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,ZCe=3200,QCe=3201,WY=0,JCe=1,Lu="",Ga="srgb",Nm="srgb-linear",Cw="linear",Wn="srgb",tp=7680,R8=519,eNe=512,tNe=513,nNe=514,qY=515,rNe=516,iNe=517,sNe=518,aNe=519,D8=35044,O8="300 es",al=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 oNe(){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 Xt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function zr(...t){const e="THREE."+t.shift();console.error(e,...t)}function W0(...t){const e=t.join(" ");e in j8||(j8[e]=!0,Xt(...t))}function lNe(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 is=["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"],c1=Math.PI/180,wP=180/Math.PI;function Gb(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(is[t&255]+is[t>>8&255]+is[t>>16&255]+is[t>>24&255]+"-"+is[e&255]+is[e>>8&255]+"-"+is[e>>16&15|64]+is[e>>24&255]+"-"+is[n&63|128]+is[n>>8&255]+"-"+is[n>>16&255]+is[n>>24&255]+is[r&255]+is[r>>8&255]+is[r>>16&255]+is[r>>24&255]).toLowerCase()}function mn(t,e,n){return Math.max(e,Math.min(n,t))}function cNe(t,e){return(t%e+e)%e}function pC(t,e,n){return(1-n)*t+n*e}function px(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 uNe={DEG2RAD:c1};let on=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=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(mn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},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),w=Math.sin(E);b=Math.sin(b*E)/w,o=Math.sin(o*E)/w,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:Xt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],a=n[1],o=n[5],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(mn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,a=e._w,o=n._x,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}},Je=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=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this.z=mn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this.z=mn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,a=n.x,o=n.y,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(mn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const mC=new Je,I8=new Jh;let un=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],w=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*w+c*k,s[6]=a*b+o*A+c*N,s[1]=u*y+d*E+f*T,s[4]=u*v+d*w+f*k,s[7]=u*b+d*A+f*N,s[2]=g*y+m*E+x*T,s[5]=g*v+m*w+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 un,U8=new un().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),F8=new un().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function dNe(){const t={enabled:!0,workingColorSpace:Nm,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Wn&&(i.r=wc(i.r),i.g=wc(i.g),i.b=wc(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Wn&&(i.r=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 W0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return W0("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({[Nm]:{primaries:e,whitePoint:r,transfer:Cw,toXYZ:U8,fromXYZ:F8,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ga},outputColorSpaceConfig:{drawingBufferColorSpace:Ga}},[Ga]:{primaries:e,whitePoint:r,transfer:Wn,toXYZ:U8,fromXYZ:F8,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ga}}}),t}const Tn=dNe();function wc(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,hNe=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]=wc(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(wc(n[r]/255)*255):n[r]=wc(n[r]);return{data:n,width:e.width,height:e.height}}else return Xt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},fNe=0,rj=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:fNe++}),this.uuid=Gb(),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?hNe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Xt("Texture: Unable to serialize Texture."),{})}let pNe=0;const bC=new Je;let Ho=class u1 extends mf{constructor(e=u1.DEFAULT_IMAGE,n=u1.DEFAULT_MAPPING,r=pc,i=pc,s=to,a=gh,o=Po,c=ml,u=u1.DEFAULT_ANISOTROPY,d=Lu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:pNe++}),this.uuid=Gb(),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 on(0,0),this.repeat=new on(1,1),this.center=new on(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new un,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(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){Xt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Xt(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==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 pc: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 pc: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++}};Ho.DEFAULT_IMAGE=null;Ho.DEFAULT_MAPPING=UY;Ho.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 w=(u+1)/2,A=(m+1)/2,T=(b+1)/2,k=(d+g)/4,N=(f+y)/4,I=(x+v)/4;return w>A&&w>T?w<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(w),i=k/r,s=N/r):A>T?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=k/i,s=I/i):T<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(T),r=N/s,i=I/s),this.set(r,i,s,n),this}let E=Math.sqrt((v-x)*(v-x)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(v-x)/E,this.y=(f-y)/E,this.z=(g-d)/E,this.w=Math.acos((u+m+b-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this.z=mn(this.z,e.z,n.z),this.w=mn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this.z=mn(this.z,e,n),this.w=mn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},mNe=class extends mf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:to,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 Ho(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:to,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 mNe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},JY=class extends Ho{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=ya,this.minFilter=ya,this.wrapR=pc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},gNe=class extends Ho{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=ya,this.minFilter=ya,this.wrapR=pc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tf=class{constructor(e=new Je(1/0,1/0,1/0),n=new Je(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(bo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(bo.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=bo.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,bo):bo.fromBufferAttribute(s,a),bo.applyMatrix4(e.matrixWorld),this.expandByPoint(bo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),jy.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),jy.copy(r.boundingBox)),jy.applyMatrix4(e.matrixWorld),this.union(jy)}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,bo),bo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(mx),Ly.subVectors(this.max,mx),rp.subVectors(e.a,mx),ip.subVectors(e.b,mx),sp.subVectors(e.c,mx),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,Ly)||(n=[1,0,0,0,1,0,0,0,1],!vC(n,rp,ip,sp,Ly))?!1:(Iy.crossVectors(hu,fu),n=[Iy.x,Iy.y,Iy.z],vC(n,rp,ip,sp,Ly))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,bo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(bo).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:($l[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),$l[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),$l[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),$l[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),$l[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),$l[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),$l[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),$l[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints($l),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 $l=[new Je,new Je,new Je,new Je,new Je,new Je,new Je,new Je],bo=new Je,jy=new tf,rp=new Je,ip=new Je,sp=new Je,hu=new Je,fu=new Je,Hd=new Je,mx=new Je,Ly=new Je,Iy=new Je,$d=new Je;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 xNe=new tf,gx=new Je,yC=new Je;let UE=class{constructor(e=new Je,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):xNe.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;gx.subVectors(e,this.center);const n=gx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(gx,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(yC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(gx.copy(e.center).add(yC)),this.expandByPoint(gx.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 Vl=new Je,_C=new Je,Uy=new Je,pu=new Je,wC=new Je,Fy=new Je,SC=new Je;let ij=class{constructor(e=new Je,n=new Je(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Vl)),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=Vl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Vl.copy(this.origin).addScaledVector(this.direction,n),Vl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){_C.copy(e).add(n).multiplyScalar(.5),Uy.copy(n).sub(e).normalize(),pu.copy(this.origin).sub(_C);const s=e.distanceTo(n)*.5,a=-this.direction.dot(Uy),o=pu.dot(this.direction),c=-pu.dot(Uy),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(Uy,g),m}intersectSphere(e,n){Vl.subVectors(e.center,this.origin);const r=Vl.dot(this.direction),i=Vl.dot(Vl)-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,Vl)!==null}intersectTriangle(e,n,r,i,s){wC.subVectors(n,e),Fy.subVectors(r,e),SC.crossVectors(wC,Fy);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(Fy.crossVectors(pu,Fy));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(bNe,e,vNe)}lookAt(e,n,r){const i=this.elements;return la.subVectors(e,n),la.lengthSq()===0&&(la.z=1),la.normalize(),mu.crossVectors(r,la),mu.lengthSq()===0&&(Math.abs(r.z)===1?la.x+=1e-4:la.z+=1e-4,la.normalize(),mu.crossVectors(r,la)),mu.normalize(),zy.crossVectors(la,mu),i[0]=mu.x,i[4]=zy.x,i[8]=la.x,i[1]=mu.y,i[5]=zy.y,i[9]=la.y,i[2]=mu.z,i[6]=zy.z,i[10]=la.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[4],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],w=r[7],A=r[11],T=r[15],k=i[0],N=i[4],I=i[8],C=i[12],D=i[1],F=i[5],j=i[9],q=i[13],R=i[2],W=i[6],K=i[10],V=i[14],te=i[3],Y=i[7],Z=i[11],U=i[15];return s[0]=a*k+o*D+c*R+u*te,s[4]=a*N+o*F+c*W+u*Y,s[8]=a*I+o*j+c*K+u*Z,s[12]=a*C+o*q+c*V+u*U,s[1]=d*k+f*D+g*R+m*te,s[5]=d*N+f*F+g*W+m*Y,s[9]=d*I+f*j+g*K+m*Z,s[13]=d*C+f*q+g*V+m*U,s[2]=x*k+y*D+v*R+b*te,s[6]=x*N+y*F+v*W+b*Y,s[10]=x*I+y*j+v*K+b*Z,s[14]=x*C+y*q+v*V+b*U,s[3]=E*k+w*D+A*R+T*te,s[7]=E*N+w*F+A*W+T*Y,s[11]=E*I+w*j+A*K+T*Z,s[15]=E*C+w*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,w=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*w+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]=w*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,w=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-w)*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+w)*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],vo.copy(this);const u=1/s,d=1/a,f=1/o;return vo.elements[0]*=u,vo.elements[1]*=u,vo.elements[2]*=u,vo.elements[4]*=d,vo.elements[5]*=d,vo.elements[6]*=d,vo.elements[8]*=f,vo.elements[9]*=f,vo.elements[10]*=f,n.setFromRotationMatrix(vo),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=al,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===al)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=al,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===al)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 Je,vo=new ri,bNe=new Je(0,0,0),vNe=new Je(1,1,1),mu=new Je,zy=new Je,la=new Je,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(mn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-mn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(mn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-mn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(mn(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(-mn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:Xt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return 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}},yNe=0;const H8=new Je,op=new Jh,Gl=new ri,By=new Je,xx=new Je,_Ne=new Je,wNe=new Jh,$8=new Je(1,0,0),V8=new Je(0,1,0),G8=new Je(0,0,1),W8={type:"added"},SNe={type:"removed"},lp={type:"childadded",child:null},EC={type:"childremoved",child:null};let Aa=class d1 extends mf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:yNe++}),this.uuid=Gb(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=d1.DEFAULT_UP.clone();const e=new Je,n=new hd,r=new Jh,i=new Je(1,1,1);function s(){r.setFromEuler(n,!1)}function a(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ri},normalMatrix:{value:new un}}),this.matrix=new ri,this.matrixWorld=new ri,this.matrixAutoUpdate=d1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=d1.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(Gl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?By.copy(e):By.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),xx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Gl.lookAt(xx,By,this.up):Gl.lookAt(By,xx,this.up),this.quaternion.setFromRotationMatrix(Gl),i&&(Gl.extractRotation(i.matrixWorld),op.setFromRotationMatrix(Gl),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(SNe),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),Gl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Gl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Gl),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(xx,e,_Ne),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xx,wNe,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}};Aa.DEFAULT_UP=new Je(0,1,0);Aa.DEFAULT_MATRIX_AUTO_UPDATE=!0;Aa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const yo=new Je,Wl=new Je,MC=new Je,ql=new Je,cp=new Je,up=new Je,q8=new Je,AC=new Je,TC=new Je,CC=new Je,NC=new Yr,kC=new Yr,PC=new Yr;let bx=class Fp{constructor(e=new Je,n=new Je,r=new Je){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),yo.subVectors(e,n),i.cross(yo);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){yo.subVectors(i,n),Wl.subVectors(r,n),MC.subVectors(e,n);const a=yo.dot(yo),o=yo.dot(Wl),c=yo.dot(MC),u=Wl.dot(Wl),d=Wl.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,ql)===null?!1:ql.x>=0&&ql.y>=0&&ql.x+ql.y<=1}static getInterpolation(e,n,r,i,s,a,o,c){return this.getBarycoord(e,n,r,i,ql)===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,ql.x),c.addScaledVector(a,ql.y),c.addScaledVector(o,ql.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 yo.subVectors(r,n),Wl.subVectors(e,n),yo.cross(Wl).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 yo.subVectors(this.c,this.b),Wl.subVectors(this.a,this.b),yo.cross(Wl).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},Hy={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 yn=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Ga){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Tn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Tn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Tn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Tn.workingColorSpace){if(e=cNe(e,1),n=mn(n,0,1),r=mn(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,a=2*r-s;this.r=RC(a,s,e+1/3),this.g=RC(a,s,e),this.b=RC(a,s,e-1/3)}return Tn.colorSpaceToWorking(this,i),this}setStyle(e,n=Ga){function r(s){s!==void 0&&parseFloat(s)<1&&Xt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:Xt("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(a===6)return this.setHex(parseInt(s,16),n);Xt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Ga){const r=nZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Xt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=wc(e.r),this.g=wc(e.g),this.b=wc(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=Ga){return Tn.workingToColorSpace(ss.copy(this),e),Math.round(mn(ss.r*255,0,255))*65536+Math.round(mn(ss.g*255,0,255))*256+Math.round(mn(ss.b*255,0,255))}getHexString(e=Ga){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Tn.workingColorSpace){Tn.workingToColorSpace(ss.copy(this),n);const r=ss.r,i=ss.g,s=ss.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=Tn.workingColorSpace){return Tn.workingToColorSpace(ss.copy(this),n),e.r=ss.r,e.g=ss.g,e.b=ss.b,e}getStyle(e=Ga){Tn.workingToColorSpace(ss.copy(this),e);const n=ss.r,r=ss.g,i=ss.b;return e!==Ga?`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(Hy);const r=pC(gu.h,Hy.h,n),i=pC(gu.s,Hy.s,n),s=pC(gu.l,Hy.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 ss=new yn;yn.NAMES=nZ;let ENe=0,og=class extends mf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ENe++}),this.uuid=Gb(),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 yn(0,0,0),this.blendAlpha=0,this.depthFunc=Am,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){Xt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Xt(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==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!==Am&&(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 og{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new yn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new 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 Je,$y=new on;let MNe=0,no=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:MNe++}),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=mc,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++)$y.fromBufferAttribute(this,n),$y.applyMatrix3(e),this.setXY(n,$y.x,$y.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=px(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=px(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=px(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=px(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=px(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 no{constructor(e,n,r){super(new Uint16Array(e),n,r)}},iZ=class extends no{constructor(e,n,r){super(new Uint32Array(e),n,r)}},jo=class extends no{constructor(e,n,r){super(new Float32Array(e),n,r)}},ANe=0;const Ia=new ri,DC=new Aa,dp=new Je,ca=new tf,vx=new tf,Ci=new Je;let El=class sZ extends mf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ANe++}),this.uuid=Gb(),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 un().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ia.makeRotationFromQuaternion(e),this.applyMatrix4(Ia),this}rotateX(e){return Ia.makeRotationX(e),this.applyMatrix4(Ia),this}rotateY(e){return Ia.makeRotationY(e),this.applyMatrix4(Ia),this}rotateZ(e){return Ia.makeRotationZ(e),this.applyMatrix4(Ia),this}translate(e,n,r){return Ia.makeTranslation(e,n,r),this.applyMatrix4(Ia),this}scale(e,n,r){return Ia.makeScale(e,n,r),this.applyMatrix4(Ia),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 jo(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const s=e[i];n.setXYZ(i,s.x,s.y,s.z||0)}e.length>n.count&&Xt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new 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 Je(-1/0,-1/0,-1/0),new Je(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];ca.setFromBufferAttribute(s),this.morphTargetsRelative?(Ci.addVectors(this.boundingBox.min,ca.min),this.boundingBox.expandByPoint(Ci),Ci.addVectors(this.boundingBox.max,ca.max),this.boundingBox.expandByPoint(Ci)):(this.boundingBox.expandByPoint(ca.min),this.boundingBox.expandByPoint(ca.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&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 Je,1/0);return}if(e){const r=this.boundingSphere.center;if(ca.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];vx.setFromBufferAttribute(o),this.morphTargetsRelative?(Ci.addVectors(ca.min,vx.min),ca.expandByPoint(Ci),Ci.addVectors(ca.max,vx.max),ca.expandByPoint(Ci)):(ca.expandByPoint(vx.min),ca.expandByPoint(vx.max))}ca.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Ci.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Ci));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],c=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)Ci.fromBufferAttribute(o,u),c&&(dp.fromBufferAttribute(e,u),Ci.add(dp)),i=Math.max(i,r.distanceToSquared(Ci))}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 no(new Float32Array(4*r.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let I=0;I<r.count;I++)o[I]=new Je,c[I]=new Je;const u=new Je,d=new Je,f=new Je,g=new on,m=new on,x=new on,y=new Je,v=new Je;function b(I,C,D){u.fromBufferAttribute(r,I),d.fromBufferAttribute(r,C),f.fromBufferAttribute(r,D),g.fromBufferAttribute(s,I),m.fromBufferAttribute(s,C),x.fromBufferAttribute(s,D),d.sub(u),f.sub(u),m.sub(g),x.sub(g);const F=1/(m.x*x.y-x.x*m.y);isFinite(F)&&(y.copy(d).multiplyScalar(x.y).addScaledVector(f,-m.y).multiplyScalar(F),v.copy(f).multiplyScalar(m.x).addScaledVector(d,-x.x).multiplyScalar(F),o[I].add(y),o[C].add(y),o[D].add(y),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 w=new Je,A=new Je,T=new Je,k=new Je;function N(I){T.fromBufferAttribute(i,I),k.copy(T);const C=o[I];w.copy(C),w.sub(T.multiplyScalar(T.dot(C))).normalize(),A.crossVectors(k,C);const F=A.dot(c[I])<0?-1:1;a.setXYZW(I,w.x,w.y,w.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 no(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new Je,s=new Je,a=new Je,o=new Je,c=new Je,u=new Je,d=new Je,f=new Je;if(e)for(let g=0,m=e.count;g<m;g+=3){const x=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),a.fromBufferAttribute(n,v),d.subVectors(a,s),f.subVectors(i,s),d.cross(f),o.fromBufferAttribute(r,x),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++)Ci.fromBufferAttribute(e,n),Ci.normalize(),e.setXYZ(n,Ci.x,Ci.y,Ci.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 no(g,d,f)}if(this.index===null)return Xt("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,Vy=new UE,X8=new Je,Gy=new Je,Wy=new Je,qy=new Je,OC=new Je,Ky=new Je,Y8=new Je,Xy=new Je;let gl=class extends Aa{constructor(e=new El,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){Ky.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?Ky.addScaledVector(OC,d):Ky.addScaledVector(OC.sub(n),d))}n.add(Ky)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Vy.copy(r.boundingSphere),Vy.applyMatrix4(s),Vd.copy(e.ray).recast(e.near),!(Vy.containsPoint(Vd.origin)===!1&&(Vd.intersectSphere(Vy,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),w=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=w;A<T;A+=3){const k=o.getX(A),N=o.getX(A+1),I=o.getX(A+2);i=Yy(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),w=o.getX(v+1),A=o.getX(v+2);i=Yy(this,a,e,r,u,d,f,E,w,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),w=Math.min(c.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=w;A<T;A+=3){const k=A,N=A+1,I=A+2;i=Yy(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,w=v+1,A=v+2;i=Yy(this,a,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}};function TNe(t,e,n,r,i,s,a,o){let c;if(e.side===qs?c=r.intersectTriangle(a,s,i,!0,o):c=r.intersectTriangle(i,s,a,e.side===dd,o),c===null)return null;Xy.copy(o),Xy.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Xy);return u<n.near||u>n.far?null:{distance:u,point:Xy.clone(),object:t}}function Yy(t,e,n,r,i,s,a,o,c,u){t.getVertexPosition(o,Gy),t.getVertexPosition(c,Wy),t.getVertexPosition(u,qy);const d=TNe(t,e,n,r,Gy,Wy,qy,Y8);if(d){const f=new Je;bx.getBarycoord(Y8,Gy,Wy,qy,f),i&&(d.uv=bx.getInterpolatedAttribute(i,o,c,u,f,new on)),s&&(d.uv1=bx.getInterpolatedAttribute(s,o,c,u,f,new on)),a&&(d.normal=bx.getInterpolatedAttribute(a,o,c,u,f,new Je),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:o,b:c,c:u,normal:new Je,materialIndex:0};bx.getNormal(Gy,Wy,qy,g.normal),d.face=g,d.barycoord=f}return d}let aj=class aZ extends El{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 jo(u,3)),this.setAttribute("normal",new jo(d,3)),this.setAttribute("uv",new jo(f,2));function x(y,v,b,E,w,A,T,k,N,I,C){const D=A/N,F=T/I,j=A/2,q=T/2,R=k/2,W=N+1,K=I+1;let V=0,te=0;const Y=new Je;for(let Z=0;Z<K;Z++){const U=Z*F-q;for(let z=0;z<W;z++){const ee=z*D-j;Y[y]=ee*E,Y[v]=U*w,Y[b]=R,u.push(Y.x,Y.y,Y.z),Y[y]=0,Y[v]=0,Y[b]=k>0?1:-1,d.push(Y.x,Y.y,Y.z),f.push(z/N),f.push(1-Z/I),V+=1}}for(let Z=0;Z<I;Z++)for(let U=0;U<N;U++){const z=g+U+W*Z,ee=g+U+W*(Z+1),ae=g+(U+1)+W*(Z+1),fe=g+(U+1)+W*Z;c.push(z,ee,fe),c.push(ee,ae,fe),te+=6}o.addGroup(m,te,C),m+=te,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function km(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(Xt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function _s(t){const e={};for(let n=0;n<t.length;n++){const r=km(t[n]);for(const i in r)e[i]=r[i]}return e}function CNe(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:Tn.workingColorSpace}const NNe={clone:km,merge:_s};var kNe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,PNe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let Oc=class extends og{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=kNe,this.fragmentShader=PNe,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=km(e.uniforms),this.uniformsGroups=CNe(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 Aa{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ri,this.projectionMatrix=new ri,this.projectionMatrixInverse=new ri,this.coordinateSystem=al,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 Je,Z8=new on,Q8=new on;let Ka=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(c1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return wP*2*Math.atan(Math.tan(c1*.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(c1*.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 RNe=class extends Aa{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ka(hp,fp,e,n);i.layers=this.layers,this.add(i);const s=new Ka(hp,fp,e,n);s.layers=this.layers,this.add(s);const a=new Ka(hp,fp,e,n);a.layers=this.layers,this.add(a);const o=new Ka(hp,fp,e,n);o.layers=this.layers,this.add(o);const c=new Ka(hp,fp,e,n);c.layers=this.layers,this.add(c);const u=new Ka(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===al)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),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 Ho{constructor(e=[],n=Tm,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}},DNe=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 Oc({name:"CubemapFromEquirect",uniforms:km(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:qs,blending:_c});s.uniforms.tEquirect.value=n;const a=new gl(i,s),o=n.minFilter;return n.minFilter===gh&&(n.minFilter=to),new RNe(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)}},jx=class extends Aa{constructor(){super(),this.isGroup=!0,this.type="Group"}};const ONe={type:"move"};let jC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new jx,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 jx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Je,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Je),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new jx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Je,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Je),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,a=null;const o=this._targetRay,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(ONe)))}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 jx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},jNe=class extends Aa{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}},LNe=class extends Ho{constructor(e=null,n=1,r=1,i,s,a,o,c,u=ya,d=ya,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 Je,INe=new Je,UNe=new un;let Nu=class{constructor(e=new Je(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=LC.subVectors(r,n).cross(INe.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||UNe.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,FNe=new on(.5,.5),Zy=new Je;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=al,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],w=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+w).normalize(),i[3].setComponents(u-o,m-f,b-y,T-w).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===al)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=FNe.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(Zy.x=i.normal.x>0?e.max.x:e.min.x,Zy.y=i.normal.y>0?e.max.y:e.min.y,Zy.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Zy)<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 og{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new yn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};const Pw=new Je,Rw=new Je,J8=new ri,yx=new ij,Qy=new UE,IC=new Je,eH=new Je;let zNe=class extends Aa{constructor(e=new El,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 jo(r,1))}else Xt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Qy.copy(r.boundingSphere),Qy.applyMatrix4(i),Qy.radius+=s,e.ray.intersectsSphere(Qy)===!1)return;J8.copy(i).invert(),yx.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),w=Jy(this,e,yx,c,b,E,y);w&&n.push(w)}if(this.isLineLoop){const y=d.getX(x-1),v=d.getX(m),b=Jy(this,e,yx,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=Jy(this,e,yx,c,y,y+1,y);b&&n.push(b)}if(this.isLineLoop){const y=Jy(this,e,yx,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 Jy(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 Je,nH=new Je;let BNe=class extends zNe{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 jo(r,1))}else Xt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},dZ=class extends Ho{constructor(e,n,r=Qh,i,s,a,o=ya,c=ya,u,d=V0,f=1){if(d!==V0&&d!==G0)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 Ho{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 El{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 w=0;w<u;w++){const A=w*f-s;x.push(A,-E,0),y.push(0,0,1),v.push(w/o),v.push(1-b/c)}}for(let b=0;b<c;b++)for(let E=0;E<o;E++){const w=E+u*b,A=E+u*(b+1),T=E+1+u*(b+1),k=E+1+u*b;m.push(w,A,k),m.push(A,T,k)}this.setIndex(m),this.setAttribute("position",new jo(x,3)),this.setAttribute("normal",new jo(y,3)),this.setAttribute("uv",new jo(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 HNe extends og{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new yn(16777215),this.specular=new yn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=WY,this.normalScale=new on(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new 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 $Ne=class extends og{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ZCe,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}},VNe=class extends og{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 Aa{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new yn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const UC=new ri,rH=new Je,iH=new Je;let GNe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new on(512,512),this.mapType=ml,this.map=null,this.mapPass=null,this.matrix=new ri,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new oj,this._frameExtents=new on(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 WNe extends GNe{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(Aa.DEFAULT_UP),this.updateMatrix(),this.target=new Aa,this.shadow=new WNe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let qNe=class extends pZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},KNe=class extends Ka{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=mn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(mn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class XNe extends BNe{constructor(e=10,n=10,r=4473924,i=8947848){r=new yn(r),i=new yn(i);const s=n/2,a=e/n,o=e/2,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 El;d.setAttribute("position",new jo(c,3)),d.setAttribute("color",new jo(u,3));const f=new uZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class YNe 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){Xt("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=ZNe(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 Po:return t*e*4/i.components*i.byteLength;case nj:return t*e*4/i.components*i.byteLength;case s1:case a1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case o1:case l1: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 ZNe(t){switch(t){case ml:case FY:return{byteLength:1,components:1};case H0:case zY:case ag:return{byteLength:2,components:1};case ZO:case QO:return{byteLength:2,components:4};case Qh:case YO:case mc: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__?Xt("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 QNe(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 JNe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,e3e=`#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`,t3e=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,n3e=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,r3e=`#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`,i3e=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,s3e=`#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`,a3e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,o3e=`#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`,l3e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,c3e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,u3e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,d3e=`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`,h3e=`#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`,f3e=`#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`,p3e=`#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`,m3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,g3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,x3e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,b3e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,v3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,y3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,_3e=`#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`,w3e=`#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`,S3e=`#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`,E3e=`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`,M3e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,A3e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,T3e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,C3e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,N3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",k3e=`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 );
- }`,P3e=`#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`,R3e=`#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`,D3e=`#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`,O3e=`#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`,j3e=`#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`,L3e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,I3e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,U3e=`#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`,F3e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,z3e=`#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
- }`,B3e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,H3e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,$3e=`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`,V3e=`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`,G3e=`#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`,W3e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,q3e=`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`,K3e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,X3e=`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`,Y3e=`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`,Z3e=`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 );
- }`,Q3e=`
- 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`,J3e=`#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`,eke=`#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`,tke=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,nke=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,rke=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,ike=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,ske=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,ake=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,oke=`#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`,lke=`#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`,cke=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,uke=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,dke=`#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`,hke=`#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`,fke=`#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`,pke=`#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`,mke=`#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`,gke=`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;`,xke=`#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`,bke=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,vke=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,yke=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,_ke=`#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`,wke=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Ske=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Eke=`#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`,Mke=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Ake=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Tke=`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 );
- }`,Cke=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,Nke=`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;`,kke=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,Pke=`#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`,Rke=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Dke=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Oke=`#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`,jke=`#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`,Lke=`#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`,Ike=`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;
- }`,Uke=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,Fke=`#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`,zke=`#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`,Bke=`#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`,Hke=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,$ke=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,Vke=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,Gke=`#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; }`,Wke=`#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`,qke=`#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`,Kke=`#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`,Xke=`#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`,Yke=`#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`,Zke=`#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 Qke=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,Jke=`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>
- }`,ePe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,tPe=`#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>
- }`,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=`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>
- }`,iPe=`#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;
- }`,sPe=`#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
- }`,aPe=`#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;
- }`,oPe=`#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 );
- }`,lPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,cPe=`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>
- }`,uPe=`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>
- }`,dPe=`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>
- }`,hPe=`#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>
- }`,fPe=`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>
- }`,pPe=`#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>
- }`,mPe=`#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>
- }`,gPe=`#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;
- }`,xPe=`#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>
- }`,bPe=`#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
- }`,vPe=`#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
- }`,yPe=`#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>
- }`,_Pe=`#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>
- }`,wPe=`#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
- }`,SPe=`#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>
- }`,EPe=`#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>
- }`,MPe=`#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>
- }`,APe=`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>
- }`,TPe=`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>
- }`,CPe=`#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>
- }`,NPe=`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>
- }`,kPe=`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>
- }`,PPe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,sn={alphahash_fragment:JNe,alphahash_pars_fragment:e3e,alphamap_fragment:t3e,alphamap_pars_fragment:n3e,alphatest_fragment:r3e,alphatest_pars_fragment:i3e,aomap_fragment:s3e,aomap_pars_fragment:a3e,batching_pars_vertex:o3e,batching_vertex:l3e,begin_vertex:c3e,beginnormal_vertex:u3e,bsdfs:d3e,iridescence_fragment:h3e,bumpmap_pars_fragment:f3e,clipping_planes_fragment:p3e,clipping_planes_pars_fragment:m3e,clipping_planes_pars_vertex:g3e,clipping_planes_vertex:x3e,color_fragment:b3e,color_pars_fragment:v3e,color_pars_vertex:y3e,color_vertex:_3e,common:w3e,cube_uv_reflection_fragment:S3e,defaultnormal_vertex:E3e,displacementmap_pars_vertex:M3e,displacementmap_vertex:A3e,emissivemap_fragment:T3e,emissivemap_pars_fragment:C3e,colorspace_fragment:N3e,colorspace_pars_fragment:k3e,envmap_fragment:P3e,envmap_common_pars_fragment:R3e,envmap_pars_fragment:D3e,envmap_pars_vertex:O3e,envmap_physical_pars_fragment:G3e,envmap_vertex:j3e,fog_vertex:L3e,fog_pars_vertex:I3e,fog_fragment:U3e,fog_pars_fragment:F3e,gradientmap_pars_fragment:z3e,lightmap_pars_fragment:B3e,lights_lambert_fragment:H3e,lights_lambert_pars_fragment:$3e,lights_pars_begin:V3e,lights_toon_fragment:W3e,lights_toon_pars_fragment:q3e,lights_phong_fragment:K3e,lights_phong_pars_fragment:X3e,lights_physical_fragment:Y3e,lights_physical_pars_fragment:Z3e,lights_fragment_begin:Q3e,lights_fragment_maps:J3e,lights_fragment_end:eke,logdepthbuf_fragment:tke,logdepthbuf_pars_fragment:nke,logdepthbuf_pars_vertex:rke,logdepthbuf_vertex:ike,map_fragment:ske,map_pars_fragment:ake,map_particle_fragment:oke,map_particle_pars_fragment:lke,metalnessmap_fragment:cke,metalnessmap_pars_fragment:uke,morphinstance_vertex:dke,morphcolor_vertex:hke,morphnormal_vertex:fke,morphtarget_pars_vertex:pke,morphtarget_vertex:mke,normal_fragment_begin:gke,normal_fragment_maps:xke,normal_pars_fragment:bke,normal_pars_vertex:vke,normal_vertex:yke,normalmap_pars_fragment:_ke,clearcoat_normal_fragment_begin:wke,clearcoat_normal_fragment_maps:Ske,clearcoat_pars_fragment:Eke,iridescence_pars_fragment:Mke,opaque_fragment:Ake,packing:Tke,premultiplied_alpha_fragment:Cke,project_vertex:Nke,dithering_fragment:kke,dithering_pars_fragment:Pke,roughnessmap_fragment:Rke,roughnessmap_pars_fragment:Dke,shadowmap_pars_fragment:Oke,shadowmap_pars_vertex:jke,shadowmap_vertex:Lke,shadowmask_pars_fragment:Ike,skinbase_vertex:Uke,skinning_pars_vertex:Fke,skinning_vertex:zke,skinnormal_vertex:Bke,specularmap_fragment:Hke,specularmap_pars_fragment:$ke,tonemapping_fragment:Vke,tonemapping_pars_fragment:Gke,transmission_fragment:Wke,transmission_pars_fragment:qke,uv_pars_fragment:Kke,uv_pars_vertex:Xke,uv_vertex:Yke,worldpos_vertex:Zke,background_vert:Qke,background_frag:Jke,backgroundCube_vert:ePe,backgroundCube_frag:tPe,cube_vert:nPe,cube_frag:rPe,depth_vert:iPe,depth_frag:sPe,distanceRGBA_vert:aPe,distanceRGBA_frag:oPe,equirect_vert:lPe,equirect_frag:cPe,linedashed_vert:uPe,linedashed_frag:dPe,meshbasic_vert:hPe,meshbasic_frag:fPe,meshlambert_vert:pPe,meshlambert_frag:mPe,meshmatcap_vert:gPe,meshmatcap_frag:xPe,meshnormal_vert:bPe,meshnormal_frag:vPe,meshphong_vert:yPe,meshphong_frag:_Pe,meshphysical_vert:wPe,meshphysical_frag:SPe,meshtoon_vert:EPe,meshtoon_frag:MPe,points_vert:APe,points_frag:TPe,shadow_vert:CPe,shadow_frag:NPe,sprite_vert:kPe,sprite_frag:PPe},Et={common:{diffuse:{value:new yn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new un}},envmap:{envMap:{value:null},envMapRotation:{value:new un},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new un}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new un}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new un},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new un},normalScale:{value:new on(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new un},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new un}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new un}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new un}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new yn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new yn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0},uvTransform:{value:new un}},sprite:{diffuse:{value:new yn(16777215)},opacity:{value:1},center:{value:new on(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}}},tl={basic:{uniforms:_s([Et.common,Et.specularmap,Et.envmap,Et.aomap,Et.lightmap,Et.fog]),vertexShader:sn.meshbasic_vert,fragmentShader:sn.meshbasic_frag},lambert:{uniforms:_s([Et.common,Et.specularmap,Et.envmap,Et.aomap,Et.lightmap,Et.emissivemap,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.fog,Et.lights,{emissive:{value:new yn(0)}}]),vertexShader:sn.meshlambert_vert,fragmentShader:sn.meshlambert_frag},phong:{uniforms:_s([Et.common,Et.specularmap,Et.envmap,Et.aomap,Et.lightmap,Et.emissivemap,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.fog,Et.lights,{emissive:{value:new yn(0)},specular:{value:new yn(1118481)},shininess:{value:30}}]),vertexShader:sn.meshphong_vert,fragmentShader:sn.meshphong_frag},standard:{uniforms:_s([Et.common,Et.envmap,Et.aomap,Et.lightmap,Et.emissivemap,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.roughnessmap,Et.metalnessmap,Et.fog,Et.lights,{emissive:{value:new yn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag},toon:{uniforms:_s([Et.common,Et.aomap,Et.lightmap,Et.emissivemap,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.gradientmap,Et.fog,Et.lights,{emissive:{value:new yn(0)}}]),vertexShader:sn.meshtoon_vert,fragmentShader:sn.meshtoon_frag},matcap:{uniforms:_s([Et.common,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.fog,{matcap:{value:null}}]),vertexShader:sn.meshmatcap_vert,fragmentShader:sn.meshmatcap_frag},points:{uniforms:_s([Et.points,Et.fog]),vertexShader:sn.points_vert,fragmentShader:sn.points_frag},dashed:{uniforms:_s([Et.common,Et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:sn.linedashed_vert,fragmentShader:sn.linedashed_frag},depth:{uniforms:_s([Et.common,Et.displacementmap]),vertexShader:sn.depth_vert,fragmentShader:sn.depth_frag},normal:{uniforms:_s([Et.common,Et.bumpmap,Et.normalmap,Et.displacementmap,{opacity:{value:1}}]),vertexShader:sn.meshnormal_vert,fragmentShader:sn.meshnormal_frag},sprite:{uniforms:_s([Et.sprite,Et.fog]),vertexShader:sn.sprite_vert,fragmentShader:sn.sprite_frag},background:{uniforms:{uvTransform:{value:new un},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:sn.background_vert,fragmentShader:sn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new un}},vertexShader:sn.backgroundCube_vert,fragmentShader:sn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:sn.cube_vert,fragmentShader:sn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:sn.equirect_vert,fragmentShader:sn.equirect_frag},distanceRGBA:{uniforms:_s([Et.common,Et.displacementmap,{referencePosition:{value:new Je},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:sn.distanceRGBA_vert,fragmentShader:sn.distanceRGBA_frag},shadow:{uniforms:_s([Et.lights,Et.fog,{color:{value:new yn(0)},opacity:{value:1}}]),vertexShader:sn.shadow_vert,fragmentShader:sn.shadow_frag}};tl.physical={uniforms:_s([tl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new un},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new un},clearcoatNormalScale:{value:new on(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new un},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new un},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new un},sheen:{value:0},sheenColor:{value:new yn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new un},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new un},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new un},transmissionSamplerSize:{value:new on},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new un},attenuationDistance:{value:0},attenuationColor:{value:new yn(0)},specularColor:{value:new yn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new un},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new un},anisotropyVector:{value:new on},anisotropyMap:{value:null},anisotropyMapTransform:{value:new un}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag};const e_={r:0,b:0,g:0},Wd=new hd,RPe=new ri;function DPe(t,e,n,r,i,s,a){const o=new yn(0);let c=s===!0?0:1,u,d,f=null,g=0,m=null;function x(w){let A=w.isScene===!0?w.background:null;return A&&A.isTexture&&(A=(w.backgroundBlurriness>0?n:e).get(A)),A}function y(w){let A=!1;const T=x(w);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(w,A){const T=x(A);T&&(T.isCubeTexture||T.mapping===IE)?(d===void 0&&(d=new gl(new aj(1,1,1),new Oc({name:"BackgroundCubeMaterial",uniforms:km(tl.backgroundCube.uniforms),vertexShader:tl.backgroundCube.vertexShader,fragmentShader:tl.backgroundCube.fragmentShader,side:qs,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(RPe.makeRotationFromEuler(Wd)),d.material.toneMapped=Tn.getTransfer(T.colorSpace)!==Wn,(f!==T||g!==T.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=T,g=T.version,m=t.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null)):T&&T.isTexture&&(u===void 0&&(u=new gl(new lj(2,2),new Oc({name:"BackgroundMaterial",uniforms:km(tl.background.uniforms),vertexShader:tl.background.vertexShader,fragmentShader:tl.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=Tn.getTransfer(T.colorSpace)!==Wn,T.matrixAutoUpdate===!0&&T.updateMatrix(),u.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||g!==T.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=T,g=T.version,m=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null))}function b(w,A){w.getRGB(e_,oZ(t)),r.buffers.color.setClear(e_.r,e_.g,e_.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(w,A=1){o.set(w),c=A,b(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(w){c=w,b(o,c)},render:y,addToRenderList:v,dispose:E}}function OPe(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 te in V)if(V[te].location>=0){const Z=R[te];let U=W[te];if(U===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(U=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(U=D.instanceColor)),Z===void 0||Z.attribute!==U||U&&Z.data!==U.data)return!0;K++}return s.attributesNum!==K||s.index!==q}function x(D,F,j,q){const R={},W=F.attributes;let K=0;const V=j.getAttributes();for(const te in V)if(V[te].location>=0){let Z=W[te];Z===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(Z=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(Z=D.instanceColor));const U={};U.attribute=Z,Z&&Z.data&&(U.data=Z.data),R[te]=U,K++}s.attributes=R,s.attributesNum=K,s.index=q}function y(){const D=s.newAttributes;for(let F=0,j=D.length;F<j;F++)D[F]=0}function v(D){b(D,0)}function b(D,F){const j=s.newAttributes,q=s.enabledAttributes,R=s.attributeDivisors;j[D]=1,q[D]===0&&(t.enableVertexAttribArray(D),q[D]=1),R[D]!==F&&(t.vertexAttribDivisor(D,F),R[D]=F)}function E(){const D=s.newAttributes,F=s.enabledAttributes;for(let j=0,q=F.length;j<q;j++)F[j]!==D[j]&&(t.disableVertexAttribArray(j),F[j]=0)}function w(D,F,j,q,R,W,K){K===!0?t.vertexAttribIPointer(D,F,j,R,W):t.vertexAttribPointer(D,F,j,q,R,W)}function A(D,F,j,q){y();const R=q.attributes,W=j.getAttributes(),K=F.defaultAttributeValues;for(const V in W){const te=W[V];if(te.location>=0){let Y=R[V];if(Y===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(Y=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(Y=D.instanceColor)),Y!==void 0){const Z=Y.normalized,U=Y.itemSize,z=e.get(Y);if(z===void 0)continue;const ee=z.buffer,ae=z.type,fe=z.bytesPerElement,de=ae===t.INT||ae===t.UNSIGNED_INT||Y.gpuType===YO;if(Y.isInterleavedBufferAttribute){const xe=Y.data,ye=xe.stride,re=Y.offset;if(xe.isInstancedInterleavedBuffer){for(let ve=0;ve<te.locationSize;ve++)b(te.location+ve,xe.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let ve=0;ve<te.locationSize;ve++)v(te.location+ve);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let ve=0;ve<te.locationSize;ve++)w(te.location+ve,U/te.locationSize,ae,Z,ye*fe,(re+U/te.locationSize*ve)*fe,de)}else{if(Y.isInstancedBufferAttribute){for(let xe=0;xe<te.locationSize;xe++)b(te.location+xe,Y.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let xe=0;xe<te.locationSize;xe++)v(te.location+xe);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let xe=0;xe<te.locationSize;xe++)w(te.location+xe,U/te.locationSize,ae,Z,U*fe,U/te.locationSize*xe*fe,de)}}else if(K!==void 0){const Z=K[V];if(Z!==void 0)switch(Z.length){case 2:t.vertexAttrib2fv(te.location,Z);break;case 3:t.vertexAttrib3fv(te.location,Z);break;case 4:t.vertexAttrib4fv(te.location,Z);break;default:t.vertexAttrib1fv(te.location,Z)}}}}E()}function T(){I();for(const D in r){const F=r[D];for(const j in F){const q=F[j];for(const R in q)d(q[R].object),delete q[R];delete F[j]}delete r[D]}}function k(D){if(r[D.id]===void 0)return;const F=r[D.id];for(const j in F){const q=F[j];for(const R in q)d(q[R].object),delete q[R];delete F[j]}delete r[D.id]}function N(D){for(const F in r){const j=r[F];if(j[D.id]===void 0)continue;const q=j[D.id];for(const R in q)d(q[R].object),delete q[R];delete j[D.id]}}function I(){C(),a=!0,s!==i&&(s=i,u(s.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:I,resetDefaultState:C,dispose:T,releaseStatesOfGeometry:k,releaseStatesOfProgram:N,initAttributes:y,enableAttribute:v,disableUnusedAttributes:E}}function jPe(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 LPe(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!==Po&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(N){const I=N===ag&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==ml&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==mc&&!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&&(Xt("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),v=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),E=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=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:w,maxFragmentUniforms:A,vertexTextures:T,maxSamples:k}}function IPe(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new Nu,o=new un,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,w=E*4;let A=b.clippingState||null;c.value=A,A=d(x,g,w,m);for(let T=0;T!==w;++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 w=0,A=m;w!==y;++w,A+=4)a.copy(f[w]).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 UPe(t){let e=new WeakMap;function n(a,o){return o===Vk?a.mapping=Tm:o===Gk&&(a.mapping=Cm),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 DNe(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,FPe=256,_x=new mZ,cH=new yn;let FC=null,zC=0,BC=0,HC=!1;const zPe=new Je;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=zPe}=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===Tm||e.mapping===Cm?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:to,minFilter:to,generateMipmaps:!1,type:ag,format:Po,colorSpace:Nm,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}=BPe(s)),this._blurMaterial=$Pe(s,e,n),this._ggxMaterial=HPe(s,e,n)}return i}_compileMaterial(e){const n=new gl(new El,e);this._renderer.compile(n,_x)}_sceneToCubeUV(e,n,r,i,s){const c=new Ka(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 gl(new aj,new sj({name:"PMREM.Background",side:qs,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 w=0;w<6;w++){const A=w%3;A===0?(c.up.set(0,u[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+d[w],s.y,s.z)):A===1?(c.up.set(0,0,u[w]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+d[w],s.z)):(c.up.set(0,u[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+d[w]));const T=this._cubeSize;pp(i,A*T,w>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===Tm||e.mapping===Cm;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,_x)}_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,_x),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,_x)}_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&&Xt(`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:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-zu?i-w+zu:0),k=4*(this._cubeSize-A);pp(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,_x)}};function BPe(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),w=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),w.set(g,v*x*k);const D=[k,k,k,k,k,k];A.set(D,b*x*k)}const T=new El;T.setAttribute("position",new no(E,y)),T.setAttribute("uv",new no(w,v)),T.setAttribute("faceIndex",new no(A,b)),r.push(new gl(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 HPe(t,e,n){return new Oc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:FPe,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:_c,depthTest:!1,depthWrite:!1})}function $Pe(t,e,n){const r=new Float32Array(oh),i=new Je(0,1,0);return new Oc({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:_c,depthTest:!1,depthWrite:!1})}function hH(){return new Oc({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:_c,depthTest:!1,depthWrite:!1})}function fH(){return new Oc({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:_c,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 VPe(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===Tm||c===Cm;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 GPe(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&&W0("WebGLRenderer: "+r+" extension not supported."),i}}}function WPe(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 w=0,A=E.length;w<A;w+=3){const T=E[w+0],k=E[w+1],N=E[w+2];g.push(T,k,k,N,N,T)}}else if(x!==void 0){const E=x.array;y=x.version;for(let w=0,A=E.length/3-1;w<A;w+=3){const T=w+0,k=w+1,N=w+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 qPe(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 KPe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,a,o){switch(n.calls++,a){case t.TRIANGLES:n.triangles+=o*(s/3);break;case t.LINES:n.lines+=o*(s/2);break;case t.LINE_STRIP:n.lines+=o*(s-1);break;case t.LINE_LOOP:n.lines+=o*s;break;case t.POINTS:n.points+=o*s;break;default: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 XPe(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||[],w=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=mc,I.needsUpdate=!0;const C=A*4;for(let F=0;F<f;F++){const j=b[F],q=E[F],R=w[F],W=T*k*4*F;for(let K=0;K<j.count;K++){const V=K*C;x===!0&&(i.fromBufferAttribute(j,K),N[W+V+0]=i.x,N[W+V+1]=i.y,N[W+V+2]=i.z,N[W+V+3]=0),y===!0&&(i.fromBufferAttribute(q,K),N[W+V+4]=i.x,N[W+V+5]=i.y,N[W+V+6]=i.z,N[W+V+7]=0),v===!0&&(i.fromBufferAttribute(R,K),N[W+V+8]=i.x,N[W+V+9]=i.y,N[W+V+10]=i.z,N[W+V+11]=R.itemSize===4?i.w:1)}}g={count:f,texture:I,size:new on(T,k)},r.set(o,g),o.addEventListener("dispose",D)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)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 YPe(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 Ho,pH=new dZ(1,1),bZ=new JY,vZ=new gNe,yZ=new cZ,mH=[],gH=[],xH=new Float32Array(16),bH=new Float32Array(9),vH=new Float32Array(4);function lg(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 fi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function pi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function 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 ZPe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function QPe(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(fi(n,e))return;t.uniform2fv(this.addr,e),pi(n,e)}}function JPe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(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(fi(n,e))return;t.uniform3fv(this.addr,e),pi(n,e)}}function eRe(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(fi(n,e))return;t.uniform4fv(this.addr,e),pi(n,e)}}function tRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(fi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),pi(n,e)}else{if(fi(n,r))return;vH.set(r),t.uniformMatrix2fv(this.addr,!1,vH),pi(n,r)}}function nRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(fi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),pi(n,e)}else{if(fi(n,r))return;bH.set(r),t.uniformMatrix3fv(this.addr,!1,bH),pi(n,r)}}function rRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(fi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),pi(n,e)}else{if(fi(n,r))return;xH.set(r),t.uniformMatrix4fv(this.addr,!1,xH),pi(n,r)}}function iRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function sRe(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(fi(n,e))return;t.uniform2iv(this.addr,e),pi(n,e)}}function aRe(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(fi(n,e))return;t.uniform3iv(this.addr,e),pi(n,e)}}function oRe(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(fi(n,e))return;t.uniform4iv(this.addr,e),pi(n,e)}}function lRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function cRe(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(fi(n,e))return;t.uniform2uiv(this.addr,e),pi(n,e)}}function uRe(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(fi(n,e))return;t.uniform3uiv(this.addr,e),pi(n,e)}}function dRe(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(fi(n,e))return;t.uniform4uiv(this.addr,e),pi(n,e)}}function hRe(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 fRe(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 pRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||yZ,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.setTexture2DArray(e||bZ,i)}function gRe(t){switch(t){case 5126:return ZPe;case 35664:return QPe;case 35665:return JPe;case 35666:return eRe;case 35674:return tRe;case 35675:return nRe;case 35676:return rRe;case 5124:case 35670:return iRe;case 35667:case 35671:return sRe;case 35668:case 35672:return aRe;case 35669:case 35673:return oRe;case 5125:return lRe;case 36294:return cRe;case 36295:return uRe;case 36296:return dRe;case 35678:case 36198:case 36298:case 36306:case 35682:return hRe;case 35679:case 36299:case 36307:return fRe;case 35680:case 36300:case 36308:case 36293:return pRe;case 36289:case 36303:case 36311:case 36292:return mRe}}function xRe(t,e){t.uniform1fv(this.addr,e)}function bRe(t,e){const n=lg(e,this.size,2);t.uniform2fv(this.addr,n)}function vRe(t,e){const n=lg(e,this.size,3);t.uniform3fv(this.addr,n)}function yRe(t,e){const n=lg(e,this.size,4);t.uniform4fv(this.addr,n)}function _Re(t,e){const n=lg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function wRe(t,e){const n=lg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function SRe(t,e){const n=lg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function ERe(t,e){t.uniform1iv(this.addr,e)}function MRe(t,e){t.uniform2iv(this.addr,e)}function ARe(t,e){t.uniform3iv(this.addr,e)}function TRe(t,e){t.uniform4iv(this.addr,e)}function CRe(t,e){t.uniform1uiv(this.addr,e)}function NRe(t,e){t.uniform2uiv(this.addr,e)}function kRe(t,e){t.uniform3uiv(this.addr,e)}function PRe(t,e){t.uniform4uiv(this.addr,e)}function RRe(t,e,n){const r=this.cache,i=e.length,s=zE(n,i);fi(r,s)||(t.uniform1iv(this.addr,s),pi(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||xZ,s[a])}function DRe(t,e,n){const r=this.cache,i=e.length,s=zE(n,i);fi(r,s)||(t.uniform1iv(this.addr,s),pi(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||vZ,s[a])}function ORe(t,e,n){const r=this.cache,i=e.length,s=zE(n,i);fi(r,s)||(t.uniform1iv(this.addr,s),pi(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||yZ,s[a])}function jRe(t,e,n){const r=this.cache,i=e.length,s=zE(n,i);fi(r,s)||(t.uniform1iv(this.addr,s),pi(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||bZ,s[a])}function LRe(t){switch(t){case 5126:return xRe;case 35664:return bRe;case 35665:return vRe;case 35666:return yRe;case 35674:return _Re;case 35675:return wRe;case 35676:return SRe;case 5124:case 35670:return ERe;case 35667:case 35671:return MRe;case 35668:case 35672:return ARe;case 35669:case 35673:return TRe;case 5125:return CRe;case 36294:return NRe;case 36295:return kRe;case 36296:return PRe;case 35678:case 36198:case 36298:case 36306:case 35682:return RRe;case 35679:case 36299:case 36307:return DRe;case 35680:case 36300:case 36308:case 36293:return ORe;case 36289:case 36303:case 36311:case 36292:return jRe}}let IRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=gRe(n.type)}},URe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=LRe(n.type)}},FRe=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 zRe(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 IRe(o,t,e):new URe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new FRe(o),yH(n,f)),n=f}}}let h1=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);zRe(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 BRe=37297;let HRe=0;function $Re(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 un;function VRe(t){Tn._getMatrix(wH,Tn.workingColorSpace,t);const e=`mat3( ${wH.elements.map(n=>n.toFixed(4))} )`;switch(Tn.getTransfer(t)){case Cw:return[e,"LinearTransferOETF"];case Wn:return[e,"sRGBTransferOETF"];default:return Xt("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+`
- `+$Re(t.getShaderSource(e),o)}else return s}function GRe(t,e){const n=VRe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function WRe(t,e){let n;switch(e){case $Ce:n="Linear";break;case VCe:n="Reinhard";break;case GCe:n="Cineon";break;case WCe:n="ACESFilmic";break;case KCe:n="AgX";break;case XCe:n="Neutral";break;case qCe:n="Custom";break;default:Xt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const t_=new Je;function qRe(){Tn.getLuminanceCoefficients(t_);const t=t_.x.toFixed(4),e=t_.y.toFixed(4),n=t_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function KRe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Lx).join(`
- `)}function XRe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function YRe(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 Lx(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 ZRe=/^[ \t]*#include +<([\w\d./]+)>/gm;function EP(t){return t.replace(ZRe,JRe)}const QRe=new Map;function JRe(t,e){let n=sn[e];if(n===void 0){const r=QRe.get(e);if(r!==void 0)n=sn[r],Xt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return EP(n)}const eDe=/#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(eDe,tDe)}function tDe(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 nDe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===IY?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===wCe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===rc&&(e="SHADOWMAP_TYPE_VSM"),e}function rDe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Tm:case Cm:e="ENVMAP_TYPE_CUBE";break;case IE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function iDe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Cm:e="ENVMAP_MODE_REFRACTION";break}return e}function sDe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case XO:e="ENVMAP_BLENDING_MULTIPLY";break;case BCe:e="ENVMAP_BLENDING_MIX";break;case HCe:e="ENVMAP_BLENDING_ADD";break}return e}function aDe(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 oDe(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const c=nDe(n),u=rDe(n),d=iDe(n),f=sDe(n),g=aDe(n),m=KRe(n),x=XRe(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(Lx).join(`
- `),v.length>0&&(v+=`
- `),b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Lx).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(Lx).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?sn.tonemapping_pars_fragment:"",n.toneMapping!==Xu?WRe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",sn.colorspace_pars_fragment,GRe("linearToOutputTexel",n.outputColorSpace),qRe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Lx).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 w=E+v+a,A=E+b+o,T=_H(i,i.VERTEX_SHADER,w),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 te=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(te=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,k);else{const Z=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+`
- `+Z+`
- `+U)}else W!==""?Xt("WebGLProgram: Program Info Log:",W):(K===""||V==="")&&(Y=!1);Y&&(F.diagnostics={runnable:te,programLog:W,vertexShader:{log:K,prefix:v},fragmentShader:{log:V,prefix:b}})}i.deleteShader(T),i.deleteShader(k),I=new h1(i,y),C=YRe(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,BRe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=HRe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=k,this}let lDe=0,cDe=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 uDe(e),n.set(e,r)),r}},uDe=class{constructor(e){this.id=lDe++,this.code=e,this.usedTimes=0}};function dDe(t,e,n,r,i,s,a){const o=new tZ,c=new cDe,u=new Set,d=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(C){return u.add(C),C===0?"uv":`uv${C}`}function v(C,D,F,j,q){const R=j.fog,W=q.geometry,K=C.isMeshStandardMaterial?j.environment:null,V=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),te=V&&V.mapping===IE?V.image.height:null,Y=x[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&Xt("WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const Z=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=Z!==void 0?Z.length:0;let z=0;W.morphAttributes.position!==void 0&&(z=1),W.morphAttributes.normal!==void 0&&(z=2),W.morphAttributes.color!==void 0&&(z=3);let ee,ae,fe,de;if(Y){const Ot=tl[Y];ee=Ot.vertexShader,ae=Ot.fragmentShader}else ee=C.vertexShader,ae=C.fragmentShader,c.update(C),fe=c.getVertexShaderID(C),de=c.getFragmentShaderID(C);const xe=t.getRenderTarget(),ye=t.state.buffers.depth.getReversed(),re=q.isInstancedMesh===!0,ve=q.isBatchedMesh===!0,je=!!C.map,ue=!!C.matcap,ut=!!V,$=!!C.aoMap,H=!!C.lightMap,ie=!!C.bumpMap,G=!!C.normalMap,J=!!C.displacementMap,le=!!C.emissiveMap,Pe=!!C.metalnessMap,Ne=!!C.roughnessMap,Se=C.anisotropy>0,B=C.clearcoat>0,L=C.dispersion>0,ne=C.iridescence>0,be=C.sheen>0,we=C.transmission>0,ge=Se&&!!C.anisotropyMap,me=B&&!!C.clearcoatMap,Ae=B&&!!C.clearcoatNormalMap,ze=B&&!!C.clearcoatRoughnessMap,st=ne&&!!C.iridescenceMap,Ve=ne&&!!C.iridescenceThicknessMap,ce=be&&!!C.sheenColorMap,Ye=be&&!!C.sheenRoughnessMap,$e=!!C.specularMap,Ze=!!C.specularColorMap,at=!!C.specularIntensityMap,Q=we&&!!C.transmissionMap,Fe=we&&!!C.thicknessMap,pe=!!C.gradientMap,Ue=!!C.alphaMap,Ce=C.alphaTest>0,_e=!!C.alphaHash,He=!!C.extensions;let ht=Xu;C.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(ht=t.toneMapping);const wt={shaderID:Y,shaderType:C.type,shaderName:C.name,vertexShader:ee,fragmentShader:ae,defines:C.defines,customVertexShaderID:fe,customFragmentShaderID:de,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:ve,batchingColor:ve&&q._colorsTexture!==null,instancing:re,instancingColor:re&&q.instanceColor!==null,instancingMorph:re&&q.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:Nm,alphaToCoverage:!!C.alphaToCoverage,map:je,matcap:ue,envMap:ut,envMapMode:ut&&V.mapping,envMapCubeUVHeight:te,aoMap:$,lightMap:H,bumpMap:ie,normalMap:G,displacementMap:g&&J,emissiveMap:le,normalMapObjectSpace:G&&C.normalMapType===JCe,normalMapTangentSpace:G&&C.normalMapType===WY,metalnessMap:Pe,roughnessMap:Ne,anisotropy:Se,anisotropyMap:ge,clearcoat:B,clearcoatMap:me,clearcoatNormalMap:Ae,clearcoatRoughnessMap:ze,dispersion:L,iridescence:ne,iridescenceMap:st,iridescenceThicknessMap:Ve,sheen:be,sheenColorMap:ce,sheenRoughnessMap:Ye,specularMap:$e,specularColorMap:Ze,specularIntensityMap:at,transmission:we,transmissionMap:Q,thicknessMap:Fe,gradientMap:pe,opaque:C.transparent===!1&&C.blending===im&&C.alphaToCoverage===!1,alphaMap:Ue,alphaTest:Ce,alphaHash:_e,combine:C.combine,mapUv:je&&y(C.map.channel),aoMapUv:$&&y(C.aoMap.channel),lightMapUv:H&&y(C.lightMap.channel),bumpMapUv:ie&&y(C.bumpMap.channel),normalMapUv:G&&y(C.normalMap.channel),displacementMapUv:J&&y(C.displacementMap.channel),emissiveMapUv:le&&y(C.emissiveMap.channel),metalnessMapUv:Pe&&y(C.metalnessMap.channel),roughnessMapUv:Ne&&y(C.roughnessMap.channel),anisotropyMapUv:ge&&y(C.anisotropyMap.channel),clearcoatMapUv:me&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:Ae&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ze&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:st&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:Ve&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Ye&&y(C.sheenRoughnessMap.channel),specularMapUv:$e&&y(C.specularMap.channel),specularColorMapUv:Ze&&y(C.specularColorMap.channel),specularIntensityMapUv:at&&y(C.specularIntensityMap.channel),transmissionMapUv:Q&&y(C.transmissionMap.channel),thicknessMapUv:Fe&&y(C.thicknessMap.channel),alphaMapUv:Ue&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(G||Se),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(je||Ue),fog:!!R,useFog:C.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:C.flatShading===!0&&C.wireframe===!1,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:ye,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:z,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:ht,decodeVideoTexture:je&&C.map.isVideoTexture===!0&&Tn.getTransfer(C.map.colorSpace)===Wn,decodeVideoTextureEmissive:le&&C.emissiveMap.isVideoTexture===!0&&Tn.getTransfer(C.emissiveMap.colorSpace)===Wn,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===nl,flipSided:C.side===qs,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:He&&C.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(He&&C.extensions.multiDraw===!0||ve)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return wt.vertexUv1s=u.has(1),wt.vertexUv2s=u.has(2),wt.vertexUv3s=u.has(3),u.clear(),wt}function b(C){const D=[];if(C.shaderID?D.push(C.shaderID):(D.push(C.customVertexShaderID),D.push(C.customFragmentShaderID)),C.defines!==void 0)for(const F in C.defines)D.push(F),D.push(C.defines[F]);return C.isRawShaderMaterial===!1&&(E(D,C),w(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 w(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=tl[D];F=NNe.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 oDe(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 hDe(){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 fDe(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||fDe),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 pDe(){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 mDe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Je,color:new yn};break;case"SpotLight":n={position:new Je,direction:new Je,color:new yn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Je,color:new yn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Je,skyColor:new yn,groundColor:new yn};break;case"RectAreaLight":n={color:new yn,position:new Je,halfWidth:new Je,halfHeight:new Je};break}return t[e.id]=n,n}}}function gDe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let xDe=0;function bDe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function vDe(t){const e=new mDe,n=gDe(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new Je);const i=new Je,s=new 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,w=0,A=0,T=0,k=0,N=0;u.sort(bDe);for(let C=0,D=u.length;C<D;C++){const F=u[C],j=F.color,q=F.intensity,R=F.distance,W=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=j.r*q,f+=j.g*q,g+=j.b*q;else if(F.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(F.sh.coefficients[K],q);N++}else if(F.isDirectionalLight){const K=e.get(F);if(K.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const V=F.shadow,te=n.get(F);te.shadowIntensity=V.intensity,te.shadowBias=V.bias,te.shadowNormalBias=V.normalBias,te.shadowRadius=V.radius,te.shadowMapSize=V.mapSize,r.directionalShadow[m]=te,r.directionalShadowMap[m]=W,r.directionalShadowMatrix[m]=F.shadow.matrix,E++}r.directional[m]=K,m++}else if(F.isSpotLight){const K=e.get(F);K.position.setFromMatrixPosition(F.matrixWorld),K.color.copy(j).multiplyScalar(q),K.distance=R,K.coneCos=Math.cos(F.angle),K.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),K.decay=F.decay,r.spot[y]=K;const V=F.shadow;if(F.map&&(r.spotLightMap[T]=F.map,T++,V.updateMatrices(F),F.castShadow&&k++),r.spotLightMatrix[y]=V.matrix,F.castShadow){const te=n.get(F);te.shadowIntensity=V.intensity,te.shadowBias=V.bias,te.shadowNormalBias=V.normalBias,te.shadowRadius=V.radius,te.shadowMapSize=V.mapSize,r.spotShadow[y]=te,r.spotShadowMap[y]=W,A++}y++}else if(F.isRectAreaLight){const K=e.get(F);K.color.copy(j).multiplyScalar(q),K.halfWidth.set(F.width*.5,0,0),K.halfHeight.set(0,F.height*.5,0),r.rectArea[v]=K,v++}else if(F.isPointLight){const K=e.get(F);if(K.color.copy(F.color).multiplyScalar(F.intensity),K.distance=F.distance,K.decay=F.decay,F.castShadow){const V=F.shadow,te=n.get(F);te.shadowIntensity=V.intensity,te.shadowBias=V.bias,te.shadowNormalBias=V.normalBias,te.shadowRadius=V.radius,te.shadowMapSize=V.mapSize,te.shadowCameraNear=V.camera.near,te.shadowCameraFar=V.camera.far,r.pointShadow[x]=te,r.pointShadowMap[x]=W,r.pointShadowMatrix[x]=F.shadow.matrix,w++}r.point[x]=K,x++}else if(F.isHemisphereLight){const K=e.get(F);K.skyColor.copy(F.color).multiplyScalar(q),K.groundColor.copy(F.groundColor).multiplyScalar(q),r.hemi[b]=K,b++}}v>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Et.LTC_FLOAT_1,r.rectAreaLTC2=Et.LTC_FLOAT_2):(r.rectAreaLTC1=Et.LTC_HALF_1,r.rectAreaLTC2=Et.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=g;const I=r.hash;(I.directionalLength!==m||I.pointLength!==x||I.spotLength!==y||I.rectAreaLength!==v||I.hemiLength!==b||I.numDirectionalShadows!==E||I.numPointShadows!==w||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=w,r.pointShadowMap.length=w,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=w,r.spotLightMatrix.length=A+T-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=w,I.numSpotShadows=A,I.numSpotMaps=T,I.numLightProbes=N,r.version=xDe++)}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 w=u[b];if(w.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(v),f++}else if(w.isSpotLight){const A=r.spot[m];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(v),A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(v),m++}else if(w.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(v),a.identity(),s.copy(w.matrixWorld),s.premultiply(v),a.extractRotation(s),A.halfWidth.set(w.width*.5,0,0),A.halfHeight.set(0,w.height*.5,0),A.halfWidth.applyMatrix4(a),A.halfHeight.applyMatrix4(a),x++}else if(w.isPointLight){const A=r.point[g];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(v),g++}else if(w.isHemisphereLight){const A=r.hemi[y];A.direction.setFromMatrixPosition(w.matrixWorld),A.direction.transformDirection(v),y++}}}return{setup:o,setupView:c,state:r}}function kH(t){const e=new vDe(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 yDe(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 _De=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,wDe=`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 SDe(t,e,n){let r=new oj;const i=new on,s=new on,a=new Yr,o=new $Ne({depthPacking:QCe}),c=new VNe,u={},d=n.maxTextureSize,f={[dd]:qs,[qs]:dd,[nl]:nl},g=new Oc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new on},radius:{value:4}},vertexShader:_De,fragmentShader:wDe}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const x=new El;x.setAttribute("position",new no(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new gl(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(_c),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!==rc&&this.type===rc,R=b===rc&&this.type!==rc;for(let W=0,K=k.length;W<K;W++){const V=k[W],te=V.shadow;if(te===void 0){Xt("WebGLShadowMap:",V,"has no shadow.");continue}if(te.autoUpdate===!1&&te.needsUpdate===!1)continue;i.copy(te.mapSize);const Y=te.getFrameExtents();if(i.multiply(Y),s.copy(te.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Y.x),i.x=s.x*Y.x,te.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Y.y),i.y=s.y*Y.y,te.mapSize.y=s.y)),te.map===null||q===!0||R===!0){const U=this.type!==rc?{minFilter:ya,magFilter:ya}:{};te.map!==null&&te.map.dispose(),te.map=new ef(i.x,i.y,U),te.map.texture.name=V.name+".shadowMap",te.camera.updateProjectionMatrix()}t.setRenderTarget(te.map),t.clear();const Z=te.getViewportCount();for(let U=0;U<Z;U++){const z=te.getViewport(U);a.set(s.x*z.x,s.y*z.y,s.x*z.z,s.y*z.w),j.viewport(a),te.updateMatrices(V,U),r=te.getFrustum(),A(N,I,te.camera,V,this.type)}te.isPointLightShadow!==!0&&this.type===rc&&E(te,I),te.needsUpdate=!1}b=this.type,v.needsUpdate=!1,t.setRenderTarget(C,D,F)};function E(k,N){const I=e.update(y);g.defines.VSM_SAMPLES!==k.blurSamples&&(g.defines.VSM_SAMPLES=k.blurSamples,m.defines.VSM_SAMPLES=k.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new 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 w(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===rc?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===rc)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,k.matrixWorld);const q=e.update(k),R=k.material;if(Array.isArray(R)){const W=q.groups;for(let K=0,V=W.length;K<V;K++){const te=W[K],Y=R[te.materialIndex];if(Y&&Y.visible){const Z=w(k,Y,C,D);k.onBeforeShadow(t,k,N,I,q,Z,te),t.renderBufferDirect(I,null,q,Z,k,te),k.onAfterShadow(t,k,N,I,q,Z,te)}}}else if(R.visible){const W=w(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 EDe={[Ik]:Uk,[Fk]:Hk,[zk]:$k,[Am]:Bk,[Uk]:Ik,[Hk]:Fk,[$k]:zk,[Bk]:Am};function MDe(t,e){function n(){let Q=!1;const Fe=new Yr;let pe=null;const Ue=new Yr(0,0,0,0);return{setMask:function(Ce){pe!==Ce&&!Q&&(t.colorMask(Ce,Ce,Ce,Ce),pe=Ce)},setLocked:function(Ce){Q=Ce},setClear:function(Ce,_e,He,ht,wt){wt===!0&&(Ce*=ht,_e*=ht,He*=ht),Fe.set(Ce,_e,He,ht),Ue.equals(Fe)===!1&&(t.clearColor(Ce,_e,He,ht),Ue.copy(Fe))},reset:function(){Q=!1,pe=null,Ue.set(-1,0,0,0)}}}function r(){let Q=!1,Fe=!1,pe=null,Ue=null,Ce=null;return{setReversed:function(_e){if(Fe!==_e){const He=e.get("EXT_clip_control");_e?He.clipControlEXT(He.LOWER_LEFT_EXT,He.ZERO_TO_ONE_EXT):He.clipControlEXT(He.LOWER_LEFT_EXT,He.NEGATIVE_ONE_TO_ONE_EXT),Fe=_e;const ht=Ce;Ce=null,this.setClear(ht)}},getReversed:function(){return Fe},setTest:function(_e){_e?xe(t.DEPTH_TEST):ye(t.DEPTH_TEST)},setMask:function(_e){pe!==_e&&!Q&&(t.depthMask(_e),pe=_e)},setFunc:function(_e){if(Fe&&(_e=EDe[_e]),Ue!==_e){switch(_e){case Ik:t.depthFunc(t.NEVER);break;case Uk:t.depthFunc(t.ALWAYS);break;case Fk:t.depthFunc(t.LESS);break;case Am: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)}Ue=_e}},setLocked:function(_e){Q=_e},setClear:function(_e){Ce!==_e&&(Fe&&(_e=1-_e),t.clearDepth(_e),Ce=_e)},reset:function(){Q=!1,pe=null,Ue=null,Ce=null,Fe=!1}}}function i(){let Q=!1,Fe=null,pe=null,Ue=null,Ce=null,_e=null,He=null,ht=null,wt=null;return{setTest:function(Ot){Q||(Ot?xe(t.STENCIL_TEST):ye(t.STENCIL_TEST))},setMask:function(Ot){Fe!==Ot&&!Q&&(t.stencilMask(Ot),Fe=Ot)},setFunc:function(Ot,cn,It){(pe!==Ot||Ue!==cn||Ce!==It)&&(t.stencilFunc(Ot,cn,It),pe=Ot,Ue=cn,Ce=It)},setOp:function(Ot,cn,It){(_e!==Ot||He!==cn||ht!==It)&&(t.stencilOp(Ot,cn,It),_e=Ot,He=cn,ht=It)},setLocked:function(Ot){Q=Ot},setClear:function(Ot){wt!==Ot&&(t.clearStencil(Ot),wt=Ot)},reset:function(){Q=!1,Fe=null,pe=null,Ue=null,Ce=null,_e=null,He=null,ht=null,wt=null}}}const s=new n,a=new r,o=new i,c=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,m=[],x=null,y=!1,v=null,b=null,E=null,w=null,A=null,T=null,k=null,N=new yn(0,0,0),I=0,C=!1,D=null,F=null,j=null,q=null,R=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,V=0;const te=t.getParameter(t.VERSION);te.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(te)[1]),K=V>=1):te.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),K=V>=2);let Y=null,Z={};const U=t.getParameter(t.SCISSOR_BOX),z=t.getParameter(t.VIEWPORT),ee=new Yr().fromArray(U),ae=new Yr().fromArray(z);function fe(Q,Fe,pe,Ue){const Ce=new Uint8Array(4),_e=t.createTexture();t.bindTexture(Q,_e),t.texParameteri(Q,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Q,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let He=0;He<pe;He++)Q===t.TEXTURE_3D||Q===t.TEXTURE_2D_ARRAY?t.texImage3D(Fe,0,t.RGBA,1,1,Ue,0,t.RGBA,t.UNSIGNED_BYTE,Ce):t.texImage2D(Fe+He,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ce);return _e}const de={};de[t.TEXTURE_2D]=fe(t.TEXTURE_2D,t.TEXTURE_2D,1),de[t.TEXTURE_CUBE_MAP]=fe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),de[t.TEXTURE_2D_ARRAY]=fe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),de[t.TEXTURE_3D]=fe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),xe(t.DEPTH_TEST),a.setFunc(Am),ie(!1),G(C8),xe(t.CULL_FACE),$(_c);function xe(Q){d[Q]!==!0&&(t.enable(Q),d[Q]=!0)}function ye(Q){d[Q]!==!1&&(t.disable(Q),d[Q]=!1)}function re(Q,Fe){return f[Q]!==Fe?(t.bindFramebuffer(Q,Fe),f[Q]=Fe,Q===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Fe),Q===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Fe),!0):!1}function ve(Q,Fe){let pe=m,Ue=!1;if(Q){pe=g.get(Fe),pe===void 0&&(pe=[],g.set(Fe,pe));const Ce=Q.textures;if(pe.length!==Ce.length||pe[0]!==t.COLOR_ATTACHMENT0){for(let _e=0,He=Ce.length;_e<He;_e++)pe[_e]=t.COLOR_ATTACHMENT0+_e;pe.length=Ce.length,Ue=!0}}else pe[0]!==t.BACK&&(pe[0]=t.BACK,Ue=!0);Ue&&t.drawBuffers(pe)}function je(Q){return x!==Q?(t.useProgram(Q),x=Q,!0):!1}const ue={[ah]:t.FUNC_ADD,[ECe]:t.FUNC_SUBTRACT,[MCe]:t.FUNC_REVERSE_SUBTRACT};ue[ACe]=t.MIN,ue[TCe]=t.MAX;const ut={[CCe]:t.ZERO,[NCe]:t.ONE,[kCe]:t.SRC_COLOR,[jk]:t.SRC_ALPHA,[LCe]:t.SRC_ALPHA_SATURATE,[OCe]:t.DST_COLOR,[RCe]:t.DST_ALPHA,[PCe]:t.ONE_MINUS_SRC_COLOR,[Lk]:t.ONE_MINUS_SRC_ALPHA,[jCe]:t.ONE_MINUS_DST_COLOR,[DCe]:t.ONE_MINUS_DST_ALPHA,[ICe]:t.CONSTANT_COLOR,[UCe]:t.ONE_MINUS_CONSTANT_COLOR,[FCe]:t.CONSTANT_ALPHA,[zCe]:t.ONE_MINUS_CONSTANT_ALPHA};function $(Q,Fe,pe,Ue,Ce,_e,He,ht,wt,Ot){if(Q===_c){y===!0&&(ye(t.BLEND),y=!1);return}if(y===!1&&(xe(t.BLEND),y=!0),Q!==SCe){if(Q!==v||Ot!==C){if((b!==ah||A!==ah)&&(t.blendEquation(t.FUNC_ADD),b=ah,A=ah),Ot)switch(Q){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: ",Q);break}else switch(Q){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: ",Q);break}E=null,w=null,T=null,k=null,N.set(0,0,0),I=0,v=Q,C=Ot}return}Ce=Ce||Fe,_e=_e||pe,He=He||Ue,(Fe!==b||Ce!==A)&&(t.blendEquationSeparate(ue[Fe],ue[Ce]),b=Fe,A=Ce),(pe!==E||Ue!==w||_e!==T||He!==k)&&(t.blendFuncSeparate(ut[pe],ut[Ue],ut[_e],ut[He]),E=pe,w=Ue,T=_e,k=He),(ht.equals(N)===!1||wt!==I)&&(t.blendColor(ht.r,ht.g,ht.b,wt),N.copy(ht),I=wt),v=Q,C=!1}function H(Q,Fe){Q.side===nl?ye(t.CULL_FACE):xe(t.CULL_FACE);let pe=Q.side===qs;Fe&&(pe=!pe),ie(pe),Q.blending===im&&Q.transparent===!1?$(_c):$(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.blendColor,Q.blendAlpha,Q.premultipliedAlpha),a.setFunc(Q.depthFunc),a.setTest(Q.depthTest),a.setMask(Q.depthWrite),s.setMask(Q.colorWrite);const Ue=Q.stencilWrite;o.setTest(Ue),Ue&&(o.setMask(Q.stencilWriteMask),o.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),o.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),le(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?xe(t.SAMPLE_ALPHA_TO_COVERAGE):ye(t.SAMPLE_ALPHA_TO_COVERAGE)}function ie(Q){D!==Q&&(Q?t.frontFace(t.CW):t.frontFace(t.CCW),D=Q)}function G(Q){Q!==yCe?(xe(t.CULL_FACE),Q!==F&&(Q===C8?t.cullFace(t.BACK):Q===_Ce?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ye(t.CULL_FACE),F=Q}function J(Q){Q!==j&&(K&&t.lineWidth(Q),j=Q)}function le(Q,Fe,pe){Q?(xe(t.POLYGON_OFFSET_FILL),(q!==Fe||R!==pe)&&(t.polygonOffset(Fe,pe),q=Fe,R=pe)):ye(t.POLYGON_OFFSET_FILL)}function Pe(Q){Q?xe(t.SCISSOR_TEST):ye(t.SCISSOR_TEST)}function Ne(Q){Q===void 0&&(Q=t.TEXTURE0+W-1),Y!==Q&&(t.activeTexture(Q),Y=Q)}function Se(Q,Fe,pe){pe===void 0&&(Y===null?pe=t.TEXTURE0+W-1:pe=Y);let Ue=Z[pe];Ue===void 0&&(Ue={type:void 0,texture:void 0},Z[pe]=Ue),(Ue.type!==Q||Ue.texture!==Fe)&&(Y!==pe&&(t.activeTexture(pe),Y=pe),t.bindTexture(Q,Fe||de[Q]),Ue.type=Q,Ue.texture=Fe)}function B(){const Q=Z[Y];Q!==void 0&&Q.type!==void 0&&(t.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ne(){try{t.compressedTexImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function be(){try{t.texSubImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function we(){try{t.texSubImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ge(){try{t.compressedTexSubImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function me(){try{t.compressedTexSubImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function Ae(){try{t.texStorage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ze(){try{t.texStorage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function st(){try{t.texImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function Ve(){try{t.texImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ce(Q){ee.equals(Q)===!1&&(t.scissor(Q.x,Q.y,Q.z,Q.w),ee.copy(Q))}function Ye(Q){ae.equals(Q)===!1&&(t.viewport(Q.x,Q.y,Q.z,Q.w),ae.copy(Q))}function $e(Q,Fe){let pe=u.get(Fe);pe===void 0&&(pe=new WeakMap,u.set(Fe,pe));let Ue=pe.get(Q);Ue===void 0&&(Ue=t.getUniformBlockIndex(Fe,Q.name),pe.set(Q,Ue))}function Ze(Q,Fe){const Ue=u.get(Fe).get(Q);c.get(Fe)!==Ue&&(t.uniformBlockBinding(Fe,Ue,Q.__bindingPointIndex),c.set(Fe,Ue))}function at(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),a.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Y=null,Z={},f={},g=new WeakMap,m=[],x=null,y=!1,v=null,b=null,E=null,w=null,A=null,T=null,k=null,N=new yn(0,0,0),I=0,C=!1,D=null,F=null,j=null,q=null,R=null,ee.set(0,0,t.canvas.width,t.canvas.height),ae.set(0,0,t.canvas.width,t.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:xe,disable:ye,bindFramebuffer:re,drawBuffers:ve,useProgram:je,setBlending:$,setMaterial:H,setFlipSided:ie,setCullFace:G,setLineWidth:J,setPolygonOffset:le,setScissorTest:Pe,activeTexture:Ne,bindTexture:Se,unbindTexture:B,compressedTexImage2D:L,compressedTexImage3D:ne,texImage2D:st,texImage3D:Ve,updateUBOMapping:$e,uniformBlockBinding:Ze,texStorage2D:Ae,texStorage3D:ze,texSubImage2D:be,texSubImage3D:we,compressedTexSubImage2D:ge,compressedTexSubImage3D:me,scissor:ce,viewport:Ye,reset:at}}function ADe(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 on,d=new WeakMap;let f;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(B,L){return m?new OffscreenCanvas(B,L):kw("canvas")}function y(B,L,ne){let be=1;const we=Se(B);if((we.width>ne||we.height>ne)&&(be=ne/Math.max(we.width,we.height)),be<1)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap||typeof VideoFrame<"u"&&B instanceof VideoFrame){const ge=Math.floor(be*we.width),me=Math.floor(be*we.height);f===void 0&&(f=x(ge,me));const Ae=L?x(ge,me):f;return Ae.width=ge,Ae.height=me,Ae.getContext("2d").drawImage(B,0,0,ge,me),Xt("WebGLRenderer: Texture has been resized from ("+we.width+"x"+we.height+") to ("+ge+"x"+me+")."),Ae}else return"data"in B&&Xt("WebGLRenderer: Image in DataTexture is too big ("+we.width+"x"+we.height+")."),B;return B}function v(B){return B.generateMipmaps}function b(B){t.generateMipmap(B)}function E(B){return B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:B.isWebGL3DRenderTarget?t.TEXTURE_3D:B.isWebGLArrayRenderTarget||B.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(B,L,ne,be,we=!1){if(B!==null){if(t[B]!==void 0)return t[B];Xt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ge=L;if(L===t.RED&&(ne===t.FLOAT&&(ge=t.R32F),ne===t.HALF_FLOAT&&(ge=t.R16F),ne===t.UNSIGNED_BYTE&&(ge=t.R8)),L===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ge=t.R8UI),ne===t.UNSIGNED_SHORT&&(ge=t.R16UI),ne===t.UNSIGNED_INT&&(ge=t.R32UI),ne===t.BYTE&&(ge=t.R8I),ne===t.SHORT&&(ge=t.R16I),ne===t.INT&&(ge=t.R32I)),L===t.RG&&(ne===t.FLOAT&&(ge=t.RG32F),ne===t.HALF_FLOAT&&(ge=t.RG16F),ne===t.UNSIGNED_BYTE&&(ge=t.RG8)),L===t.RG_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ge=t.RG8UI),ne===t.UNSIGNED_SHORT&&(ge=t.RG16UI),ne===t.UNSIGNED_INT&&(ge=t.RG32UI),ne===t.BYTE&&(ge=t.RG8I),ne===t.SHORT&&(ge=t.RG16I),ne===t.INT&&(ge=t.RG32I)),L===t.RGB_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ge=t.RGB8UI),ne===t.UNSIGNED_SHORT&&(ge=t.RGB16UI),ne===t.UNSIGNED_INT&&(ge=t.RGB32UI),ne===t.BYTE&&(ge=t.RGB8I),ne===t.SHORT&&(ge=t.RGB16I),ne===t.INT&&(ge=t.RGB32I)),L===t.RGBA_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ge=t.RGBA8UI),ne===t.UNSIGNED_SHORT&&(ge=t.RGBA16UI),ne===t.UNSIGNED_INT&&(ge=t.RGBA32UI),ne===t.BYTE&&(ge=t.RGBA8I),ne===t.SHORT&&(ge=t.RGBA16I),ne===t.INT&&(ge=t.RGBA32I)),L===t.RGB&&(ne===t.UNSIGNED_INT_5_9_9_9_REV&&(ge=t.RGB9_E5),ne===t.UNSIGNED_INT_10F_11F_11F_REV&&(ge=t.R11F_G11F_B10F)),L===t.RGBA){const me=we?Cw:Tn.getTransfer(be);ne===t.FLOAT&&(ge=t.RGBA32F),ne===t.HALF_FLOAT&&(ge=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ge=me===Wn?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ge=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ge=t.RGB5_A1)}return(ge===t.R16F||ge===t.R32F||ge===t.RG16F||ge===t.RG32F||ge===t.RGBA16F||ge===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function A(B,L){let ne;return B?L===null||L===Qh||L===$0?ne=t.DEPTH24_STENCIL8:L===mc?ne=t.DEPTH32F_STENCIL8:L===H0&&(ne=t.DEPTH24_STENCIL8,Xt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Qh||L===$0?ne=t.DEPTH_COMPONENT24:L===mc?ne=t.DEPTH_COMPONENT32F:L===H0&&(ne=t.DEPTH_COMPONENT16),ne}function T(B,L){return v(B)===!0||B.isFramebufferTexture&&B.minFilter!==ya&&B.minFilter!==to?Math.log2(Math.max(L.width,L.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?L.mipmaps.length:1}function k(B){const L=B.target;L.removeEventListener("dispose",k),I(L),L.isVideoTexture&&d.delete(L)}function N(B){const L=B.target;L.removeEventListener("dispose",N),D(L)}function I(B){const L=r.get(B);if(L.__webglInit===void 0)return;const ne=B.source,be=g.get(ne);if(be){const we=be[L.__cacheKey];we.usedTimes--,we.usedTimes===0&&C(B),Object.keys(be).length===0&&g.delete(ne)}r.remove(B)}function C(B){const L=r.get(B);t.deleteTexture(L.__webglTexture);const ne=B.source,be=g.get(ne);delete be[L.__cacheKey],a.memory.textures--}function D(B){const L=r.get(B);if(B.depthTexture&&(B.depthTexture.dispose(),r.remove(B.depthTexture)),B.isWebGLCubeRenderTarget)for(let be=0;be<6;be++){if(Array.isArray(L.__webglFramebuffer[be]))for(let we=0;we<L.__webglFramebuffer[be].length;we++)t.deleteFramebuffer(L.__webglFramebuffer[be][we]);else t.deleteFramebuffer(L.__webglFramebuffer[be]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[be])}else{if(Array.isArray(L.__webglFramebuffer))for(let be=0;be<L.__webglFramebuffer.length;be++)t.deleteFramebuffer(L.__webglFramebuffer[be]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let be=0;be<L.__webglColorRenderbuffer.length;be++)L.__webglColorRenderbuffer[be]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[be]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const ne=B.textures;for(let be=0,we=ne.length;be<we;be++){const ge=r.get(ne[be]);ge.__webglTexture&&(t.deleteTexture(ge.__webglTexture),a.memory.textures--),r.remove(ne[be])}r.remove(B)}let F=0;function j(){F=0}function q(){const B=F;return B>=i.maxTextures&&Xt("WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+i.maxTextures),F+=1,B}function R(B){const L=[];return L.push(B.wrapS),L.push(B.wrapT),L.push(B.wrapR||0),L.push(B.magFilter),L.push(B.minFilter),L.push(B.anisotropy),L.push(B.internalFormat),L.push(B.format),L.push(B.type),L.push(B.generateMipmaps),L.push(B.premultiplyAlpha),L.push(B.flipY),L.push(B.unpackAlignment),L.push(B.colorSpace),L.join()}function W(B,L){const ne=r.get(B);if(B.isVideoTexture&&Pe(B),B.isRenderTargetTexture===!1&&B.isExternalTexture!==!0&&B.version>0&&ne.__version!==B.version){const be=B.image;if(be===null)Xt("WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)Xt("WebGLRenderer: Texture marked for update but image is incomplete");else{de(ne,B,L);return}}else B.isExternalTexture&&(ne.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+L)}function K(B,L){const ne=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&ne.__version!==B.version){de(ne,B,L);return}else B.isExternalTexture&&(ne.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+L)}function V(B,L){const ne=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&ne.__version!==B.version){de(ne,B,L);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+L)}function te(B,L){const ne=r.get(B);if(B.version>0&&ne.__version!==B.version){xe(ne,B,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+L)}const Y={[Wk]:t.REPEAT,[pc]:t.CLAMP_TO_EDGE,[qk]:t.MIRRORED_REPEAT},Z={[ya]:t.NEAREST,[YCe]:t.NEAREST_MIPMAP_NEAREST,[Oy]:t.NEAREST_MIPMAP_LINEAR,[to]:t.LINEAR,[fC]:t.LINEAR_MIPMAP_NEAREST,[gh]:t.LINEAR_MIPMAP_LINEAR},U={[eNe]:t.NEVER,[aNe]:t.ALWAYS,[tNe]:t.LESS,[qY]:t.LEQUAL,[nNe]:t.EQUAL,[sNe]:t.GEQUAL,[rNe]:t.GREATER,[iNe]:t.NOTEQUAL};function z(B,L){if(L.type===mc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===to||L.magFilter===fC||L.magFilter===Oy||L.magFilter===gh||L.minFilter===to||L.minFilter===fC||L.minFilter===Oy||L.minFilter===gh)&&Xt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(B,t.TEXTURE_WRAP_S,Y[L.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,Y[L.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,Y[L.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,Z[L.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,Z[L.minFilter]),L.compareFunction&&(t.texParameteri(B,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(B,t.TEXTURE_COMPARE_FUNC,U[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===ya||L.minFilter!==Oy&&L.minFilter!==gh||L.type===mc&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const ne=e.get("EXT_texture_filter_anisotropic");t.texParameterf(B,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function ee(B,L){let ne=!1;B.__webglInit===void 0&&(B.__webglInit=!0,L.addEventListener("dispose",k));const be=L.source;let we=g.get(be);we===void 0&&(we={},g.set(be,we));const ge=R(L);if(ge!==B.__cacheKey){we[ge]===void 0&&(we[ge]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,ne=!0),we[ge].usedTimes++;const me=we[B.__cacheKey];me!==void 0&&(we[B.__cacheKey].usedTimes--,me.usedTimes===0&&C(L)),B.__cacheKey=ge,B.__webglTexture=we[ge].texture}return ne}function ae(B,L,ne){return Math.floor(Math.floor(B/ne)/L)}function fe(B,L,ne,be){const ge=B.updateRanges;if(ge.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,ne,be,L.data);else{ge.sort((Ve,ce)=>Ve.start-ce.start);let me=0;for(let Ve=1;Ve<ge.length;Ve++){const ce=ge[me],Ye=ge[Ve],$e=ce.start+ce.count,Ze=ae(Ye.start,L.width,4),at=ae(ce.start,L.width,4);Ye.start<=$e+1&&Ze===at&&ae(Ye.start+Ye.count-1,L.width,4)===Ze?ce.count=Math.max(ce.count,Ye.start+Ye.count-ce.start):(++me,ge[me]=Ye)}ge.length=me+1;const Ae=t.getParameter(t.UNPACK_ROW_LENGTH),ze=t.getParameter(t.UNPACK_SKIP_PIXELS),st=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Ve=0,ce=ge.length;Ve<ce;Ve++){const Ye=ge[Ve],$e=Math.floor(Ye.start/4),Ze=Math.ceil(Ye.count/4),at=$e%L.width,Q=Math.floor($e/L.width),Fe=Ze,pe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,at),t.pixelStorei(t.UNPACK_SKIP_ROWS,Q),n.texSubImage2D(t.TEXTURE_2D,0,at,Q,Fe,pe,ne,be,L.data)}B.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ae),t.pixelStorei(t.UNPACK_SKIP_PIXELS,ze),t.pixelStorei(t.UNPACK_SKIP_ROWS,st)}}function de(B,L,ne){let be=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(be=t.TEXTURE_3D);const we=ee(B,L),ge=L.source;n.bindTexture(be,B.__webglTexture,t.TEXTURE0+ne);const me=r.get(ge);if(ge.version!==me.__version||we===!0){n.activeTexture(t.TEXTURE0+ne);const Ae=Tn.getPrimaries(Tn.workingColorSpace),ze=L.colorSpace===Lu?null:Tn.getPrimaries(L.colorSpace),st=L.colorSpace===Lu||Ae===ze?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,st);let Ve=y(L.image,!1,i.maxTextureSize);Ve=Ne(L,Ve);const ce=s.convert(L.format,L.colorSpace),Ye=s.convert(L.type);let $e=w(L.internalFormat,ce,Ye,L.colorSpace,L.isVideoTexture);z(be,L);let Ze;const at=L.mipmaps,Q=L.isVideoTexture!==!0,Fe=me.__version===void 0||we===!0,pe=ge.dataReady,Ue=T(L,Ve);if(L.isDepthTexture)$e=A(L.format===G0,L.type),Fe&&(Q?n.texStorage2D(t.TEXTURE_2D,1,$e,Ve.width,Ve.height):n.texImage2D(t.TEXTURE_2D,0,$e,Ve.width,Ve.height,0,ce,Ye,null));else if(L.isDataTexture)if(at.length>0){Q&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,$e,at[0].width,at[0].height);for(let Ce=0,_e=at.length;Ce<_e;Ce++)Ze=at[Ce],Q?pe&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ze.width,Ze.height,ce,Ye,Ze.data):n.texImage2D(t.TEXTURE_2D,Ce,$e,Ze.width,Ze.height,0,ce,Ye,Ze.data);L.generateMipmaps=!1}else Q?(Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ve.width,Ve.height),pe&&fe(L,Ve,ce,Ye)):n.texImage2D(t.TEXTURE_2D,0,$e,Ve.width,Ve.height,0,ce,Ye,Ve.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){Q&&Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,$e,at[0].width,at[0].height,Ve.depth);for(let Ce=0,_e=at.length;Ce<_e;Ce++)if(Ze=at[Ce],L.format!==Po)if(ce!==null)if(Q){if(pe)if(L.layerUpdates.size>0){const He=oH(Ze.width,Ze.height,L.format,L.type);for(const ht of L.layerUpdates){const wt=Ze.data.subarray(ht*He/Ze.data.BYTES_PER_ELEMENT,(ht+1)*He/Ze.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,ht,Ze.width,Ze.height,1,ce,wt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ze.width,Ze.height,Ve.depth,ce,Ze.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ce,$e,Ze.width,Ze.height,Ve.depth,0,Ze.data,0,0);else Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Q?pe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ze.width,Ze.height,Ve.depth,ce,Ye,Ze.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ce,$e,Ze.width,Ze.height,Ve.depth,0,ce,Ye,Ze.data)}else{Q&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,$e,at[0].width,at[0].height);for(let Ce=0,_e=at.length;Ce<_e;Ce++)Ze=at[Ce],L.format!==Po?ce!==null?Q?pe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ce,0,0,Ze.width,Ze.height,ce,Ze.data):n.compressedTexImage2D(t.TEXTURE_2D,Ce,$e,Ze.width,Ze.height,0,Ze.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Q?pe&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ze.width,Ze.height,ce,Ye,Ze.data):n.texImage2D(t.TEXTURE_2D,Ce,$e,Ze.width,Ze.height,0,ce,Ye,Ze.data)}else if(L.isDataArrayTexture)if(Q){if(Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,$e,Ve.width,Ve.height,Ve.depth),pe)if(L.layerUpdates.size>0){const Ce=oH(Ve.width,Ve.height,L.format,L.type);for(const _e of L.layerUpdates){const He=Ve.data.subarray(_e*Ce/Ve.data.BYTES_PER_ELEMENT,(_e+1)*Ce/Ve.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,_e,Ve.width,Ve.height,1,ce,Ye,He)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ve.width,Ve.height,Ve.depth,ce,Ye,Ve.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,$e,Ve.width,Ve.height,Ve.depth,0,ce,Ye,Ve.data);else if(L.isData3DTexture)Q?(Fe&&n.texStorage3D(t.TEXTURE_3D,Ue,$e,Ve.width,Ve.height,Ve.depth),pe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ve.width,Ve.height,Ve.depth,ce,Ye,Ve.data)):n.texImage3D(t.TEXTURE_3D,0,$e,Ve.width,Ve.height,Ve.depth,0,ce,Ye,Ve.data);else if(L.isFramebufferTexture){if(Fe)if(Q)n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ve.width,Ve.height);else{let Ce=Ve.width,_e=Ve.height;for(let He=0;He<Ue;He++)n.texImage2D(t.TEXTURE_2D,He,$e,Ce,_e,0,ce,Ye,null),Ce>>=1,_e>>=1}}else if(at.length>0){if(Q&&Fe){const Ce=Se(at[0]);n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ce.width,Ce.height)}for(let Ce=0,_e=at.length;Ce<_e;Ce++)Ze=at[Ce],Q?pe&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,ce,Ye,Ze):n.texImage2D(t.TEXTURE_2D,Ce,$e,ce,Ye,Ze);L.generateMipmaps=!1}else if(Q){if(Fe){const Ce=Se(Ve);n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ce.width,Ce.height)}pe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ce,Ye,Ve)}else n.texImage2D(t.TEXTURE_2D,0,$e,ce,Ye,Ve);v(L)&&b(be),me.__version=ge.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function xe(B,L,ne){if(L.image.length!==6)return;const be=ee(B,L),we=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+ne);const ge=r.get(we);if(we.version!==ge.__version||be===!0){n.activeTexture(t.TEXTURE0+ne);const me=Tn.getPrimaries(Tn.workingColorSpace),Ae=L.colorSpace===Lu?null:Tn.getPrimaries(L.colorSpace),ze=L.colorSpace===Lu||me===Ae?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ze);const st=L.isCompressedTexture||L.image[0].isCompressedTexture,Ve=L.image[0]&&L.image[0].isDataTexture,ce=[];for(let _e=0;_e<6;_e++)!st&&!Ve?ce[_e]=y(L.image[_e],!0,i.maxCubemapSize):ce[_e]=Ve?L.image[_e].image:L.image[_e],ce[_e]=Ne(L,ce[_e]);const Ye=ce[0],$e=s.convert(L.format,L.colorSpace),Ze=s.convert(L.type),at=w(L.internalFormat,$e,Ze,L.colorSpace),Q=L.isVideoTexture!==!0,Fe=ge.__version===void 0||be===!0,pe=we.dataReady;let Ue=T(L,Ye);z(t.TEXTURE_CUBE_MAP,L);let Ce;if(st){Q&&Fe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,at,Ye.width,Ye.height);for(let _e=0;_e<6;_e++){Ce=ce[_e].mipmaps;for(let He=0;He<Ce.length;He++){const ht=Ce[He];L.format!==Po?$e!==null?Q?pe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,0,0,ht.width,ht.height,$e,ht.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,at,ht.width,ht.height,0,ht.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,0,0,ht.width,ht.height,$e,Ze,ht.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,at,ht.width,ht.height,0,$e,Ze,ht.data)}}}else{if(Ce=L.mipmaps,Q&&Fe){Ce.length>0&&Ue++;const _e=Se(ce[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,at,_e.width,_e.height)}for(let _e=0;_e<6;_e++)if(Ve){Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,ce[_e].width,ce[_e].height,$e,Ze,ce[_e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,at,ce[_e].width,ce[_e].height,0,$e,Ze,ce[_e].data);for(let He=0;He<Ce.length;He++){const wt=Ce[He].image[_e].image;Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,0,0,wt.width,wt.height,$e,Ze,wt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,at,wt.width,wt.height,0,$e,Ze,wt.data)}}else{Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,$e,Ze,ce[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,at,$e,Ze,ce[_e]);for(let He=0;He<Ce.length;He++){const ht=Ce[He];Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,0,0,$e,Ze,ht.image[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,at,$e,Ze,ht.image[_e])}}}v(L)&&b(t.TEXTURE_CUBE_MAP),ge.__version=we.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function ye(B,L,ne,be,we,ge){const me=s.convert(ne.format,ne.colorSpace),Ae=s.convert(ne.type),ze=w(ne.internalFormat,me,Ae,ne.colorSpace),st=r.get(L),Ve=r.get(ne);if(Ve.__renderTarget=L,!st.__hasExternalTextures){const ce=Math.max(1,L.width>>ge),Ye=Math.max(1,L.height>>ge);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ge,ze,ce,Ye,L.depth,0,me,Ae,null):n.texImage2D(we,ge,ze,ce,Ye,0,me,Ae,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,we,Ve.__webglTexture,0,J(L)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,we,Ve.__webglTexture,ge),n.bindFramebuffer(t.FRAMEBUFFER,null)}function re(B,L,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,B),L.depthBuffer){const be=L.depthTexture,we=be&&be.isDepthTexture?be.type:null,ge=A(L.stencilBuffer,we),me=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ae=J(L);le(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ae,ge,L.width,L.height):ne?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ae,ge,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ge,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,me,t.RENDERBUFFER,B)}else{const be=L.textures;for(let we=0;we<be.length;we++){const ge=be[we],me=s.convert(ge.format,ge.colorSpace),Ae=s.convert(ge.type),ze=w(ge.internalFormat,me,Ae,ge.colorSpace),st=J(L);ne&&le(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,st,ze,L.width,L.height):le(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,st,ze,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ze,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ve(B,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,B),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const be=r.get(L.depthTexture);be.__renderTarget=L,(!be.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),W(L.depthTexture,0);const we=be.__webglTexture,ge=J(L);if(L.depthTexture.format===V0)le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0,ge):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0);else if(L.depthTexture.format===G0)le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0,ge):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0);else throw new Error("Unknown depthTexture format")}function je(B){const L=r.get(B),ne=B.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==B.depthTexture){const be=B.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),be){const we=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,be.removeEventListener("dispose",we)};be.addEventListener("dispose",we),L.__depthDisposeCallback=we}L.__boundDepthTexture=be}if(B.depthTexture&&!L.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");const be=B.texture.mipmaps;be&&be.length>0?ve(L.__webglFramebuffer[0],B):ve(L.__webglFramebuffer,B)}else if(ne){L.__webglDepthbuffer=[];for(let be=0;be<6;be++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[be]),L.__webglDepthbuffer[be]===void 0)L.__webglDepthbuffer[be]=t.createRenderbuffer(),re(L.__webglDepthbuffer[be],B,!1);else{const we=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ge=L.__webglDepthbuffer[be];t.bindRenderbuffer(t.RENDERBUFFER,ge),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ge)}}else{const be=B.texture.mipmaps;if(be&&be.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),re(L.__webglDepthbuffer,B,!1);else{const we=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ge=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ge),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ge)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(B,L,ne){const be=r.get(B);L!==void 0&&ye(be.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&je(B)}function ut(B){const L=B.texture,ne=r.get(B),be=r.get(L);B.addEventListener("dispose",N);const we=B.textures,ge=B.isWebGLCubeRenderTarget===!0,me=we.length>1;if(me||(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=L.version,a.memory.textures++),ge){ne.__webglFramebuffer=[];for(let Ae=0;Ae<6;Ae++)if(L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer[Ae]=[];for(let ze=0;ze<L.mipmaps.length;ze++)ne.__webglFramebuffer[Ae][ze]=t.createFramebuffer()}else ne.__webglFramebuffer[Ae]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Ae=0;Ae<L.mipmaps.length;Ae++)ne.__webglFramebuffer[Ae]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(me)for(let Ae=0,ze=we.length;Ae<ze;Ae++){const st=r.get(we[Ae]);st.__webglTexture===void 0&&(st.__webglTexture=t.createTexture(),a.memory.textures++)}if(B.samples>0&&le(B)===!1){ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Ae=0;Ae<we.length;Ae++){const ze=we[Ae];ne.__webglColorRenderbuffer[Ae]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ae]);const st=s.convert(ze.format,ze.colorSpace),Ve=s.convert(ze.type),ce=w(ze.internalFormat,st,Ve,ze.colorSpace,B.isXRRenderTarget===!0),Ye=J(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ye,ce,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ae,t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ae])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),re(ne.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ge){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),z(t.TEXTURE_CUBE_MAP,L);for(let Ae=0;Ae<6;Ae++)if(L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)ye(ne.__webglFramebuffer[Ae][ze],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,ze);else ye(ne.__webglFramebuffer[Ae],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0);v(L)&&b(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(me){for(let Ae=0,ze=we.length;Ae<ze;Ae++){const st=we[Ae],Ve=r.get(st);let ce=t.TEXTURE_2D;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(ce=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ce,Ve.__webglTexture),z(ce,st),ye(ne.__webglFramebuffer,B,st,t.COLOR_ATTACHMENT0+Ae,ce,0),v(st)&&b(ce)}n.unbindTexture()}else{let Ae=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(Ae=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ae,be.__webglTexture),z(Ae,L),L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)ye(ne.__webglFramebuffer[ze],B,L,t.COLOR_ATTACHMENT0,Ae,ze);else ye(ne.__webglFramebuffer,B,L,t.COLOR_ATTACHMENT0,Ae,0);v(L)&&b(Ae),n.unbindTexture()}B.depthBuffer&&je(B)}function $(B){const L=B.textures;for(let ne=0,be=L.length;ne<be;ne++){const we=L[ne];if(v(we)){const ge=E(B),me=r.get(we).__webglTexture;n.bindTexture(ge,me),b(ge),n.unbindTexture()}}}const H=[],ie=[];function G(B){if(B.samples>0){if(le(B)===!1){const L=B.textures,ne=B.width,be=B.height;let we=t.COLOR_BUFFER_BIT;const ge=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,me=r.get(B),Ae=L.length>1;if(Ae)for(let st=0;st<L.length;st++)n.bindFramebuffer(t.FRAMEBUFFER,me.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,me.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,me.__webglMultisampledFramebuffer);const ze=B.texture.mipmaps;ze&&ze.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,me.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,me.__webglFramebuffer);for(let st=0;st<L.length;st++){if(B.resolveDepthBuffer&&(B.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&B.resolveStencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),Ae){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,me.__webglColorRenderbuffer[st]);const Ve=r.get(L[st]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ve,0)}t.blitFramebuffer(0,0,ne,be,0,0,ne,be,we,t.NEAREST),c===!0&&(H.length=0,ie.length=0,H.push(t.COLOR_ATTACHMENT0+st),B.depthBuffer&&B.resolveDepthBuffer===!1&&(H.push(ge),ie.push(ge),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ie)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ae)for(let st=0;st<L.length;st++){n.bindFramebuffer(t.FRAMEBUFFER,me.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,me.__webglColorRenderbuffer[st]);const Ve=r.get(L[st]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,me.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,Ve,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,me.__webglMultisampledFramebuffer)}else if(B.depthBuffer&&B.resolveDepthBuffer===!1&&c){const L=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function J(B){return Math.min(i.maxSamples,B.samples)}function le(B){const L=r.get(B);return B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Pe(B){const L=a.render.frame;d.get(B)!==L&&(d.set(B,L),B.update())}function Ne(B,L){const ne=B.colorSpace,be=B.format,we=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||ne!==Nm&&ne!==Lu&&(Tn.getTransfer(ne)===Wn?(be!==Po||we!==ml)&&Xt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):zr("WebGLTextures: Unsupported texture color space:",ne)),L}function Se(B){return typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement?(u.width=B.naturalWidth||B.width,u.height=B.naturalHeight||B.height):typeof VideoFrame<"u"&&B instanceof VideoFrame?(u.width=B.displayWidth,u.height=B.displayHeight):(u.width=B.width,u.height=B.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=j,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=V,this.setTextureCube=te,this.rebindTextures=ue,this.setupRenderTarget=ut,this.updateRenderTargetMipmap=$,this.updateMultisampleRenderTarget=G,this.setupDepthRenderbuffer=je,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=le}function TDe(t,e){function n(r,i=Lu){let s;const a=Tn.getTransfer(i);if(r===ml)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===H0)return t.UNSIGNED_SHORT;if(r===YO)return t.INT;if(r===Qh)return t.UNSIGNED_INT;if(r===mc)return t.FLOAT;if(r===ag)return t.HALF_FLOAT;if(r===$Y)return t.ALPHA;if(r===VY)return t.RGB;if(r===Po)return t.RGBA;if(r===V0)return t.DEPTH_COMPONENT;if(r===G0)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===s1||r===a1||r===o1||r===l1)if(a===Wn)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===s1)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===a1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===o1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===l1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===s1)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===a1)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===o1)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===l1)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===Wn?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===eP)return a===Wn?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===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===nP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===rP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===iP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===sP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===aP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===oP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===lP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===cP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===uP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===dP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===hP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===fP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===pP)return a===Wn?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===Wn?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===$0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const CDe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,NDe=`
- 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 kDe{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 Oc({vertexShader:CDe,fragmentShader:NDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new gl(new lj(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let PDe=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 kDe,b={},E=n.getContextAttributes();let w=null,A=null;const T=[],k=[],N=new on;let I=null;const C=new Ka;C.viewport=new Yr;const D=new Ka;D.viewport=new Yr;const F=[C,D],j=new KNe;let q=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(de){let xe=T[de];return xe===void 0&&(xe=new jC,T[de]=xe),xe.getTargetRaySpace()},this.getControllerGrip=function(de){let xe=T[de];return xe===void 0&&(xe=new jC,T[de]=xe),xe.getGripSpace()},this.getHand=function(de){let xe=T[de];return xe===void 0&&(xe=new jC,T[de]=xe),xe.getHandSpace()};function W(de){const xe=k.indexOf(de.inputSource);if(xe===-1)return;const ye=T[xe];ye!==void 0&&(ye.update(de.inputSource,de.frame,u||a),ye.dispatchEvent({type:de.type,data:de.inputSource}))}function K(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",V);for(let de=0;de<T.length;de++){const xe=k[de];xe!==null&&(k[de]=null,T[de].disconnect(xe))}q=null,R=null,v.reset();for(const de in b)delete b[de];e.setRenderTarget(w),m=null,g=null,f=null,i=null,A=null,fe.stop(),r.isPresenting=!1,e.setPixelRatio(I),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(de){s=de,r.isPresenting===!0&&Xt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(de){o=de,r.isPresenting===!0&&Xt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||a},this.setReferenceSpace=function(de){u=de},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(de){if(i=de,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",K),i.addEventListener("inputsourceschange",V),E.xrCompatible!==!0&&await n.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(N),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let ye=null,re=null,ve=null;E.depth&&(ve=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ye=E.stencil?G0:V0,re=E.stencil?$0:Qh);const je={colorFormat:n.RGBA8,depthFormat:ve,scaleFactor:s};f=this.getBinding(),g=f.createProjectionLayer(je),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),A=new ef(g.textureWidth,g.textureHeight,{format:Po,type:ml,depthTexture:new dZ(g.textureWidth,g.textureHeight,re,void 0,void 0,void 0,void 0,void 0,void 0,ye),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const ye={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,ye),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),A=new ef(m.framebufferWidth,m.framebufferHeight,{format:Po,type:ml,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),fe.setContext(i),fe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function V(de){for(let xe=0;xe<de.removed.length;xe++){const ye=de.removed[xe],re=k.indexOf(ye);re>=0&&(k[re]=null,T[re].disconnect(ye))}for(let xe=0;xe<de.added.length;xe++){const ye=de.added[xe];let re=k.indexOf(ye);if(re===-1){for(let je=0;je<T.length;je++)if(je>=k.length){k.push(ye),re=je;break}else if(k[je]===null){k[je]=ye,re=je;break}if(re===-1)break}const ve=T[re];ve&&ve.connect(ye)}}const te=new Je,Y=new Je;function Z(de,xe,ye){te.setFromMatrixPosition(xe.matrixWorld),Y.setFromMatrixPosition(ye.matrixWorld);const re=te.distanceTo(Y),ve=xe.projectionMatrix.elements,je=ye.projectionMatrix.elements,ue=ve[14]/(ve[10]-1),ut=ve[14]/(ve[10]+1),$=(ve[9]+1)/ve[5],H=(ve[9]-1)/ve[5],ie=(ve[8]-1)/ve[0],G=(je[8]+1)/je[0],J=ue*ie,le=ue*G,Pe=re/(-ie+G),Ne=Pe*-ie;if(xe.matrixWorld.decompose(de.position,de.quaternion,de.scale),de.translateX(Ne),de.translateZ(Pe),de.matrixWorld.compose(de.position,de.quaternion,de.scale),de.matrixWorldInverse.copy(de.matrixWorld).invert(),ve[10]===-1)de.projectionMatrix.copy(xe.projectionMatrix),de.projectionMatrixInverse.copy(xe.projectionMatrixInverse);else{const Se=ue+Pe,B=ut+Pe,L=J-Ne,ne=le+(re-Ne),be=$*ut/B*Se,we=H*ut/B*Se;de.projectionMatrix.makePerspective(L,ne,be,we,Se,B),de.projectionMatrixInverse.copy(de.projectionMatrix).invert()}}function U(de,xe){xe===null?de.matrixWorld.copy(de.matrix):de.matrixWorld.multiplyMatrices(xe.matrixWorld,de.matrix),de.matrixWorldInverse.copy(de.matrixWorld).invert()}this.updateCamera=function(de){if(i===null)return;let xe=de.near,ye=de.far;v.texture!==null&&(v.depthNear>0&&(xe=v.depthNear),v.depthFar>0&&(ye=v.depthFar)),j.near=D.near=C.near=xe,j.far=D.far=C.far=ye,(q!==j.near||R!==j.far)&&(i.updateRenderState({depthNear:j.near,depthFar:j.far}),q=j.near,R=j.far),j.layers.mask=de.layers.mask|6,C.layers.mask=j.layers.mask&3,D.layers.mask=j.layers.mask&5;const re=de.parent,ve=j.cameras;U(j,re);for(let je=0;je<ve.length;je++)U(ve[je],re);ve.length===2?Z(j,C,D):j.projectionMatrix.copy(C.projectionMatrix),z(de,j,re)};function z(de,xe,ye){ye===null?de.matrix.copy(xe.matrixWorld):(de.matrix.copy(ye.matrixWorld),de.matrix.invert(),de.matrix.multiply(xe.matrixWorld)),de.matrix.decompose(de.position,de.quaternion,de.scale),de.updateMatrixWorld(!0),de.projectionMatrix.copy(xe.projectionMatrix),de.projectionMatrixInverse.copy(xe.projectionMatrixInverse),de.isPerspectiveCamera&&(de.fov=wP*2*Math.atan(1/de.projectionMatrix.elements[5]),de.zoom=1)}this.getCamera=function(){return j},this.getFoveation=function(){if(!(g===null&&m===null))return c},this.setFoveation=function(de){c=de,g!==null&&(g.fixedFoveation=de),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=de)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(j)},this.getCameraTexture=function(de){return b[de]};let ee=null;function ae(de,xe){if(d=xe.getViewerPose(u||a),x=xe,d!==null){const ye=d.views;m!==null&&(e.setRenderTargetFramebuffer(A,m.framebuffer),e.setRenderTarget(A));let re=!1;ye.length!==j.cameras.length&&(j.cameras.length=0,re=!0);for(let ut=0;ut<ye.length;ut++){const $=ye[ut];let H=null;if(m!==null)H=m.getViewport($);else{const G=f.getViewSubImage(g,$);H=G.viewport,ut===0&&(e.setRenderTargetTextures(A,G.colorTexture,G.depthStencilTexture),e.setRenderTarget(A))}let ie=F[ut];ie===void 0&&(ie=new Ka,ie.layers.enable(ut),ie.viewport=new Yr,F[ut]=ie),ie.matrix.fromArray($.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray($.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set(H.x,H.y,H.width,H.height),ut===0&&(j.matrix.copy(ie.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale)),re===!0&&j.cameras.push(ie)}const ve=i.enabledFeatures;if(ve&&ve.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const ut=f.getDepthInformation(ye[0]);ut&&ut.isValid&&ut.texture&&v.init(ut,i.renderState)}if(ve&&ve.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let ut=0;ut<ye.length;ut++){const $=ye[ut].camera;if($){let H=b[$];H||(H=new hZ,b[$]=H);const ie=f.getCameraImage($);H.sourceTexture=ie}}}}for(let ye=0;ye<T.length;ye++){const re=k[ye],ve=T[ye];re!==null&&ve!==void 0&&ve.update(re,xe,u||a)}ee&&ee(de,xe),xe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:xe}),x=null}const fe=new gZ;fe.setAnimationLoop(ae),this.setAnimationLoop=function(de){ee=de},this.dispose=function(){}}};const qd=new hd,RDe=new ri;function DDe(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,w,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,w):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===qs&&(v.bumpScale.value*=-1)),b.normalMap&&(v.normalMap.value=b.normalMap,n(b.normalMap,v.normalMapTransform),v.normalScale.value.copy(b.normalScale),b.side===qs&&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),w=E.envMap,A=E.envMapRotation;w&&(v.envMap.value=w,qd.copy(A),qd.x*=-1,qd.y*=-1,qd.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(qd.y*=-1,qd.z*=-1),v.envMapRotation.value.setFromMatrix4(RDe.makeRotationFromEuler(qd)),v.flipEnvMap.value=w.isCubeTexture&&w.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,w){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.size.value=b.size*E,v.scale.value=w*.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===qs&&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 ODe(t,e,n,r){let i={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(E,w){const A=w.program;r.uniformBlockBinding(E,A)}function u(E,w){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",v));const T=w.program;r.updateUBOMapping(E,T);const k=e.render.frame;s[E.id]!==k&&(g(E),s[E.id]=k)}function d(E){const w=f();E.__bindingPointIndex=w;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,w,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 w=i[E.id],A=E.uniforms,T=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);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,w,A,T){const k=E.value,N=w+"_"+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 w=E.uniforms;let A=0;const T=16;for(let N=0,I=w.length;N<I;N++){const C=Array.isArray(w[N])?w[N]:[w[N]];for(let D=0,F=C.length;D<F;D++){const j=C[D],q=Array.isArray(j.value)?j.value:[j.value];for(let R=0,W=q.length;R<W;R++){const K=q[R],V=y(K),te=A%T,Y=te%V.boundary,Z=te+Y;A+=Y,Z!==0&&T-Z<V.storage&&(A+=T-Z),j.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),j.__offset=A,A+=V.storage}}}const k=A%T;return k>0&&(A+=T-k),E.__size=A,E.__cache={},this}function y(E){const w={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?Xt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Xt("WebGLRenderer: Unsupported uniform value type.",E),w}function v(E){const w=E.target;w.removeEventListener("dispose",v);const A=a.indexOf(w.__bindingPointIndex);a.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete s[w.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);a=[],i={},s={}}return{bind:c,update:u,dispose:b}}const jDe=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 Kl=null;function LDe(){return Kl===null&&(Kl=new LNe(jDe,32,32,ej,ag),Kl.minFilter=to,Kl.magFilter=to,Kl.wrapS=pc,Kl.wrapT=pc,Kl.generateMipmaps=!1,Kl.needsUpdate=!0),Kl}let IDe=class{constructor(e={}){const{canvas:n=oNe(),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([ml,Qh,H0,$0,ZO,QO]),v=new Uint32Array(4),b=new Int32Array(4);let E=null,w=null;const A=[],T=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Xu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const k=this;let N=!1;this._outputColorSpace=Ga;let I=0,C=0,D=null,F=-1,j=null;const q=new Yr,R=new Yr;let W=null;const K=new yn(0);let V=0,te=n.width,Y=n.height,Z=1,U=null,z=null;const ee=new Yr(0,0,te,Y),ae=new Yr(0,0,te,Y);let fe=!1;const de=new oj;let xe=!1,ye=!1;const re=new ri,ve=new Je,je=new Yr,ue={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ut=!1;function $(){return D===null?Z:1}let H=r;function ie(se,Ee){return n.getContext(se,Ee)}try{const se={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha: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",_e,!1),n.addEventListener("webglcontextcreationerror",He,!1),H===null){const Ee="webgl2";if(H=ie(Ee,se),H===null)throw ie(Ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(se){throw se("WebGLRenderer: "+se.message),se}let G,J,le,Pe,Ne,Se,B,L,ne,be,we,ge,me,Ae,ze,st,Ve,ce,Ye,$e,Ze,at,Q,Fe;function pe(){G=new GPe(H),G.init(),at=new TDe(H,G),J=new LPe(H,G,e,at),le=new MDe(H,G),J.reversedDepthBuffer&&g&&le.buffers.depth.setReversed(!0),Pe=new KPe(H),Ne=new hDe,Se=new ADe(H,G,le,Ne,J,at,Pe),B=new UPe(k),L=new VPe(k),ne=new QNe(H),Q=new OPe(H,ne),be=new WPe(H,ne,Pe,Q),we=new YPe(H,be,ne,Pe),Ye=new XPe(H,J,Se),st=new IPe(Ne),ge=new dDe(k,B,L,G,J,Q,st),me=new DDe(k,Ne),Ae=new pDe,ze=new yDe(G),ce=new DPe(k,B,L,le,we,m,c),Ve=new SDe(k,we,J),Fe=new ODe(H,Pe,J,le),$e=new jPe(H,G,Pe),Ze=new qPe(H,G,Pe),Pe.programs=ge.programs,k.capabilities=J,k.extensions=G,k.properties=Ne,k.renderLists=Ae,k.shadowMap=Ve,k.state=le,k.info=Pe}pe();const Ue=new PDe(k,H);this.xr=Ue,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const se=G.get("WEBGL_lose_context");se&&se.loseContext()},this.forceContextRestore=function(){const se=G.get("WEBGL_lose_context");se&&se.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(se){se!==void 0&&(Z=se,this.setSize(te,Y,!1))},this.getSize=function(se){return se.set(te,Y)},this.setSize=function(se,Ee,Le=!0){if(Ue.isPresenting){Xt("WebGLRenderer: Can't change size while VR device is presenting.");return}te=se,Y=Ee,n.width=Math.floor(se*Z),n.height=Math.floor(Ee*Z),Le===!0&&(n.style.width=se+"px",n.style.height=Ee+"px"),this.setViewport(0,0,se,Ee)},this.getDrawingBufferSize=function(se){return se.set(te*Z,Y*Z).floor()},this.setDrawingBufferSize=function(se,Ee,Le){te=se,Y=Ee,Z=Le,n.width=Math.floor(se*Le),n.height=Math.floor(Ee*Le),this.setViewport(0,0,se,Ee)},this.getCurrentViewport=function(se){return se.copy(q)},this.getViewport=function(se){return se.copy(ee)},this.setViewport=function(se,Ee,Le,Oe){se.isVector4?ee.set(se.x,se.y,se.z,se.w):ee.set(se,Ee,Le,Oe),le.viewport(q.copy(ee).multiplyScalar(Z).round())},this.getScissor=function(se){return se.copy(ae)},this.setScissor=function(se,Ee,Le,Oe){se.isVector4?ae.set(se.x,se.y,se.z,se.w):ae.set(se,Ee,Le,Oe),le.scissor(R.copy(ae).multiplyScalar(Z).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(se){le.setScissorTest(fe=se)},this.setOpaqueSort=function(se){U=se},this.setTransparentSort=function(se){z=se},this.getClearColor=function(se){return se.copy(ce.getClearColor())},this.setClearColor=function(){ce.setClearColor(...arguments)},this.getClearAlpha=function(){return ce.getClearAlpha()},this.setClearAlpha=function(){ce.setClearAlpha(...arguments)},this.clear=function(se=!0,Ee=!0,Le=!0){let Oe=0;if(se){let Te=!1;if(D!==null){const ot=D.texture.format;Te=x.has(ot)}if(Te){const ot=D.texture.type,ft=y.has(ot),bt=ce.getClearColor(),xt=ce.getClearAlpha(),jt=bt.r,Mt=bt.g,mt=bt.b;ft?(v[0]=jt,v[1]=Mt,v[2]=mt,v[3]=xt,H.clearBufferuiv(H.COLOR,0,v)):(b[0]=jt,b[1]=Mt,b[2]=mt,b[3]=xt,H.clearBufferiv(H.COLOR,0,b))}else Oe|=H.COLOR_BUFFER_BIT}Ee&&(Oe|=H.DEPTH_BUFFER_BIT),Le&&(Oe|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(Oe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Ce,!1),n.removeEventListener("webglcontextrestored",_e,!1),n.removeEventListener("webglcontextcreationerror",He,!1),ce.dispose(),Ae.dispose(),ze.dispose(),Ne.dispose(),B.dispose(),L.dispose(),we.dispose(),Q.dispose(),Fe.dispose(),ge.dispose(),Ue.dispose(),Ue.removeEventListener("sessionstart",Qn),Ue.removeEventListener("sessionend",Si),ai.stop()};function Ce(se){se.preventDefault(),L8("WebGLRenderer: Context Lost."),N=!0}function _e(){L8("WebGLRenderer: Context Restored."),N=!1;const se=Pe.autoReset,Ee=Ve.enabled,Le=Ve.autoUpdate,Oe=Ve.needsUpdate,Te=Ve.type;pe(),Pe.autoReset=se,Ve.enabled=Ee,Ve.autoUpdate=Le,Ve.needsUpdate=Oe,Ve.type=Te}function He(se){zr("WebGLRenderer: A WebGL context could not be created. Reason: ",se.statusMessage)}function ht(se){const Ee=se.target;Ee.removeEventListener("dispose",ht),wt(Ee)}function wt(se){Ot(se),Ne.remove(se)}function Ot(se){const Ee=Ne.get(se).programs;Ee!==void 0&&(Ee.forEach(function(Le){ge.releaseProgram(Le)}),se.isShaderMaterial&&ge.releaseShaderCache(se))}this.renderBufferDirect=function(se,Ee,Le,Oe,Te,ot){Ee===null&&(Ee=ue);const ft=Te.isMesh&&Te.matrixWorld.determinant()<0,bt=he(se,Ee,Le,Oe,Te);le.setMaterial(Oe,ft);let xt=Le.index,jt=1;if(Oe.wireframe===!0){if(xt=be.getWireframeAttribute(Le),xt===void 0)return;jt=2}const Mt=Le.drawRange,mt=Le.attributes.position;let Kt=Mt.start*jt,Ft=(Mt.start+Mt.count)*jt;ot!==null&&(Kt=Math.max(Kt,ot.start*jt),Ft=Math.min(Ft,(ot.start+ot.count)*jt)),xt!==null?(Kt=Math.max(Kt,0),Ft=Math.min(Ft,xt.count)):mt!=null&&(Kt=Math.max(Kt,0),Ft=Math.min(Ft,mt.count));const nn=Ft-Kt;if(nn<0||nn===1/0)return;Q.setup(Te,Oe,bt,Le,xt);let dn,xn=$e;if(xt!==null&&(dn=ne.get(xt),xn=Ze,xn.setIndex(dn)),Te.isMesh)Oe.wireframe===!0?(le.setLineWidth(Oe.wireframeLinewidth*$()),xn.setMode(H.LINES)):xn.setMode(H.TRIANGLES);else if(Te.isLine){let Ut=Oe.linewidth;Ut===void 0&&(Ut=1),le.setLineWidth(Ut*$()),Te.isLineSegments?xn.setMode(H.LINES):Te.isLineLoop?xn.setMode(H.LINE_LOOP):xn.setMode(H.LINE_STRIP)}else Te.isPoints?xn.setMode(H.POINTS):Te.isSprite&&xn.setMode(H.TRIANGLES);if(Te.isBatchedMesh)if(Te._multiDrawInstances!==null)W0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),xn.renderMultiDrawInstances(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount,Te._multiDrawInstances);else if(G.get("WEBGL_multi_draw"))xn.renderMultiDraw(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount);else{const Ut=Te._multiDrawStarts,Zt=Te._multiDrawCounts,Jt=Te._multiDrawCount,Ar=xt?ne.get(xt).bytesPerElement:1,jr=Ne.get(Oe).currentProgram.getUniforms();for(let Pn=0;Pn<Jt;Pn++)jr.setValue(H,"_gl_DrawID",Pn),xn.render(Ut[Pn]/Ar,Zt[Pn])}else if(Te.isInstancedMesh)xn.renderInstances(Kt,nn,Te.count);else if(Le.isInstancedBufferGeometry){const Ut=Le._maxInstanceCount!==void 0?Le._maxInstanceCount:1/0,Zt=Math.min(Le.instanceCount,Ut);xn.renderInstances(Kt,nn,Zt)}else xn.render(Kt,nn)};function cn(se,Ee,Le){se.transparent===!0&&se.side===nl&&se.forceSinglePass===!1?(se.side=qs,se.needsUpdate=!0,Or(se,Ee,Le),se.side=dd,se.needsUpdate=!0,Or(se,Ee,Le),se.side=nl):Or(se,Ee,Le)}this.compile=function(se,Ee,Le=null){Le===null&&(Le=se),w=ze.get(Le),w.init(Ee),T.push(w),Le.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Ee.layers)&&(w.pushLight(Te),Te.castShadow&&w.pushShadow(Te))}),se!==Le&&se.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Ee.layers)&&(w.pushLight(Te),Te.castShadow&&w.pushShadow(Te))}),w.setupLights();const Oe=new Set;return se.traverse(function(Te){if(!(Te.isMesh||Te.isPoints||Te.isLine||Te.isSprite))return;const ot=Te.material;if(ot)if(Array.isArray(ot))for(let ft=0;ft<ot.length;ft++){const bt=ot[ft];cn(bt,Le,Te),Oe.add(bt)}else cn(ot,Le,Te),Oe.add(ot)}),w=T.pop(),Oe},this.compileAsync=function(se,Ee,Le=null){const Oe=this.compile(se,Ee,Le);return new Promise(Te=>{function ot(){if(Oe.forEach(function(ft){Ne.get(ft).currentProgram.isReady()&&Oe.delete(ft)}),Oe.size===0){Te(se);return}setTimeout(ot,10)}G.get("KHR_parallel_shader_compile")!==null?ot():setTimeout(ot,10)})};let It=null;function Dn(se){It&&It(se)}function Qn(){ai.stop()}function Si(){ai.start()}const ai=new gZ;ai.setAnimationLoop(Dn),typeof self<"u"&&ai.setContext(self),this.setAnimationLoop=function(se){It=se,Ue.setAnimationLoop(se),se===null?ai.stop():ai.start()},Ue.addEventListener("sessionstart",Qn),Ue.addEventListener("sessionend",Si),this.render=function(se,Ee){if(Ee!==void 0&&Ee.isCamera!==!0){zr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(se.matrixWorldAutoUpdate===!0&&se.updateMatrixWorld(),Ee.parent===null&&Ee.matrixWorldAutoUpdate===!0&&Ee.updateMatrixWorld(),Ue.enabled===!0&&Ue.isPresenting===!0&&(Ue.cameraAutoUpdate===!0&&Ue.updateCamera(Ee),Ee=Ue.getCamera()),se.isScene===!0&&se.onBeforeRender(k,se,Ee,D),w=ze.get(se,T.length),w.init(Ee),T.push(w),re.multiplyMatrices(Ee.projectionMatrix,Ee.matrixWorldInverse),de.setFromProjectionMatrix(re,al,Ee.reversedDepth),ye=this.localClippingEnabled,xe=st.init(this.clippingPlanes,ye),E=Ae.get(se,A.length),E.init(),A.push(E),Ue.enabled===!0&&Ue.isPresenting===!0){const ot=k.xr.getDepthSensingMesh();ot!==null&&Ei(ot,Ee,-1/0,k.sortObjects)}Ei(se,Ee,0,k.sortObjects),E.finish(),k.sortObjects===!0&&E.sort(U,z),ut=Ue.enabled===!1||Ue.isPresenting===!1||Ue.hasDepthSensing()===!1,ut&&ce.addToRenderList(E,se),this.info.render.frame++,xe===!0&&st.beginShadows();const Le=w.state.shadowsArray;Ve.render(Le,se,Ee),xe===!0&&st.endShadows(),this.info.autoReset===!0&&this.info.reset();const Oe=E.opaque,Te=E.transmissive;if(w.setupLights(),Ee.isArrayCamera){const ot=Ee.cameras;if(Te.length>0)for(let ft=0,bt=ot.length;ft<bt;ft++){const xt=ot[ft];ns(Oe,Te,se,xt)}ut&&ce.render(se);for(let ft=0,bt=ot.length;ft<bt;ft++){const xt=ot[ft];Fi(E,se,xt,xt.viewport)}}else Te.length>0&&ns(Oe,Te,se,Ee),ut&&ce.render(se),Fi(E,se,Ee);D!==null&&C===0&&(Se.updateMultisampleRenderTarget(D),Se.updateRenderTargetMipmap(D)),se.isScene===!0&&se.onAfterRender(k,se,Ee),Q.resetDefaultState(),F=-1,j=null,T.pop(),T.length>0?(w=T[T.length-1],xe===!0&&st.setGlobalState(k.clippingPlanes,w.state.camera)):w=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function Ei(se,Ee,Le,Oe){if(se.visible===!1)return;if(se.layers.test(Ee.layers)){if(se.isGroup)Le=se.renderOrder;else if(se.isLOD)se.autoUpdate===!0&&se.update(Ee);else if(se.isLight)w.pushLight(se),se.castShadow&&w.pushShadow(se);else if(se.isSprite){if(!se.frustumCulled||de.intersectsSprite(se)){Oe&&je.setFromMatrixPosition(se.matrixWorld).applyMatrix4(re);const ft=we.update(se),bt=se.material;bt.visible&&E.push(se,ft,bt,Le,je.z,null)}}else if((se.isMesh||se.isLine||se.isPoints)&&(!se.frustumCulled||de.intersectsObject(se))){const ft=we.update(se),bt=se.material;if(Oe&&(se.boundingSphere!==void 0?(se.boundingSphere===null&&se.computeBoundingSphere(),je.copy(se.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),je.copy(ft.boundingSphere.center)),je.applyMatrix4(se.matrixWorld).applyMatrix4(re)),Array.isArray(bt)){const xt=ft.groups;for(let jt=0,Mt=xt.length;jt<Mt;jt++){const mt=xt[jt],Kt=bt[mt.materialIndex];Kt&&Kt.visible&&E.push(se,ft,Kt,Le,je.z,mt)}}else bt.visible&&E.push(se,ft,bt,Le,je.z,null)}}const ot=se.children;for(let ft=0,bt=ot.length;ft<bt;ft++)Ei(ot[ft],Ee,Le,Oe)}function Fi(se,Ee,Le,Oe){const{opaque:Te,transmissive:ot,transparent:ft}=se;w.setupLightsView(Le),xe===!0&&st.setGlobalState(k.clippingPlanes,Le),Oe&&le.viewport(q.copy(Oe)),Te.length>0&&Hr(Te,Ee,Le),ot.length>0&&Hr(ot,Ee,Le),ft.length>0&&Hr(ft,Ee,Le),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function ns(se,Ee,Le,Oe){if((Le.isScene===!0?Le.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Oe.id]===void 0&&(w.state.transmissionRenderTarget[Oe.id]=new ef(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")||G.has("EXT_color_buffer_float")?ag:ml,minFilter:gh,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Tn.workingColorSpace}));const ot=w.state.transmissionRenderTarget[Oe.id],ft=Oe.viewport||q;ot.setSize(ft.z*k.transmissionResolutionScale,ft.w*k.transmissionResolutionScale);const bt=k.getRenderTarget(),xt=k.getActiveCubeFace(),jt=k.getActiveMipmapLevel();k.setRenderTarget(ot),k.getClearColor(K),V=k.getClearAlpha(),V<1&&k.setClearColor(16777215,.5),k.clear(),ut&&ce.render(Le);const Mt=k.toneMapping;k.toneMapping=Xu;const mt=Oe.viewport;if(Oe.viewport!==void 0&&(Oe.viewport=void 0),w.setupLightsView(Oe),xe===!0&&st.setGlobalState(k.clippingPlanes,Oe),Hr(se,Le,Oe),Se.updateMultisampleRenderTarget(ot),Se.updateRenderTargetMipmap(ot),G.has("WEBGL_multisampled_render_to_texture")===!1){let Kt=!1;for(let Ft=0,nn=Ee.length;Ft<nn;Ft++){const dn=Ee[Ft],{object:xn,geometry:Ut,material:Zt,group:Jt}=dn;if(Zt.side===nl&&xn.layers.test(Oe.layers)){const Ar=Zt.side;Zt.side=qs,Zt.needsUpdate=!0,br(xn,Le,Oe,Ut,Zt,Jt),Zt.side=Ar,Zt.needsUpdate=!0,Kt=!0}}Kt===!0&&(Se.updateMultisampleRenderTarget(ot),Se.updateRenderTargetMipmap(ot))}k.setRenderTarget(bt,xt,jt),k.setClearColor(K,V),mt!==void 0&&(Oe.viewport=mt),k.toneMapping=Mt}function Hr(se,Ee,Le){const Oe=Ee.isScene===!0?Ee.overrideMaterial:null;for(let Te=0,ot=se.length;Te<ot;Te++){const ft=se[Te],{object:bt,geometry:xt,group:jt}=ft;let Mt=ft.material;Mt.allowOverride===!0&&Oe!==null&&(Mt=Oe),bt.layers.test(Le.layers)&&br(bt,Ee,Le,xt,Mt,jt)}}function br(se,Ee,Le,Oe,Te,ot){se.onBeforeRender(k,Ee,Le,Oe,Te,ot),se.modelViewMatrix.multiplyMatrices(Le.matrixWorldInverse,se.matrixWorld),se.normalMatrix.getNormalMatrix(se.modelViewMatrix),Te.onBeforeRender(k,Ee,Le,Oe,se,ot),Te.transparent===!0&&Te.side===nl&&Te.forceSinglePass===!1?(Te.side=qs,Te.needsUpdate=!0,k.renderBufferDirect(Le,Ee,Oe,Te,se,ot),Te.side=dd,Te.needsUpdate=!0,k.renderBufferDirect(Le,Ee,Oe,Te,se,ot),Te.side=nl):k.renderBufferDirect(Le,Ee,Oe,Te,se,ot),se.onAfterRender(k,Ee,Le,Oe,Te,ot)}function Or(se,Ee,Le){Ee.isScene!==!0&&(Ee=ue);const Oe=Ne.get(se),Te=w.state.lights,ot=w.state.shadowsArray,ft=Te.state.version,bt=ge.getParameters(se,Te.state,ot,Ee,Le),xt=ge.getProgramCacheKey(bt);let jt=Oe.programs;Oe.environment=se.isMeshStandardMaterial?Ee.environment:null,Oe.fog=Ee.fog,Oe.envMap=(se.isMeshStandardMaterial?L:B).get(se.envMap||Oe.environment),Oe.envMapRotation=Oe.environment!==null&&se.envMap===null?Ee.environmentRotation:se.envMapRotation,jt===void 0&&(se.addEventListener("dispose",ht),jt=new Map,Oe.programs=jt);let Mt=jt.get(xt);if(Mt!==void 0){if(Oe.currentProgram===Mt&&Oe.lightsStateVersion===ft)return Hc(se,bt),Mt}else bt.uniforms=ge.getUniforms(se),se.onBeforeCompile(bt,k),Mt=ge.acquireProgram(bt,xt),jt.set(xt,Mt),Oe.uniforms=bt.uniforms;const mt=Oe.uniforms;return(!se.isShaderMaterial&&!se.isRawShaderMaterial||se.clipping===!0)&&(mt.clippingPlanes=st.uniform),Hc(se,bt),Oe.needsLights=nt(se),Oe.lightsStateVersion=ft,Oe.needsLights&&(mt.ambientLightColor.value=Te.state.ambient,mt.lightProbe.value=Te.state.probe,mt.directionalLights.value=Te.state.directional,mt.directionalLightShadows.value=Te.state.directionalShadow,mt.spotLights.value=Te.state.spot,mt.spotLightShadows.value=Te.state.spotShadow,mt.rectAreaLights.value=Te.state.rectArea,mt.ltc_1.value=Te.state.rectAreaLTC1,mt.ltc_2.value=Te.state.rectAreaLTC2,mt.pointLights.value=Te.state.point,mt.pointLightShadows.value=Te.state.pointShadow,mt.hemisphereLights.value=Te.state.hemi,mt.directionalShadowMap.value=Te.state.directionalShadowMap,mt.directionalShadowMatrix.value=Te.state.directionalShadowMatrix,mt.spotShadowMap.value=Te.state.spotShadowMap,mt.spotLightMatrix.value=Te.state.spotLightMatrix,mt.spotLightMap.value=Te.state.spotLightMap,mt.pointShadowMap.value=Te.state.pointShadowMap,mt.pointShadowMatrix.value=Te.state.pointShadowMatrix),Oe.currentProgram=Mt,Oe.uniformsList=null,Mt}function fo(se){if(se.uniformsList===null){const Ee=se.currentProgram.getUniforms();se.uniformsList=h1.seqWithValue(Ee.seq,se.uniforms)}return se.uniformsList}function Hc(se,Ee){const Le=Ne.get(se);Le.outputColorSpace=Ee.outputColorSpace,Le.batching=Ee.batching,Le.batchingColor=Ee.batchingColor,Le.instancing=Ee.instancing,Le.instancingColor=Ee.instancingColor,Le.instancingMorph=Ee.instancingMorph,Le.skinning=Ee.skinning,Le.morphTargets=Ee.morphTargets,Le.morphNormals=Ee.morphNormals,Le.morphColors=Ee.morphColors,Le.morphTargetsCount=Ee.morphTargetsCount,Le.numClippingPlanes=Ee.numClippingPlanes,Le.numIntersection=Ee.numClipIntersection,Le.vertexAlphas=Ee.vertexAlphas,Le.vertexTangents=Ee.vertexTangents,Le.toneMapping=Ee.toneMapping}function he(se,Ee,Le,Oe,Te){Ee.isScene!==!0&&(Ee=ue),Se.resetTextureUnits();const ot=Ee.fog,ft=Oe.isMeshStandardMaterial?Ee.environment:null,bt=D===null?k.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:Nm,xt=(Oe.isMeshStandardMaterial?L:B).get(Oe.envMap||ft),jt=Oe.vertexColors===!0&&!!Le.attributes.color&&Le.attributes.color.itemSize===4,Mt=!!Le.attributes.tangent&&(!!Oe.normalMap||Oe.anisotropy>0),mt=!!Le.morphAttributes.position,Kt=!!Le.morphAttributes.normal,Ft=!!Le.morphAttributes.color;let nn=Xu;Oe.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(nn=k.toneMapping);const dn=Le.morphAttributes.position||Le.morphAttributes.normal||Le.morphAttributes.color,xn=dn!==void 0?dn.length:0,Ut=Ne.get(Oe),Zt=w.state.lights;if(xe===!0&&(ye===!0||se!==j)){const Ai=se===j&&Oe.id===F;st.setState(Oe,se,Ai)}let Jt=!1;Oe.version===Ut.__version?(Ut.needsLights&&Ut.lightsStateVersion!==Zt.state.version||Ut.outputColorSpace!==bt||Te.isBatchedMesh&&Ut.batching===!1||!Te.isBatchedMesh&&Ut.batching===!0||Te.isBatchedMesh&&Ut.batchingColor===!0&&Te.colorTexture===null||Te.isBatchedMesh&&Ut.batchingColor===!1&&Te.colorTexture!==null||Te.isInstancedMesh&&Ut.instancing===!1||!Te.isInstancedMesh&&Ut.instancing===!0||Te.isSkinnedMesh&&Ut.skinning===!1||!Te.isSkinnedMesh&&Ut.skinning===!0||Te.isInstancedMesh&&Ut.instancingColor===!0&&Te.instanceColor===null||Te.isInstancedMesh&&Ut.instancingColor===!1&&Te.instanceColor!==null||Te.isInstancedMesh&&Ut.instancingMorph===!0&&Te.morphTexture===null||Te.isInstancedMesh&&Ut.instancingMorph===!1&&Te.morphTexture!==null||Ut.envMap!==xt||Oe.fog===!0&&Ut.fog!==ot||Ut.numClippingPlanes!==void 0&&(Ut.numClippingPlanes!==st.numPlanes||Ut.numIntersection!==st.numIntersection)||Ut.vertexAlphas!==jt||Ut.vertexTangents!==Mt||Ut.morphTargets!==mt||Ut.morphNormals!==Kt||Ut.morphColors!==Ft||Ut.toneMapping!==nn||Ut.morphTargetsCount!==xn)&&(Jt=!0):(Jt=!0,Ut.__version=Oe.version);let Ar=Ut.currentProgram;Jt===!0&&(Ar=Or(Oe,Ee,Te));let jr=!1,Pn=!1,po=!1;const On=Ar.getUniforms(),Mi=Ut.uniforms;if(le.useProgram(Ar.program)&&(jr=!0,Pn=!0,po=!0),Oe.id!==F&&(F=Oe.id,Pn=!0),jr||j!==se){le.buffers.depth.getReversed()&&se.reversedDepth!==!0&&(se._reversedDepth=!0,se.updateProjectionMatrix()),On.setValue(H,"projectionMatrix",se.projectionMatrix),On.setValue(H,"viewMatrix",se.matrixWorldInverse);const zi=On.map.cameraPosition;zi!==void 0&&zi.setValue(H,ve.setFromMatrixPosition(se.matrixWorld)),J.logarithmicDepthBuffer&&On.setValue(H,"logDepthBufFC",2/(Math.log(se.far+1)/Math.LN2)),(Oe.isMeshPhongMaterial||Oe.isMeshToonMaterial||Oe.isMeshLambertMaterial||Oe.isMeshBasicMaterial||Oe.isMeshStandardMaterial||Oe.isShaderMaterial)&&On.setValue(H,"isOrthographic",se.isOrthographicCamera===!0),j!==se&&(j=se,Pn=!0,po=!0)}if(Te.isSkinnedMesh){On.setOptional(H,Te,"bindMatrix"),On.setOptional(H,Te,"bindMatrixInverse");const Ai=Te.skeleton;Ai&&(Ai.boneTexture===null&&Ai.computeBoneTexture(),On.setValue(H,"boneTexture",Ai.boneTexture,Se))}Te.isBatchedMesh&&(On.setOptional(H,Te,"batchingTexture"),On.setValue(H,"batchingTexture",Te._matricesTexture,Se),On.setOptional(H,Te,"batchingIdTexture"),On.setValue(H,"batchingIdTexture",Te._indirectTexture,Se),On.setOptional(H,Te,"batchingColorTexture"),Te._colorsTexture!==null&&On.setValue(H,"batchingColorTexture",Te._colorsTexture,Se));const oi=Le.morphAttributes;if((oi.position!==void 0||oi.normal!==void 0||oi.color!==void 0)&&Ye.update(Te,Le,Ar),(Pn||Ut.receiveShadow!==Te.receiveShadow)&&(Ut.receiveShadow=Te.receiveShadow,On.setValue(H,"receiveShadow",Te.receiveShadow)),Oe.isMeshGouraudMaterial&&Oe.envMap!==null&&(Mi.envMap.value=xt,Mi.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),Oe.isMeshStandardMaterial&&Oe.envMap===null&&Ee.environment!==null&&(Mi.envMapIntensity.value=Ee.environmentIntensity),Mi.dfgLUT!==void 0&&(Mi.dfgLUT.value=LDe()),Pn&&(On.setValue(H,"toneMappingExposure",k.toneMappingExposure),Ut.needsLights&&Ge(Mi,po),ot&&Oe.fog===!0&&me.refreshFogUniforms(Mi,ot),me.refreshMaterialUniforms(Mi,Oe,Z,Y,w.state.transmissionRenderTarget[se.id]),h1.upload(H,fo(Ut),Mi,Se)),Oe.isShaderMaterial&&Oe.uniformsNeedUpdate===!0&&(h1.upload(H,fo(Ut),Mi,Se),Oe.uniformsNeedUpdate=!1),Oe.isSpriteMaterial&&On.setValue(H,"center",Te.center),On.setValue(H,"modelViewMatrix",Te.modelViewMatrix),On.setValue(H,"normalMatrix",Te.normalMatrix),On.setValue(H,"modelMatrix",Te.matrixWorld),Oe.isShaderMaterial||Oe.isRawShaderMaterial){const Ai=Oe.uniformsGroups;for(let zi=0,$o=Ai.length;zi<$o;zi++){const Ml=Ai[zi];Fe.update(Ml,Ar),Fe.bind(Ml,Ar)}}return Ar}function Ge(se,Ee){se.ambientLightColor.needsUpdate=Ee,se.lightProbe.needsUpdate=Ee,se.directionalLights.needsUpdate=Ee,se.directionalLightShadows.needsUpdate=Ee,se.pointLights.needsUpdate=Ee,se.pointLightShadows.needsUpdate=Ee,se.spotLights.needsUpdate=Ee,se.spotLightShadows.needsUpdate=Ee,se.rectAreaLights.needsUpdate=Ee,se.hemisphereLights.needsUpdate=Ee}function nt(se){return se.isMeshLambertMaterial||se.isMeshToonMaterial||se.isMeshPhongMaterial||se.isMeshStandardMaterial||se.isShadowMaterial||se.isShaderMaterial&&se.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(se,Ee,Le){const Oe=Ne.get(se);Oe.__autoAllocateDepthBuffer=se.resolveDepthBuffer===!1,Oe.__autoAllocateDepthBuffer===!1&&(Oe.__useRenderToTexture=!1),Ne.get(se.texture).__webglTexture=Ee,Ne.get(se.depthTexture).__webglTexture=Oe.__autoAllocateDepthBuffer?void 0:Le,Oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(se,Ee){const Le=Ne.get(se);Le.__webglFramebuffer=Ee,Le.__useDefaultFramebuffer=Ee===void 0};const rt=H.createFramebuffer();this.setRenderTarget=function(se,Ee=0,Le=0){D=se,I=Ee,C=Le;let Oe=!0,Te=null,ot=!1,ft=!1;if(se){const xt=Ne.get(se);if(xt.__useDefaultFramebuffer!==void 0)le.bindFramebuffer(H.FRAMEBUFFER,null),Oe=!1;else if(xt.__webglFramebuffer===void 0)Se.setupRenderTarget(se);else if(xt.__hasExternalTextures)Se.rebindTextures(se,Ne.get(se.texture).__webglTexture,Ne.get(se.depthTexture).__webglTexture);else if(se.depthBuffer){const mt=se.depthTexture;if(xt.__boundDepthTexture!==mt){if(mt!==null&&Ne.has(mt)&&(se.width!==mt.image.width||se.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Se.setupDepthRenderbuffer(se)}}const jt=se.texture;(jt.isData3DTexture||jt.isDataArrayTexture||jt.isCompressedArrayTexture)&&(ft=!0);const Mt=Ne.get(se).__webglFramebuffer;se.isWebGLCubeRenderTarget?(Array.isArray(Mt[Ee])?Te=Mt[Ee][Le]:Te=Mt[Ee],ot=!0):se.samples>0&&Se.useMultisampledRTT(se)===!1?Te=Ne.get(se).__webglMultisampledFramebuffer:Array.isArray(Mt)?Te=Mt[Le]:Te=Mt,q.copy(se.viewport),R.copy(se.scissor),W=se.scissorTest}else q.copy(ee).multiplyScalar(Z).floor(),R.copy(ae).multiplyScalar(Z).floor(),W=fe;if(Le!==0&&(Te=rt),le.bindFramebuffer(H.FRAMEBUFFER,Te)&&Oe&&le.drawBuffers(se,Te),le.viewport(q),le.scissor(R),le.setScissorTest(W),ot){const xt=Ne.get(se.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,xt.__webglTexture,Le)}else if(ft){const xt=Ee;for(let jt=0;jt<se.textures.length;jt++){const Mt=Ne.get(se.textures[jt]);H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0+jt,Mt.__webglTexture,Le,xt)}}else if(se!==null&&Le!==0){const xt=Ne.get(se.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,xt.__webglTexture,Le)}F=-1},this.readRenderTargetPixels=function(se,Ee,Le,Oe,Te,ot,ft,bt=0){if(!(se&&se.isWebGLRenderTarget)){zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xt=Ne.get(se).__webglFramebuffer;if(se.isWebGLCubeRenderTarget&&ft!==void 0&&(xt=xt[ft]),xt){le.bindFramebuffer(H.FRAMEBUFFER,xt);try{const jt=se.textures[bt],Mt=jt.format,mt=jt.type;if(!J.textureFormatReadable(Mt)){zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!J.textureTypeReadable(mt)){zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ee>=0&&Ee<=se.width-Oe&&Le>=0&&Le<=se.height-Te&&(se.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+bt),H.readPixels(Ee,Le,Oe,Te,at.convert(Mt),at.convert(mt),ot))}finally{const jt=D!==null?Ne.get(D).__webglFramebuffer:null;le.bindFramebuffer(H.FRAMEBUFFER,jt)}}},this.readRenderTargetPixelsAsync=async function(se,Ee,Le,Oe,Te,ot,ft,bt=0){if(!(se&&se.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xt=Ne.get(se).__webglFramebuffer;if(se.isWebGLCubeRenderTarget&&ft!==void 0&&(xt=xt[ft]),xt)if(Ee>=0&&Ee<=se.width-Oe&&Le>=0&&Le<=se.height-Te){le.bindFramebuffer(H.FRAMEBUFFER,xt);const jt=se.textures[bt],Mt=jt.format,mt=jt.type;if(!J.textureFormatReadable(Mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!J.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Kt=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,Kt),H.bufferData(H.PIXEL_PACK_BUFFER,ot.byteLength,H.STREAM_READ),se.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+bt),H.readPixels(Ee,Le,Oe,Te,at.convert(Mt),at.convert(mt),0);const Ft=D!==null?Ne.get(D).__webglFramebuffer:null;le.bindFramebuffer(H.FRAMEBUFFER,Ft);const nn=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await lNe(H,nn,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,Kt),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,ot),H.deleteBuffer(Kt),H.deleteSync(nn),ot}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(se,Ee=null,Le=0){const Oe=Math.pow(2,-Le),Te=Math.floor(se.image.width*Oe),ot=Math.floor(se.image.height*Oe),ft=Ee!==null?Ee.x:0,bt=Ee!==null?Ee.y:0;Se.setTexture2D(se,0),H.copyTexSubImage2D(H.TEXTURE_2D,Le,0,0,ft,bt,Te,ot),le.unbindTexture()};const et=H.createFramebuffer(),St=H.createFramebuffer();this.copyTextureToTexture=function(se,Ee,Le=null,Oe=null,Te=0,ot=null){ot===null&&(Te!==0?(W0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ot=Te,Te=0):ot=0);let ft,bt,xt,jt,Mt,mt,Kt,Ft,nn;const dn=se.isCompressedTexture?se.mipmaps[ot]:se.image;if(Le!==null)ft=Le.max.x-Le.min.x,bt=Le.max.y-Le.min.y,xt=Le.isBox3?Le.max.z-Le.min.z:1,jt=Le.min.x,Mt=Le.min.y,mt=Le.isBox3?Le.min.z:0;else{const oi=Math.pow(2,-Te);ft=Math.floor(dn.width*oi),bt=Math.floor(dn.height*oi),se.isDataArrayTexture?xt=dn.depth:se.isData3DTexture?xt=Math.floor(dn.depth*oi):xt=1,jt=0,Mt=0,mt=0}Oe!==null?(Kt=Oe.x,Ft=Oe.y,nn=Oe.z):(Kt=0,Ft=0,nn=0);const xn=at.convert(Ee.format),Ut=at.convert(Ee.type);let Zt;Ee.isData3DTexture?(Se.setTexture3D(Ee,0),Zt=H.TEXTURE_3D):Ee.isDataArrayTexture||Ee.isCompressedArrayTexture?(Se.setTexture2DArray(Ee,0),Zt=H.TEXTURE_2D_ARRAY):(Se.setTexture2D(Ee,0),Zt=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,Ee.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ee.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,Ee.unpackAlignment);const Jt=H.getParameter(H.UNPACK_ROW_LENGTH),Ar=H.getParameter(H.UNPACK_IMAGE_HEIGHT),jr=H.getParameter(H.UNPACK_SKIP_PIXELS),Pn=H.getParameter(H.UNPACK_SKIP_ROWS),po=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,dn.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,dn.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,jt),H.pixelStorei(H.UNPACK_SKIP_ROWS,Mt),H.pixelStorei(H.UNPACK_SKIP_IMAGES,mt);const On=se.isDataArrayTexture||se.isData3DTexture,Mi=Ee.isDataArrayTexture||Ee.isData3DTexture;if(se.isDepthTexture){const oi=Ne.get(se),Ai=Ne.get(Ee),zi=Ne.get(oi.__renderTarget),$o=Ne.get(Ai.__renderTarget);le.bindFramebuffer(H.READ_FRAMEBUFFER,zi.__webglFramebuffer),le.bindFramebuffer(H.DRAW_FRAMEBUFFER,$o.__webglFramebuffer);for(let Ml=0;Ml<xt;Ml++)On&&(H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ne.get(se).__webglTexture,Te,mt+Ml),H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ne.get(Ee).__webglTexture,ot,nn+Ml)),H.blitFramebuffer(jt,Mt,ft,bt,Kt,Ft,ft,bt,H.DEPTH_BUFFER_BIT,H.NEAREST);le.bindFramebuffer(H.READ_FRAMEBUFFER,null),le.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else if(Te!==0||se.isRenderTargetTexture||Ne.has(se)){const oi=Ne.get(se),Ai=Ne.get(Ee);le.bindFramebuffer(H.READ_FRAMEBUFFER,et),le.bindFramebuffer(H.DRAW_FRAMEBUFFER,St);for(let zi=0;zi<xt;zi++)On?H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,oi.__webglTexture,Te,mt+zi):H.framebufferTexture2D(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,oi.__webglTexture,Te),Mi?H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ai.__webglTexture,ot,nn+zi):H.framebufferTexture2D(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Ai.__webglTexture,ot),Te!==0?H.blitFramebuffer(jt,Mt,ft,bt,Kt,Ft,ft,bt,H.COLOR_BUFFER_BIT,H.NEAREST):Mi?H.copyTexSubImage3D(Zt,ot,Kt,Ft,nn+zi,jt,Mt,ft,bt):H.copyTexSubImage2D(Zt,ot,Kt,Ft,jt,Mt,ft,bt);le.bindFramebuffer(H.READ_FRAMEBUFFER,null),le.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else Mi?se.isDataTexture||se.isData3DTexture?H.texSubImage3D(Zt,ot,Kt,Ft,nn,ft,bt,xt,xn,Ut,dn.data):Ee.isCompressedArrayTexture?H.compressedTexSubImage3D(Zt,ot,Kt,Ft,nn,ft,bt,xt,xn,dn.data):H.texSubImage3D(Zt,ot,Kt,Ft,nn,ft,bt,xt,xn,Ut,dn):se.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,ot,Kt,Ft,ft,bt,xn,Ut,dn.data):se.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,ot,Kt,Ft,dn.width,dn.height,xn,dn.data):H.texSubImage2D(H.TEXTURE_2D,ot,Kt,Ft,ft,bt,xn,Ut,dn);H.pixelStorei(H.UNPACK_ROW_LENGTH,Jt),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,Ar),H.pixelStorei(H.UNPACK_SKIP_PIXELS,jr),H.pixelStorei(H.UNPACK_SKIP_ROWS,Pn),H.pixelStorei(H.UNPACK_SKIP_IMAGES,po),ot===0&&Ee.generateMipmaps&&H.generateMipmap(Zt),le.unbindTexture()},this.initRenderTarget=function(se){Ne.get(se).__webglFramebuffer===void 0&&Se.setupRenderTarget(se)},this.initTexture=function(se){se.isCubeTexture?Se.setTextureCube(se,0):se.isData3DTexture?Se.setTexture3D(se,0):se.isDataArrayTexture||se.isCompressedArrayTexture?Se.setTexture2DArray(se,0):Se.setTexture2D(se,0),le.unbindTexture()},this.resetState=function(){I=0,C=0,D=null,le.reset(),Q.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return al}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Tn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Tn._getUnpackColorSpace()}};const PH={type:"change"},cj={type:"start"},_Z={type:"end"},n_=new ij,RH=new Nu,UDe=Math.cos(70*uNe.DEG2RAD),ci=new Je,Hs=2*Math.PI,Xn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},VC=1e-6;class FDe extends YNe{constructor(e,n=null){super(e,n),this.state=Xn.NONE,this.target=new Je,this.cursor=new Je,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT: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 Je,this._lastQuaternion=new Jh,this._lastTargetPosition=new Je,this._quat=new Jh().setFromUnitVectors(e.up,new Je(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new aH,this._sphericalDelta=new aH,this._scale=1,this._panOffset=new Je,this._rotateStart=new on,this._rotateEnd=new on,this._rotateDelta=new on,this._panStart=new on,this._panEnd=new on,this._panDelta=new on,this._dollyStart=new on,this._dollyEnd=new on,this._dollyDelta=new on,this._dollyDirection=new Je,this._mouse=new on,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=BDe.bind(this),this._onPointerDown=zDe.bind(this),this._onPointerUp=HDe.bind(this),this._onContextMenu=XDe.bind(this),this._onMouseWheel=GDe.bind(this),this._onKeyDown=WDe.bind(this),this._onTouchStart=qDe.bind(this),this._onTouchMove=KDe.bind(this),this._onMouseDown=$De.bind(this),this._onMouseMove=VDe.bind(this),this._interceptControlDown=YDe.bind(this),this._interceptControlUp=ZDe.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=Xn.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===Xn.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=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 Je(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 Je(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):(n_.origin.copy(this.object.position),n_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(n_.direction))<UDe?this.object.lookAt(this.target):(RH.setFromNormalAndCoplanarPoint(this.object.up,this.target),n_.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 on,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function zDe(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 BDe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function HDe(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=Xn.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function $De(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=Xn.DOLLY;break;case rm.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Xn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Xn.ROTATE}break;case rm.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Xn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Xn.PAN}break;default:this.state=Xn.NONE}this.state!==Xn.NONE&&this.dispatchEvent(cj)}function VDe(t){switch(this.state){case Xn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Xn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Xn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function GDe(t){this.enabled===!1||this.enableZoom===!1||this.state!==Xn.NONE||(t.preventDefault(),this.dispatchEvent(cj),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(_Z))}function WDe(t){this.enabled!==!1&&this._handleKeyDown(t)}function qDe(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=Xn.TOUCH_ROTATE;break;case Kp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Xn.TOUCH_PAN;break;default:this.state=Xn.NONE}break;case 2:switch(this.touches.TWO){case Kp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Xn.TOUCH_DOLLY_PAN;break;case Kp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Xn.TOUCH_DOLLY_ROTATE;break;default:this.state=Xn.NONE}break;default:this.state=Xn.NONE}this.state!==Xn.NONE&&this.dispatchEvent(cj)}function KDe(t){switch(this._trackPointer(t),this.state){case Xn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Xn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Xn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Xn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Xn.NONE}}function XDe(t){this.enabled!==!1&&t.preventDefault()}function YDe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ZDe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function QDe(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 El;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 no(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 r_(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 JDe(){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 r_=="function"&&r_;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 r_=="function"&&r_,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,w=E,A=s.getTypeOf(c)!=="string";b<c.length;)w=E-b,f=A?(u=c[b++],d=b<E?c[b++]:0,b<E?c[b++]:0):(u=c.charCodeAt(b++),d=b<E?c.charCodeAt(b++):0,b<E?c.charCodeAt(b++):0),g=u>>2,m=(3&u)<<4|d>>4,x=1<w?(15&d)<<2|f>>6:64,y=2<w?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,w=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===o.charAt(64)&&w--,c.charAt(c.length-2)===o.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(E=a.uint8array?new Uint8Array(0|w):new Array(0|w);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 w,A,T=m.file,k=m.compression,N=E!==u.utf8encode,I=o.transformTo("string",E(T.name)),C=o.transformTo("string",u.utf8encode(T.name)),D=T.comment,F=o.transformTo("string",E(D)),j=o.transformTo("string",u.utf8encode(D)),q=C.length!==T.name.length,R=j.length!==D.length,W="",K="",V="",te=T.dir,Y=T.date,Z={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(Z.crc32=m.crc32,Z.compressedSize=m.compressedSize,Z.uncompressedSize=m.uncompressedSize);var U=0;x&&(U|=8),N||!q&&!R||(U|=2048);var z=0,ee=0;te&&(z|=16),b==="UNIX"?(ee=798,z|=(function(fe,de){var xe=fe;return fe||(xe=de?16893:33204),(65535&xe)<<16})(T.unixPermissions,te)):(ee=20,z|=(function(fe){return 63&(fe||0)})(T.dosPermissions)),w=Y.getUTCHours(),w<<=6,w|=Y.getUTCMinutes(),w<<=5,w|=Y.getUTCSeconds()/2,A=Y.getUTCFullYear()-1980,A<<=4,A|=Y.getUTCMonth()+1,A<<=5,A|=Y.getUTCDate(),q&&(K=s(1,1)+s(d(I),4)+C,W+="up"+s(K.length,2)+K),R&&(V=s(1,1)+s(d(F),4)+j,W+="uc"+s(V.length,2)+V);var ae="";return ae+=`
- \0`,ae+=s(U,2),ae+=k.magic,ae+=s(w,2),ae+=s(A,2),ae+=s(Z.crc32,4),ae+=s(Z.compressedSize,4),ae+=s(Z.uncompressedSize,4),ae+=s(I.length,2),ae+=s(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ae+I+W,dirRecord:f.CENTRAL_FILE_HEADER+s(ee,2)+ae+s(F.length,2)+"\0\0\0\0"+s(z,4)+s(v,4)+I+W+F}}var o=n("../utils"),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,w,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(w,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,w){var A=E||w,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 w=b[E],A=w.fileNameStr,T=s.resolve(w.fileNameStr);x.file(T,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:m.createFolders}),w.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 w(T){return Object.prototype.toString.call(T)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var 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(w(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(w(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=[],w=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+"'")}})(w,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,w,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=w=0;w<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[w++]=v:(v<2048?y[w++]=192|v>>>6:(v<65536?y[w++]=224|v>>>12:(y[w++]=240|v>>>18,y[w++]=128|v>>>12&63),y[w++]=128|v>>>6&63),y[w++]=128|63&v);return y})(m)},i.utf8decode=function(m){return a.nodebuffer?s.transformTo("nodebuffer",m).toString("utf-8"):(function(x){var y,v,b,E,w=x.length,A=new Array(2*w);for(y=v=0;y<w;)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<w;)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,w){var A;for((w=w||E.length)>E.length&&(w=E.length),A=w-1;0<=A&&(192&E[A])==128;)A--;return A<0||A===0?w:A+u[E[A]]>w?A:w})(x),b=x;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=[],w=0,A=y.length;if(A<=b)return String.fromCharCode.apply(null,y);for(;w<A;)v==="array"||v==="nodebuffer"?E.push(String.fromCharCode.apply(null,y.slice(w,Math.min(w+b,A)))):E.push(String.fromCharCode.apply(null,y.subarray(w,Math.min(w+b,A)))),w+=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 w=v[E];w==="."||w===""&&E!==0&&E!==v.length-1||(w===".."?b.pop():b.push(w))}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,w){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"&&(w?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(w){(y=new d("error")).error(w)}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 dy<"u"?dy: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,w){this.promise=b,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function m(b,E,w){s(function(){var A;try{A=E(w)}catch(T){return o.reject(b,T)}A===b?o.reject(b,new TypeError("Cannot resolve promise with itself")):o.resolve(b,A)})}function x(b){var E=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof E=="function")return function(){E.apply(b,arguments)}}function y(b,E){var w=!1;function A(N){w||(w=!0,o.reject(b,N))}function T(N){w||(w=!0,o.resolve(b,N))}var k=v(function(){E(T,A)});k.status==="error"&&A(k.value)}function v(b,E){var w={};try{w.value=b(E),w.status="success"}catch(A){w.status="error",w.value=A}return w}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var E=this.constructor;return this.then(function(w){return E.resolve(b()).then(function(){return w})},function(w){return E.resolve(b()).then(function(){throw w})})},f.prototype.catch=function(b){return this.then(null,b)},f.prototype.then=function(b,E){if(typeof b!="function"&&this.state===u||typeof E!="function"&&this.state===c)return this;var w=new this.constructor(a);return this.state!==d?m(w,this.state===u?b:E,this.outcome):this.queue.push(new g(w,b,E)),w},g.prototype.callFulfilled=function(b){o.resolve(this.promise,b)},g.prototype.otherCallFulfilled=function(b){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 w=v(x,E);if(w.status==="error")return o.reject(b,w.value);var A=w.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 w=-1,A=b.queue.length;++w<A;)b.queue[w].callRejected(E);return b},f.resolve=function(b){return b instanceof this?b:o.resolve(new this(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 w=b.length,A=!1;if(!w)return this.resolve([]);for(var T=new Array(w),k=0,N=-1,I=new this(a);++N<w;)C(b[N],N);return I;function C(D,F){E.resolve(D).then(function(j){T[F]=j,++k!==w||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 w=b.length,A=!1;if(!w)return this.resolve([]);for(var T=-1,k=new this(a);++T<w;)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 w=s.deflateInit2(this.strm,E.level,E.method,E.windowBits,E.memLevel,E.strategy);if(w!==f)throw new Error(c[w]);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,(w=s.deflateSetDictionary(this.strm,A))!==f)throw new Error(c[w]);this._dict_set=!0}}function v(b,E){var w=new y(E);if(w.push(b,!0),w.err)throw w.msg||c[w.err];return w.result}y.prototype.push=function(b,E){var w,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),(w=s.deflate(T,A))!==1&&w!==f)return this.onEnd(w),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(T.output,T.next_out))):this.onData(a.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&w!==1);return A===4?(w=s.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===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,w,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"?(w=o.utf8border(N.output,N.next_out),A=N.next_out-w,T=o.buf2string(N.output,w),N.next_out=A,N.avail_out=I-A,A&&a.arraySet(N.output,N.output,w,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,w=9,A=286,T=30,k=19,N=2*A+1,I=15,C=3,D=258,F=D+C+1,j=42,q=113,R=1,W=2,K=3,V=4;function te($,H){return $.msg=d[H],H}function Y($){return($<<1)-(4<$?9:0)}function Z($){for(var H=$.length;0<=--H;)$[H]=0}function U($){var H=$.state,ie=H.pending;ie>$.avail_out&&(ie=$.avail_out),ie!==0&&(a.arraySet($.output,H.pending_buf,H.pending_out,ie,$.next_out),$.next_out+=ie,H.pending_out+=ie,$.total_out+=ie,$.avail_out-=ie,H.pending-=ie,H.pending===0&&(H.pending_out=0))}function z($,H){o._tr_flush_block($,0<=$.block_start?$.block_start:-1,$.strstart-$.block_start,H),$.block_start=$.strstart,U($.strm)}function ee($,H){$.pending_buf[$.pending++]=H}function ae($,H){$.pending_buf[$.pending++]=H>>>8&255,$.pending_buf[$.pending++]=255&H}function fe($,H){var ie,G,J=$.max_chain_length,le=$.strstart,Pe=$.prev_length,Ne=$.nice_match,Se=$.strstart>$.w_size-F?$.strstart-($.w_size-F):0,B=$.window,L=$.w_mask,ne=$.prev,be=$.strstart+D,we=B[le+Pe-1],ge=B[le+Pe];$.prev_length>=$.good_match&&(J>>=2),Ne>$.lookahead&&(Ne=$.lookahead);do if(B[(ie=H)+Pe]===ge&&B[ie+Pe-1]===we&&B[ie]===B[le]&&B[++ie]===B[le+1]){le+=2,ie++;do;while(B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&le<be);if(G=D-(be-le),le=be-D,Pe<G){if($.match_start=H,Ne<=(Pe=G))break;we=B[le+Pe-1],ge=B[le+Pe]}}while((H=ne[H&L])>Se&&--J!=0);return Pe<=$.lookahead?Pe:$.lookahead}function de($){var H,ie,G,J,le,Pe,Ne,Se,B,L,ne=$.w_size;do{if(J=$.window_size-$.lookahead-$.strstart,$.strstart>=ne+(ne-F)){for(a.arraySet($.window,$.window,ne,ne,0),$.match_start-=ne,$.strstart-=ne,$.block_start-=ne,H=ie=$.hash_size;G=$.head[--H],$.head[H]=ne<=G?G-ne:0,--ie;);for(H=ie=ne;G=$.prev[--H],$.prev[H]=ne<=G?G-ne:0,--ie;);J+=ne}if($.strm.avail_in===0)break;if(Pe=$.strm,Ne=$.window,Se=$.strstart+$.lookahead,B=J,L=void 0,L=Pe.avail_in,B<L&&(L=B),ie=L===0?0:(Pe.avail_in-=L,a.arraySet(Ne,Pe.input,Pe.next_in,L,Se),Pe.state.wrap===1?Pe.adler=c(Pe.adler,Ne,L,Se):Pe.state.wrap===2&&(Pe.adler=u(Pe.adler,Ne,L,Se)),Pe.next_in+=L,Pe.total_in+=L,L),$.lookahead+=ie,$.lookahead+$.insert>=C)for(le=$.strstart-$.insert,$.ins_h=$.window[le],$.ins_h=($.ins_h<<$.hash_shift^$.window[le+1])&$.hash_mask;$.insert&&($.ins_h=($.ins_h<<$.hash_shift^$.window[le+C-1])&$.hash_mask,$.prev[le&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=le,le++,$.insert--,!($.lookahead+$.insert<C)););}while($.lookahead<F&&$.strm.avail_in!==0)}function xe($,H){for(var ie,G;;){if($.lookahead<F){if(de($),$.lookahead<F&&H===f)return R;if($.lookahead===0)break}if(ie=0,$.lookahead>=C&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ie=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),ie!==0&&$.strstart-ie<=$.w_size-F&&($.match_length=fe($,ie)),$.match_length>=C)if(G=o._tr_tally($,$.strstart-$.match_start,$.match_length-C),$.lookahead-=$.match_length,$.match_length<=$.max_lazy_match&&$.lookahead>=C){for($.match_length--;$.strstart++,$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ie=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart,--$.match_length!=0;);$.strstart++}else $.strstart+=$.match_length,$.match_length=0,$.ins_h=$.window[$.strstart],$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+1])&$.hash_mask;else G=o._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++;if(G&&(z($,!1),$.strm.avail_out===0))return R}return $.insert=$.strstart<C-1?$.strstart:C-1,H===g?(z($,!0),$.strm.avail_out===0?K:V):$.last_lit&&(z($,!1),$.strm.avail_out===0)?R:W}function ye($,H){for(var ie,G,J;;){if($.lookahead<F){if(de($),$.lookahead<F&&H===f)return R;if($.lookahead===0)break}if(ie=0,$.lookahead>=C&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ie=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),$.prev_length=$.match_length,$.prev_match=$.match_start,$.match_length=C-1,ie!==0&&$.prev_length<$.max_lazy_match&&$.strstart-ie<=$.w_size-F&&($.match_length=fe($,ie),$.match_length<=5&&($.strategy===1||$.match_length===C&&4096<$.strstart-$.match_start)&&($.match_length=C-1)),$.prev_length>=C&&$.match_length<=$.prev_length){for(J=$.strstart+$.lookahead-C,G=o._tr_tally($,$.strstart-1-$.prev_match,$.prev_length-C),$.lookahead-=$.prev_length-1,$.prev_length-=2;++$.strstart<=J&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ie=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),--$.prev_length!=0;);if($.match_available=0,$.match_length=C-1,$.strstart++,G&&(z($,!1),$.strm.avail_out===0))return R}else if($.match_available){if((G=o._tr_tally($,0,$.window[$.strstart-1]))&&z($,!1),$.strstart++,$.lookahead--,$.strm.avail_out===0)return R}else $.match_available=1,$.strstart++,$.lookahead--}return $.match_available&&(G=o._tr_tally($,0,$.window[$.strstart-1]),$.match_available=0),$.insert=$.strstart<C-1?$.strstart:C-1,H===g?(z($,!0),$.strm.avail_out===0?K:V):$.last_lit&&(z($,!1),$.strm.avail_out===0)?R:W}function re($,H,ie,G,J){this.good_length=$,this.max_lazy=H,this.nice_length=ie,this.max_chain=G,this.func=J}function ve(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=E,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*N),this.dyn_dtree=new a.Buf16(2*(2*T+1)),this.bl_tree=new a.Buf16(2*(2*k+1)),Z(this.dyn_ltree),Z(this.dyn_dtree),Z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(I+1),this.heap=new a.Buf16(2*A+1),Z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*A+1),Z(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function je($){var H;return $&&$.state?($.total_in=$.total_out=0,$.data_type=b,(H=$.state).pending=0,H.pending_out=0,H.wrap<0&&(H.wrap=-H.wrap),H.status=H.wrap?j:q,$.adler=H.wrap===2?0:1,H.last_flush=f,o._tr_init(H),m):te($,x)}function ue($){var H=je($);return H===m&&(function(ie){ie.window_size=2*ie.w_size,Z(ie.head),ie.max_lazy_match=s[ie.level].max_lazy,ie.good_match=s[ie.level].good_length,ie.nice_match=s[ie.level].nice_length,ie.max_chain_length=s[ie.level].max_chain,ie.strstart=0,ie.block_start=0,ie.lookahead=0,ie.insert=0,ie.match_length=ie.prev_length=C-1,ie.match_available=0,ie.ins_h=0})($.state),H}function ut($,H,ie,G,J,le){if(!$)return x;var Pe=1;if(H===y&&(H=6),G<0?(Pe=0,G=-G):15<G&&(Pe=2,G-=16),J<1||w<J||ie!==E||G<8||15<G||H<0||9<H||le<0||v<le)return te($,x);G===8&&(G=9);var Ne=new ve;return($.state=Ne).strm=$,Ne.wrap=Pe,Ne.gzhead=null,Ne.w_bits=G,Ne.w_size=1<<Ne.w_bits,Ne.w_mask=Ne.w_size-1,Ne.hash_bits=J+7,Ne.hash_size=1<<Ne.hash_bits,Ne.hash_mask=Ne.hash_size-1,Ne.hash_shift=~~((Ne.hash_bits+C-1)/C),Ne.window=new a.Buf8(2*Ne.w_size),Ne.head=new a.Buf16(Ne.hash_size),Ne.prev=new a.Buf16(Ne.w_size),Ne.lit_bufsize=1<<J+6,Ne.pending_buf_size=4*Ne.lit_bufsize,Ne.pending_buf=new a.Buf8(Ne.pending_buf_size),Ne.d_buf=1*Ne.lit_bufsize,Ne.l_buf=3*Ne.lit_bufsize,Ne.level=H,Ne.strategy=le,Ne.method=ie,ue($)}s=[new re(0,0,0,0,function($,H){var ie=65535;for(ie>$.pending_buf_size-5&&(ie=$.pending_buf_size-5);;){if($.lookahead<=1){if(de($),$.lookahead===0&&H===f)return R;if($.lookahead===0)break}$.strstart+=$.lookahead,$.lookahead=0;var G=$.block_start+ie;if(($.strstart===0||$.strstart>=G)&&($.lookahead=$.strstart-G,$.strstart=G,z($,!1),$.strm.avail_out===0)||$.strstart-$.block_start>=$.w_size-F&&(z($,!1),$.strm.avail_out===0))return R}return $.insert=0,H===g?(z($,!0),$.strm.avail_out===0?K:V):($.strstart>$.block_start&&(z($,!1),$.strm.avail_out),R)}),new re(4,4,8,4,xe),new re(4,5,16,8,xe),new re(4,6,32,32,xe),new re(4,4,16,16,ye),new re(8,16,32,32,ye),new re(8,16,128,128,ye),new re(8,32,128,256,ye),new re(32,128,258,1024,ye),new re(32,258,258,4096,ye)],i.deflateInit=function($,H){return ut($,H,E,15,8,0)},i.deflateInit2=ut,i.deflateReset=ue,i.deflateResetKeep=je,i.deflateSetHeader=function($,H){return $&&$.state?$.state.wrap!==2?x:($.state.gzhead=H,m):x},i.deflate=function($,H){var ie,G,J,le;if(!$||!$.state||5<H||H<0)return $?te($,x):x;if(G=$.state,!$.output||!$.input&&$.avail_in!==0||G.status===666&&H!==g)return te($,$.avail_out===0?-5:x);if(G.strm=$,ie=G.last_flush,G.last_flush=H,G.status===j)if(G.wrap===2)$.adler=0,ee(G,31),ee(G,139),ee(G,8),G.gzhead?(ee(G,(G.gzhead.text?1:0)+(G.gzhead.hcrc?2:0)+(G.gzhead.extra?4:0)+(G.gzhead.name?8:0)+(G.gzhead.comment?16:0)),ee(G,255&G.gzhead.time),ee(G,G.gzhead.time>>8&255),ee(G,G.gzhead.time>>16&255),ee(G,G.gzhead.time>>24&255),ee(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),ee(G,255&G.gzhead.os),G.gzhead.extra&&G.gzhead.extra.length&&(ee(G,255&G.gzhead.extra.length),ee(G,G.gzhead.extra.length>>8&255)),G.gzhead.hcrc&&($.adler=u($.adler,G.pending_buf,G.pending,0)),G.gzindex=0,G.status=69):(ee(G,0),ee(G,0),ee(G,0),ee(G,0),ee(G,0),ee(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),ee(G,3),G.status=q);else{var Pe=E+(G.w_bits-8<<4)<<8;Pe|=(2<=G.strategy||G.level<2?0:G.level<6?1:G.level===6?2:3)<<6,G.strstart!==0&&(Pe|=32),Pe+=31-Pe%31,G.status=q,ae(G,Pe),G.strstart!==0&&(ae(G,$.adler>>>16),ae(G,65535&$.adler)),$.adler=1}if(G.status===69)if(G.gzhead.extra){for(J=G.pending;G.gzindex<(65535&G.gzhead.extra.length)&&(G.pending!==G.pending_buf_size||(G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),U($),J=G.pending,G.pending!==G.pending_buf_size));)ee(G,255&G.gzhead.extra[G.gzindex]),G.gzindex++;G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),G.gzindex===G.gzhead.extra.length&&(G.gzindex=0,G.status=73)}else G.status=73;if(G.status===73)if(G.gzhead.name){J=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),U($),J=G.pending,G.pending===G.pending_buf_size)){le=1;break}le=G.gzindex<G.gzhead.name.length?255&G.gzhead.name.charCodeAt(G.gzindex++):0,ee(G,le)}while(le!==0);G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),le===0&&(G.gzindex=0,G.status=91)}else G.status=91;if(G.status===91)if(G.gzhead.comment){J=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),U($),J=G.pending,G.pending===G.pending_buf_size)){le=1;break}le=G.gzindex<G.gzhead.comment.length?255&G.gzhead.comment.charCodeAt(G.gzindex++):0,ee(G,le)}while(le!==0);G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),le===0&&(G.status=103)}else G.status=103;if(G.status===103&&(G.gzhead.hcrc?(G.pending+2>G.pending_buf_size&&U($),G.pending+2<=G.pending_buf_size&&(ee(G,255&$.adler),ee(G,$.adler>>8&255),$.adler=0,G.status=q)):G.status=q),G.pending!==0){if(U($),$.avail_out===0)return G.last_flush=-1,m}else if($.avail_in===0&&Y(H)<=Y(ie)&&H!==g)return te($,-5);if(G.status===666&&$.avail_in!==0)return te($,-5);if($.avail_in!==0||G.lookahead!==0||H!==f&&G.status!==666){var Ne=G.strategy===2?(function(Se,B){for(var L;;){if(Se.lookahead===0&&(de(Se),Se.lookahead===0)){if(B===f)return R;break}if(Se.match_length=0,L=o._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++,L&&(z(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,B===g?(z(Se,!0),Se.strm.avail_out===0?K:V):Se.last_lit&&(z(Se,!1),Se.strm.avail_out===0)?R:W})(G,H):G.strategy===3?(function(Se,B){for(var L,ne,be,we,ge=Se.window;;){if(Se.lookahead<=D){if(de(Se),Se.lookahead<=D&&B===f)return R;if(Se.lookahead===0)break}if(Se.match_length=0,Se.lookahead>=C&&0<Se.strstart&&(ne=ge[be=Se.strstart-1])===ge[++be]&&ne===ge[++be]&&ne===ge[++be]){we=Se.strstart+D;do;while(ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&be<we);Se.match_length=D-(we-be),Se.match_length>Se.lookahead&&(Se.match_length=Se.lookahead)}if(Se.match_length>=C?(L=o._tr_tally(Se,1,Se.match_length-C),Se.lookahead-=Se.match_length,Se.strstart+=Se.match_length,Se.match_length=0):(L=o._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++),L&&(z(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,B===g?(z(Se,!0),Se.strm.avail_out===0?K:V):Se.last_lit&&(z(Se,!1),Se.strm.avail_out===0)?R:W})(G,H):s[G.level].func(G,H);if(Ne!==K&&Ne!==V||(G.status=666),Ne===R||Ne===K)return $.avail_out===0&&(G.last_flush=-1),m;if(Ne===W&&(H===1?o._tr_align(G):H!==5&&(o._tr_stored_block(G,0,0,!1),H===3&&(Z(G.head),G.lookahead===0&&(G.strstart=0,G.block_start=0,G.insert=0))),U($),$.avail_out===0))return G.last_flush=-1,m}return H!==g?m:G.wrap<=0?1:(G.wrap===2?(ee(G,255&$.adler),ee(G,$.adler>>8&255),ee(G,$.adler>>16&255),ee(G,$.adler>>24&255),ee(G,255&$.total_in),ee(G,$.total_in>>8&255),ee(G,$.total_in>>16&255),ee(G,$.total_in>>24&255)):(ae(G,$.adler>>>16),ae(G,65535&$.adler)),U($),0<G.wrap&&(G.wrap=-G.wrap),G.pending!==0?m:1)},i.deflateEnd=function($){var H;return $&&$.state?(H=$.state.status)!==j&&H!==69&&H!==73&&H!==91&&H!==103&&H!==q&&H!==666?te($,x):($.state=null,H===q?te($,-3):m):x},i.deflateSetDictionary=function($,H){var ie,G,J,le,Pe,Ne,Se,B,L=H.length;if(!$||!$.state||(le=(ie=$.state).wrap)===2||le===1&&ie.status!==j||ie.lookahead)return x;for(le===1&&($.adler=c($.adler,H,L,0)),ie.wrap=0,L>=ie.w_size&&(le===0&&(Z(ie.head),ie.strstart=0,ie.block_start=0,ie.insert=0),B=new a.Buf8(ie.w_size),a.arraySet(B,H,L-ie.w_size,ie.w_size,0),H=B,L=ie.w_size),Pe=$.avail_in,Ne=$.next_in,Se=$.input,$.avail_in=L,$.next_in=0,$.input=H,de(ie);ie.lookahead>=C;){for(G=ie.strstart,J=ie.lookahead-(C-1);ie.ins_h=(ie.ins_h<<ie.hash_shift^ie.window[G+C-1])&ie.hash_mask,ie.prev[G&ie.w_mask]=ie.head[ie.ins_h],ie.head[ie.ins_h]=G,G++,--J;);ie.strstart=G,ie.lookahead=C-1,de(ie)}return ie.strstart+=ie.lookahead,ie.block_start=ie.strstart,ie.insert=ie.lookahead,ie.lookahead=0,ie.match_length=ie.prev_length=C-1,ie.match_available=0,$.next_in=Ne,$.input=Se,$.avail_in=Pe,ie.wrap=le,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(s,a){var o,c,u,d,f,g,m,x,y,v,b,E,w,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,w=o.bits,A=o.lencode,T=o.distcode,k=(1<<o.lenbits)-1,N=(1<<o.distbits)-1;e:do{w<15&&(E+=R[c++]<<w,w+=8,E+=R[c++]<<w,w+=8),I=A[E&k];t:for(;;){if(E>>>=C=I>>>24,w-=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)&&(w<C&&(E+=R[c++]<<w,w+=8),D+=E&(1<<C)-1,E>>>=C,w-=C),w<15&&(E+=R[c++]<<w,w+=8,E+=R[c++]<<w,w+=8),I=T[E&N];n:for(;;){if(E>>>=C=I>>>24,w-=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,w<(C&=15)&&(E+=R[c++]<<w,(w+=8)<C&&(E+=R[c++]<<w,w+=8)),m<(F+=E&(1<<C)-1)){s.msg="invalid distance too far back",o.mode=30;break e}if(E>>>=C,w-=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=w>>3,E&=(1<<(w-=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=w}},{}],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 w(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,w(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=w,i.inflateInit=function(j){return k(j,15)},i.inflateInit2=k,i.inflate=function(j,q){var R,W,K,V,te,Y,Z,U,z,ee,ae,fe,de,xe,ye,re,ve,je,ue,ut,$,H,ie,G,J=0,le=new s.Buf8(4),Pe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!j||!j.state||!j.output||!j.input&&j.avail_in!==0)return m;(R=j.state).mode===12&&(R.mode=13),te=j.next_out,K=j.output,Z=j.avail_out,V=j.next_in,W=j.input,Y=j.avail_in,U=R.hold,z=R.bits,ee=Y,ae=Z,H=g;e:for(;;)switch(R.mode){case x:if(R.wrap===0){R.mode=13;break}for(;z<16;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(2&R.wrap&&U===35615){le[R.check=0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0),z=U=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&U)<<8)+(U>>8))%31){j.msg="incorrect header check",R.mode=30;break}if((15&U)!=8){j.msg="unknown compression method",R.mode=30;break}if(z-=4,$=8+(15&(U>>>=4)),R.wbits===0)R.wbits=$;else if($>R.wbits){j.msg="invalid window size",R.mode=30;break}R.dmax=1<<$,j.adler=R.check=1,R.mode=512&U?10:12,z=U=0;break;case 2:for(;z<16;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(R.flags=U,(255&R.flags)!=8){j.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){j.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=U>>8&1),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0)),z=U=0,R.mode=3;case 3:for(;z<32;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.head&&(R.head.time=U),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,le[2]=U>>>16&255,le[3]=U>>>24&255,R.check=o(R.check,le,4,0)),z=U=0,R.mode=4;case 4:for(;z<16;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.head&&(R.head.xflags=255&U,R.head.os=U>>8),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0)),z=U=0,R.mode=5;case 5:if(1024&R.flags){for(;z<16;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.length=U,R.head&&(R.head.extra_len=U),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0)),z=U=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(Y<(fe=R.length)&&(fe=Y),fe&&(R.head&&($=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),s.arraySet(R.head.extra,W,V,fe,$)),512&R.flags&&(R.check=o(R.check,W,fe,V)),Y-=fe,V+=fe,R.length-=fe),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(Y===0)break e;for(fe=0;$=W[V+fe++],R.head&&$&&R.length<65536&&(R.head.name+=String.fromCharCode($)),$&&fe<Y;);if(512&R.flags&&(R.check=o(R.check,W,fe,V)),Y-=fe,V+=fe,$)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(Y===0)break e;for(fe=0;$=W[V+fe++],R.head&&$&&R.length<65536&&(R.head.comment+=String.fromCharCode($)),$&&fe<Y;);if(512&R.flags&&(R.check=o(R.check,W,fe,V)),Y-=fe,V+=fe,$)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;z<16;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(U!==(65535&R.check)){j.msg="header crc mismatch",R.mode=30;break}z=U=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),j.adler=R.check=0,R.mode=12;break;case 10:for(;z<32;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}j.adler=R.check=b(U),z=U=0,R.mode=11;case 11:if(R.havedict===0)return j.next_out=te,j.avail_out=Z,j.next_in=V,j.avail_in=Y,R.hold=U,R.bits=z,2;j.adler=R.check=1,R.mode=12;case 12:if(q===5||q===6)break e;case 13:if(R.last){U>>>=7&z,z-=7&z,R.mode=27;break}for(;z<3;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}switch(R.last=1&U,z-=1,3&(U>>>=1)){case 0:R.mode=14;break;case 1:if(D(R),R.mode=20,q!==6)break;U>>>=2,z-=2;break e;case 2:R.mode=17;break;case 3:j.msg="invalid block type",R.mode=30}U>>>=2,z-=2;break;case 14:for(U>>>=7&z,z-=7&z;z<32;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if((65535&U)!=(U>>>16^65535)){j.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&U,z=U=0,R.mode=15,q===6)break e;case 15:R.mode=16;case 16:if(fe=R.length){if(Y<fe&&(fe=Y),Z<fe&&(fe=Z),fe===0)break e;s.arraySet(K,W,V,fe,te),Y-=fe,V+=fe,Z-=fe,te+=fe,R.length-=fe;break}R.mode=12;break;case 17:for(;z<14;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(R.nlen=257+(31&U),U>>>=5,z-=5,R.ndist=1+(31&U),U>>>=5,z-=5,R.ncode=4+(15&U),U>>>=4,z-=4,286<R.nlen||30<R.ndist){j.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;z<3;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.lens[Pe[R.have++]]=7&U,U>>>=3,z-=3}for(;R.have<19;)R.lens[Pe[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,ie={bits:R.lenbits},H=u(0,R.lens,0,19,R.lencode,0,R.work,ie),R.lenbits=ie.bits,H){j.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;re=(J=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,ve=65535&J,!((ye=J>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(ve<16)U>>>=ye,z-=ye,R.lens[R.have++]=ve;else{if(ve===16){for(G=ye+2;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(U>>>=ye,z-=ye,R.have===0){j.msg="invalid bit length repeat",R.mode=30;break}$=R.lens[R.have-1],fe=3+(3&U),U>>>=2,z-=2}else if(ve===17){for(G=ye+3;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}z-=ye,$=0,fe=3+(7&(U>>>=ye)),U>>>=3,z-=3}else{for(G=ye+7;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}z-=ye,$=0,fe=11+(127&(U>>>=ye)),U>>>=7,z-=7}if(R.have+fe>R.nlen+R.ndist){j.msg="invalid bit length repeat",R.mode=30;break}for(;fe--;)R.lens[R.have++]=$}}if(R.mode===30)break;if(R.lens[256]===0){j.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,ie={bits:R.lenbits},H=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,ie),R.lenbits=ie.bits,H){j.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,ie={bits:R.distbits},H=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,ie),R.distbits=ie.bits,H){j.msg="invalid distances set",R.mode=30;break}if(R.mode=20,q===6)break e;case 20:R.mode=21;case 21:if(6<=Y&&258<=Z){j.next_out=te,j.avail_out=Z,j.next_in=V,j.avail_in=Y,R.hold=U,R.bits=z,c(j,ae),te=j.next_out,K=j.output,Z=j.avail_out,V=j.next_in,W=j.input,Y=j.avail_in,U=R.hold,z=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;re=(J=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,ve=65535&J,!((ye=J>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(re&&(240&re)==0){for(je=ye,ue=re,ut=ve;re=(J=R.lencode[ut+((U&(1<<je+ue)-1)>>je)])>>>16&255,ve=65535&J,!(je+(ye=J>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}U>>>=je,z-=je,R.back+=je}if(U>>>=ye,z-=ye,R.back+=ye,R.length=ve,re===0){R.mode=26;break}if(32&re){R.back=-1,R.mode=12;break}if(64&re){j.msg="invalid literal/length code",R.mode=30;break}R.extra=15&re,R.mode=22;case 22:if(R.extra){for(G=R.extra;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.length+=U&(1<<R.extra)-1,U>>>=R.extra,z-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;re=(J=R.distcode[U&(1<<R.distbits)-1])>>>16&255,ve=65535&J,!((ye=J>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if((240&re)==0){for(je=ye,ue=re,ut=ve;re=(J=R.distcode[ut+((U&(1<<je+ue)-1)>>je)])>>>16&255,ve=65535&J,!(je+(ye=J>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}U>>>=je,z-=je,R.back+=je}if(U>>>=ye,z-=ye,R.back+=ye,64&re){j.msg="invalid distance code",R.mode=30;break}R.offset=ve,R.extra=15&re,R.mode=24;case 24:if(R.extra){for(G=R.extra;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.offset+=U&(1<<R.extra)-1,U>>>=R.extra,z-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){j.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(Z===0)break e;if(fe=ae-Z,R.offset>fe){if((fe=R.offset-fe)>R.whave&&R.sane){j.msg="invalid distance too far back",R.mode=30;break}de=fe>R.wnext?(fe-=R.wnext,R.wsize-fe):R.wnext-fe,fe>R.length&&(fe=R.length),xe=R.window}else xe=K,de=te-R.offset,fe=R.length;for(Z<fe&&(fe=Z),Z-=fe,R.length-=fe;K[te++]=xe[de++],--fe;);R.length===0&&(R.mode=21);break;case 26:if(Z===0)break e;K[te++]=R.length,Z--,R.mode=21;break;case 27:if(R.wrap){for(;z<32;){if(Y===0)break e;Y--,U|=W[V++]<<z,z+=8}if(ae-=Z,j.total_out+=ae,R.total+=ae,ae&&(j.adler=R.check=R.flags?o(R.check,K,ae,te-ae):a(R.check,K,ae,te-ae)),ae=Z,(R.flags?U:b(U))!==R.check){j.msg="incorrect data check",R.mode=30;break}z=U=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;z<32;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(U!==(4294967295&R.total)){j.msg="incorrect length check",R.mode=30;break}z=U=0}R.mode=29;case 29:H=1;break e;case 30:H=-3;break e;case 31:return-4;case 32:default:return m}return j.next_out=te,j.avail_out=Z,j.next_in=V,j.avail_in=Y,R.hold=U,R.bits=z,(R.wsize||ae!==j.avail_out&&R.mode<30&&(R.mode<27||q!==4))&&F(j,j.output,j.next_out,ae-j.avail_out)?(R.mode=31,-4):(ee-=j.avail_in,ae-=j.avail_out,j.total_in+=ee,j.total_out+=ae,R.total+=ae,R.wrap&&ae&&(j.adler=R.check=R.flags?o(R.check,K,ae,j.next_out-ae):a(R.check,K,ae,j.next_out-ae)),j.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(ee==0&&ae===0||q===4)&&H===g&&(H=-5),H)},i.inflateEnd=function(j){if(!j||!j.state)return m;var q=j.state;return q.window&&(q.window=null),j.state=null,g},i.inflateGetHeader=function(j,q){var R;return j&&j.state?(2&(R=j.state).wrap)==0?m:((R.head=q).done=!1,g):m},i.inflateSetDictionary=function(j,q){var R,W=q.length;return j&&j.state?(R=j.state).wrap!==0&&R.mode!==11?m:R.mode===11&&a(1,q,W,0)!==R.check?-3:F(j,q,W,W)?(R.mode=31,-4):(R.havedict=1,g):m},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var s=n("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],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,w,A,T,k,N,I,C,D,F=b.bits,j=0,q=0,R=0,W=0,K=0,V=0,te=0,Y=0,Z=0,U=0,z=null,ee=0,ae=new s.Buf16(16),fe=new s.Buf16(16),de=null,xe=0;for(j=0;j<=15;j++)ae[j]=0;for(q=0;q<m;q++)ae[f[g+q]]++;for(K=F,W=15;1<=W&&ae[W]===0;W--);if(W<K&&(K=W),W===0)return x[y++]=20971520,x[y++]=20971520,b.bits=1,0;for(R=1;R<W&&ae[R]===0;R++);for(K<R&&(K=R),j=Y=1;j<=15;j++)if(Y<<=1,(Y-=ae[j])<0)return-1;if(0<Y&&(d===0||W!==1))return-1;for(fe[1]=0,j=1;j<15;j++)fe[j+1]=fe[j]+ae[j];for(q=0;q<m;q++)f[g+q]!==0&&(v[fe[f[g+q]]++]=q);if(N=d===0?(z=de=v,19):d===1?(z=a,ee-=257,de=o,xe-=257,256):(z=c,de=u,-1),j=R,k=y,te=q=U=0,A=-1,T=(Z=1<<(V=K))-1,d===1&&852<Z||d===2&&592<Z)return 1;for(;;){for(I=j-te,D=v[q]<N?(C=0,v[q]):v[q]>N?(C=de[xe+v[q]],z[ee+v[q]]):(C=96,0),E=1<<j-te,R=w=1<<V;x[k+(U>>te)+(w-=E)]=I<<24|C<<16|D|0,w!==0;);for(E=1<<j-1;U&E;)E>>=1;if(E!==0?(U&=E-1,U+=E):U=0,q++,--ae[j]==0){if(j===W)break;j=f[g+v[q]]}if(K<j&&(U&T)!==A){for(te===0&&(te=K),k+=R,Y=1<<(V=j-te);V+te<W&&!((Y-=ae[V+te])<=0);)V++,Y<<=1;if(Z+=1<<V,d===1&&852<Z||d===2&&592<Z)return 1;x[A=U&T]=K<<24|V<<16|k-y|0}}return U!==0&&(x[k+U]=j-te<<24|64<<16|0),b.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var s=n("../utils/common"),a=0,o=1;function c(J){for(var le=J.length;0<=--le;)J[le]=0}var u=0,d=29,f=256,g=f+1+d,m=30,x=19,y=2*g+1,v=15,b=16,E=7,w=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,te,Y=new Array(m);function Z(J,le,Pe,Ne,Se){this.static_tree=J,this.extra_bits=le,this.extra_base=Pe,this.elems=Ne,this.max_length=Se,this.has_stree=J&&J.length}function U(J,le){this.dyn_tree=J,this.max_code=0,this.stat_desc=le}function z(J){return J<256?q[J]:q[256+(J>>>7)]}function ee(J,le){J.pending_buf[J.pending++]=255&le,J.pending_buf[J.pending++]=le>>>8&255}function ae(J,le,Pe){J.bi_valid>b-Pe?(J.bi_buf|=le<<J.bi_valid&65535,ee(J,J.bi_buf),J.bi_buf=le>>b-J.bi_valid,J.bi_valid+=Pe-b):(J.bi_buf|=le<<J.bi_valid&65535,J.bi_valid+=Pe)}function fe(J,le,Pe){ae(J,Pe[2*le],Pe[2*le+1])}function de(J,le){for(var Pe=0;Pe|=1&J,J>>>=1,Pe<<=1,0<--le;);return Pe>>>1}function xe(J,le,Pe){var Ne,Se,B=new Array(v+1),L=0;for(Ne=1;Ne<=v;Ne++)B[Ne]=L=L+Pe[Ne-1]<<1;for(Se=0;Se<=le;Se++){var ne=J[2*Se+1];ne!==0&&(J[2*Se]=de(B[ne]++,ne))}}function ye(J){var le;for(le=0;le<g;le++)J.dyn_ltree[2*le]=0;for(le=0;le<m;le++)J.dyn_dtree[2*le]=0;for(le=0;le<x;le++)J.bl_tree[2*le]=0;J.dyn_ltree[2*w]=1,J.opt_len=J.static_len=0,J.last_lit=J.matches=0}function re(J){8<J.bi_valid?ee(J,J.bi_buf):0<J.bi_valid&&(J.pending_buf[J.pending++]=J.bi_buf),J.bi_buf=0,J.bi_valid=0}function ve(J,le,Pe,Ne){var Se=2*le,B=2*Pe;return J[Se]<J[B]||J[Se]===J[B]&&Ne[le]<=Ne[Pe]}function je(J,le,Pe){for(var Ne=J.heap[Pe],Se=Pe<<1;Se<=J.heap_len&&(Se<J.heap_len&&ve(le,J.heap[Se+1],J.heap[Se],J.depth)&&Se++,!ve(le,Ne,J.heap[Se],J.depth));)J.heap[Pe]=J.heap[Se],Pe=Se,Se<<=1;J.heap[Pe]=Ne}function ue(J,le,Pe){var Ne,Se,B,L,ne=0;if(J.last_lit!==0)for(;Ne=J.pending_buf[J.d_buf+2*ne]<<8|J.pending_buf[J.d_buf+2*ne+1],Se=J.pending_buf[J.l_buf+ne],ne++,Ne===0?fe(J,Se,le):(fe(J,(B=R[Se])+f+1,le),(L=N[B])!==0&&ae(J,Se-=W[B],L),fe(J,B=z(--Ne),Pe),(L=I[B])!==0&&ae(J,Ne-=Y[B],L)),ne<J.last_lit;);fe(J,w,le)}function ut(J,le){var Pe,Ne,Se,B=le.dyn_tree,L=le.stat_desc.static_tree,ne=le.stat_desc.has_stree,be=le.stat_desc.elems,we=-1;for(J.heap_len=0,J.heap_max=y,Pe=0;Pe<be;Pe++)B[2*Pe]!==0?(J.heap[++J.heap_len]=we=Pe,J.depth[Pe]=0):B[2*Pe+1]=0;for(;J.heap_len<2;)B[2*(Se=J.heap[++J.heap_len]=we<2?++we:0)]=1,J.depth[Se]=0,J.opt_len--,ne&&(J.static_len-=L[2*Se+1]);for(le.max_code=we,Pe=J.heap_len>>1;1<=Pe;Pe--)je(J,B,Pe);for(Se=be;Pe=J.heap[1],J.heap[1]=J.heap[J.heap_len--],je(J,B,1),Ne=J.heap[1],J.heap[--J.heap_max]=Pe,J.heap[--J.heap_max]=Ne,B[2*Se]=B[2*Pe]+B[2*Ne],J.depth[Se]=(J.depth[Pe]>=J.depth[Ne]?J.depth[Pe]:J.depth[Ne])+1,B[2*Pe+1]=B[2*Ne+1]=Se,J.heap[1]=Se++,je(J,B,1),2<=J.heap_len;);J.heap[--J.heap_max]=J.heap[1],(function(ge,me){var Ae,ze,st,Ve,ce,Ye,$e=me.dyn_tree,Ze=me.max_code,at=me.stat_desc.static_tree,Q=me.stat_desc.has_stree,Fe=me.stat_desc.extra_bits,pe=me.stat_desc.extra_base,Ue=me.stat_desc.max_length,Ce=0;for(Ve=0;Ve<=v;Ve++)ge.bl_count[Ve]=0;for($e[2*ge.heap[ge.heap_max]+1]=0,Ae=ge.heap_max+1;Ae<y;Ae++)Ue<(Ve=$e[2*$e[2*(ze=ge.heap[Ae])+1]+1]+1)&&(Ve=Ue,Ce++),$e[2*ze+1]=Ve,Ze<ze||(ge.bl_count[Ve]++,ce=0,pe<=ze&&(ce=Fe[ze-pe]),Ye=$e[2*ze],ge.opt_len+=Ye*(Ve+ce),Q&&(ge.static_len+=Ye*(at[2*ze+1]+ce)));if(Ce!==0){do{for(Ve=Ue-1;ge.bl_count[Ve]===0;)Ve--;ge.bl_count[Ve]--,ge.bl_count[Ve+1]+=2,ge.bl_count[Ue]--,Ce-=2}while(0<Ce);for(Ve=Ue;Ve!==0;Ve--)for(ze=ge.bl_count[Ve];ze!==0;)Ze<(st=ge.heap[--Ae])||($e[2*st+1]!==Ve&&(ge.opt_len+=(Ve-$e[2*st+1])*$e[2*st],$e[2*st+1]=Ve),ze--)}})(J,le),xe(B,we,J.bl_count)}function $(J,le,Pe){var Ne,Se,B=-1,L=le[1],ne=0,be=7,we=4;for(L===0&&(be=138,we=3),le[2*(Pe+1)+1]=65535,Ne=0;Ne<=Pe;Ne++)Se=L,L=le[2*(Ne+1)+1],++ne<be&&Se===L||(ne<we?J.bl_tree[2*Se]+=ne:Se!==0?(Se!==B&&J.bl_tree[2*Se]++,J.bl_tree[2*A]++):ne<=10?J.bl_tree[2*T]++:J.bl_tree[2*k]++,B=Se,we=(ne=0)===L?(be=138,3):Se===L?(be=6,3):(be=7,4))}function H(J,le,Pe){var Ne,Se,B=-1,L=le[1],ne=0,be=7,we=4;for(L===0&&(be=138,we=3),Ne=0;Ne<=Pe;Ne++)if(Se=L,L=le[2*(Ne+1)+1],!(++ne<be&&Se===L)){if(ne<we)for(;fe(J,Se,J.bl_tree),--ne!=0;);else Se!==0?(Se!==B&&(fe(J,Se,J.bl_tree),ne--),fe(J,A,J.bl_tree),ae(J,ne-3,2)):ne<=10?(fe(J,T,J.bl_tree),ae(J,ne-3,3)):(fe(J,k,J.bl_tree),ae(J,ne-11,7));B=Se,we=(ne=0)===L?(be=138,3):Se===L?(be=6,3):(be=7,4)}}c(Y);var ie=!1;function G(J,le,Pe,Ne){ae(J,(u<<1)+(Ne?1:0),3),(function(Se,B,L,ne){re(Se),ee(Se,L),ee(Se,~L),s.arraySet(Se.pending_buf,Se.window,B,L,Se.pending),Se.pending+=L})(J,le,Pe)}i._tr_init=function(J){ie||((function(){var le,Pe,Ne,Se,B,L=new Array(v+1);for(Se=Ne=0;Se<d-1;Se++)for(W[Se]=Ne,le=0;le<1<<N[Se];le++)R[Ne++]=Se;for(R[Ne-1]=Se,Se=B=0;Se<16;Se++)for(Y[Se]=B,le=0;le<1<<I[Se];le++)q[B++]=Se;for(B>>=7;Se<m;Se++)for(Y[Se]=B<<7,le=0;le<1<<I[Se]-7;le++)q[256+B++]=Se;for(Pe=0;Pe<=v;Pe++)L[Pe]=0;for(le=0;le<=143;)F[2*le+1]=8,le++,L[8]++;for(;le<=255;)F[2*le+1]=9,le++,L[9]++;for(;le<=279;)F[2*le+1]=7,le++,L[7]++;for(;le<=287;)F[2*le+1]=8,le++,L[8]++;for(xe(F,g+1,L),le=0;le<m;le++)j[2*le+1]=5,j[2*le]=de(le,5);K=new Z(F,N,f+1,g,v),V=new Z(j,I,0,m,v),te=new Z(new Array(0),C,0,x,E)})(),ie=!0),J.l_desc=new U(J.dyn_ltree,K),J.d_desc=new U(J.dyn_dtree,V),J.bl_desc=new U(J.bl_tree,te),J.bi_buf=0,J.bi_valid=0,ye(J)},i._tr_stored_block=G,i._tr_flush_block=function(J,le,Pe,Ne){var Se,B,L=0;0<J.level?(J.strm.data_type===2&&(J.strm.data_type=(function(ne){var be,we=4093624447;for(be=0;be<=31;be++,we>>>=1)if(1&we&&ne.dyn_ltree[2*be]!==0)return a;if(ne.dyn_ltree[18]!==0||ne.dyn_ltree[20]!==0||ne.dyn_ltree[26]!==0)return o;for(be=32;be<f;be++)if(ne.dyn_ltree[2*be]!==0)return o;return a})(J)),ut(J,J.l_desc),ut(J,J.d_desc),L=(function(ne){var be;for($(ne,ne.dyn_ltree,ne.l_desc.max_code),$(ne,ne.dyn_dtree,ne.d_desc.max_code),ut(ne,ne.bl_desc),be=x-1;3<=be&&ne.bl_tree[2*D[be]+1]===0;be--);return ne.opt_len+=3*(be+1)+5+5+4,be})(J),Se=J.opt_len+3+7>>>3,(B=J.static_len+3+7>>>3)<=Se&&(Se=B)):Se=B=Pe+5,Pe+4<=Se&&le!==-1?G(J,le,Pe,Ne):J.strategy===4||B===Se?(ae(J,2+(Ne?1:0),3),ue(J,F,j)):(ae(J,4+(Ne?1:0),3),(function(ne,be,we,ge){var me;for(ae(ne,be-257,5),ae(ne,we-1,5),ae(ne,ge-4,4),me=0;me<ge;me++)ae(ne,ne.bl_tree[2*D[me]+1],3);H(ne,ne.dyn_ltree,be-1),H(ne,ne.dyn_dtree,we-1)})(J,J.l_desc.max_code+1,J.d_desc.max_code+1,L+1),ue(J,J.dyn_ltree,J.dyn_dtree)),ye(J),Ne&&re(J)},i._tr_tally=function(J,le,Pe){return J.pending_buf[J.d_buf+2*J.last_lit]=le>>>8&255,J.pending_buf[J.d_buf+2*J.last_lit+1]=255&le,J.pending_buf[J.l_buf+J.last_lit]=255&Pe,J.last_lit++,le===0?J.dyn_ltree[2*Pe]++:(J.matches++,le--,J.dyn_ltree[2*(R[Pe]+f+1)]++,J.dyn_dtree[2*z(le)]++),J.last_lit===J.lit_bufsize-1},i._tr_align=function(J){ae(J,2,3),fe(J,w,F),(function(le){le.bi_valid===16?(ee(le,le.bi_buf),le.bi_buf=0,le.bi_valid=0):8<=le.bi_valid&&(le.pending_buf[le.pending++]=255&le.bi_buf,le.bi_buf>>=8,le.bi_valid-=8)})(J)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(s){(function(a,o){if(!a.setImmediate){var 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",w,!1):a.attachEvent("onmessage",w),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 w(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 dy<"u"?dy:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(GC)),GC.exports}var eOe=JDe();const tOe=uo(eOe);function nOe(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=nOe;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 rOe(t){const e=await tOe.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=[],w=[],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];w.push(parseInt(N.getAttribute("v1")||"0"),parseInt(N.getAttribute("v2")||"0"),parseInt(N.getAttribute("v3")||"0"))}E.length>0&&w.length>0&&m.push({vertices:E,triangles:w})}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 w=await s(E);if(w){const A=await LH(w),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 Je(N.vertices[C],N.vertices[C+1],N.vertices[C+2]);D.applyMatrix4(k),I.push(D.x,D.y,D.z)}m.push({vertices:I,triangles:N.triangles})}else m.push(N)}}}m.length>0&&n.set(g,{id:g,meshes:m})}const u=o.getElementsByTagName("build");if(u.length>0){const d=u[0].getElementsByTagName("item");for(let f=0;f<d.length;f++){const g=d[f],m=g.getAttribute("objectid");if(!m)continue;const x=jH(g.getAttribute("transform"));r.push({objectId:m,transform:x})}}return{objects:n,buildItems:r}}function IH(t){const e=new El,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 no(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function iOe({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 jNe;b.background=new yn(1710618),s.current=b;const E=new Ka(45,y/v,.1,1e4);E.position.set(150,150,150),a.current=E;const w=new IDe({antialias:!0});w.setSize(y,v),w.setPixelRatio(window.devicePixelRatio),x.appendChild(w.domElement),i.current=w;const A=new FDe(E,w.domElement);A.enableDamping=!0,A.dampingFactor=.05,o.current=A;const T=new qNe(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 XNe(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:nl}),q=new gl(F,j);q.rotation.x=-Math.PI/2,q.position.y=-.5,b.add(q);let R;const W=()=>{R=requestAnimationFrame(W),A.update(),w.render(b,E)};W(),fetch(t).then(V=>{if(!V.ok)throw new Error("Failed to load file");return V.arrayBuffer()}).then(rOe).then(({objects:V,buildItems:te})=>{if(V.size===0)throw new Error("No meshes found in 3MF file");const Y=new HNe({color:44610,shininess:30,flatShading:!1}),Z=new jx,U=[];if(te.length>0)for(const re of te){const ve=V.get(re.objectId);if(ve)for(const je of ve.meshes){const ue=[];for(let $=0;$<je.vertices.length;$+=3){const H=new Je(je.vertices[$],je.vertices[$+1],je.vertices[$+2]);H.applyMatrix4(re.transform),ue.push(H.x,H.y,H.z)}const ut=IH({vertices:ue,triangles:je.triangles});U.push(ut)}}else for(const re of V.values())for(const ve of re.meshes){const je=IH(ve);U.push(je)}if(U.length>0){const re=U.length===1?U[0]:QDe(U,!1);if(re){const ve=new gl(re,Y);Z.add(ve)}if(U.length>1)for(const ve of U)ve.dispose()}const z=new tf().setFromObject(Z),ee=z.getCenter(new Je);Z.position.y=-z.min.y,te.length===0&&(Z.position.x=-ee.x,Z.position.z=-ee.z),b.add(Z);const ae=new tf().setFromObject(Z),fe=ae.getCenter(new Je),de=ae.getSize(new Je),ye=Math.max(de.x,de.y,de.z)*1.8;E.position.set(fe.x+ye*.7,fe.y+ye*.5,fe.z+ye*.7),A.target.copy(fe),A.update(),u(!1)}).catch(V=>{f(V.message),u(!1)});const K=()=>{if(!x)return;const V=x.clientWidth,te=x.clientHeight;E.aspect=V/te,E.updateProjectionMatrix(),w.setSize(V,te)};return window.addEventListener("resize",K),()=>{window.removeEventListener("resize",K),cancelAnimationFrame(R),A.dispose(),w.dispose(),x.removeChild(w.domElement)}},[t,e]);const g=()=>{a.current&&o.current&&(a.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},m=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(Ie,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:l.jsx(Lue,{className:"w-4 h-4"})}),l.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:l.jsx(Fue,{className:"w-4 h-4"})}),l.jsx(Ie,{variant:"secondary",size:"sm",onClick:g,children:l.jsx(Km,{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},sOe=0,UH=1,aOe=2,wZ=1,oOe=2,ic=3,fd=0,Ks=1,uc=2,Yu=0,am=1,FH=2,zH=3,BH=4,lOe=5,lh=100,cOe=101,uOe=102,HH=103,$H=104,dOe=200,hOe=201,fOe=202,pOe=203,MP=204,AP=205,mOe=206,gOe=207,xOe=208,bOe=209,vOe=210,yOe=211,_Oe=212,wOe=213,SOe=214,EOe=0,MOe=1,AOe=2,Dw=3,TOe=4,COe=5,NOe=6,kOe=7,uj=0,POe=1,ROe=2,Zu=0,DOe=1,OOe=2,jOe=3,LOe=4,IOe=5,SZ=300,Pm=301,Rm=302,TP=303,CP=304,HE=306,NP=1e3,Co=1001,kP=1002,Yi=1003,VH=1004,WC=1005,Xa=1006,UOe=1007,q0=1008,Qu=1009,FOe=1010,zOe=1011,dj=1012,EZ=1013,Bu=1014,gc=1015,K0=1016,MZ=1017,AZ=1018,Nh=1020,BOe=1021,Ya=1023,HOe=1024,$Oe=1025,kh=1026,Dm=1027,VOe=1028,TZ=1029,GOe=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,WOe=36283,f$=36284,p$=36285,m$=36286,PZ=3e3,Ph=3001,qOe=3200,KOe=3201,RZ=0,XOe=1,Za="",Zi="srgb",jc="srgb-linear",hj="display-p3",$E="display-p3-linear",Ow="linear",lr="srgb",jw="rec709",Lw="p3",xp=7680,g$=519,YOe=512,ZOe=513,QOe=514,DZ=515,JOe=516,eje=517,tje=518,nje=519,PP=35044,x$="300 es",RP=1035,ol=2e3,X0=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 as=["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 qx=Math.PI/180,Y0=180/Math.PI;function Sc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(as[t&255]+as[t>>8&255]+as[t>>16&255]+as[t>>24&255]+"-"+as[e&255]+as[e>>8&255]+"-"+as[e>>16&15|64]+as[e>>24&255]+"-"+as[n&63|128]+as[n>>8&255]+"-"+as[n>>16&255]+as[n>>24&255]+as[r&255]+as[r>>8&255]+as[r>>16&255]+as[r>>24&255]).toLowerCase()}function Qi(t,e,n){return Math.max(e,Math.min(n,t))}function fj(t,e){return(t%e+e)%e}function rje(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function ije(t,e,n){return t!==e?(n-t)/(e-t):0}function Kx(t,e,n){return(1-n)*t+n*e}function sje(t,e,n,r){return Kx(t,e,1-Math.exp(-n*r))}function aje(t,e=1){return e-Math.abs(fj(t,e*2)-e)}function oje(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function lje(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function cje(t,e){return t+Math.floor(Math.random()*(e-t+1))}function uje(t,e){return t+Math.random()*(e-t)}function dje(t){return t*(.5-Math.random())}function hje(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 fje(t){return t*qx}function pje(t){return t*Y0}function DP(t){return(t&t-1)===0&&t!==0}function mje(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 gje(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 rl(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function qn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const OZ={DEG2RAD:qx,RAD2DEG:Y0,generateUUID:Sc,clamp:Qi,euclideanModulo:fj,mapLinear:rje,inverseLerp:ije,lerp:Kx,damp:sje,pingpong:aje,smoothstep:oje,smootherstep:lje,randInt:cje,randFloat:uje,randFloatSpread:dje,seededRandom:hje,degToRad:fje,radToDeg:pje,isPowerOfTwo:DP,ceilPowerOfTwo:mje,floorPowerOfTwo:Iw,setQuaternionFromProperEuler:gje,normalize:qn,denormalize:rl};class Yt{constructor(e=0,n=0){Yt.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Qi(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class hn{constructor(e,n,r,i,s,a,o,c,u){hn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,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],w=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*w+c*k,s[6]=a*b+o*A+c*N,s[1]=u*y+d*E+f*T,s[4]=u*v+d*w+f*k,s[7]=u*b+d*A+f*N,s[2]=g*y+m*E+x*T,s[5]=g*v+m*w+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 hn;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 xje(){const t=Uw("canvas");return t.style.display="block",t}const v$={};function Xx(t){t in v$||(v$[t]=!0,console.warn(t))}const y$=new hn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),_$=new hn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),i_={[jc]:{transfer:Ow,primaries:jw,toReference:t=>t,fromReference:t=>t},[Zi]:{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()}},bje=new Set([jc,$E]),Kn={enabled:!0,_workingColorSpace:jc,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(!bje.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=i_[e].toReference,i=i_[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 i_[t].primaries},getTransfer:function(t){return t===Za?Ow:i_[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 vje=0;class IZ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:vje++}),this.uuid=Sc(),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 yje=0;class Xs extends gf{constructor(e=Xs.DEFAULT_IMAGE,n=Xs.DEFAULT_MAPPING,r=Co,i=Co,s=Xa,a=q0,o=Ya,c=Qu,u=Xs.DEFAULT_ANISOTROPY,d=Za){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:yje++}),this.uuid=Sc(),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 Yt(0,0),this.repeat=new Yt(1,1),this.center=new Yt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new hn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Xx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Ph?Zi:Za),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 Co: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 Co: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 Xx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Zi?Ph:PZ}set encoding(e){Xx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ph?Zi:Za}}Xs.DEFAULT_IMAGE=null;Xs.DEFAULT_MAPPING=SZ;Xs.DEFAULT_ANISOTROPY=1;class Yn{constructor(e=0,n=0,r=0,i=1){Yn.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*n+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*n+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*n+a[7]*r+a[11]*i+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const 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 w=(u+1)/2,A=(m+1)/2,T=(b+1)/2,k=(d+g)/4,N=(f+y)/4,I=(x+v)/4;return w>A&&w>T?w<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(w),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 _je extends gf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Yn(0,0,e,n),this.scissorTest=!1,this.viewport=new Yn(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Xx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Ph?Zi:Za),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xa,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Xs(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 _je{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class UZ extends Xs{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=Yi,this.minFilter=Yi,this.wrapR=Co,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class wje extends Xs{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=Yi,this.minFilter=Yi,this.wrapR=Co,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,w=1-b*b;if(w>Number.EPSILON){const T=Math.sqrt(w),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(Qi(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(Qi(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 ro{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(_o.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(_o.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=_o.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const 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,_o):_o.fromBufferAttribute(s,a),_o.applyMatrix4(e.matrixWorld),this.expandByPoint(_o);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),s_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),s_.copy(r.boundingBox)),s_.applyMatrix4(e.matrixWorld),this.union(s_)}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,_o),_o.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(wx),a_.subVectors(this.max,wx),vp.subVectors(e.a,wx),yp.subVectors(e.b,wx),_p.subVectors(e.c,wx),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,a_)||(n=[1,0,0,0,1,0,0,0,1],!nN(n,vp,yp,_p,a_))?!1:(o_.crossVectors(bu,vu),n=[o_.x,o_.y,o_.z],nN(n,vp,yp,_p,a_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,_o).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(_o).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Xl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Xl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Xl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Xl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Xl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Xl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Xl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Xl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Xl),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 Xl=[new De,new De,new De,new De,new De,new De,new De,new De],_o=new De,s_=new ro,vp=new De,yp=new De,_p=new De,bu=new De,vu=new De,Kd=new De,wx=new De,a_=new De,o_=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 Sje=new ro,Sx=new De,rN=new De;class cl{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):Sje.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;Sx.subVectors(e,this.center);const n=Sx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Sx,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(Sx.copy(e.center).add(rN)),this.expandByPoint(Sx.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 Yl=new De,iN=new De,l_=new De,yu=new De,sN=new De,c_=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,Yl)),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=Yl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Yl.copy(this.origin).addScaledVector(this.direction,n),Yl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){iN.copy(e).add(n).multiplyScalar(.5),l_.copy(n).sub(e).normalize(),yu.copy(this.origin).sub(iN);const s=e.distanceTo(n)*.5,a=-this.direction.dot(l_),o=yu.dot(this.direction),c=-yu.dot(l_),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(l_,g),m}intersectSphere(e,n){Yl.subVectors(e.center,this.origin);const r=Yl.dot(this.direction),i=Yl.dot(Yl)-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,Yl)!==null}intersectTriangle(e,n,r,i,s){sN.subVectors(n,e),c_.subVectors(r,e),aN.crossVectors(sN,c_);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(c_.crossVectors(yu,c_));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(Eje,e,Mje)}lookAt(e,n,r){const i=this.elements;return ua.subVectors(e,n),ua.lengthSq()===0&&(ua.z=1),ua.normalize(),_u.crossVectors(r,ua),_u.lengthSq()===0&&(Math.abs(r.z)===1?ua.x+=1e-4:ua.z+=1e-4,ua.normalize(),_u.crossVectors(r,ua)),_u.normalize(),u_.crossVectors(ua,_u),i[0]=_u.x,i[4]=u_.x,i[8]=ua.x,i[1]=_u.y,i[5]=u_.y,i[9]=ua.y,i[2]=_u.z,i[6]=u_.z,i[10]=ua.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],w=r[7],A=r[11],T=r[15],k=i[0],N=i[4],I=i[8],C=i[12],D=i[1],F=i[5],j=i[9],q=i[13],R=i[2],W=i[6],K=i[10],V=i[14],te=i[3],Y=i[7],Z=i[11],U=i[15];return s[0]=a*k+o*D+c*R+u*te,s[4]=a*N+o*F+c*W+u*Y,s[8]=a*I+o*j+c*K+u*Z,s[12]=a*C+o*q+c*V+u*U,s[1]=d*k+f*D+g*R+m*te,s[5]=d*N+f*F+g*W+m*Y,s[9]=d*I+f*j+g*K+m*Z,s[13]=d*C+f*q+g*V+m*U,s[2]=x*k+y*D+v*R+b*te,s[6]=x*N+y*F+v*W+b*Y,s[10]=x*I+y*j+v*K+b*Z,s[14]=x*C+y*q+v*V+b*U,s[3]=E*k+w*D+A*R+T*te,s[7]=E*N+w*F+A*W+T*Y,s[11]=E*I+w*j+A*K+T*Z,s[15]=E*C+w*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,w=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*w+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]=w*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,w=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-w)*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+w)*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],wo.copy(this);const u=1/s,d=1/a,f=1/o;return wo.elements[0]*=u,wo.elements[1]*=u,wo.elements[2]*=u,wo.elements[4]*=d,wo.elements[5]*=d,wo.elements[6]*=d,wo.elements[8]*=f,wo.elements[9]*=f,wo.elements[10]*=f,n.setFromRotationMatrix(wo),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=ol){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===ol)m=-(a+s)/(a-s),x=-2*a*s/(a-s);else if(o===X0)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=ol){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===ol)x=(a+s)*f,y=-2*f;else if(o===X0)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,wo=new sr,Eje=new De(0,0,0),Mje=new De(1,1,1),_u=new De,u_=new De,ua=new De,S$=new sr,E$=new rf;class Wb{constructor(e=0,n=0,r=0,i=Wb.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(Qi(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(-Qi(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(Qi(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(-Qi(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(Qi(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(-Qi(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}}Wb.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 Aje=0;const M$=new De,Sp=new rf,Zl=new sr,d_=new De,Ex=new De,Tje=new De,Cje=new rf,A$=new De(1,0,0),T$=new De(0,1,0),C$=new De(0,0,1),Nje={type:"added"},kje={type:"removed"};class Ts extends gf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Aje++}),this.uuid=Sc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ts.DEFAULT_UP.clone();const e=new De,n=new Wb,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 hn}}),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(Zl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?d_.copy(e):d_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Ex.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zl.lookAt(Ex,d_,this.up):Zl.lookAt(d_,Ex,this.up),this.quaternion.setFromRotationMatrix(Zl),i&&(Zl.extractRotation(i.matrixWorld),Sp.setFromRotationMatrix(Zl),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(Nje)):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(kje)),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),Zl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Zl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Zl),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const a=this.children[r].getObjectByProperty(e,n);if(a!==void 0)return a}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ex,e,Tje),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ex,Cje,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 So=new De,Ql=new De,oN=new De,Jl=new De,Ep=new De,Mp=new De,N$=new De,lN=new De,cN=new De,uN=new De;let h_=!1;class Eo{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),So.subVectors(e,n),i.cross(So);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){So.subVectors(i,n),Ql.subVectors(r,n),oN.subVectors(e,n);const a=So.dot(So),o=So.dot(Ql),c=So.dot(oN),u=Ql.dot(Ql),d=Ql.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,Jl),Jl.x>=0&&Jl.y>=0&&Jl.x+Jl.y<=1}static getUV(e,n,r,i,s,a,o,c){return h_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),h_=!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,Jl),c.setScalar(0),c.addScaledVector(s,Jl.x),c.addScaledVector(a,Jl.y),c.addScaledVector(o,Jl.z),c}static isFrontFacing(e,n,r,i){return So.subVectors(r,n),Ql.subVectors(e,n),So.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 So.subVectors(this.c,this.b),Ql.subVectors(this.a,this.b),So.cross(Ql).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Eo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Eo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return h_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),h_=!0),Eo.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return Eo.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Eo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Eo.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},f_={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=Zi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Kn.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Kn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Kn.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Kn.workingColorSpace){if(e=fj(e,1),n=Qi(n,0,1),r=Qi(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 Kn.toWorkingColorSpace(this,i),this}setStyle(e,n=Zi){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=Zi){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=Zi){return Kn.fromWorkingColorSpace(ls.copy(this),e),Math.round(Qi(ls.r*255,0,255))*65536+Math.round(Qi(ls.g*255,0,255))*256+Math.round(Qi(ls.b*255,0,255))}getHexString(e=Zi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Kn.workingColorSpace){Kn.fromWorkingColorSpace(ls.copy(this),n);const r=ls.r,i=ls.g,s=ls.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=Kn.workingColorSpace){return Kn.fromWorkingColorSpace(ls.copy(this),n),e.r=ls.r,e.g=ls.g,e.b=ls.b,e}getStyle(e=Zi){Kn.fromWorkingColorSpace(ls.copy(this),e);const n=ls.r,r=ls.g,i=ls.b;return e!==Zi?`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(f_);const r=Kx(wu.h,f_.h,n),i=Kx(wu.s,f_.s,n),s=Kx(wu.l,f_.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 ls=new $t;$t.NAMES=zZ;let Pje=0;class cg extends gf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Pje++}),this.uuid=Sc(),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 cg{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,p_=new Yt;class _a{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=gc,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++)p_.fromBufferAttribute(this,n),p_.applyMatrix3(e),this.setXY(n,p_.x,p_.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=rl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=qn(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=rl(n,this.array)),n}setX(e,n){return this.normalized&&(n=qn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=rl(n,this.array)),n}setY(e,n){return this.normalized&&(n=qn(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=rl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=qn(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=rl(n,this.array)),n}setW(e,n){return this.normalized&&(n=qn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=qn(n,this.array),r=qn(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=qn(n,this.array),r=qn(r,this.array),i=qn(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=qn(n,this.array),r=qn(r,this.array),i=qn(i,this.array),s=qn(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==PP&&(e.usage=this.usage),e}}class HZ extends _a{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class $Z extends _a{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Br extends _a{constructor(e,n,r){super(new Float32Array(e),n,r)}}let Rje=0;const Ua=new sr,hN=new Ts,Ap=new De,da=new ro,Mx=new ro,Ni=new De;class xs extends gf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Rje++}),this.uuid=Sc(),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 hn().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ua.makeRotationFromQuaternion(e),this.applyMatrix4(Ua),this}rotateX(e){return Ua.makeRotationX(e),this.applyMatrix4(Ua),this}rotateY(e){return Ua.makeRotationY(e),this.applyMatrix4(Ua),this}rotateZ(e){return Ua.makeRotationZ(e),this.applyMatrix4(Ua),this}translate(e,n,r){return Ua.makeTranslation(e,n,r),this.applyMatrix4(Ua),this}scale(e,n,r){return Ua.makeScale(e,n,r),this.applyMatrix4(Ua),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 ro);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];da.setFromBufferAttribute(s),this.morphTargetsRelative?(Ni.addVectors(this.boundingBox.min,da.min),this.boundingBox.expandByPoint(Ni),Ni.addVectors(this.boundingBox.max,da.max),this.boundingBox.expandByPoint(Ni)):(this.boundingBox.expandByPoint(da.min),this.boundingBox.expandByPoint(da.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 cl);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(da.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];Mx.setFromBufferAttribute(o),this.morphTargetsRelative?(Ni.addVectors(da.min,Mx.min),da.expandByPoint(Ni),Ni.addVectors(da.max,Mx.max),da.expandByPoint(Ni)):(da.expandByPoint(Mx.min),da.expandByPoint(Mx.max))}da.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&&(Ap.fromBufferAttribute(e,u),Ni.add(Ap)),i=Math.max(i,r.distanceToSquared(Ni))}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 _a(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 Yt,y=new Yt,v=new Yt,b=new De,E=new De;function w(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)w(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 _a(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++)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 _a(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,m_=new cl,P$=new De,Tp=new De,Cp=new De,Np=new De,fN=new De,g_=new De,x_=new Yt,b_=new Yt,v_=new Yt,R$=new De,D$=new De,O$=new De,y_=new De,__=new De;class Ro 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){g_.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?g_.addScaledVector(fN,d):g_.addScaledVector(fN.sub(n),d))}n.add(g_)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),m_.copy(r.boundingSphere),m_.applyMatrix4(s),Yd.copy(e.ray).recast(e.near),!(m_.containsPoint(Yd.origin)===!1&&(Yd.intersectSphere(m_,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),w=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=w;A<T;A+=3){const k=o.getX(A),N=o.getX(A+1),I=o.getX(A+2);i=w_(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),w=o.getX(v+1),A=o.getX(v+2);i=w_(this,a,e,r,u,d,f,E,w,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),w=Math.min(c.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=w;A<T;A+=3){const k=A,N=A+1,I=A+2;i=w_(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,w=v+1,A=v+2;i=w_(this,a,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}}function Dje(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===fd,o),c===null)return null;__.copy(o),__.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(__);return u<n.near||u>n.far?null:{distance:u,point:__.clone(),object:t}}function w_(t,e,n,r,i,s,a,o,c,u){t.getVertexPosition(o,Tp),t.getVertexPosition(c,Cp),t.getVertexPosition(u,Np);const d=Dje(t,e,n,r,Tp,Cp,Np,y_);if(d){i&&(x_.fromBufferAttribute(i,o),b_.fromBufferAttribute(i,c),v_.fromBufferAttribute(i,u),d.uv=Eo.getInterpolation(y_,Tp,Cp,Np,x_,b_,v_,new Yt)),s&&(x_.fromBufferAttribute(s,o),b_.fromBufferAttribute(s,c),v_.fromBufferAttribute(s,u),d.uv1=Eo.getInterpolation(y_,Tp,Cp,Np,x_,b_,v_,new Yt),d.uv2=d.uv1),a&&(R$.fromBufferAttribute(a,o),D$.fromBufferAttribute(a,c),O$.fromBufferAttribute(a,u),d.normal=Eo.getInterpolation(y_,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};Eo.getNormal(Tp,Cp,Np,f.normal),d.face=f}return d}class qb 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,w,A,T,k,N,I,C){const D=A/N,F=T/I,j=A/2,q=T/2,R=k/2,W=N+1,K=I+1;let V=0,te=0;const Y=new De;for(let Z=0;Z<K;Z++){const U=Z*F-q;for(let z=0;z<W;z++){const ee=z*D-j;Y[y]=ee*E,Y[v]=U*w,Y[b]=R,u.push(Y.x,Y.y,Y.z),Y[y]=0,Y[v]=0,Y[b]=k>0?1:-1,d.push(Y.x,Y.y,Y.z),f.push(z/N),f.push(1-Z/I),V+=1}}for(let Z=0;Z<I;Z++)for(let U=0;U<N;U++){const z=g+U+W*Z,ee=g+U+W*(Z+1),ae=g+(U+1)+W*(Z+1),fe=g+(U+1)+W*Z;c.push(z,ee,fe),c.push(ee,ae,fe),te+=6}o.addGroup(m,te,C),m+=te,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qb(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Om(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=Om(t[n]);for(const i in r)e[i]=r[i]}return e}function Oje(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:Kn.workingColorSpace}const mj={clone:Om,merge:ws};var jje=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Lje=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class pd extends cg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=jje,this.fragmentShader=Lje,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=Om(e.uniforms),this.uniformsGroups=Oje(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=ol}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 pa 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=Y0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(qx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Y0*2*Math.atan(Math.tan(qx*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,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(qx*.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 Ije extends Ts{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new pa(kp,Pp,e,n);i.layers=this.layers,this.add(i);const s=new pa(kp,Pp,e,n);s.layers=this.layers,this.add(s);const a=new pa(kp,Pp,e,n);a.layers=this.layers,this.add(a);const o=new pa(kp,Pp,e,n);o.layers=this.layers,this.add(o);const c=new pa(kp,Pp,e,n);c.layers=this.layers,this.add(c);const u=new pa(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===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===X0)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 Xs{constructor(e,n,r,i,s,a,o,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Pm,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 Uje 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&&(Xx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Ph?Zi:Za),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:Xa}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 qb(5,5,5),s=new pd({name:"CubemapFromEquirect",uniforms:Om(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ks,blending:Yu});s.uniforms.tEquirect.value=n;const a=new Ro(i,s),o=n.minFilter;return n.minFilter===q0&&(n.minFilter=Xa),new Ije(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,Fje=new De,zje=new hn;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(Fje.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||zje.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 cl,S_=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=ol){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],w=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-w).normalize(),n===ol)r[5].setComponents(c+o,g+f,v+y,A+w).normalize();else if(n===X0)r[5].setComponents(o,f,y,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Zd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Zd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Zd)}intersectsSprite(e){return Zd.center.set(0,0,0),Zd.radius=.7071067811865476,Zd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Zd)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(S_.x=i.normal.x>0?e.max.x:e.min.x,S_.y=i.normal.y>0?e.max.y:e.min.y,S_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(S_)<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 Bje(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 w=0;w<u;w++){const A=w*f-s;x.push(A,-E,0),y.push(0,0,1),v.push(w/o),v.push(1-b/c)}}for(let b=0;b<c;b++)for(let E=0;E<o;E++){const w=E+u*b,A=E+u*(b+1),T=E+1+u*(b+1),k=E+1+u*b;m.push(w,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 Hje=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,$je=`#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`,Vje=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,Gje=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Wje=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,qje=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Kje=`#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`,Xje=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,Yje=`#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`,Zje=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,Qje=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,Jje=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,eLe=`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`,tLe=`#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`,nLe=`#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`,rLe=`#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`,iLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,sLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,aLe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,oLe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,lLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,cLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,uLe=`#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`,dLe=`#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`,hLe=`#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`,fLe=`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`,pLe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,mLe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,gLe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,xLe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,bLe="gl_FragColor = linearToOutputTexel( gl_FragColor );",vLe=`
- 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 );
- }`,yLe=`#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`,_Le=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,wLe=`#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`,SLe=`#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`,ELe=`#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`,MLe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,ALe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,TLe=`#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`,CLe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,NLe=`#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
- }`,kLe=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,PLe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,RLe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,DLe=`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`,OLe=`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`,jLe=`#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`,LLe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,ILe=`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`,ULe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,FLe=`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`,zLe=`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`,BLe=`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 );
- }`,HLe=`
- 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`,$Le=`#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`,VLe=`#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`,GLe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,WLe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,qLe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,KLe=`#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`,XLe=`#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`,YLe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,ZLe=`#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`,QLe=`#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`,JLe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,eIe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,tIe=`#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`,nIe=`#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`,rIe=`#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`,iIe=`#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`,sIe=`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;`,aIe=`#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`,oIe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,lIe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,cIe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,uIe=`#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`,dIe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,hIe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,fIe=`#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`,pIe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,mIe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,gIe=`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 );
- }`,xIe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,bIe=`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;`,vIe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,yIe=`#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`,_Ie=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,wIe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,SIe=`#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`,EIe=`#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`,MIe=`#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`,AIe=`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;
- }`,TIe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,CIe=`#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`,NIe=`#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`,kIe=`#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`,PIe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,RIe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,DIe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,OIe=`#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; }`,jIe=`#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`,LIe=`#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`,IIe=`#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`,UIe=`#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`,FIe=`#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`,zIe=`#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 BIe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,HIe=`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>
- }`,$Ie=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,VIe=`#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>
- }`,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=`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>
- }`,qIe=`#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;
- }`,KIe=`#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
- }`,XIe=`#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;
- }`,YIe=`#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 );
- }`,ZIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,QIe=`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>
- }`,JIe=`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>
- }`,e4e=`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>
- }`,t4e=`#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>
- }`,n4e=`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>
- }`,r4e=`#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>
- }`,i4e=`#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>
- }`,s4e=`#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;
- }`,a4e=`#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>
- }`,o4e=`#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
- }`,l4e=`#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
- }`,c4e=`#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>
- }`,u4e=`#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>
- }`,d4e=`#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
- }`,h4e=`#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>
- }`,f4e=`#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>
- }`,p4e=`#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>
- }`,m4e=`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>
- }`,g4e=`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>
- }`,x4e=`#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>
- }`,b4e=`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>
- }`,v4e=`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>
- }`,y4e=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,an={alphahash_fragment:Hje,alphahash_pars_fragment:$je,alphamap_fragment:Vje,alphamap_pars_fragment:Gje,alphatest_fragment:Wje,alphatest_pars_fragment:qje,aomap_fragment:Kje,aomap_pars_fragment:Xje,batching_pars_vertex:Yje,batching_vertex:Zje,begin_vertex:Qje,beginnormal_vertex:Jje,bsdfs:eLe,iridescence_fragment:tLe,bumpmap_pars_fragment:nLe,clipping_planes_fragment:rLe,clipping_planes_pars_fragment:iLe,clipping_planes_pars_vertex:sLe,clipping_planes_vertex:aLe,color_fragment:oLe,color_pars_fragment:lLe,color_pars_vertex:cLe,color_vertex:uLe,common:dLe,cube_uv_reflection_fragment:hLe,defaultnormal_vertex:fLe,displacementmap_pars_vertex:pLe,displacementmap_vertex:mLe,emissivemap_fragment:gLe,emissivemap_pars_fragment:xLe,colorspace_fragment:bLe,colorspace_pars_fragment:vLe,envmap_fragment:yLe,envmap_common_pars_fragment:_Le,envmap_pars_fragment:wLe,envmap_pars_vertex:SLe,envmap_physical_pars_fragment:jLe,envmap_vertex:ELe,fog_vertex:MLe,fog_pars_vertex:ALe,fog_fragment:TLe,fog_pars_fragment:CLe,gradientmap_pars_fragment:NLe,lightmap_fragment:kLe,lightmap_pars_fragment:PLe,lights_lambert_fragment:RLe,lights_lambert_pars_fragment:DLe,lights_pars_begin:OLe,lights_toon_fragment:LLe,lights_toon_pars_fragment:ILe,lights_phong_fragment:ULe,lights_phong_pars_fragment:FLe,lights_physical_fragment:zLe,lights_physical_pars_fragment:BLe,lights_fragment_begin:HLe,lights_fragment_maps:$Le,lights_fragment_end:VLe,logdepthbuf_fragment:GLe,logdepthbuf_pars_fragment:WLe,logdepthbuf_pars_vertex:qLe,logdepthbuf_vertex:KLe,map_fragment:XLe,map_pars_fragment:YLe,map_particle_fragment:ZLe,map_particle_pars_fragment:QLe,metalnessmap_fragment:JLe,metalnessmap_pars_fragment:eIe,morphcolor_vertex:tIe,morphnormal_vertex:nIe,morphtarget_pars_vertex:rIe,morphtarget_vertex:iIe,normal_fragment_begin:sIe,normal_fragment_maps:aIe,normal_pars_fragment:oIe,normal_pars_vertex:lIe,normal_vertex:cIe,normalmap_pars_fragment:uIe,clearcoat_normal_fragment_begin:dIe,clearcoat_normal_fragment_maps:hIe,clearcoat_pars_fragment:fIe,iridescence_pars_fragment:pIe,opaque_fragment:mIe,packing:gIe,premultiplied_alpha_fragment:xIe,project_vertex:bIe,dithering_fragment:vIe,dithering_pars_fragment:yIe,roughnessmap_fragment:_Ie,roughnessmap_pars_fragment:wIe,shadowmap_pars_fragment:SIe,shadowmap_pars_vertex:EIe,shadowmap_vertex:MIe,shadowmask_pars_fragment:AIe,skinbase_vertex:TIe,skinning_pars_vertex:CIe,skinning_vertex:NIe,skinnormal_vertex:kIe,specularmap_fragment:PIe,specularmap_pars_fragment:RIe,tonemapping_fragment:DIe,tonemapping_pars_fragment:OIe,transmission_fragment:jIe,transmission_pars_fragment:LIe,uv_pars_fragment:IIe,uv_pars_vertex:UIe,uv_vertex:FIe,worldpos_vertex:zIe,background_vert:BIe,background_frag:HIe,backgroundCube_vert:$Ie,backgroundCube_frag:VIe,cube_vert:GIe,cube_frag:WIe,depth_vert:qIe,depth_frag:KIe,distanceRGBA_vert:XIe,distanceRGBA_frag:YIe,equirect_vert:ZIe,equirect_frag:QIe,linedashed_vert:JIe,linedashed_frag:e4e,meshbasic_vert:t4e,meshbasic_frag:n4e,meshlambert_vert:r4e,meshlambert_frag:i4e,meshmatcap_vert:s4e,meshmatcap_frag:a4e,meshnormal_vert:o4e,meshnormal_frag:l4e,meshphong_vert:c4e,meshphong_frag:u4e,meshphysical_vert:d4e,meshphysical_frag:h4e,meshtoon_vert:f4e,meshtoon_frag:p4e,points_vert:m4e,points_frag:g4e,shadow_vert:x4e,shadow_frag:b4e,sprite_vert:v4e,sprite_frag:y4e},yt={common:{diffuse:{value:new $t(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new hn},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new hn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new hn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new hn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new hn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new hn},normalScale:{value:new Yt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new hn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new hn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new hn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new hn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new $t(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new $t(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0},uvTransform:{value:new hn}},sprite:{diffuse:{value:new $t(16777215)},opacity:{value:1},center:{value:new Yt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new hn},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0}}},Vs={basic:{uniforms:ws([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.fog]),vertexShader:an.meshbasic_vert,fragmentShader:an.meshbasic_frag},lambert:{uniforms:ws([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new $t(0)}}]),vertexShader:an.meshlambert_vert,fragmentShader:an.meshlambert_frag},phong:{uniforms:ws([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new $t(0)},specular:{value:new $t(1118481)},shininess:{value:30}}]),vertexShader:an.meshphong_vert,fragmentShader:an.meshphong_frag},standard:{uniforms:ws([yt.common,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.roughnessmap,yt.metalnessmap,yt.fog,yt.lights,{emissive:{value:new $t(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag},toon:{uniforms:ws([yt.common,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.gradientmap,yt.fog,yt.lights,{emissive:{value:new $t(0)}}]),vertexShader:an.meshtoon_vert,fragmentShader:an.meshtoon_frag},matcap:{uniforms:ws([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,{matcap:{value:null}}]),vertexShader:an.meshmatcap_vert,fragmentShader:an.meshmatcap_frag},points:{uniforms:ws([yt.points,yt.fog]),vertexShader:an.points_vert,fragmentShader:an.points_frag},dashed:{uniforms:ws([yt.common,yt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:an.linedashed_vert,fragmentShader:an.linedashed_frag},depth:{uniforms:ws([yt.common,yt.displacementmap]),vertexShader:an.depth_vert,fragmentShader:an.depth_frag},normal:{uniforms:ws([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,{opacity:{value:1}}]),vertexShader:an.meshnormal_vert,fragmentShader:an.meshnormal_frag},sprite:{uniforms:ws([yt.sprite,yt.fog]),vertexShader:an.sprite_vert,fragmentShader:an.sprite_frag},background:{uniforms:{uvTransform:{value:new hn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:an.background_vert,fragmentShader:an.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:an.backgroundCube_vert,fragmentShader:an.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:an.cube_vert,fragmentShader:an.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:an.equirect_vert,fragmentShader:an.equirect_frag},distanceRGBA:{uniforms:ws([yt.common,yt.displacementmap,{referencePosition:{value:new De},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:an.distanceRGBA_vert,fragmentShader:an.distanceRGBA_frag},shadow:{uniforms:ws([yt.lights,yt.fog,{color:{value:new $t(0)},opacity:{value:1}}]),vertexShader:an.shadow_vert,fragmentShader:an.shadow_frag}};Vs.physical={uniforms:ws([Vs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new hn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new hn},clearcoatNormalScale:{value:new Yt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new hn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new hn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new hn},sheen:{value:0},sheenColor:{value:new $t(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new hn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new hn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new hn},transmissionSamplerSize:{value:new Yt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new hn},attenuationDistance:{value:0},attenuationColor:{value:new $t(0)},specularColor:{value:new $t(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new hn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new hn},anisotropyVector:{value:new Yt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new hn}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag};const E_={r:0,b:0,g:0};function _4e(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,w=b.isScene===!0?b.background:null;w&&w.isTexture&&(w=(b.backgroundBlurriness>0?n:e).get(w)),w===null?y(o,c):w&&w.isColor&&(y(w,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),w&&(w.isCubeTexture||w.mapping===HE)?(d===void 0&&(d=new Ro(new qb(1,1,1),new pd({name:"BackgroundCubeMaterial",uniforms:Om(Vs.backgroundCube.uniforms),vertexShader:Vs.backgroundCube.vertexShader,fragmentShader:Vs.backgroundCube.fragmentShader,side:Ks,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=w,d.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,d.material.toneMapped=Kn.getTransfer(w.colorSpace)!==lr,(f!==w||g!==w.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=w,g=w.version,m=t.toneMapping),d.layers.enableAll(),v.unshift(d,d.geometry,d.material,0,0,null)):w&&w.isTexture&&(u===void 0&&(u=new Ro(new gj(2,2),new pd({name:"BackgroundMaterial",uniforms:Om(Vs.background.uniforms),vertexShader:Vs.background.vertexShader,fragmentShader:Vs.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=w,u.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,u.material.toneMapped=Kn.getTransfer(w.colorSpace)!==lr,w.matrixAutoUpdate===!0&&w.updateMatrix(),u.material.uniforms.uvTransform.value.copy(w.matrix),(f!==w||g!==w.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=w,g=w.version,m=t.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null))}function y(v,b){v.getRGB(E_,VZ(t)),r.buffers.color.setClear(E_.r,E_.g,E_.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 w4e(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,te){let Y=!1;if(a){const Z=y(V,K,W);u!==Z&&(u=Z,m(u.object)),Y=b(R,V,K,te),Y&&E(R,V,K,te)}else{const Z=W.wireframe===!0;(u.geometry!==V.id||u.program!==K.id||u.wireframe!==Z)&&(u.geometry=V.id,u.program=K.id,u.wireframe=Z,Y=!0)}te!==null&&n.update(te,t.ELEMENT_ARRAY_BUFFER),(Y||d)&&(d=!1,I(R,W,K,V),te!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(te).buffer))}function g(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function m(R){return r.isWebGL2?t.bindVertexArray(R):s.bindVertexArrayOES(R)}function x(R){return r.isWebGL2?t.deleteVertexArray(R):s.deleteVertexArrayOES(R)}function y(R,W,K){const V=K.wireframe===!0;let te=o[R.id];te===void 0&&(te={},o[R.id]=te);let Y=te[W.id];Y===void 0&&(Y={},te[W.id]=Y);let Z=Y[V];return Z===void 0&&(Z=v(g()),Y[V]=Z),Z}function v(R){const W=[],K=[],V=[];for(let te=0;te<i;te++)W[te]=0,K[te]=0,V[te]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:K,attributeDivisors:V,object:R,attributes:{},index:null}}function b(R,W,K,V){const te=u.attributes,Y=W.attributes;let Z=0;const U=K.getAttributes();for(const z in U)if(U[z].location>=0){const ae=te[z];let fe=Y[z];if(fe===void 0&&(z==="instanceMatrix"&&R.instanceMatrix&&(fe=R.instanceMatrix),z==="instanceColor"&&R.instanceColor&&(fe=R.instanceColor)),ae===void 0||ae.attribute!==fe||fe&&ae.data!==fe.data)return!0;Z++}return u.attributesNum!==Z||u.index!==V}function E(R,W,K,V){const te={},Y=W.attributes;let Z=0;const U=K.getAttributes();for(const z in U)if(U[z].location>=0){let ae=Y[z];ae===void 0&&(z==="instanceMatrix"&&R.instanceMatrix&&(ae=R.instanceMatrix),z==="instanceColor"&&R.instanceColor&&(ae=R.instanceColor));const fe={};fe.attribute=ae,ae&&ae.data&&(fe.data=ae.data),te[z]=fe,Z++}u.attributes=te,u.attributesNum=Z,u.index=V}function w(){const R=u.newAttributes;for(let W=0,K=R.length;W<K;W++)R[W]=0}function A(R){T(R,0)}function T(R,W){const K=u.newAttributes,V=u.enabledAttributes,te=u.attributeDivisors;K[R]=1,V[R]===0&&(t.enableVertexAttribArray(R),V[R]=1),te[R]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,W),te[R]=W)}function k(){const R=u.newAttributes,W=u.enabledAttributes;for(let K=0,V=W.length;K<V;K++)W[K]!==R[K]&&(t.disableVertexAttribArray(K),W[K]=0)}function N(R,W,K,V,te,Y,Z){Z===!0?t.vertexAttribIPointer(R,W,K,te,Y):t.vertexAttribPointer(R,W,K,V,te,Y)}function I(R,W,K,V){if(r.isWebGL2===!1&&(R.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const te=V.attributes,Y=K.getAttributes(),Z=W.defaultAttributeValues;for(const U in Y){const z=Y[U];if(z.location>=0){let ee=te[U];if(ee===void 0&&(U==="instanceMatrix"&&R.instanceMatrix&&(ee=R.instanceMatrix),U==="instanceColor"&&R.instanceColor&&(ee=R.instanceColor)),ee!==void 0){const ae=ee.normalized,fe=ee.itemSize,de=n.get(ee);if(de===void 0)continue;const xe=de.buffer,ye=de.type,re=de.bytesPerElement,ve=r.isWebGL2===!0&&(ye===t.INT||ye===t.UNSIGNED_INT||ee.gpuType===EZ);if(ee.isInterleavedBufferAttribute){const je=ee.data,ue=je.stride,ut=ee.offset;if(je.isInstancedInterleavedBuffer){for(let $=0;$<z.locationSize;$++)T(z.location+$,je.meshPerAttribute);R.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=je.meshPerAttribute*je.count)}else for(let $=0;$<z.locationSize;$++)A(z.location+$);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let $=0;$<z.locationSize;$++)N(z.location+$,fe/z.locationSize,ye,ae,ue*re,(ut+fe/z.locationSize*$)*re,ve)}else{if(ee.isInstancedBufferAttribute){for(let je=0;je<z.locationSize;je++)T(z.location+je,ee.meshPerAttribute);R.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let je=0;je<z.locationSize;je++)A(z.location+je);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let je=0;je<z.locationSize;je++)N(z.location+je,fe/z.locationSize,ye,ae,fe*re,fe/z.locationSize*je*re,ve)}}else if(Z!==void 0){const ae=Z[U];if(ae!==void 0)switch(ae.length){case 2:t.vertexAttrib2fv(z.location,ae);break;case 3:t.vertexAttrib3fv(z.location,ae);break;case 4:t.vertexAttrib4fv(z.location,ae);break;default:t.vertexAttrib1fv(z.location,ae)}}}}k()}function C(){j();for(const R in o){const W=o[R];for(const K in W){const V=W[K];for(const te in V)x(V[te].object),delete V[te];delete W[K]}delete o[R]}}function D(R){if(o[R.id]===void 0)return;const W=o[R.id];for(const K in W){const V=W[K];for(const te in V)x(V[te].object),delete V[te];delete W[K]}delete o[R.id]}function F(R){for(const W in o){const K=o[W];if(K[R.id]===void 0)continue;const V=K[R.id];for(const te in V)x(V[te].object),delete V[te];delete K[R.id]}}function j(){q(),d=!0,u!==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:w,enableAttribute:A,disableUnusedAttributes:k}}function S4e(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 E4e(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),w=g>0,A=a||e.has("OES_texture_float"),T=w&&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:w,floatFragmentTextures:A,floatVertexTextures:T,maxSamples:k}}function M4e(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new ku,o=new hn,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,w=E*4;let A=b.clippingState||null;c.value=A,A=d(x,g,w,m);for(let T=0;T!==w;++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 w=0,A=m;w!==y;++w,A+=4)a.copy(f[w]).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 A4e(t){let e=new WeakMap;function n(a,o){return o===TP?a.mapping=Pm:o===CP&&(a.mapping=Rm),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 Uje(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 T4e 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 T4e,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,M_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Pm||e.mapping===Rm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),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:Xa,minFilter:Xa,generateMipmaps:!1,type:K0,format:Ya,colorSpace:jc,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}=C4e(s)),this._blurMaterial=N4e(s,e,n)}return i}_compileMaterial(e){const n=new Ro(this._lodPlanes[0],e);this._renderer.compile(n,mN)}_sceneToCubeUV(e,n,r,i){const o=new pa(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:Ks,depthWrite:!1,depthTest:!1}),x=new Ro(new qb,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 w=this._cubeSize;M_(i,E*w,b>2?w:0,w,w),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===Pm||e.mapping===Rm;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 Ro(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;M_(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 Ro(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:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-Xp?i-w+Xp:0),k=4*(this._cubeSize-A);M_(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,mN)}}function C4e(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),w=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),w.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 _a(E,y)),T.setAttribute("uv",new _a(w,v)),T.setAttribute("faceIndex",new _a(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 M_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function N4e(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 k4e(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===Pm||c===Rm;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 P4e(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 R4e(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 w=0,A=E.length;w<A;w+=3){const T=E[w+0],k=E[w+1],N=E[w+2];g.push(T,k,k,N,N,T)}}else if(x!==void 0){const E=x.array;y=x.version;for(let w=0,A=E.length/3-1;w<A;w+=3){const T=w+0,k=w+1,N=w+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 D4e(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 O4e(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 j4e(t,e){return t[0]-e[0]}function L4e(t,e){return Math.abs(e[1])-Math.abs(t[1])}function I4e(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,a=new Yn,o=[];for(let u=0;u<8;u++)o[u]=[u,0];function 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 w=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;w===!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=gc,q.needsUpdate=!0;const R=C*4;for(let K=0;K<y;K++){const V=k[K],te=N[K],Y=I[K],Z=D*F*4*K;for(let U=0;U<V.count;U++){const z=U*R;w===!0&&(a.fromBufferAttribute(V,U),j[Z+z+0]=a.x,j[Z+z+1]=a.y,j[Z+z+2]=a.z,j[Z+z+3]=0),A===!0&&(a.fromBufferAttribute(te,U),j[Z+z+4]=a.x,j[Z+z+5]=a.y,j[Z+z+6]=a.z,j[Z+z+7]=0),T===!0&&(a.fromBufferAttribute(Y,U),j[Z+z+8]=a.x,j[Z+z+9]=a.y,j[Z+z+10]=a.z,j[Z+z+11]=Y.itemSize===4?a.w:1)}}v={count:y,texture:q,size:new Yt(D,F)},s.set(d,v),d.addEventListener("dispose",W)}let b=0;for(let w=0;w<g.length;w++)b+=g[w];const E=d.morphTargetsRelative?1:1-b;f.getUniforms().setValue(t,"morphTargetBaseInfluence",E),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",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(L4e);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(j4e);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 w=d.morphTargetsRelative?1:1-E;f.getUniforms().setValue(t,"morphTargetBaseInfluence",w),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function U4e(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 Xs{constructor(e,n,r,i,s,a,o,c,u,d){if(d=d!==void 0?d:kh,d!==kh&&d!==Dm)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===kh&&(r=Bu),r===void 0&&d===Dm&&(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:Yi,this.minFilter=c!==void 0?c:Yi,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 Xs,YZ=new KZ(1,1);YZ.compareFunction=DZ;const ZZ=new UZ,QZ=new wje,JZ=new WZ,H$=[],$$=[],V$=new Float32Array(16),G$=new Float32Array(9),W$=new Float32Array(4);function ug(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 mi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function gi(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 F4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function z4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(mi(n,e))return;t.uniform2fv(this.addr,e),gi(n,e)}}function B4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(mi(n,e))return;t.uniform3fv(this.addr,e),gi(n,e)}}function H4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(mi(n,e))return;t.uniform4fv(this.addr,e),gi(n,e)}}function $4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(mi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),gi(n,e)}else{if(mi(n,r))return;W$.set(r),t.uniformMatrix2fv(this.addr,!1,W$),gi(n,r)}}function V4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(mi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),gi(n,e)}else{if(mi(n,r))return;G$.set(r),t.uniformMatrix3fv(this.addr,!1,G$),gi(n,r)}}function G4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(mi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),gi(n,e)}else{if(mi(n,r))return;V$.set(r),t.uniformMatrix4fv(this.addr,!1,V$),gi(n,r)}}function W4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function q4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(mi(n,e))return;t.uniform2iv(this.addr,e),gi(n,e)}}function K4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(mi(n,e))return;t.uniform3iv(this.addr,e),gi(n,e)}}function X4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(mi(n,e))return;t.uniform4iv(this.addr,e),gi(n,e)}}function Y4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Z4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(mi(n,e))return;t.uniform2uiv(this.addr,e),gi(n,e)}}function Q4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(mi(n,e))return;t.uniform3uiv(this.addr,e),gi(n,e)}}function J4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(mi(n,e))return;t.uniform4uiv(this.addr,e),gi(n,e)}}function eUe(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 tUe(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 nUe(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 rUe(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 iUe(t){switch(t){case 5126:return F4e;case 35664:return z4e;case 35665:return B4e;case 35666:return H4e;case 35674:return $4e;case 35675:return V4e;case 35676:return G4e;case 5124:case 35670:return W4e;case 35667:case 35671:return q4e;case 35668:case 35672:return K4e;case 35669:case 35673:return X4e;case 5125:return Y4e;case 36294:return Z4e;case 36295:return Q4e;case 36296:return J4e;case 35678:case 36198:case 36298:case 36306:case 35682:return eUe;case 35679:case 36299:case 36307:return tUe;case 35680:case 36300:case 36308:case 36293:return nUe;case 36289:case 36303:case 36311:case 36292:return rUe}}function sUe(t,e){t.uniform1fv(this.addr,e)}function aUe(t,e){const n=ug(e,this.size,2);t.uniform2fv(this.addr,n)}function oUe(t,e){const n=ug(e,this.size,3);t.uniform3fv(this.addr,n)}function lUe(t,e){const n=ug(e,this.size,4);t.uniform4fv(this.addr,n)}function cUe(t,e){const n=ug(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function uUe(t,e){const n=ug(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function dUe(t,e){const n=ug(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function hUe(t,e){t.uniform1iv(this.addr,e)}function fUe(t,e){t.uniform2iv(this.addr,e)}function pUe(t,e){t.uniform3iv(this.addr,e)}function mUe(t,e){t.uniform4iv(this.addr,e)}function gUe(t,e){t.uniform1uiv(this.addr,e)}function xUe(t,e){t.uniform2uiv(this.addr,e)}function bUe(t,e){t.uniform3uiv(this.addr,e)}function vUe(t,e){t.uniform4uiv(this.addr,e)}function yUe(t,e,n){const r=this.cache,i=e.length,s=GE(n,i);mi(r,s)||(t.uniform1iv(this.addr,s),gi(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||XZ,s[a])}function _Ue(t,e,n){const r=this.cache,i=e.length,s=GE(n,i);mi(r,s)||(t.uniform1iv(this.addr,s),gi(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||QZ,s[a])}function wUe(t,e,n){const r=this.cache,i=e.length,s=GE(n,i);mi(r,s)||(t.uniform1iv(this.addr,s),gi(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||JZ,s[a])}function SUe(t,e,n){const r=this.cache,i=e.length,s=GE(n,i);mi(r,s)||(t.uniform1iv(this.addr,s),gi(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||ZZ,s[a])}function EUe(t){switch(t){case 5126:return sUe;case 35664:return aUe;case 35665:return oUe;case 35666:return lUe;case 35674:return cUe;case 35675:return uUe;case 35676:return dUe;case 5124:case 35670:return hUe;case 35667:case 35671:return fUe;case 35668:case 35672:return pUe;case 35669:case 35673:return mUe;case 5125:return gUe;case 36294:return xUe;case 36295:return bUe;case 36296:return vUe;case 35678:case 36198:case 36298:case 36306:case 35682:return yUe;case 35679:case 36299:case 36307:return _Ue;case 35680:case 36300:case 36308:case 36293:return wUe;case 36289:case 36303:case 36311:case 36292:return SUe}}class MUe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=iUe(n.type)}}class AUe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=EUe(n.type)}}class TUe{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 CUe(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 MUe(o,t,e):new AUe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new TUe(o),q$(n,f)),n=f}}}class f1{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);CUe(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 NUe=37297;let kUe=0;function PUe(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 RUe(t){const e=Kn.getPrimaries(Kn.workingColorSpace),n=Kn.getPrimaries(t);let r;switch(e===n?r="":e===Lw&&n===jw?r="LinearDisplayP3ToLinearSRGB":e===jw&&n===Lw&&(r="LinearSRGBToLinearDisplayP3"),t){case jc:case $E:return[r,"LinearTransferOETF"];case Zi: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+`
- `+PUe(t.getShaderSource(e),a)}else return i}function DUe(t,e){const n=RUe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function OUe(t,e){let n;switch(e){case DOe:n="Linear";break;case OOe:n="Reinhard";break;case jOe:n="OptimizedCineon";break;case LOe:n="ACESFilmic";break;case IOe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function jUe(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(Ix).join(`
- `)}function LUe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function IUe(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 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 UUe=/^[ \t]*#include +<([\w\d./]+)>/gm;function OP(t){return t.replace(UUe,zUe)}const FUe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function zUe(t,e){let n=an[e];if(n===void 0){const r=FUe.get(e);if(r!==void 0)n=an[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return OP(n)}const BUe=/#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(BUe,HUe)}function HUe(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 $Ue(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===wZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===oOe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ic&&(e="SHADOWMAP_TYPE_VSM"),e}function VUe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Pm:case Rm:e="ENVMAP_TYPE_CUBE";break;case HE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function GUe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Rm:e="ENVMAP_MODE_REFRACTION";break}return e}function WUe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case uj:e="ENVMAP_BLENDING_MULTIPLY";break;case POe:e="ENVMAP_BLENDING_MIX";break;case ROe:e="ENVMAP_BLENDING_ADD";break}return e}function qUe(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 KUe(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const c=$Ue(n),u=VUe(n),d=GUe(n),f=WUe(n),g=qUe(n),m=n.isWebGL2?"":jUe(n),x=LUe(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=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Ix).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(Ix).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?an.tonemapping_pars_fragment:"",n.toneMapping!==Zu?OUe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",an.colorspace_pars_fragment,DUe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Ix).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 w=E+v+a,A=E+b+o,T=K$(i,i.VERTEX_SHADER,w),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"),te=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+`
- `+te)}else j!==""?console.warn("THREE.WebGLProgram: Program Info Log:",j):(q===""||R==="")&&(K=!1);K&&(F.diagnostics={runnable:W,programLog:j,vertexShader:{log:q,prefix:v},fragmentShader:{log:R,prefix:b}})}i.deleteShader(T),i.deleteShader(k),I=new f1(i,y),C=IUe(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,NUe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=kUe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=k,this}let XUe=0;class YUe{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 ZUe(e),n.set(e,r)),r}}class ZUe{constructor(e){this.id=XUe++,this.code=e,this.usedTimes=0}}function QUe(t,e,n,r,i,s,a){const o=new FZ,c=new YUe,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(C){return C===0?"uv":`uv${C}`}function v(C,D,F,j,q){const R=j.fog,W=q.geometry,K=C.isMeshStandardMaterial?j.environment:null,V=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),te=V&&V.mapping===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 Z=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=Z!==void 0?Z.length:0;let z=0;W.morphAttributes.position!==void 0&&(z=1),W.morphAttributes.normal!==void 0&&(z=2),W.morphAttributes.color!==void 0&&(z=3);let ee,ae,fe,de;if(Y){const cn=Vs[Y];ee=cn.vertexShader,ae=cn.fragmentShader}else ee=C.vertexShader,ae=C.fragmentShader,c.update(C),fe=c.getVertexShaderID(C),de=c.getFragmentShaderID(C);const xe=t.getRenderTarget(),ye=q.isInstancedMesh===!0,re=q.isBatchedMesh===!0,ve=!!C.map,je=!!C.matcap,ue=!!V,ut=!!C.aoMap,$=!!C.lightMap,H=!!C.bumpMap,ie=!!C.normalMap,G=!!C.displacementMap,J=!!C.emissiveMap,le=!!C.metalnessMap,Pe=!!C.roughnessMap,Ne=C.anisotropy>0,Se=C.clearcoat>0,B=C.iridescence>0,L=C.sheen>0,ne=C.transmission>0,be=Ne&&!!C.anisotropyMap,we=Se&&!!C.clearcoatMap,ge=Se&&!!C.clearcoatNormalMap,me=Se&&!!C.clearcoatRoughnessMap,Ae=B&&!!C.iridescenceMap,ze=B&&!!C.iridescenceThicknessMap,st=L&&!!C.sheenColorMap,Ve=L&&!!C.sheenRoughnessMap,ce=!!C.specularMap,Ye=!!C.specularColorMap,$e=!!C.specularIntensityMap,Ze=ne&&!!C.transmissionMap,at=ne&&!!C.thicknessMap,Q=!!C.gradientMap,Fe=!!C.alphaMap,pe=C.alphaTest>0,Ue=!!C.alphaHash,Ce=!!C.extensions,_e=!!W.attributes.uv1,He=!!W.attributes.uv2,ht=!!W.attributes.uv3;let wt=Zu;return C.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(wt=t.toneMapping),{isWebGL2:d,shaderID:Y,shaderType:C.type,shaderName:C.name,vertexShader:ee,fragmentShader:ae,defines:C.defines,customVertexShaderID:fe,customFragmentShaderID:de,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:re,instancing:ye,instancingColor:ye&&q.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:jc,map:ve,matcap:je,envMap:ue,envMapMode:ue&&V.mapping,envMapCubeUVHeight:te,aoMap:ut,lightMap:$,bumpMap:H,normalMap:ie,displacementMap:g&&G,emissiveMap:J,normalMapObjectSpace:ie&&C.normalMapType===XOe,normalMapTangentSpace:ie&&C.normalMapType===RZ,metalnessMap:le,roughnessMap:Pe,anisotropy:Ne,anisotropyMap:be,clearcoat:Se,clearcoatMap:we,clearcoatNormalMap:ge,clearcoatRoughnessMap:me,iridescence:B,iridescenceMap:Ae,iridescenceThicknessMap:ze,sheen:L,sheenColorMap:st,sheenRoughnessMap:Ve,specularMap:ce,specularColorMap:Ye,specularIntensityMap:$e,transmission:ne,transmissionMap:Ze,thicknessMap:at,gradientMap:Q,opaque:C.transparent===!1&&C.blending===am,alphaMap:Fe,alphaTest:pe,alphaHash:Ue,combine:C.combine,mapUv:ve&&y(C.map.channel),aoMapUv:ut&&y(C.aoMap.channel),lightMapUv:$&&y(C.lightMap.channel),bumpMapUv:H&&y(C.bumpMap.channel),normalMapUv:ie&&y(C.normalMap.channel),displacementMapUv:G&&y(C.displacementMap.channel),emissiveMapUv:J&&y(C.emissiveMap.channel),metalnessMapUv:le&&y(C.metalnessMap.channel),roughnessMapUv:Pe&&y(C.roughnessMap.channel),anisotropyMapUv:be&&y(C.anisotropyMap.channel),clearcoatMapUv:we&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:ge&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:me&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Ae&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:ze&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:st&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&y(C.sheenRoughnessMap.channel),specularMapUv:ce&&y(C.specularMap.channel),specularColorMapUv:Ye&&y(C.specularColorMap.channel),specularIntensityMapUv:$e&&y(C.specularIntensityMap.channel),transmissionMapUv:Ze&&y(C.transmissionMap.channel),thicknessMapUv:at&&y(C.thicknessMap.channel),alphaMapUv:Fe&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(ie||Ne),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:_e,vertexUv2s:He,vertexUv3s:ht,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(ve||Fe),fog:!!R,useFog:C.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:z,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:wt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:ve&&C.map.isVideoTexture===!0&&Kn.getTransfer(C.map.colorSpace)===lr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===uc,flipSided:C.side===Ks,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),w(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 w(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=Vs[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 KUe(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 JUe(){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 e5e(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||e5e),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 t5e(){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 n5e(){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 r5e(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Yt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Yt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Yt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let i5e=0;function s5e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function a5e(t,e){const n=new n5e,r=r5e(),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,w=0,A=0,T=0,k=0,N=0,I=0,C=0;d.sort(s5e);const D=f===!0?Math.PI:1;for(let j=0,q=d.length;j<q;j++){const R=d[j],W=R.color,K=R.intensity,V=R.distance,te=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)g+=W.r*K*D,m+=W.g*K*D,x+=W.b*K*D;else if(R.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(R.sh.coefficients[Y],K);C++}else if(R.isDirectionalLight){const Y=n.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity*D),R.castShadow){const Z=R.shadow,U=r.get(R);U.shadowBias=Z.bias,U.shadowNormalBias=Z.normalBias,U.shadowRadius=Z.radius,U.shadowMapSize=Z.mapSize,i.directionalShadow[y]=U,i.directionalShadowMap[y]=te,i.directionalShadowMatrix[y]=R.shadow.matrix,A++}i.directional[y]=Y,y++}else if(R.isSpotLight){const Y=n.get(R);Y.position.setFromMatrixPosition(R.matrixWorld),Y.color.copy(W).multiplyScalar(K*D),Y.distance=V,Y.coneCos=Math.cos(R.angle),Y.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),Y.decay=R.decay,i.spot[b]=Y;const Z=R.shadow;if(R.map&&(i.spotLightMap[N]=R.map,N++,Z.updateMatrices(R),R.castShadow&&I++),i.spotLightMatrix[b]=Z.matrix,R.castShadow){const U=r.get(R);U.shadowBias=Z.bias,U.shadowNormalBias=Z.normalBias,U.shadowRadius=Z.radius,U.shadowMapSize=Z.mapSize,i.spotShadow[b]=U,i.spotShadowMap[b]=te,k++}b++}else if(R.isRectAreaLight){const Y=n.get(R);Y.color.copy(W).multiplyScalar(K),Y.halfWidth.set(R.width*.5,0,0),Y.halfHeight.set(0,R.height*.5,0),i.rectArea[E]=Y,E++}else if(R.isPointLight){const Y=n.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity*D),Y.distance=R.distance,Y.decay=R.decay,R.castShadow){const Z=R.shadow,U=r.get(R);U.shadowBias=Z.bias,U.shadowNormalBias=Z.normalBias,U.shadowRadius=Z.radius,U.shadowMapSize=Z.mapSize,U.shadowCameraNear=Z.camera.near,U.shadowCameraFar=Z.camera.far,i.pointShadow[v]=U,i.pointShadowMap[v]=te,i.pointShadowMatrix[v]=R.shadow.matrix,T++}i.point[v]=Y,v++}else if(R.isHemisphereLight){const Y=n.get(R);Y.skyColor.copy(R.color).multiplyScalar(K*D),Y.groundColor.copy(R.groundColor).multiplyScalar(K*D),i.hemi[w]=Y,w++}}E>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=yt.LTC_FLOAT_1,i.rectAreaLTC2=yt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=yt.LTC_HALF_1,i.rectAreaLTC2=yt.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!==w||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=w,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=w,F.numDirectionalShadows=A,F.numPointShadows=T,F.numSpotShadows=k,F.numSpotMaps=N,F.numLightProbes=C,i.version=i5e++)}function u(d,f){let g=0,m=0,x=0,y=0,v=0;const b=f.matrixWorldInverse;for(let E=0,w=d.length;E<w;E++){const A=d[E];if(A.isDirectionalLight){const T=i.directional[g];T.direction.setFromMatrixPosition(A.matrixWorld),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 a5e(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 o5e(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 l5e extends cg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=qOe,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 c5e extends cg{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 u5e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,d5e=`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 h5e(t,e,n){let r=new VE;const i=new Yt,s=new Yt,a=new Yn,o=new l5e({depthPacking:KOe}),c=new c5e,u={},d=n.maxTextureSize,f={[fd]:Ks,[Ks]:fd,[uc]:uc},g=new pd({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Yt},radius:{value:4}},vertexShader:u5e,fragmentShader:d5e}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const x=new xs;x.setAttribute("position",new _a(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Ro(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!==ic&&this.type===ic,q=b===ic&&this.type!==ic;for(let R=0,W=T.length;R<W;R++){const K=T[R],V=K.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const te=V.getFrameExtents();if(i.multiply(te),s.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/te.x),i.x=s.x*te.x,V.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/te.y),i.y=s.y*te.y,V.mapSize.y=s.y)),V.map===null||j===!0||q===!0){const Z=this.type!==ic?{minFilter:Yi,magFilter:Yi}:{};V.map!==null&&V.map.dispose(),V.map=new nf(i.x,i.y,Z),V.map.texture.name=K.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const Y=V.getViewportCount();for(let Z=0;Z<Y;Z++){const U=V.getViewport(Z);a.set(s.x*U.x,s.y*U.y,s.x*U.z,s.y*U.w),F.viewport(a),V.updateMatrices(K,Z),r=V.getFrustum(),A(k,N,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===ic&&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 w(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===ic?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===ic)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,T.matrixWorld);const j=e.update(T),q=T.material;if(Array.isArray(q)){const R=j.groups;for(let W=0,K=R.length;W<K;W++){const V=R[W],te=q[V.materialIndex];if(te&&te.visible){const Y=w(T,te,I,C);T.onBeforeShadow(t,T,k,N,j,Y,V),t.renderBufferDirect(N,null,j,Y,T,V),T.onAfterShadow(t,T,k,N,j,Y,V)}}}else if(q.visible){const R=w(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 f5e(t,e,n){const r=n.isWebGL2;function i(){let pe=!1;const Ue=new Yn;let Ce=null;const _e=new Yn(0,0,0,0);return{setMask:function(He){Ce!==He&&!pe&&(t.colorMask(He,He,He,He),Ce=He)},setLocked:function(He){pe=He},setClear:function(He,ht,wt,Ot,cn){cn===!0&&(He*=Ot,ht*=Ot,wt*=Ot),Ue.set(He,ht,wt,Ot),_e.equals(Ue)===!1&&(t.clearColor(He,ht,wt,Ot),_e.copy(Ue))},reset:function(){pe=!1,Ce=null,_e.set(-1,0,0,0)}}}function s(){let pe=!1,Ue=null,Ce=null,_e=null;return{setTest:function(He){He?re(t.DEPTH_TEST):ve(t.DEPTH_TEST)},setMask:function(He){Ue!==He&&!pe&&(t.depthMask(He),Ue=He)},setFunc:function(He){if(Ce!==He){switch(He){case EOe:t.depthFunc(t.NEVER);break;case MOe:t.depthFunc(t.ALWAYS);break;case AOe:t.depthFunc(t.LESS);break;case Dw:t.depthFunc(t.LEQUAL);break;case TOe:t.depthFunc(t.EQUAL);break;case COe:t.depthFunc(t.GEQUAL);break;case NOe:t.depthFunc(t.GREATER);break;case kOe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ce=He}},setLocked:function(He){pe=He},setClear:function(He){_e!==He&&(t.clearDepth(He),_e=He)},reset:function(){pe=!1,Ue=null,Ce=null,_e=null}}}function a(){let pe=!1,Ue=null,Ce=null,_e=null,He=null,ht=null,wt=null,Ot=null,cn=null;return{setTest:function(It){pe||(It?re(t.STENCIL_TEST):ve(t.STENCIL_TEST))},setMask:function(It){Ue!==It&&!pe&&(t.stencilMask(It),Ue=It)},setFunc:function(It,Dn,Qn){(Ce!==It||_e!==Dn||He!==Qn)&&(t.stencilFunc(It,Dn,Qn),Ce=It,_e=Dn,He=Qn)},setOp:function(It,Dn,Qn){(ht!==It||wt!==Dn||Ot!==Qn)&&(t.stencilOp(It,Dn,Qn),ht=It,wt=Dn,Ot=Qn)},setLocked:function(It){pe=It},setClear:function(It){cn!==It&&(t.clearStencil(It),cn=It)},reset:function(){pe=!1,Ue=null,Ce=null,_e=null,He=null,ht=null,wt=null,Ot=null,cn=null}}}const o=new i,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,w=null,A=null,T=null,k=null,N=null,I=null,C=new $t(0,0,0),D=0,F=!1,j=null,q=null,R=null,W=null,K=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let te=!1,Y=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(Z)[1]),te=Y>=1):Z.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),te=Y>=2);let U=null,z={};const ee=t.getParameter(t.SCISSOR_BOX),ae=t.getParameter(t.VIEWPORT),fe=new Yn().fromArray(ee),de=new Yn().fromArray(ae);function xe(pe,Ue,Ce,_e){const He=new Uint8Array(4),ht=t.createTexture();t.bindTexture(pe,ht),t.texParameteri(pe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(pe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let wt=0;wt<Ce;wt++)r&&(pe===t.TEXTURE_3D||pe===t.TEXTURE_2D_ARRAY)?t.texImage3D(Ue,0,t.RGBA,1,1,_e,0,t.RGBA,t.UNSIGNED_BYTE,He):t.texImage2D(Ue+wt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,He);return ht}const ye={};ye[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),ye[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(ye[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),ye[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),c.setClear(1),u.setClear(0),re(t.DEPTH_TEST),c.setFunc(Dw),J(!1),le(UH),re(t.CULL_FACE),ie(Yu);function re(pe){g[pe]!==!0&&(t.enable(pe),g[pe]=!0)}function ve(pe){g[pe]!==!1&&(t.disable(pe),g[pe]=!1)}function je(pe,Ue){return m[pe]!==Ue?(t.bindFramebuffer(pe,Ue),m[pe]=Ue,r&&(pe===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Ue),pe===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Ue)),!0):!1}function ue(pe,Ue){let Ce=y,_e=!1;if(pe)if(Ce=x.get(Ue),Ce===void 0&&(Ce=[],x.set(Ue,Ce)),pe.isWebGLMultipleRenderTargets){const He=pe.texture;if(Ce.length!==He.length||Ce[0]!==t.COLOR_ATTACHMENT0){for(let ht=0,wt=He.length;ht<wt;ht++)Ce[ht]=t.COLOR_ATTACHMENT0+ht;Ce.length=He.length,_e=!0}}else Ce[0]!==t.COLOR_ATTACHMENT0&&(Ce[0]=t.COLOR_ATTACHMENT0,_e=!0);else Ce[0]!==t.BACK&&(Ce[0]=t.BACK,_e=!0);_e&&(n.isWebGL2?t.drawBuffers(Ce):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ce))}function ut(pe){return v!==pe?(t.useProgram(pe),v=pe,!0):!1}const $={[lh]:t.FUNC_ADD,[cOe]:t.FUNC_SUBTRACT,[uOe]:t.FUNC_REVERSE_SUBTRACT};if(r)$[HH]=t.MIN,$[$H]=t.MAX;else{const pe=e.get("EXT_blend_minmax");pe!==null&&($[HH]=pe.MIN_EXT,$[$H]=pe.MAX_EXT)}const H={[dOe]:t.ZERO,[hOe]:t.ONE,[fOe]:t.SRC_COLOR,[MP]:t.SRC_ALPHA,[vOe]:t.SRC_ALPHA_SATURATE,[xOe]:t.DST_COLOR,[mOe]:t.DST_ALPHA,[pOe]:t.ONE_MINUS_SRC_COLOR,[AP]:t.ONE_MINUS_SRC_ALPHA,[bOe]:t.ONE_MINUS_DST_COLOR,[gOe]:t.ONE_MINUS_DST_ALPHA,[yOe]:t.CONSTANT_COLOR,[_Oe]:t.ONE_MINUS_CONSTANT_COLOR,[wOe]:t.CONSTANT_ALPHA,[SOe]:t.ONE_MINUS_CONSTANT_ALPHA};function ie(pe,Ue,Ce,_e,He,ht,wt,Ot,cn,It){if(pe===Yu){b===!0&&(ve(t.BLEND),b=!1);return}if(b===!1&&(re(t.BLEND),b=!0),pe!==lOe){if(pe!==E||It!==F){if((w!==lh||k!==lh)&&(t.blendEquation(t.FUNC_ADD),w=lh,k=lh),It)switch(pe){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: ",pe);break}else switch(pe){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: ",pe);break}A=null,T=null,N=null,I=null,C.set(0,0,0),D=0,E=pe,F=It}return}He=He||Ue,ht=ht||Ce,wt=wt||_e,(Ue!==w||He!==k)&&(t.blendEquationSeparate($[Ue],$[He]),w=Ue,k=He),(Ce!==A||_e!==T||ht!==N||wt!==I)&&(t.blendFuncSeparate(H[Ce],H[_e],H[ht],H[wt]),A=Ce,T=_e,N=ht,I=wt),(Ot.equals(C)===!1||cn!==D)&&(t.blendColor(Ot.r,Ot.g,Ot.b,cn),C.copy(Ot),D=cn),E=pe,F=!1}function G(pe,Ue){pe.side===uc?ve(t.CULL_FACE):re(t.CULL_FACE);let Ce=pe.side===Ks;Ue&&(Ce=!Ce),J(Ce),pe.blending===am&&pe.transparent===!1?ie(Yu):ie(pe.blending,pe.blendEquation,pe.blendSrc,pe.blendDst,pe.blendEquationAlpha,pe.blendSrcAlpha,pe.blendDstAlpha,pe.blendColor,pe.blendAlpha,pe.premultipliedAlpha),c.setFunc(pe.depthFunc),c.setTest(pe.depthTest),c.setMask(pe.depthWrite),o.setMask(pe.colorWrite);const _e=pe.stencilWrite;u.setTest(_e),_e&&(u.setMask(pe.stencilWriteMask),u.setFunc(pe.stencilFunc,pe.stencilRef,pe.stencilFuncMask),u.setOp(pe.stencilFail,pe.stencilZFail,pe.stencilZPass)),Ne(pe.polygonOffset,pe.polygonOffsetFactor,pe.polygonOffsetUnits),pe.alphaToCoverage===!0?re(t.SAMPLE_ALPHA_TO_COVERAGE):ve(t.SAMPLE_ALPHA_TO_COVERAGE)}function J(pe){j!==pe&&(pe?t.frontFace(t.CW):t.frontFace(t.CCW),j=pe)}function le(pe){pe!==sOe?(re(t.CULL_FACE),pe!==q&&(pe===UH?t.cullFace(t.BACK):pe===aOe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ve(t.CULL_FACE),q=pe}function Pe(pe){pe!==R&&(te&&t.lineWidth(pe),R=pe)}function Ne(pe,Ue,Ce){pe?(re(t.POLYGON_OFFSET_FILL),(W!==Ue||K!==Ce)&&(t.polygonOffset(Ue,Ce),W=Ue,K=Ce)):ve(t.POLYGON_OFFSET_FILL)}function Se(pe){pe?re(t.SCISSOR_TEST):ve(t.SCISSOR_TEST)}function B(pe){pe===void 0&&(pe=t.TEXTURE0+V-1),U!==pe&&(t.activeTexture(pe),U=pe)}function L(pe,Ue,Ce){Ce===void 0&&(U===null?Ce=t.TEXTURE0+V-1:Ce=U);let _e=z[Ce];_e===void 0&&(_e={type:void 0,texture:void 0},z[Ce]=_e),(_e.type!==pe||_e.texture!==Ue)&&(U!==Ce&&(t.activeTexture(Ce),U=Ce),t.bindTexture(pe,Ue||ye[pe]),_e.type=pe,_e.texture=Ue)}function ne(){const pe=z[U];pe!==void 0&&pe.type!==void 0&&(t.bindTexture(pe.type,null),pe.type=void 0,pe.texture=void 0)}function be(){try{t.compressedTexImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function we(){try{t.compressedTexImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function ge(){try{t.texSubImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function me(){try{t.texSubImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ae(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function ze(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function st(){try{t.texStorage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ve(){try{t.texStorage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function ce(){try{t.texImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ye(){try{t.texImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function $e(pe){fe.equals(pe)===!1&&(t.scissor(pe.x,pe.y,pe.z,pe.w),fe.copy(pe))}function Ze(pe){de.equals(pe)===!1&&(t.viewport(pe.x,pe.y,pe.z,pe.w),de.copy(pe))}function at(pe,Ue){let Ce=f.get(Ue);Ce===void 0&&(Ce=new WeakMap,f.set(Ue,Ce));let _e=Ce.get(pe);_e===void 0&&(_e=t.getUniformBlockIndex(Ue,pe.name),Ce.set(pe,_e))}function Q(pe,Ue){const _e=f.get(Ue).get(pe);d.get(Ue)!==_e&&(t.uniformBlockBinding(Ue,_e,pe.__bindingPointIndex),d.set(Ue,_e))}function Fe(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),g={},U=null,z={},m={},x=new WeakMap,y=[],v=null,b=!1,E=null,w=null,A=null,T=null,k=null,N=null,I=null,C=new $t(0,0,0),D=0,F=!1,j=null,q=null,R=null,W=null,K=null,fe.set(0,0,t.canvas.width,t.canvas.height),de.set(0,0,t.canvas.width,t.canvas.height),o.reset(),c.reset(),u.reset()}return{buffers:{color:o,depth:c,stencil:u},enable:re,disable:ve,bindFramebuffer:je,drawBuffers:ue,useProgram:ut,setBlending:ie,setMaterial:G,setFlipSided:J,setCullFace:le,setLineWidth:Pe,setPolygonOffset:Ne,setScissorTest:Se,activeTexture:B,bindTexture:L,unbindTexture:ne,compressedTexImage2D:be,compressedTexImage3D:we,texImage2D:ce,texImage3D:Ye,updateUBOMapping:at,uniformBlockBinding:Q,texStorage2D:st,texStorage3D:Ve,texSubImage2D:ge,texSubImage3D:me,compressedTexSubImage2D:Ae,compressedTexSubImage3D:ze,scissor:$e,viewport:Ze,reset:Fe}}function p5e(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 w(B,L,ne,be){let we=1;if((B.width>be||B.height>be)&&(we=be/Math.max(B.width,B.height)),we<1||L===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){const ge=L?Iw:Math.floor,me=ge(we*B.width),Ae=ge(we*B.height);y===void 0&&(y=E(me,Ae));const ze=ne?E(me,Ae):y;return ze.width=me,ze.height=Ae,ze.getContext("2d").drawImage(B,0,0,me,Ae),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+me+"x"+Ae+")."),ze}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function A(B){return DP(B.width)&&DP(B.height)}function T(B){return o?!1:B.wrapS!==Co||B.wrapT!==Co||B.minFilter!==Yi&&B.minFilter!==Xa}function k(B,L){return B.generateMipmaps&&L&&B.minFilter!==Yi&&B.minFilter!==Xa}function N(B){t.generateMipmap(B)}function I(B,L,ne,be,we=!1){if(o===!1)return L;if(B!==null){if(t[B]!==void 0)return t[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ge=L;if(L===t.RED&&(ne===t.FLOAT&&(ge=t.R32F),ne===t.HALF_FLOAT&&(ge=t.R16F),ne===t.UNSIGNED_BYTE&&(ge=t.R8)),L===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ge=t.R8UI),ne===t.UNSIGNED_SHORT&&(ge=t.R16UI),ne===t.UNSIGNED_INT&&(ge=t.R32UI),ne===t.BYTE&&(ge=t.R8I),ne===t.SHORT&&(ge=t.R16I),ne===t.INT&&(ge=t.R32I)),L===t.RG&&(ne===t.FLOAT&&(ge=t.RG32F),ne===t.HALF_FLOAT&&(ge=t.RG16F),ne===t.UNSIGNED_BYTE&&(ge=t.RG8)),L===t.RGBA){const me=we?Ow:Kn.getTransfer(be);ne===t.FLOAT&&(ge=t.RGBA32F),ne===t.HALF_FLOAT&&(ge=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ge=me===lr?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ge=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ge=t.RGB5_A1)}return(ge===t.R16F||ge===t.R32F||ge===t.RG16F||ge===t.RG32F||ge===t.RGBA16F||ge===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function C(B,L,ne){return k(B,ne)===!0||B.isFramebufferTexture&&B.minFilter!==Yi&&B.minFilter!==Xa?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===Yi||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 ne=B.source,be=v.get(ne);if(be){const we=be[L.__cacheKey];we.usedTimes--,we.usedTimes===0&&R(B),Object.keys(be).length===0&&v.delete(ne)}r.remove(B)}function R(B){const L=r.get(B);t.deleteTexture(L.__webglTexture);const ne=B.source,be=v.get(ne);delete be[L.__cacheKey],a.memory.textures--}function W(B){const L=B.texture,ne=r.get(B),be=r.get(L);if(be.__webglTexture!==void 0&&(t.deleteTexture(be.__webglTexture),a.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let we=0;we<6;we++){if(Array.isArray(ne.__webglFramebuffer[we]))for(let ge=0;ge<ne.__webglFramebuffer[we].length;ge++)t.deleteFramebuffer(ne.__webglFramebuffer[we][ge]);else t.deleteFramebuffer(ne.__webglFramebuffer[we]);ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer[we])}else{if(Array.isArray(ne.__webglFramebuffer))for(let we=0;we<ne.__webglFramebuffer.length;we++)t.deleteFramebuffer(ne.__webglFramebuffer[we]);else t.deleteFramebuffer(ne.__webglFramebuffer);if(ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let we=0;we<ne.__webglColorRenderbuffer.length;we++)ne.__webglColorRenderbuffer[we]&&t.deleteRenderbuffer(ne.__webglColorRenderbuffer[we]);ne.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let we=0,ge=L.length;we<ge;we++){const me=r.get(L[we]);me.__webglTexture&&(t.deleteTexture(me.__webglTexture),a.memory.textures--),r.remove(L[we])}r.remove(L),r.remove(B)}let K=0;function V(){K=0}function te(){const B=K;return B>=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 Z(B,L){const ne=r.get(B);if(B.isVideoTexture&&Ne(B),B.isRenderTargetTexture===!1&&B.version>0&&ne.__version!==B.version){const be=B.image;if(be===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{re(ne,B,L);return}}n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+L)}function U(B,L){const ne=r.get(B);if(B.version>0&&ne.__version!==B.version){re(ne,B,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+L)}function z(B,L){const ne=r.get(B);if(B.version>0&&ne.__version!==B.version){re(ne,B,L);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+L)}function ee(B,L){const ne=r.get(B);if(B.version>0&&ne.__version!==B.version){ve(ne,B,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+L)}const ae={[NP]:t.REPEAT,[Co]:t.CLAMP_TO_EDGE,[kP]:t.MIRRORED_REPEAT},fe={[Yi]:t.NEAREST,[VH]:t.NEAREST_MIPMAP_NEAREST,[WC]:t.NEAREST_MIPMAP_LINEAR,[Xa]:t.LINEAR,[UOe]:t.LINEAR_MIPMAP_NEAREST,[q0]:t.LINEAR_MIPMAP_LINEAR},de={[YOe]:t.NEVER,[nje]:t.ALWAYS,[ZOe]:t.LESS,[DZ]:t.LEQUAL,[QOe]:t.EQUAL,[tje]:t.GEQUAL,[JOe]:t.GREATER,[eje]:t.NOTEQUAL};function xe(B,L,ne){if(ne?(t.texParameteri(B,t.TEXTURE_WRAP_S,ae[L.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,ae[L.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,ae[L.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,fe[L.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,fe[L.minFilter])):(t.texParameteri(B,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(B,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==Co||L.wrapT!==Co)&&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!==Yi&&L.minFilter!==Xa&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri(B,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(B,t.TEXTURE_COMPARE_FUNC,de[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const be=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Yi||L.minFilter!==WC&&L.minFilter!==q0||L.type===gc&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===K0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(B,be.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function ye(B,L){let ne=!1;B.__webglInit===void 0&&(B.__webglInit=!0,L.addEventListener("dispose",F));const be=L.source;let we=v.get(be);we===void 0&&(we={},v.set(be,we));const ge=Y(L);if(ge!==B.__cacheKey){we[ge]===void 0&&(we[ge]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,ne=!0),we[ge].usedTimes++;const me=we[B.__cacheKey];me!==void 0&&(we[B.__cacheKey].usedTimes--,me.usedTimes===0&&R(L)),B.__cacheKey=ge,B.__webglTexture=we[ge].texture}return ne}function re(B,L,ne){let be=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(be=t.TEXTURE_3D);const we=ye(B,L),ge=L.source;n.bindTexture(be,B.__webglTexture,t.TEXTURE0+ne);const me=r.get(ge);if(ge.version!==me.__version||we===!0){n.activeTexture(t.TEXTURE0+ne);const Ae=Kn.getPrimaries(Kn.workingColorSpace),ze=L.colorSpace===Za?null:Kn.getPrimaries(L.colorSpace),st=L.colorSpace===Za||Ae===ze?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,st);const Ve=T(L)&&A(L.image)===!1;let ce=w(L.image,Ve,!1,d);ce=Se(L,ce);const Ye=A(ce)||o,$e=s.convert(L.format,L.colorSpace);let Ze=s.convert(L.type),at=I(L.internalFormat,$e,Ze,L.colorSpace,L.isVideoTexture);xe(be,L,Ye);let Q;const Fe=L.mipmaps,pe=o&&L.isVideoTexture!==!0&&at!==kZ,Ue=me.__version===void 0||we===!0,Ce=C(L,ce,Ye);if(L.isDepthTexture)at=t.DEPTH_COMPONENT,o?L.type===gc?at=t.DEPTH_COMPONENT32F:L.type===Bu?at=t.DEPTH_COMPONENT24:L.type===Nh?at=t.DEPTH24_STENCIL8:at=t.DEPTH_COMPONENT16:L.type===gc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===kh&&at===t.DEPTH_COMPONENT&&L.type!==dj&&L.type!==Bu&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Bu,Ze=s.convert(L.type)),L.format===Dm&&at===t.DEPTH_COMPONENT&&(at=t.DEPTH_STENCIL,L.type!==Nh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Nh,Ze=s.convert(L.type))),Ue&&(pe?n.texStorage2D(t.TEXTURE_2D,1,at,ce.width,ce.height):n.texImage2D(t.TEXTURE_2D,0,at,ce.width,ce.height,0,$e,Ze,null));else if(L.isDataTexture)if(Fe.length>0&&Ye){pe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,Fe[0].width,Fe[0].height);for(let _e=0,He=Fe.length;_e<He;_e++)Q=Fe[_e],pe?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,Q.width,Q.height,$e,Ze,Q.data):n.texImage2D(t.TEXTURE_2D,_e,at,Q.width,Q.height,0,$e,Ze,Q.data);L.generateMipmaps=!1}else pe?(Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,ce.width,ce.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ce.width,ce.height,$e,Ze,ce.data)):n.texImage2D(t.TEXTURE_2D,0,at,ce.width,ce.height,0,$e,Ze,ce.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){pe&&Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,at,Fe[0].width,Fe[0].height,ce.depth);for(let _e=0,He=Fe.length;_e<He;_e++)Q=Fe[_e],L.format!==Ya?$e!==null?pe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,_e,0,0,0,Q.width,Q.height,ce.depth,$e,Q.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,_e,at,Q.width,Q.height,ce.depth,0,Q.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pe?n.texSubImage3D(t.TEXTURE_2D_ARRAY,_e,0,0,0,Q.width,Q.height,ce.depth,$e,Ze,Q.data):n.texImage3D(t.TEXTURE_2D_ARRAY,_e,at,Q.width,Q.height,ce.depth,0,$e,Ze,Q.data)}else{pe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,Fe[0].width,Fe[0].height);for(let _e=0,He=Fe.length;_e<He;_e++)Q=Fe[_e],L.format!==Ya?$e!==null?pe?n.compressedTexSubImage2D(t.TEXTURE_2D,_e,0,0,Q.width,Q.height,$e,Q.data):n.compressedTexImage2D(t.TEXTURE_2D,_e,at,Q.width,Q.height,0,Q.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pe?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,Q.width,Q.height,$e,Ze,Q.data):n.texImage2D(t.TEXTURE_2D,_e,at,Q.width,Q.height,0,$e,Ze,Q.data)}else if(L.isDataArrayTexture)pe?(Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,at,ce.width,ce.height,ce.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ce.width,ce.height,ce.depth,$e,Ze,ce.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,at,ce.width,ce.height,ce.depth,0,$e,Ze,ce.data);else if(L.isData3DTexture)pe?(Ue&&n.texStorage3D(t.TEXTURE_3D,Ce,at,ce.width,ce.height,ce.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ce.width,ce.height,ce.depth,$e,Ze,ce.data)):n.texImage3D(t.TEXTURE_3D,0,at,ce.width,ce.height,ce.depth,0,$e,Ze,ce.data);else if(L.isFramebufferTexture){if(Ue)if(pe)n.texStorage2D(t.TEXTURE_2D,Ce,at,ce.width,ce.height);else{let _e=ce.width,He=ce.height;for(let ht=0;ht<Ce;ht++)n.texImage2D(t.TEXTURE_2D,ht,at,_e,He,0,$e,Ze,null),_e>>=1,He>>=1}}else if(Fe.length>0&&Ye){pe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,Fe[0].width,Fe[0].height);for(let _e=0,He=Fe.length;_e<He;_e++)Q=Fe[_e],pe?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,$e,Ze,Q):n.texImage2D(t.TEXTURE_2D,_e,at,$e,Ze,Q);L.generateMipmaps=!1}else pe?(Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,ce.width,ce.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,$e,Ze,ce)):n.texImage2D(t.TEXTURE_2D,0,at,$e,Ze,ce);k(L,Ye)&&N(be),me.__version=ge.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function ve(B,L,ne){if(L.image.length!==6)return;const be=ye(B,L),we=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+ne);const ge=r.get(we);if(we.version!==ge.__version||be===!0){n.activeTexture(t.TEXTURE0+ne);const me=Kn.getPrimaries(Kn.workingColorSpace),Ae=L.colorSpace===Za?null:Kn.getPrimaries(L.colorSpace),ze=L.colorSpace===Za||me===Ae?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ze);const st=L.isCompressedTexture||L.image[0].isCompressedTexture,Ve=L.image[0]&&L.image[0].isDataTexture,ce=[];for(let _e=0;_e<6;_e++)!st&&!Ve?ce[_e]=w(L.image[_e],!1,!0,u):ce[_e]=Ve?L.image[_e].image:L.image[_e],ce[_e]=Se(L,ce[_e]);const Ye=ce[0],$e=A(Ye)||o,Ze=s.convert(L.format,L.colorSpace),at=s.convert(L.type),Q=I(L.internalFormat,Ze,at,L.colorSpace),Fe=o&&L.isVideoTexture!==!0,pe=ge.__version===void 0||be===!0;let Ue=C(L,Ye,$e);xe(t.TEXTURE_CUBE_MAP,L,$e);let Ce;if(st){Fe&&pe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,Q,Ye.width,Ye.height);for(let _e=0;_e<6;_e++){Ce=ce[_e].mipmaps;for(let He=0;He<Ce.length;He++){const ht=Ce[He];L.format!==Ya?Ze!==null?Fe?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,0,0,ht.width,ht.height,Ze,ht.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,Q,ht.width,ht.height,0,ht.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,0,0,ht.width,ht.height,Ze,at,ht.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,Q,ht.width,ht.height,0,Ze,at,ht.data)}}}else{Ce=L.mipmaps,Fe&&pe&&(Ce.length>0&&Ue++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,Q,ce[0].width,ce[0].height));for(let _e=0;_e<6;_e++)if(Ve){Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,ce[_e].width,ce[_e].height,Ze,at,ce[_e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,Q,ce[_e].width,ce[_e].height,0,Ze,at,ce[_e].data);for(let He=0;He<Ce.length;He++){const wt=Ce[He].image[_e].image;Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,0,0,wt.width,wt.height,Ze,at,wt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,Q,wt.width,wt.height,0,Ze,at,wt.data)}}else{Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,Ze,at,ce[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,Q,Ze,at,ce[_e]);for(let He=0;He<Ce.length;He++){const ht=Ce[He];Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,0,0,Ze,at,ht.image[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,Q,Ze,at,ht.image[_e])}}}k(L,$e)&&N(t.TEXTURE_CUBE_MAP),ge.__version=we.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function je(B,L,ne,be,we,ge){const me=s.convert(ne.format,ne.colorSpace),Ae=s.convert(ne.type),ze=I(ne.internalFormat,me,Ae,ne.colorSpace);if(!r.get(L).__hasExternalTextures){const Ve=Math.max(1,L.width>>ge),ce=Math.max(1,L.height>>ge);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ge,ze,Ve,ce,L.depth,0,me,Ae,null):n.texImage2D(we,ge,ze,Ve,ce,0,me,Ae,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),Pe(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,we,r.get(ne).__webglTexture,0,le(L)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,we,r.get(ne).__webglTexture,ge),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(B,L,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,B),L.depthBuffer&&!L.stencilBuffer){let be=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ne||Pe(L)){const we=L.depthTexture;we&&we.isDepthTexture&&(we.type===gc?be=t.DEPTH_COMPONENT32F:we.type===Bu&&(be=t.DEPTH_COMPONENT24));const ge=le(L);Pe(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ge,be,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ge,be,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,be,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,B)}else if(L.depthBuffer&&L.stencilBuffer){const be=le(L);ne&&Pe(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,L.width,L.height):Pe(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,B)}else{const be=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let we=0;we<be.length;we++){const ge=be[we],me=s.convert(ge.format,ge.colorSpace),Ae=s.convert(ge.type),ze=I(ge.internalFormat,me,Ae,ge.colorSpace),st=le(L);ne&&Pe(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,st,ze,L.width,L.height):Pe(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,st,ze,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ze,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ut(B,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,B),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),Z(L.depthTexture,0);const be=r.get(L.depthTexture).__webglTexture,we=le(L);if(L.depthTexture.format===kh)Pe(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0);else if(L.depthTexture.format===Dm)Pe(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0);else throw new Error("Unknown depthTexture format")}function $(B){const L=r.get(B),ne=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!L.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");ut(L.__webglFramebuffer,B)}else if(ne){L.__webglDepthbuffer=[];for(let be=0;be<6;be++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[be]),L.__webglDepthbuffer[be]=t.createRenderbuffer(),ue(L.__webglDepthbuffer[be],B,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),ue(L.__webglDepthbuffer,B,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function H(B,L,ne){const be=r.get(B);L!==void 0&&je(be.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&$(B)}function ie(B){const L=B.texture,ne=r.get(B),be=r.get(L);B.addEventListener("dispose",j),B.isWebGLMultipleRenderTargets!==!0&&(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=L.version,a.memory.textures++);const we=B.isWebGLCubeRenderTarget===!0,ge=B.isWebGLMultipleRenderTargets===!0,me=A(B)||o;if(we){ne.__webglFramebuffer=[];for(let Ae=0;Ae<6;Ae++)if(o&&L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer[Ae]=[];for(let ze=0;ze<L.mipmaps.length;ze++)ne.__webglFramebuffer[Ae][ze]=t.createFramebuffer()}else ne.__webglFramebuffer[Ae]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Ae=0;Ae<L.mipmaps.length;Ae++)ne.__webglFramebuffer[Ae]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(ge)if(i.drawBuffers){const Ae=B.texture;for(let ze=0,st=Ae.length;ze<st;ze++){const Ve=r.get(Ae[ze]);Ve.__webglTexture===void 0&&(Ve.__webglTexture=t.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&B.samples>0&&Pe(B)===!1){const Ae=ge?L:[L];ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let ze=0;ze<Ae.length;ze++){const st=Ae[ze];ne.__webglColorRenderbuffer[ze]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[ze]);const Ve=s.convert(st.format,st.colorSpace),ce=s.convert(st.type),Ye=I(st.internalFormat,Ve,ce,st.colorSpace,B.isXRRenderTarget===!0),$e=le(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,$e,Ye,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ze,t.RENDERBUFFER,ne.__webglColorRenderbuffer[ze])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),ue(ne.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),xe(t.TEXTURE_CUBE_MAP,L,me);for(let Ae=0;Ae<6;Ae++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)je(ne.__webglFramebuffer[Ae][ze],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,ze);else je(ne.__webglFramebuffer[Ae],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0);k(L,me)&&N(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ge){const Ae=B.texture;for(let ze=0,st=Ae.length;ze<st;ze++){const Ve=Ae[ze],ce=r.get(Ve);n.bindTexture(t.TEXTURE_2D,ce.__webglTexture),xe(t.TEXTURE_2D,Ve,me),je(ne.__webglFramebuffer,B,Ve,t.COLOR_ATTACHMENT0+ze,t.TEXTURE_2D,0),k(Ve,me)&&N(t.TEXTURE_2D)}n.unbindTexture()}else{let Ae=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(o?Ae=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ae,be.__webglTexture),xe(Ae,L,me),o&&L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)je(ne.__webglFramebuffer[ze],B,L,t.COLOR_ATTACHMENT0,Ae,ze);else je(ne.__webglFramebuffer,B,L,t.COLOR_ATTACHMENT0,Ae,0);k(L,me)&&N(Ae),n.unbindTexture()}B.depthBuffer&&$(B)}function G(B){const L=A(B)||o,ne=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let be=0,we=ne.length;be<we;be++){const ge=ne[be];if(k(ge,L)){const me=B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ae=r.get(ge).__webglTexture;n.bindTexture(me,Ae),N(me),n.unbindTexture()}}}function J(B){if(o&&B.samples>0&&Pe(B)===!1){const L=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],ne=B.width,be=B.height;let we=t.COLOR_BUFFER_BIT;const ge=[],me=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ae=r.get(B),ze=B.isWebGLMultipleRenderTargets===!0;if(ze)for(let st=0;st<L.length;st++)n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ae.__webglFramebuffer);for(let st=0;st<L.length;st++){ge.push(t.COLOR_ATTACHMENT0+st),B.depthBuffer&&ge.push(me);const Ve=Ae.__ignoreDepthValues!==void 0?Ae.__ignoreDepthValues:!1;if(Ve===!1&&(B.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),ze&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ae.__webglColorRenderbuffer[st]),Ve===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[me]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[me])),ze){const ce=r.get(L[st]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ce,0)}t.blitFramebuffer(0,0,ne,be,0,0,ne,be,we,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ge)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),ze)for(let st=0;st<L.length;st++){n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,Ae.__webglColorRenderbuffer[st]);const Ve=r.get(L[st]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,Ve,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer)}}function le(B){return Math.min(f,B.samples)}function Pe(B){const L=r.get(B);return o&&B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ne(B){const L=a.render.frame;x.get(B)!==L&&(x.set(B,L),B.update())}function Se(B,L){const ne=B.colorSpace,be=B.format,we=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===RP||ne!==jc&&ne!==Za&&(Kn.getTransfer(ne)===lr?o===!1?e.has("EXT_sRGB")===!0&&be===Ya?(B.format=RP,B.minFilter=Xa,B.generateMipmaps=!1):L=LZ.sRGBToLinear(L):(be!==Ya||we!==Qu)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ne)),L}this.allocateTextureUnit=te,this.resetTextureUnits=V,this.setTexture2D=Z,this.setTexture2DArray=U,this.setTexture3D=z,this.setTextureCube=ee,this.rebindTextures=H,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=J,this.setupDepthRenderbuffer=$,this.setupFrameBufferTexture=je,this.useMultisampledRTT=Pe}function m5e(t,e,n){const r=n.isWebGL2;function i(s,a=Za){let o;const c=Kn.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===FOe)return t.BYTE;if(s===zOe)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===gc)return t.FLOAT;if(s===K0)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===BOe)return t.ALPHA;if(s===Ya)return t.RGBA;if(s===HOe)return t.LUMINANCE;if(s===$Oe)return t.LUMINANCE_ALPHA;if(s===kh)return t.DEPTH_COMPONENT;if(s===Dm)return t.DEPTH_STENCIL;if(s===RP)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===VOe)return t.RED;if(s===TZ)return t.RED_INTEGER;if(s===GOe)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===WOe||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 g5e extends pa{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Ux extends Ts{constructor(){super(),this.isGroup=!0,this.type="Group"}}const x5e={type:"move"};class yN{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ux,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 Ux,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 Ux,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(x5e)))}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 Ux;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class b5e 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=[],w=[],A=new Yt;let T=null;const k=new pa;k.layers.enable(1),k.viewport=new Yn;const N=new pa;N.layers.enable(2),N.viewport=new Yn;const I=[k,N],C=new g5e;C.layers.enable(1),C.layers.enable(2);let D=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ee){let ae=E[ee];return ae===void 0&&(ae=new yN,E[ee]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(ee){let ae=E[ee];return ae===void 0&&(ae=new yN,E[ee]=ae),ae.getGripSpace()},this.getHand=function(ee){let ae=E[ee];return ae===void 0&&(ae=new yN,E[ee]=ae),ae.getHandSpace()};function j(ee){const ae=w.indexOf(ee.inputSource);if(ae===-1)return;const fe=E[ae];fe!==void 0&&(fe.update(ee.inputSource,ee.frame,u||a),fe.dispatchEvent({type:ee.type,data:ee.inputSource}))}function q(){i.removeEventListener("select",j),i.removeEventListener("selectstart",j),i.removeEventListener("selectend",j),i.removeEventListener("squeeze",j),i.removeEventListener("squeezestart",j),i.removeEventListener("squeezeend",j),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",R);for(let ee=0;ee<E.length;ee++){const ae=w[ee];ae!==null&&(w[ee]=null,E[ee].disconnect(ae))}D=null,F=null,e.setRenderTarget(v),m=null,g=null,f=null,i=null,b=null,z.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ee){s=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ee){o=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||a},this.setReferenceSpace=function(ee){u=ee},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ee){if(i=ee,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",j),i.addEventListener("selectstart",j),i.addEventListener("selectend",j),i.addEventListener("squeeze",j),i.addEventListener("squeezestart",j),i.addEventListener("squeezeend",j),i.addEventListener("end",q),i.addEventListener("inputsourceschange",R),y.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ae={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,ae),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),b=new nf(m.framebufferWidth,m.framebufferHeight,{format:Ya,type:Qu,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ae=null,fe=null,de=null;y.depth&&(de=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ae=y.stencil?Dm:kh,fe=y.stencil?Nh:Bu);const xe={colorFormat:n.RGBA8,depthFormat:de,scaleFactor:s};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(xe),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),b=new nf(g.textureWidth,g.textureHeight,{format:Ya,type:Qu,depthTexture:new KZ(g.textureWidth,g.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const ye=e.properties.get(b);ye.__ignoreDepthValues=g.ignoreDepthValues}b.isXRRenderTarget=!0,this.setFoveation(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(ee){for(let ae=0;ae<ee.removed.length;ae++){const fe=ee.removed[ae],de=w.indexOf(fe);de>=0&&(w[de]=null,E[de].disconnect(fe))}for(let ae=0;ae<ee.added.length;ae++){const fe=ee.added[ae];let de=w.indexOf(fe);if(de===-1){for(let ye=0;ye<E.length;ye++)if(ye>=w.length){w.push(fe),de=ye;break}else if(w[ye]===null){w[ye]=fe,de=ye;break}if(de===-1)break}const xe=E[de];xe&&xe.connect(fe)}}const W=new De,K=new De;function V(ee,ae,fe){W.setFromMatrixPosition(ae.matrixWorld),K.setFromMatrixPosition(fe.matrixWorld);const de=W.distanceTo(K),xe=ae.projectionMatrix.elements,ye=fe.projectionMatrix.elements,re=xe[14]/(xe[10]-1),ve=xe[14]/(xe[10]+1),je=(xe[9]+1)/xe[5],ue=(xe[9]-1)/xe[5],ut=(xe[8]-1)/xe[0],$=(ye[8]+1)/ye[0],H=re*ut,ie=re*$,G=de/(-ut+$),J=G*-ut;ae.matrixWorld.decompose(ee.position,ee.quaternion,ee.scale),ee.translateX(J),ee.translateZ(G),ee.matrixWorld.compose(ee.position,ee.quaternion,ee.scale),ee.matrixWorldInverse.copy(ee.matrixWorld).invert();const le=re+G,Pe=ve+G,Ne=H-J,Se=ie+(de-J),B=je*ve/Pe*le,L=ue*ve/Pe*le;ee.projectionMatrix.makePerspective(Ne,Se,B,L,le,Pe),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert()}function te(ee,ae){ae===null?ee.matrixWorld.copy(ee.matrix):ee.matrixWorld.multiplyMatrices(ae.matrixWorld,ee.matrix),ee.matrixWorldInverse.copy(ee.matrixWorld).invert()}this.updateCamera=function(ee){if(i===null)return;C.near=N.near=k.near=ee.near,C.far=N.far=k.far=ee.far,(D!==C.near||F!==C.far)&&(i.updateRenderState({depthNear:C.near,depthFar:C.far}),D=C.near,F=C.far);const ae=ee.parent,fe=C.cameras;te(C,ae);for(let de=0;de<fe.length;de++)te(fe[de],ae);fe.length===2?V(C,k,N):C.projectionMatrix.copy(k.projectionMatrix),Y(ee,C,ae)};function Y(ee,ae,fe){fe===null?ee.matrix.copy(ae.matrixWorld):(ee.matrix.copy(fe.matrixWorld),ee.matrix.invert(),ee.matrix.multiply(ae.matrixWorld)),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.updateMatrixWorld(!0),ee.projectionMatrix.copy(ae.projectionMatrix),ee.projectionMatrixInverse.copy(ae.projectionMatrixInverse),ee.isPerspectiveCamera&&(ee.fov=Y0*2*Math.atan(1/ee.projectionMatrix.elements[5]),ee.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(g===null&&m===null))return c},this.setFoveation=function(ee){c=ee,g!==null&&(g.fixedFoveation=ee),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ee)};let Z=null;function U(ee,ae){if(d=ae.getViewerPose(u||a),x=ae,d!==null){const fe=d.views;m!==null&&(e.setRenderTargetFramebuffer(b,m.framebuffer),e.setRenderTarget(b));let de=!1;fe.length!==C.cameras.length&&(C.cameras.length=0,de=!0);for(let xe=0;xe<fe.length;xe++){const ye=fe[xe];let re=null;if(m!==null)re=m.getViewport(ye);else{const je=f.getViewSubImage(g,ye);re=je.viewport,xe===0&&(e.setRenderTargetTextures(b,je.colorTexture,g.ignoreDepthValues?void 0:je.depthStencilTexture),e.setRenderTarget(b))}let ve=I[xe];ve===void 0&&(ve=new pa,ve.layers.enable(xe),ve.viewport=new Yn,I[xe]=ve),ve.matrix.fromArray(ye.transform.matrix),ve.matrix.decompose(ve.position,ve.quaternion,ve.scale),ve.projectionMatrix.fromArray(ye.projectionMatrix),ve.projectionMatrixInverse.copy(ve.projectionMatrix).invert(),ve.viewport.set(re.x,re.y,re.width,re.height),xe===0&&(C.matrix.copy(ve.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),de===!0&&C.cameras.push(ve)}}for(let fe=0;fe<E.length;fe++){const de=w[fe],xe=E[fe];de!==null&&xe!==void 0&&xe.update(de,ae,u||a)}Z&&Z(ee,ae),ae.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ae}),x=null}const z=new qZ;z.setAnimationLoop(U),this.setAnimationLoop=function(ee){Z=ee},this.dispose=function(){}}}function v5e(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,w,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,w):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).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 w=t._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=b.lightMapIntensity*w,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,w){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.size.value=b.size*E,v.scale.value=w*.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===Ks&&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 y5e(t,e,n,r){let i={},s={},a=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(E,w){const A=w.program;r.uniformBlockBinding(E,A)}function u(E,w){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",v));const T=w.program;r.updateUBOMapping(E,T);const k=e.render.frame;s[E.id]!==k&&(g(E),s[E.id]=k)}function d(E){const w=f();E.__bindingPointIndex=w;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,w,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 w=i[E.id],A=E.uniforms,T=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);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,w,A){const T=E.value;if(A[w]===void 0){if(typeof T=="number")A[w]=T;else{const k=Array.isArray(T)?T:[T],N=[];for(let I=0;I<k.length;I++)N.push(k[I].clone());A[w]=N}return!0}else if(typeof T=="number"){if(A[w]!==T)return A[w]=T,!0}else{const k=Array.isArray(A[w])?A[w]:[A[w]],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 w=E.uniforms;let A=0;const T=16;let k=0;for(let N=0,I=w.length;N<I;N++){const C=w[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 w={boundary:0,storage:0};return typeof E=="number"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),w}function v(E){const w=E.target;w.removeEventListener("dispose",v);const A=a.indexOf(w.__bindingPointIndex);a.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete s[w.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=xje(),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=Zi,this._useLegacyLights=!1,this.toneMapping=Zu,this.toneMappingExposure=1;const w=this;let A=!1,T=0,k=0,N=null,I=-1,C=null;const D=new Yn,F=new Yn;let j=null;const q=new $t(0);let R=0,W=n.width,K=n.height,V=1,te=null,Y=null;const Z=new Yn(0,0,W,K),U=new Yn(0,0,W,K);let z=!1;const ee=new VE;let ae=!1,fe=!1,de=null;const xe=new sr,ye=new Yt,re=new De,ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function je(){return N===null?V:1}let ue=r;function ut(he,Ge){for(let nt=0;nt<he.length;nt++){const rt=he[nt],et=n.getContext(rt,Ge);if(et!==null)return et}return null}try{const he={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${BE}`),n.addEventListener("webglcontextlost",Fe,!1),n.addEventListener("webglcontextrestored",pe,!1),n.addEventListener("webglcontextcreationerror",Ue,!1),ue===null){const Ge=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&Ge.shift(),ue=ut(Ge,he),ue===null)throw ut(Ge)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ue instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ue.getShaderPrecisionFormat===void 0&&(ue.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(he){throw console.error("THREE.WebGLRenderer: "+he.message),he}let $,H,ie,G,J,le,Pe,Ne,Se,B,L,ne,be,we,ge,me,Ae,ze,st,Ve,ce,Ye,$e,Ze;function at(){$=new P4e(ue),H=new E4e(ue,$,e),$.init(H),Ye=new m5e(ue,$,H),ie=new f5e(ue,$,H),G=new O4e(ue),J=new JUe,le=new p5e(ue,$,ie,J,H,Ye,G),Pe=new A4e(w),Ne=new k4e(w),Se=new Bje(ue,H),$e=new w4e(ue,$,Se,H),B=new R4e(ue,Se,G,$e),L=new U4e(ue,B,Se,G),st=new I4e(ue,H,le),me=new M4e(J),ne=new QUe(w,Pe,Ne,$,H,$e,me),be=new v5e(w,J),we=new t5e,ge=new o5e($,H),ze=new _4e(w,Pe,Ne,ie,L,g,c),Ae=new h5e(w,L,H),Ze=new y5e(ue,G,H,ie),Ve=new S4e(ue,$,G,H),ce=new D4e(ue,$,G,H),G.programs=ne.programs,w.capabilities=H,w.extensions=$,w.properties=J,w.renderLists=we,w.shadowMap=Ae,w.state=ie,w.info=G}at();const Q=new b5e(w,ue);this.xr=Q,this.getContext=function(){return ue},this.getContextAttributes=function(){return ue.getContextAttributes()},this.forceContextLoss=function(){const he=$.get("WEBGL_lose_context");he&&he.loseContext()},this.forceContextRestore=function(){const he=$.get("WEBGL_lose_context");he&&he.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(he){he!==void 0&&(V=he,this.setSize(W,K,!1))},this.getSize=function(he){return he.set(W,K)},this.setSize=function(he,Ge,nt=!0){if(Q.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=he,K=Ge,n.width=Math.floor(he*V),n.height=Math.floor(Ge*V),nt===!0&&(n.style.width=he+"px",n.style.height=Ge+"px"),this.setViewport(0,0,he,Ge)},this.getDrawingBufferSize=function(he){return he.set(W*V,K*V).floor()},this.setDrawingBufferSize=function(he,Ge,nt){W=he,K=Ge,V=nt,n.width=Math.floor(he*nt),n.height=Math.floor(Ge*nt),this.setViewport(0,0,he,Ge)},this.getCurrentViewport=function(he){return he.copy(D)},this.getViewport=function(he){return he.copy(Z)},this.setViewport=function(he,Ge,nt,rt){he.isVector4?Z.set(he.x,he.y,he.z,he.w):Z.set(he,Ge,nt,rt),ie.viewport(D.copy(Z).multiplyScalar(V).floor())},this.getScissor=function(he){return he.copy(U)},this.setScissor=function(he,Ge,nt,rt){he.isVector4?U.set(he.x,he.y,he.z,he.w):U.set(he,Ge,nt,rt),ie.scissor(F.copy(U).multiplyScalar(V).floor())},this.getScissorTest=function(){return z},this.setScissorTest=function(he){ie.setScissorTest(z=he)},this.setOpaqueSort=function(he){te=he},this.setTransparentSort=function(he){Y=he},this.getClearColor=function(he){return he.copy(ze.getClearColor())},this.setClearColor=function(){ze.setClearColor.apply(ze,arguments)},this.getClearAlpha=function(){return ze.getClearAlpha()},this.setClearAlpha=function(){ze.setClearAlpha.apply(ze,arguments)},this.clear=function(he=!0,Ge=!0,nt=!0){let rt=0;if(he){let et=!1;if(N!==null){const St=N.texture.format;et=St===NZ||St===CZ||St===TZ}if(et){const St=N.texture.type,se=St===Qu||St===Bu||St===dj||St===Nh||St===MZ||St===AZ,Ee=ze.getClearColor(),Le=ze.getClearAlpha(),Oe=Ee.r,Te=Ee.g,ot=Ee.b;se?(m[0]=Oe,m[1]=Te,m[2]=ot,m[3]=Le,ue.clearBufferuiv(ue.COLOR,0,m)):(x[0]=Oe,x[1]=Te,x[2]=ot,x[3]=Le,ue.clearBufferiv(ue.COLOR,0,x))}else rt|=ue.COLOR_BUFFER_BIT}Ge&&(rt|=ue.DEPTH_BUFFER_BIT),nt&&(rt|=ue.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ue.clear(rt)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Fe,!1),n.removeEventListener("webglcontextrestored",pe,!1),n.removeEventListener("webglcontextcreationerror",Ue,!1),we.dispose(),ge.dispose(),J.dispose(),Pe.dispose(),Ne.dispose(),L.dispose(),$e.dispose(),Ze.dispose(),ne.dispose(),Q.dispose(),Q.removeEventListener("sessionstart",cn),Q.removeEventListener("sessionend",It),de&&(de.dispose(),de=null),Dn.stop()};function Fe(he){he.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function pe(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const he=G.autoReset,Ge=Ae.enabled,nt=Ae.autoUpdate,rt=Ae.needsUpdate,et=Ae.type;at(),G.autoReset=he,Ae.enabled=Ge,Ae.autoUpdate=nt,Ae.needsUpdate=rt,Ae.type=et}function Ue(he){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",he.statusMessage)}function Ce(he){const Ge=he.target;Ge.removeEventListener("dispose",Ce),_e(Ge)}function _e(he){He(he),J.remove(he)}function He(he){const Ge=J.get(he).programs;Ge!==void 0&&(Ge.forEach(function(nt){ne.releaseProgram(nt)}),he.isShaderMaterial&&ne.releaseShaderCache(he))}this.renderBufferDirect=function(he,Ge,nt,rt,et,St){Ge===null&&(Ge=ve);const se=et.isMesh&&et.matrixWorld.determinant()<0,Ee=Or(he,Ge,nt,rt,et);ie.setMaterial(rt,se);let Le=nt.index,Oe=1;if(rt.wireframe===!0){if(Le=B.getWireframeAttribute(nt),Le===void 0)return;Oe=2}const Te=nt.drawRange,ot=nt.attributes.position;let ft=Te.start*Oe,bt=(Te.start+Te.count)*Oe;St!==null&&(ft=Math.max(ft,St.start*Oe),bt=Math.min(bt,(St.start+St.count)*Oe)),Le!==null?(ft=Math.max(ft,0),bt=Math.min(bt,Le.count)):ot!=null&&(ft=Math.max(ft,0),bt=Math.min(bt,ot.count));const xt=bt-ft;if(xt<0||xt===1/0)return;$e.setup(et,rt,Ee,nt,Le);let jt,Mt=Ve;if(Le!==null&&(jt=Se.get(Le),Mt=ce,Mt.setIndex(jt)),et.isMesh)rt.wireframe===!0?(ie.setLineWidth(rt.wireframeLinewidth*je()),Mt.setMode(ue.LINES)):Mt.setMode(ue.TRIANGLES);else if(et.isLine){let mt=rt.linewidth;mt===void 0&&(mt=1),ie.setLineWidth(mt*je()),et.isLineSegments?Mt.setMode(ue.LINES):et.isLineLoop?Mt.setMode(ue.LINE_LOOP):Mt.setMode(ue.LINE_STRIP)}else et.isPoints?Mt.setMode(ue.POINTS):et.isSprite&&Mt.setMode(ue.TRIANGLES);if(et.isBatchedMesh)Mt.renderMultiDraw(et._multiDrawStarts,et._multiDrawCounts,et._multiDrawCount);else if(et.isInstancedMesh)Mt.renderInstances(ft,xt,et.count);else if(nt.isInstancedBufferGeometry){const mt=nt._maxInstanceCount!==void 0?nt._maxInstanceCount:1/0,Kt=Math.min(nt.instanceCount,mt);Mt.renderInstances(ft,xt,Kt)}else Mt.render(ft,xt)};function ht(he,Ge,nt){he.transparent===!0&&he.side===uc&&he.forceSinglePass===!1?(he.side=Ks,he.needsUpdate=!0,ns(he,Ge,nt),he.side=fd,he.needsUpdate=!0,ns(he,Ge,nt),he.side=uc):ns(he,Ge,nt)}this.compile=function(he,Ge,nt=null){nt===null&&(nt=he),v=ge.get(nt),v.init(),E.push(v),nt.traverseVisible(function(et){et.isLight&&et.layers.test(Ge.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),he!==nt&&he.traverseVisible(function(et){et.isLight&&et.layers.test(Ge.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),v.setupLights(w._useLegacyLights);const rt=new Set;return he.traverse(function(et){const St=et.material;if(St)if(Array.isArray(St))for(let se=0;se<St.length;se++){const Ee=St[se];ht(Ee,nt,et),rt.add(Ee)}else ht(St,nt,et),rt.add(St)}),E.pop(),v=null,rt},this.compileAsync=function(he,Ge,nt=null){const rt=this.compile(he,Ge,nt);return new Promise(et=>{function St(){if(rt.forEach(function(se){J.get(se).currentProgram.isReady()&&rt.delete(se)}),rt.size===0){et(he);return}setTimeout(St,10)}$.get("KHR_parallel_shader_compile")!==null?St():setTimeout(St,10)})};let wt=null;function Ot(he){wt&&wt(he)}function cn(){Dn.stop()}function It(){Dn.start()}const Dn=new qZ;Dn.setAnimationLoop(Ot),typeof self<"u"&&Dn.setContext(self),this.setAnimationLoop=function(he){wt=he,Q.setAnimationLoop(he),he===null?Dn.stop():Dn.start()},Q.addEventListener("sessionstart",cn),Q.addEventListener("sessionend",It),this.render=function(he,Ge){if(Ge!==void 0&&Ge.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),Ge.parent===null&&Ge.matrixWorldAutoUpdate===!0&&Ge.updateMatrixWorld(),Q.enabled===!0&&Q.isPresenting===!0&&(Q.cameraAutoUpdate===!0&&Q.updateCamera(Ge),Ge=Q.getCamera()),he.isScene===!0&&he.onBeforeRender(w,he,Ge,N),v=ge.get(he,E.length),v.init(),E.push(v),xe.multiplyMatrices(Ge.projectionMatrix,Ge.matrixWorldInverse),ee.setFromProjectionMatrix(xe),fe=this.localClippingEnabled,ae=me.init(this.clippingPlanes,fe),y=we.get(he,b.length),y.init(),b.push(y),Qn(he,Ge,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(te,Y),this.info.render.frame++,ae===!0&&me.beginShadows();const nt=v.state.shadowsArray;if(Ae.render(nt,he,Ge),ae===!0&&me.endShadows(),this.info.autoReset===!0&&this.info.reset(),ze.render(y,he),v.setupLights(w._useLegacyLights),Ge.isArrayCamera){const rt=Ge.cameras;for(let et=0,St=rt.length;et<St;et++){const se=rt[et];Si(y,he,se,se.viewport)}}else Si(y,he,Ge);N!==null&&(le.updateMultisampleRenderTarget(N),le.updateRenderTargetMipmap(N)),he.isScene===!0&&he.onAfterRender(w,he,Ge),$e.resetDefaultState(),I=-1,C=null,E.pop(),E.length>0?v=E[E.length-1]:v=null,b.pop(),b.length>0?y=b[b.length-1]:y=null};function Qn(he,Ge,nt,rt){if(he.visible===!1)return;if(he.layers.test(Ge.layers)){if(he.isGroup)nt=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(Ge);else if(he.isLight)v.pushLight(he),he.castShadow&&v.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||ee.intersectsSprite(he)){rt&&re.setFromMatrixPosition(he.matrixWorld).applyMatrix4(xe);const se=L.update(he),Ee=he.material;Ee.visible&&y.push(he,se,Ee,nt,re.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||ee.intersectsObject(he))){const se=L.update(he),Ee=he.material;if(rt&&(he.boundingSphere!==void 0?(he.boundingSphere===null&&he.computeBoundingSphere(),re.copy(he.boundingSphere.center)):(se.boundingSphere===null&&se.computeBoundingSphere(),re.copy(se.boundingSphere.center)),re.applyMatrix4(he.matrixWorld).applyMatrix4(xe)),Array.isArray(Ee)){const Le=se.groups;for(let Oe=0,Te=Le.length;Oe<Te;Oe++){const ot=Le[Oe],ft=Ee[ot.materialIndex];ft&&ft.visible&&y.push(he,se,ft,nt,re.z,ot)}}else Ee.visible&&y.push(he,se,Ee,nt,re.z,null)}}const St=he.children;for(let se=0,Ee=St.length;se<Ee;se++)Qn(St[se],Ge,nt,rt)}function Si(he,Ge,nt,rt){const et=he.opaque,St=he.transmissive,se=he.transparent;v.setupLightsView(nt),ae===!0&&me.setGlobalState(w.clippingPlanes,nt),St.length>0&&ai(et,St,Ge,nt),rt&&ie.viewport(D.copy(rt)),et.length>0&&Ei(et,Ge,nt),St.length>0&&Ei(St,Ge,nt),se.length>0&&Ei(se,Ge,nt),ie.buffers.depth.setTest(!0),ie.buffers.depth.setMask(!0),ie.buffers.color.setMask(!0),ie.setPolygonOffset(!1)}function ai(he,Ge,nt,rt){if((nt.isScene===!0?nt.overrideMaterial:null)!==null)return;const St=H.isWebGL2;de===null&&(de=new nf(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")?K0:Qu,minFilter:q0,samples:St?4:0})),w.getDrawingBufferSize(ye),St?de.setSize(ye.x,ye.y):de.setSize(Iw(ye.x),Iw(ye.y));const se=w.getRenderTarget();w.setRenderTarget(de),w.getClearColor(q),R=w.getClearAlpha(),R<1&&w.setClearColor(16777215,.5),w.clear();const Ee=w.toneMapping;w.toneMapping=Zu,Ei(he,nt,rt),le.updateMultisampleRenderTarget(de),le.updateRenderTargetMipmap(de);let Le=!1;for(let Oe=0,Te=Ge.length;Oe<Te;Oe++){const ot=Ge[Oe],ft=ot.object,bt=ot.geometry,xt=ot.material,jt=ot.group;if(xt.side===uc&&ft.layers.test(rt.layers)){const Mt=xt.side;xt.side=Ks,xt.needsUpdate=!0,Fi(ft,nt,rt,bt,xt,jt),xt.side=Mt,xt.needsUpdate=!0,Le=!0}}Le===!0&&(le.updateMultisampleRenderTarget(de),le.updateRenderTargetMipmap(de)),w.setRenderTarget(se),w.setClearColor(q,R),w.toneMapping=Ee}function Ei(he,Ge,nt){const rt=Ge.isScene===!0?Ge.overrideMaterial:null;for(let et=0,St=he.length;et<St;et++){const se=he[et],Ee=se.object,Le=se.geometry,Oe=rt===null?se.material:rt,Te=se.group;Ee.layers.test(nt.layers)&&Fi(Ee,Ge,nt,Le,Oe,Te)}}function Fi(he,Ge,nt,rt,et,St){he.onBeforeRender(w,Ge,nt,rt,et,St),he.modelViewMatrix.multiplyMatrices(nt.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),et.onBeforeRender(w,Ge,nt,rt,he,St),et.transparent===!0&&et.side===uc&&et.forceSinglePass===!1?(et.side=Ks,et.needsUpdate=!0,w.renderBufferDirect(nt,Ge,rt,et,he,St),et.side=fd,et.needsUpdate=!0,w.renderBufferDirect(nt,Ge,rt,et,he,St),et.side=uc):w.renderBufferDirect(nt,Ge,rt,et,he,St),he.onAfterRender(w,Ge,nt,rt,et,St)}function ns(he,Ge,nt){Ge.isScene!==!0&&(Ge=ve);const rt=J.get(he),et=v.state.lights,St=v.state.shadowsArray,se=et.state.version,Ee=ne.getParameters(he,et.state,St,Ge,nt),Le=ne.getProgramCacheKey(Ee);let Oe=rt.programs;rt.environment=he.isMeshStandardMaterial?Ge.environment:null,rt.fog=Ge.fog,rt.envMap=(he.isMeshStandardMaterial?Ne:Pe).get(he.envMap||rt.environment),Oe===void 0&&(he.addEventListener("dispose",Ce),Oe=new Map,rt.programs=Oe);let Te=Oe.get(Le);if(Te!==void 0){if(rt.currentProgram===Te&&rt.lightsStateVersion===se)return br(he,Ee),Te}else Ee.uniforms=ne.getUniforms(he),he.onBuild(nt,Ee,w),he.onBeforeCompile(Ee,w),Te=ne.acquireProgram(Ee,Le),Oe.set(Le,Te),rt.uniforms=Ee.uniforms;const ot=rt.uniforms;return(!he.isShaderMaterial&&!he.isRawShaderMaterial||he.clipping===!0)&&(ot.clippingPlanes=me.uniform),br(he,Ee),rt.needsLights=Hc(he),rt.lightsStateVersion=se,rt.needsLights&&(ot.ambientLightColor.value=et.state.ambient,ot.lightProbe.value=et.state.probe,ot.directionalLights.value=et.state.directional,ot.directionalLightShadows.value=et.state.directionalShadow,ot.spotLights.value=et.state.spot,ot.spotLightShadows.value=et.state.spotShadow,ot.rectAreaLights.value=et.state.rectArea,ot.ltc_1.value=et.state.rectAreaLTC1,ot.ltc_2.value=et.state.rectAreaLTC2,ot.pointLights.value=et.state.point,ot.pointLightShadows.value=et.state.pointShadow,ot.hemisphereLights.value=et.state.hemi,ot.directionalShadowMap.value=et.state.directionalShadowMap,ot.directionalShadowMatrix.value=et.state.directionalShadowMatrix,ot.spotShadowMap.value=et.state.spotShadowMap,ot.spotLightMatrix.value=et.state.spotLightMatrix,ot.spotLightMap.value=et.state.spotLightMap,ot.pointShadowMap.value=et.state.pointShadowMap,ot.pointShadowMatrix.value=et.state.pointShadowMatrix),rt.currentProgram=Te,rt.uniformsList=null,Te}function Hr(he){if(he.uniformsList===null){const Ge=he.currentProgram.getUniforms();he.uniformsList=f1.seqWithValue(Ge.seq,he.uniforms)}return he.uniformsList}function br(he,Ge){const nt=J.get(he);nt.outputColorSpace=Ge.outputColorSpace,nt.batching=Ge.batching,nt.instancing=Ge.instancing,nt.instancingColor=Ge.instancingColor,nt.skinning=Ge.skinning,nt.morphTargets=Ge.morphTargets,nt.morphNormals=Ge.morphNormals,nt.morphColors=Ge.morphColors,nt.morphTargetsCount=Ge.morphTargetsCount,nt.numClippingPlanes=Ge.numClippingPlanes,nt.numIntersection=Ge.numClipIntersection,nt.vertexAlphas=Ge.vertexAlphas,nt.vertexTangents=Ge.vertexTangents,nt.toneMapping=Ge.toneMapping}function Or(he,Ge,nt,rt,et){Ge.isScene!==!0&&(Ge=ve),le.resetTextureUnits();const St=Ge.fog,se=rt.isMeshStandardMaterial?Ge.environment:null,Ee=N===null?w.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:jc,Le=(rt.isMeshStandardMaterial?Ne:Pe).get(rt.envMap||se),Oe=rt.vertexColors===!0&&!!nt.attributes.color&&nt.attributes.color.itemSize===4,Te=!!nt.attributes.tangent&&(!!rt.normalMap||rt.anisotropy>0),ot=!!nt.morphAttributes.position,ft=!!nt.morphAttributes.normal,bt=!!nt.morphAttributes.color;let xt=Zu;rt.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(xt=w.toneMapping);const jt=nt.morphAttributes.position||nt.morphAttributes.normal||nt.morphAttributes.color,Mt=jt!==void 0?jt.length:0,mt=J.get(rt),Kt=v.state.lights;if(ae===!0&&(fe===!0||he!==C)){const jr=he===C&&rt.id===I;me.setState(rt,he,jr)}let Ft=!1;rt.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Kt.state.version||mt.outputColorSpace!==Ee||et.isBatchedMesh&&mt.batching===!1||!et.isBatchedMesh&&mt.batching===!0||et.isInstancedMesh&&mt.instancing===!1||!et.isInstancedMesh&&mt.instancing===!0||et.isSkinnedMesh&&mt.skinning===!1||!et.isSkinnedMesh&&mt.skinning===!0||et.isInstancedMesh&&mt.instancingColor===!0&&et.instanceColor===null||et.isInstancedMesh&&mt.instancingColor===!1&&et.instanceColor!==null||mt.envMap!==Le||rt.fog===!0&&mt.fog!==St||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==me.numPlanes||mt.numIntersection!==me.numIntersection)||mt.vertexAlphas!==Oe||mt.vertexTangents!==Te||mt.morphTargets!==ot||mt.morphNormals!==ft||mt.morphColors!==bt||mt.toneMapping!==xt||H.isWebGL2===!0&&mt.morphTargetsCount!==Mt)&&(Ft=!0):(Ft=!0,mt.__version=rt.version);let nn=mt.currentProgram;Ft===!0&&(nn=ns(rt,Ge,et));let dn=!1,xn=!1,Ut=!1;const Zt=nn.getUniforms(),Jt=mt.uniforms;if(ie.useProgram(nn.program)&&(dn=!0,xn=!0,Ut=!0),rt.id!==I&&(I=rt.id,xn=!0),dn||C!==he){Zt.setValue(ue,"projectionMatrix",he.projectionMatrix),Zt.setValue(ue,"viewMatrix",he.matrixWorldInverse);const jr=Zt.map.cameraPosition;jr!==void 0&&jr.setValue(ue,re.setFromMatrixPosition(he.matrixWorld)),H.logarithmicDepthBuffer&&Zt.setValue(ue,"logDepthBufFC",2/(Math.log(he.far+1)/Math.LN2)),(rt.isMeshPhongMaterial||rt.isMeshToonMaterial||rt.isMeshLambertMaterial||rt.isMeshBasicMaterial||rt.isMeshStandardMaterial||rt.isShaderMaterial)&&Zt.setValue(ue,"isOrthographic",he.isOrthographicCamera===!0),C!==he&&(C=he,xn=!0,Ut=!0)}if(et.isSkinnedMesh){Zt.setOptional(ue,et,"bindMatrix"),Zt.setOptional(ue,et,"bindMatrixInverse");const jr=et.skeleton;jr&&(H.floatVertexTextures?(jr.boneTexture===null&&jr.computeBoneTexture(),Zt.setValue(ue,"boneTexture",jr.boneTexture,le)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}et.isBatchedMesh&&(Zt.setOptional(ue,et,"batchingTexture"),Zt.setValue(ue,"batchingTexture",et._matricesTexture,le));const Ar=nt.morphAttributes;if((Ar.position!==void 0||Ar.normal!==void 0||Ar.color!==void 0&&H.isWebGL2===!0)&&st.update(et,nt,nn),(xn||mt.receiveShadow!==et.receiveShadow)&&(mt.receiveShadow=et.receiveShadow,Zt.setValue(ue,"receiveShadow",et.receiveShadow)),rt.isMeshGouraudMaterial&&rt.envMap!==null&&(Jt.envMap.value=Le,Jt.flipEnvMap.value=Le.isCubeTexture&&Le.isRenderTargetTexture===!1?-1:1),xn&&(Zt.setValue(ue,"toneMappingExposure",w.toneMappingExposure),mt.needsLights&&fo(Jt,Ut),St&&rt.fog===!0&&be.refreshFogUniforms(Jt,St),be.refreshMaterialUniforms(Jt,rt,V,K,de),f1.upload(ue,Hr(mt),Jt,le)),rt.isShaderMaterial&&rt.uniformsNeedUpdate===!0&&(f1.upload(ue,Hr(mt),Jt,le),rt.uniformsNeedUpdate=!1),rt.isSpriteMaterial&&Zt.setValue(ue,"center",et.center),Zt.setValue(ue,"modelViewMatrix",et.modelViewMatrix),Zt.setValue(ue,"normalMatrix",et.normalMatrix),Zt.setValue(ue,"modelMatrix",et.matrixWorld),rt.isShaderMaterial||rt.isRawShaderMaterial){const jr=rt.uniformsGroups;for(let Pn=0,po=jr.length;Pn<po;Pn++)if(H.isWebGL2){const On=jr[Pn];Ze.update(On,nn),Ze.bind(On,nn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return nn}function fo(he,Ge){he.ambientLightColor.needsUpdate=Ge,he.lightProbe.needsUpdate=Ge,he.directionalLights.needsUpdate=Ge,he.directionalLightShadows.needsUpdate=Ge,he.pointLights.needsUpdate=Ge,he.pointLightShadows.needsUpdate=Ge,he.spotLights.needsUpdate=Ge,he.spotLightShadows.needsUpdate=Ge,he.rectAreaLights.needsUpdate=Ge,he.hemisphereLights.needsUpdate=Ge}function Hc(he){return he.isMeshLambertMaterial||he.isMeshToonMaterial||he.isMeshPhongMaterial||he.isMeshStandardMaterial||he.isShadowMaterial||he.isShaderMaterial&&he.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(he,Ge,nt){J.get(he.texture).__webglTexture=Ge,J.get(he.depthTexture).__webglTexture=nt;const rt=J.get(he);rt.__hasExternalTextures=!0,rt.__hasExternalTextures&&(rt.__autoAllocateDepthBuffer=nt===void 0,rt.__autoAllocateDepthBuffer||$.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),rt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(he,Ge){const nt=J.get(he);nt.__webglFramebuffer=Ge,nt.__useDefaultFramebuffer=Ge===void 0},this.setRenderTarget=function(he,Ge=0,nt=0){N=he,T=Ge,k=nt;let rt=!0,et=null,St=!1,se=!1;if(he){const Le=J.get(he);Le.__useDefaultFramebuffer!==void 0?(ie.bindFramebuffer(ue.FRAMEBUFFER,null),rt=!1):Le.__webglFramebuffer===void 0?le.setupRenderTarget(he):Le.__hasExternalTextures&&le.rebindTextures(he,J.get(he.texture).__webglTexture,J.get(he.depthTexture).__webglTexture);const Oe=he.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(se=!0);const Te=J.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(Array.isArray(Te[Ge])?et=Te[Ge][nt]:et=Te[Ge],St=!0):H.isWebGL2&&he.samples>0&&le.useMultisampledRTT(he)===!1?et=J.get(he).__webglMultisampledFramebuffer:Array.isArray(Te)?et=Te[nt]:et=Te,D.copy(he.viewport),F.copy(he.scissor),j=he.scissorTest}else D.copy(Z).multiplyScalar(V).floor(),F.copy(U).multiplyScalar(V).floor(),j=z;if(ie.bindFramebuffer(ue.FRAMEBUFFER,et)&&H.drawBuffers&&rt&&ie.drawBuffers(he,et),ie.viewport(D),ie.scissor(F),ie.setScissorTest(j),St){const Le=J.get(he.texture);ue.framebufferTexture2D(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,Le.__webglTexture,nt)}else if(se){const Le=J.get(he.texture),Oe=Ge||0;ue.framebufferTextureLayer(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,Le.__webglTexture,nt||0,Oe)}I=-1},this.readRenderTargetPixels=function(he,Ge,nt,rt,et,St,se){if(!(he&&he.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ee=J.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&se!==void 0&&(Ee=Ee[se]),Ee){ie.bindFramebuffer(ue.FRAMEBUFFER,Ee);try{const Le=he.texture,Oe=Le.format,Te=Le.type;if(Oe!==Ya&&Ye.convert(Oe)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ot=Te===K0&&($.has("EXT_color_buffer_half_float")||H.isWebGL2&&$.has("EXT_color_buffer_float"));if(Te!==Qu&&Ye.convert(Te)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Te===gc&&(H.isWebGL2||$.has("OES_texture_float")||$.has("WEBGL_color_buffer_float")))&&!ot){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ge>=0&&Ge<=he.width-rt&&nt>=0&&nt<=he.height-et&&ue.readPixels(Ge,nt,rt,et,Ye.convert(Oe),Ye.convert(Te),St)}finally{const Le=N!==null?J.get(N).__webglFramebuffer:null;ie.bindFramebuffer(ue.FRAMEBUFFER,Le)}}},this.copyFramebufferToTexture=function(he,Ge,nt=0){const rt=Math.pow(2,-nt),et=Math.floor(Ge.image.width*rt),St=Math.floor(Ge.image.height*rt);le.setTexture2D(Ge,0),ue.copyTexSubImage2D(ue.TEXTURE_2D,nt,0,0,he.x,he.y,et,St),ie.unbindTexture()},this.copyTextureToTexture=function(he,Ge,nt,rt=0){const et=Ge.image.width,St=Ge.image.height,se=Ye.convert(nt.format),Ee=Ye.convert(nt.type);le.setTexture2D(nt,0),ue.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,nt.flipY),ue.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,nt.premultiplyAlpha),ue.pixelStorei(ue.UNPACK_ALIGNMENT,nt.unpackAlignment),Ge.isDataTexture?ue.texSubImage2D(ue.TEXTURE_2D,rt,he.x,he.y,et,St,se,Ee,Ge.image.data):Ge.isCompressedTexture?ue.compressedTexSubImage2D(ue.TEXTURE_2D,rt,he.x,he.y,Ge.mipmaps[0].width,Ge.mipmaps[0].height,se,Ge.mipmaps[0].data):ue.texSubImage2D(ue.TEXTURE_2D,rt,he.x,he.y,se,Ee,Ge.image),rt===0&&nt.generateMipmaps&&ue.generateMipmap(ue.TEXTURE_2D),ie.unbindTexture()},this.copyTextureToTexture3D=function(he,Ge,nt,rt,et=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const St=he.max.x-he.min.x+1,se=he.max.y-he.min.y+1,Ee=he.max.z-he.min.z+1,Le=Ye.convert(rt.format),Oe=Ye.convert(rt.type);let Te;if(rt.isData3DTexture)le.setTexture3D(rt,0),Te=ue.TEXTURE_3D;else if(rt.isDataArrayTexture)le.setTexture2DArray(rt,0),Te=ue.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ue.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,rt.flipY),ue.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,rt.premultiplyAlpha),ue.pixelStorei(ue.UNPACK_ALIGNMENT,rt.unpackAlignment);const ot=ue.getParameter(ue.UNPACK_ROW_LENGTH),ft=ue.getParameter(ue.UNPACK_IMAGE_HEIGHT),bt=ue.getParameter(ue.UNPACK_SKIP_PIXELS),xt=ue.getParameter(ue.UNPACK_SKIP_ROWS),jt=ue.getParameter(ue.UNPACK_SKIP_IMAGES),Mt=nt.isCompressedTexture?nt.mipmaps[0]:nt.image;ue.pixelStorei(ue.UNPACK_ROW_LENGTH,Mt.width),ue.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,Mt.height),ue.pixelStorei(ue.UNPACK_SKIP_PIXELS,he.min.x),ue.pixelStorei(ue.UNPACK_SKIP_ROWS,he.min.y),ue.pixelStorei(ue.UNPACK_SKIP_IMAGES,he.min.z),nt.isDataTexture||nt.isData3DTexture?ue.texSubImage3D(Te,et,Ge.x,Ge.y,Ge.z,St,se,Ee,Le,Oe,Mt.data):nt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ue.compressedTexSubImage3D(Te,et,Ge.x,Ge.y,Ge.z,St,se,Ee,Le,Mt.data)):ue.texSubImage3D(Te,et,Ge.x,Ge.y,Ge.z,St,se,Ee,Le,Oe,Mt),ue.pixelStorei(ue.UNPACK_ROW_LENGTH,ot),ue.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,ft),ue.pixelStorei(ue.UNPACK_SKIP_PIXELS,bt),ue.pixelStorei(ue.UNPACK_SKIP_ROWS,xt),ue.pixelStorei(ue.UNPACK_SKIP_IMAGES,jt),et===0&&rt.generateMipmaps&&ue.generateMipmap(Te),ie.unbindTexture()},this.initTexture=function(he){he.isCubeTexture?le.setTextureCube(he,0):he.isData3DTexture?le.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?le.setTexture2DArray(he,0):le.setTexture2D(he,0),ie.unbindTexture()},this.resetState=function(){T=0,k=0,N=null,ie.reset(),$e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ol}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===hj?"display-p3":"srgb",n.unpackColorSpace=Kn.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===Zi?Ph:PZ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ph?Zi:jc}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 _5e extends jP{}_5e.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 w5e 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 S5e{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=Sc()}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=Sc()),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=Sc()),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=qn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=qn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=qn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=qn(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=rl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=rl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=rl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=rl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=qn(n,this.array),r=qn(r,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this}setXYZ(e,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(n=qn(n,this.array),r=qn(r,this.array),i=qn(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(n=qn(n,this.array),r=qn(r,this.array),i=qn(i,this.array),s=qn(s,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return new _a(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 E5e extends Xs{constructor(e=null,n=1,r=1,i,s,a,o,c,u=Yi,d=Yi,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 M5e(t,e){return t.z-e.z}function A5e(t,e){return e.z-t.z}class T5e{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,C5e=new sr,iV=new sr,_N=new VE,A_=new ro,Qd=new cl,Ax=new De,wN=new T5e,cs=new Ro,T_=[];function N5e(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 k5e extends Ro{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 E5e(n,e,e,Ya,gc);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 _a(o,1))}const a=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Dp,new _a(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 ro);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,A_).applyMatrix4(Su),n.union(A_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new cl);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++,C5e.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 ro,sphereInitialized:!1,sphere:new cl});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);N5e(x,y,c);const v=x.itemSize;for(let b=x.count,E=u;b<E;b++){const w=c+b;for(let A=0;A<v;A++)y.setComponent(w,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(Ax.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,A_),A_.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)),Ax.fromBufferAttribute(c,m),d=Math.max(d,s.center.distanceToSquared(Ax))}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;cs.material=this.material,cs.geometry.index=c.index,cs.geometry.attributes=c.attributes,cs.geometry.boundingBox===null&&(cs.geometry.boundingBox=new ro),cs.geometry.boundingSphere===null&&(cs.geometry.boundingSphere=new cl);for(let u=0;u<a;u++){if(!r[u]||!i[u])continue;const d=s[u];cs.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,cs.matrixWorld).premultiply(o),this.getBoundingBoxAt(u,cs.geometry.boundingBox),this.getBoundingSphereAt(u,cs.geometry.boundingSphere),cs.raycast(e,T_);for(let f=0,g=T_.length;f<g;f++){const m=T_[f];m.object=this,m.batchId=u,n.push(m)}T_.length=0}cs.material=null,cs.geometry.index=null,cs.geometry.attributes={},cs.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?X0:ol));let m=0;if(this.sortObjects){rV.copy(this.matrixWorld).invert(),Ax.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 w=Ax.distanceTo(Qd.center);wN.push(f[v],w)}}const x=wN.list,y=this.customSort;y===null?x.sort(s.transparent?A5e:M5e):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 Kb extends cg{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,C_=new cl;class P5e extends Ts{constructor(e=new xs,n=new Kb){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(),C_.copy(r.boundingSphere),C_.applyMatrix4(i),C_.radius+=s,e.ray.intersectsSphere(C_)===!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 w=b,A=E-1;w<A;w+=m){const T=x.getX(w),k=x.getX(w+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:w,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 w=b,A=E-1;w<A;w+=m){if(u.fromBufferAttribute(v,w),d.fromBufferAttribute(v,w+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:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}const lV=new De,cV=new De;class WE extends P5e{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 R5e 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 D5e extends cg{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 Yt(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 O5e extends Kb{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 j5e{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Yt(512,512),this.map=null,this.mapPass=null,this.matrix=new sr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new VE,this._frameExtents=new Yt(1,1),this._viewportCount=1,this._viewports=[new Yn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;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,Tx=new De,MN=new De;class L5e extends j5e{constructor(){super(new pa(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Yt(4,2),this._viewportCount=6,this._viewports=[new Yn(2,1,1,1),new Yn(0,1,1,1),new Yn(3,1,1,1),new Yn(1,1,1,1),new Yn(3,0,1,1),new Yn(1,0,1,1)],this._cubeDirections=[new De(1,0,0),new De(-1,0,0),new De(0,0,1),new De(0,0,-1),new De(0,1,0),new De(0,-1,0)],this._cubeUps=[new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,0,1),new De(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Tx.setFromMatrixPosition(e.matrixWorld),r.position.copy(Tx),MN.copy(r.position),MN.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(MN),r.updateMatrixWorld(),i.makeTranslation(-Tx.x,-Tx.y,-Tx.z),fV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(fV)}}class I5e 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 L5e}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 U5e extends eQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class F5e 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 S5e{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(Qi(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const mV=new De,N_=new De;class z5e{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),N_.subVectors(this.end,this.start);const r=N_.dot(N_);let s=N_.dot(mV)/r;return n&&(s=Qi(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 B5e 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 Kb({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 ul{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"),ul.nextNameID=ul.nextNameID||0,this.$name.id=`lil-gui-name-${++ul.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 H5e extends ul{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 $5e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:IP,toHexString:IP},Z0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},V5e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=Z0.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 Z0.toHexString(i)}},G5e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=Z0.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 Z0.toHexString(i)}},W5e=[$5e,Z0,V5e,G5e];function q5e(t){return W5e.find(e=>e.match(t))}class K5e extends ul{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=q5e(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 ul{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 X5e extends ul{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 w=parseFloat(this.$input.value);isNaN(w)||(this._snapClampSetValue(w+E),this.$input.value=this.getValue())},i=E=>{E.key==="Enter"&&this.$input.blur(),E.code==="ArrowUp"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E))),E.code==="ArrowDown"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E)*-1))},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 w=E.clientX-o,A=E.clientY-c;Math.abs(A)>g?(E.preventDefault(),this.$input.blur(),a=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>g&&y()}if(!a){const w=E.clientY-u;f-=w*this._step*this._arrowKeyMultiplier(E),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=E.clientY},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,w,A,T)=>(b-E)/(w-E)*(T-A)+A,n=b=>{const E=this.$slider.getBoundingClientRect();let w=e(b,E.left,E.right,this._min,this._max);this._snapClampSetValue(w)},r=b=>{this._setDraggingStyle(!0),n(b.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",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,w=b.touches[0].clientY-c;Math.abs(E)>Math.abs(w)?u(b):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else b.preventDefault(),n(b.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},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 w=this._normalizeMouseWheel(b)*this._step;this._snapClampSetValue(this.getValue()+w),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 Y5e extends ul{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 Z5e extends ul{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 Q5e=`.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 J5e(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&&(J5e(Q5e),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 Y5e(this,e,n,r);const a=e[n];switch(typeof a){case"number":return new X5e(this,e,n,r,i,s);case"boolean":return new H5e(this,e,n);case"string":return new Z5e(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 K5e(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"},k_=new pj,_V=new ku,eFe=Math.cos(70*OZ.DEG2RAD);class tFe 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",je),this._domElementKeyEvents=H},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",je),this._domElementKeyEvents=null},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(vV),r.update(),s=i.NONE},this.update=(function(){const H=new De,ie=new rf().setFromUnitVectors(e.up,new De(0,1,0)),G=ie.clone().invert(),J=new De,le=new rf,Pe=new De,Ne=2*Math.PI;return function(Se=null){const B=r.object.position;H.copy(B).sub(r.target),H.applyQuaternion(ie),o.setFromVector3(H),r.autoRotate&&s===i.NONE&&D((function(we){return we!==null?2*Math.PI/60*r.autoRotateSpeed*we:2*Math.PI/60/60*r.autoRotateSpeed})(Se)),r.enableDamping?(o.theta+=c.theta*r.dampingFactor,o.phi+=c.phi*r.dampingFactor):(o.theta+=c.theta,o.phi+=c.phi);let L=r.minAzimuthAngle,ne=r.maxAzimuthAngle;isFinite(L)&&isFinite(ne)&&(L<-Math.PI?L+=Ne:L>Math.PI&&(L-=Ne),ne<-Math.PI?ne+=Ne:ne>Math.PI&&(ne-=Ne),o.theta=L<=ne?Math.max(L,Math.min(ne,o.theta)):o.theta>(L+ne)/2?Math.max(L,o.theta):Math.min(ne,o.theta)),o.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,o.phi)),o.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&k||r.object.isOrthographicCamera?o.radius=te(o.radius):o.radius=te(o.radius*u),H.setFromSpherical(o),H.applyQuaternion(G),B.copy(r.target).add(H),r.object.lookAt(r.target),r.enableDamping===!0?(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 be=!1;if(r.zoomToCursor&&k){let we=null;if(r.object.isPerspectiveCamera){const ge=H.length();we=te(ge*u);const me=ge-we;r.object.position.addScaledVector(A,me),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ge=new De(T.x,T.y,0);ge.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0;const me=new De(T.x,T.y,0);me.unproject(r.object),r.object.position.sub(me).add(ge),r.object.updateMatrixWorld(),we=H.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;we!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(we).add(r.object.position):(k_.origin.copy(r.object.position),k_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(k_.direction))<eFe?e.lookAt(r.target):(_V.setFromNormalAndCoplanarPoint(r.object.up,r.target),k_.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(),be=!0);return u=1,k=!1,!!(be||J.distanceToSquared(r.object.position)>a||8*(1-le.dot(r.object.quaternion))>a||Pe.distanceToSquared(r.target)>0)&&(r.dispatchEvent(vV),J.copy(r.object.position),le.copy(r.object.quaternion),Pe.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ue),r.domElement.removeEventListener("pointerdown",xe),r.domElement.removeEventListener("pointercancel",re),r.domElement.removeEventListener("wheel",ve),r.domElement.removeEventListener("pointermove",ye),r.domElement.removeEventListener("pointerup",re),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",je),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const a=1e-6,o=new pV,c=new pV;let u=1;const d=new De,f=new Yt,g=new Yt,m=new Yt,x=new Yt,y=new Yt,v=new Yt,b=new Yt,E=new Yt,w=new Yt,A=new De,T=new Yt;let k=!1;const N=[],I={};function C(){return Math.pow(.95,r.zoomSpeed)}function D(H){c.theta-=H}function F(H){c.phi-=H}const j=(function(){const H=new De;return function(ie,G){H.setFromMatrixColumn(G,0),H.multiplyScalar(-ie),d.add(H)}})(),q=(function(){const H=new De;return function(ie,G){r.screenSpacePanning===!0?H.setFromMatrixColumn(G,1):(H.setFromMatrixColumn(G,0),H.crossVectors(r.object.up,H)),H.multiplyScalar(ie),d.add(H)}})(),R=(function(){const H=new De;return function(ie,G){const J=r.domElement;if(r.object.isPerspectiveCamera){const le=r.object.position;H.copy(le).sub(r.target);let Pe=H.length();Pe*=Math.tan(r.object.fov/2*Math.PI/180),j(2*ie*Pe/J.clientHeight,r.object.matrix),q(2*G*Pe/J.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(j(ie*(r.object.right-r.object.left)/r.object.zoom/J.clientWidth,r.object.matrix),q(G*(r.object.top-r.object.bottom)/r.object.zoom/J.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function W(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(H){if(!r.zoomToCursor)return;k=!0;const ie=r.domElement.getBoundingClientRect(),G=H.clientX-ie.left,J=H.clientY-ie.top,le=ie.width,Pe=ie.height;T.x=G/le*2-1,T.y=-J/Pe*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function te(H){return Math.max(r.minDistance,Math.min(r.maxDistance,H))}function Y(H){f.set(H.clientX,H.clientY)}function Z(H){x.set(H.clientX,H.clientY)}function U(){if(N.length===1)f.set(N[0].pageX,N[0].pageY);else{const H=.5*(N[0].pageX+N[1].pageX),ie=.5*(N[0].pageY+N[1].pageY);f.set(H,ie)}}function z(){if(N.length===1)x.set(N[0].pageX,N[0].pageY);else{const H=.5*(N[0].pageX+N[1].pageX),ie=.5*(N[0].pageY+N[1].pageY);x.set(H,ie)}}function ee(){const H=N[0].pageX-N[1].pageX,ie=N[0].pageY-N[1].pageY,G=Math.sqrt(H*H+ie*ie);b.set(0,G)}function ae(H){if(N.length==1)g.set(H.pageX,H.pageY);else{const G=$(H),J=.5*(H.pageX+G.x),le=.5*(H.pageY+G.y);g.set(J,le)}m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const ie=r.domElement;D(2*Math.PI*m.x/ie.clientHeight),F(2*Math.PI*m.y/ie.clientHeight),f.copy(g)}function fe(H){if(N.length===1)y.set(H.pageX,H.pageY);else{const ie=$(H),G=.5*(H.pageX+ie.x),J=.5*(H.pageY+ie.y);y.set(G,J)}v.subVectors(y,x).multiplyScalar(r.panSpeed),R(v.x,v.y),x.copy(y)}function de(H){const ie=$(H),G=H.pageX-ie.x,J=H.pageY-ie.y,le=Math.sqrt(G*G+J*J);E.set(0,le),w.set(0,Math.pow(E.y/b.y,r.zoomSpeed)),W(w.y),b.copy(E)}function xe(H){r.enabled!==!1&&(N.length===0&&(r.domElement.setPointerCapture(H.pointerId),r.domElement.addEventListener("pointermove",ye),r.domElement.addEventListener("pointerup",re)),(function(ie){N.push(ie)})(H),H.pointerType==="touch"?(function(ie){switch(ut(ie),N.length){case 1:switch(r.touches.ONE){case 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&&ee(),r.enablePan&&z(),s=i.TOUCH_DOLLY_PAN;break;case gp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ee(),r.enableRotate&&U(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(CN)})(H):(function(ie){let G;switch(ie.button){case 0:G=r.mouseButtons.LEFT;break;case 1:G=r.mouseButtons.MIDDLE;break;case 2:G=r.mouseButtons.RIGHT;break;default:G=-1}switch(G){case mp.DOLLY:if(r.enableZoom===!1)return;(function(J){V(J),b.set(J.clientX,J.clientY)})(ie),s=i.DOLLY;break;case mp.ROTATE:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enablePan===!1)return;Z(ie),s=i.PAN}else{if(r.enableRotate===!1)return;Y(ie),s=i.ROTATE}break;case mp.PAN:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enableRotate===!1)return;Y(ie),s=i.ROTATE}else{if(r.enablePan===!1)return;Z(ie),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(CN)})(H))}function ye(H){r.enabled!==!1&&(H.pointerType==="touch"?(function(ie){switch(ut(ie),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ae(ie),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;fe(ie),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(G){r.enableZoom&&de(G),r.enablePan&&fe(G)})(ie),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(G){r.enableZoom&&de(G),r.enableRotate&&ae(G)})(ie),r.update();break;default:s=i.NONE}})(H):(function(ie){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(G){g.set(G.clientX,G.clientY),m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const J=r.domElement;D(2*Math.PI*m.x/J.clientHeight),F(2*Math.PI*m.y/J.clientHeight),f.copy(g),r.update()})(ie);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(G){E.set(G.clientX,G.clientY),w.subVectors(E,b),w.y>0?W(C()):w.y<0&&K(C()),b.copy(E),r.update()})(ie);break;case i.PAN:if(r.enablePan===!1)return;(function(G){y.set(G.clientX,G.clientY),v.subVectors(y,x).multiplyScalar(r.panSpeed),R(v.x,v.y),x.copy(y),r.update()})(ie)}})(H))}function re(H){(function(ie){delete I[ie.pointerId];for(let G=0;G<N.length;G++)if(N[G].pointerId==ie.pointerId)return void N.splice(G,1)})(H),N.length===0&&(r.domElement.releasePointerCapture(H.pointerId),r.domElement.removeEventListener("pointermove",ye),r.domElement.removeEventListener("pointerup",re)),r.dispatchEvent(yV),s=i.NONE}function ve(H){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(H.preventDefault(),r.dispatchEvent(CN),(function(ie){V(ie),ie.deltaY<0?K(C()):ie.deltaY>0&&W(C()),r.update()})(H),r.dispatchEvent(yV))}function je(H){r.enabled!==!1&&r.enablePan!==!1&&(function(ie){let G=!1;switch(ie.code){case r.keys.UP:ie.ctrlKey||ie.metaKey||ie.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,r.keyPanSpeed),G=!0;break;case r.keys.BOTTOM:ie.ctrlKey||ie.metaKey||ie.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,-r.keyPanSpeed),G=!0;break;case r.keys.LEFT:ie.ctrlKey||ie.metaKey||ie.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(r.keyPanSpeed,0),G=!0;break;case r.keys.RIGHT:ie.ctrlKey||ie.metaKey||ie.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(-r.keyPanSpeed,0),G=!0}G&&(ie.preventDefault(),r.update())})(H)}function ue(H){r.enabled!==!1&&H.preventDefault()}function ut(H){let ie=I[H.pointerId];ie===void 0&&(ie=new Yt,I[H.pointerId]=ie),ie.set(H.pageX,H.pageY)}function $(H){const ie=H.pointerId===N[0].pointerId?N[1]:N[0];return I[ie.pointerId]}r.domElement.addEventListener("contextmenu",ue),r.domElement.addEventListener("pointerdown",xe),r.domElement.addEventListener("pointercancel",re),r.domElement.addEventListener("wheel",ve,{passive:!1}),this.update()}}yt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Yt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Vs.line={uniforms:mj.merge([yt.common,yt.fog,yt.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(Vs.line.uniforms),vertexShader:Vs.line.vertexShader,fragmentShader:Vs.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 ro,P_=new De;class nQ extends F5e{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 R5e(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ro);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 cl),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++)P_.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(P_)),P_.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(P_));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,Gi=new Yn,Wi=new Yn,Ko=new Yn,NN=new De,kN=new sr,qi=new z5e,MV=new De,R_=new ro,D_=new cl,Xo=new Yn;let Yo,uh;function AV(t,e,n){return Xo.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Xo.multiplyScalar(1/Xo.w),Xo.x=uh/n.width,Xo.y=uh/n.height,Xo.applyMatrix4(t.projectionMatrixInverse),Xo.multiplyScalar(1/Xo.w),Math.abs(Math.max(Xo.x,Xo.y))}class nFe extends Ro{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;Yo=e.ray;const a=this.matrixWorld,o=this.geometry,c=this.material;let u,d;uh=c.linewidth+s,o.boundingSphere===null&&o.computeBoundingSphere(),D_.copy(o.boundingSphere).applyMatrix4(a),r?u=.5*uh:u=AV(i,Math.max(i.near,D_.distanceToPoint(Yo.origin)),c.resolution),D_.radius+=u,Yo.intersectsSphere(D_)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),R_.copy(o.boundingBox).applyMatrix4(a),r?d=.5*uh:d=AV(i,Math.max(i.near,R_.distanceToPoint(Yo.origin)),c.resolution),R_.expandByScalar(d),Yo.intersectsBox(R_)!==!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++){qi.start.fromBufferAttribute(y,b),qi.end.fromBufferAttribute(v,b),qi.applyMatrix4(m);const w=new De,A=new De;Yo.distanceSqToSegment(qi.start,qi.end,A,w),A.distanceTo(w)<.5*uh&&g.push({point:A,pointOnLine:w,distance:Yo.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,w=b.attributes.instanceEnd,A=Math.min(b.instanceCount,E.count),T=-g.near;Yo.at(1,Ko),Ko.w=1,Ko.applyMatrix4(g.matrixWorldInverse),Ko.applyMatrix4(x),Ko.multiplyScalar(1/Ko.w),Ko.x*=y.x/2,Ko.y*=y.y/2,Ko.z=0,NN.copy(Ko),kN.multiplyMatrices(g.matrixWorldInverse,v);for(let k=0,N=A;k<N;k++){if(Gi.fromBufferAttribute(E,k),Wi.fromBufferAttribute(w,k),Gi.w=1,Wi.w=1,Gi.applyMatrix4(kN),Wi.applyMatrix4(kN),Gi.z>T&&Wi.z>T)continue;if(Gi.z>T){const j=Gi.z-Wi.z,q=(Gi.z-T)/j;Gi.lerp(Wi,q)}else if(Wi.z>T){const j=Wi.z-Gi.z,q=(Wi.z-T)/j;Wi.lerp(Gi,q)}Gi.applyMatrix4(x),Wi.applyMatrix4(x),Gi.multiplyScalar(1/Gi.w),Wi.multiplyScalar(1/Wi.w),Gi.x*=y.x/2,Gi.y*=y.y/2,Wi.x*=y.x/2,Wi.y*=y.y/2,qi.start.copy(Gi),qi.start.z=0,qi.end.copy(Wi),qi.end.z=0;const I=qi.closestPointToPointParameter(NN,!0);qi.at(I,MV);const C=OZ.lerp(Gi.z,Wi.z,I),D=C>=-1&&C<=1,F=NN.distanceTo(MV)<.5*uh;if(D&&F){qi.start.fromBufferAttribute(E,k),qi.end.fromBufferAttribute(w,k),qi.start.applyMatrix4(v),qi.end.applyMatrix4(v);const j=new De,q=new De;Yo.distanceSqToSegment(qi.start,qi.end,q,j),m.push({point:q,pointOnLine:j,distance:Yo.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class rFe 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 Kb({vertexColors:!0,toneMapped:!1}))}}function iFe(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 O5e({color:new $t(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var Yx=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 Yx.Panel("FPS","#0ff","#002")),c=n(new Yx.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Yx.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}};Yx.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 sFe=Yx;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 aFe 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 Yt,c=[],u=[],d=[],f=[];function g(m){const[x,y,v]=(function(b){const E=e[b],w=new De,A=new De,T=new De,k=new De;w.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(w.x),C=Math.abs(w.y),D=Math.abs(w.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(w,A).normalize(),A.crossVectors(w,k),T.crossVectors(w,A),[E,A,T]})(m);for(let b=0;b<=i;b++){const E=b/i*Math.PI*2,w=Math.sin(E),A=-Math.cos(E);a.x=A*y.x+w*v.x,a.y=A*y.y+w*v.y,a.z=A*y.z+w*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 Zx{static get initial(){const e=new Zx;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=Zx.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 w5e,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 sFe: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 pa(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 tFe(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 B5e(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 U5e(13421772,.3*Math.PI),n=new I5e(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 Ux;return n.name=e,n.quaternion.setFromEuler(new Wb(-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=Zx.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 rFe(this.buildVolume.x,10,this.buildVolume.y,10));const e=iFe(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=Zx.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 te=Math.pow(W,2)+Math.pow(K,2),Y=Math.pow(m,2)-te/4;let Z=Math.sqrt(Y/te);(s&&m<0||!s&&m>0)&&(Z=-Z),x=W/2+K*Z,y=K/2-W*Z}const v=o==d&&c==f,b=o+x,E=c+y,w=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=w*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+w*Math.cos(R),j=E+w*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 Kb({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 aFe(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 nFe(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 D5e({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((o,c)=>3*c.attributes.position.count+o),0),a=new k5e(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 oFe=function(t){return new lm(t)};function lFe({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=oFe({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 w=()=>{if(b.parentElement){const A=b.parentElement.getBoundingClientRect();b.width=A.width,b.height=A.height,E.resize()}};return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w),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 cFe({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(Ie,{variant:"secondary",size:"sm",onClick:u,children:[l.jsx(ao,{className:"w-4 h-4"}),"Open in Slicer"]}),l.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,children:l.jsx(Gt,{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(iOe,{url:ke.getArchiveDownload(t),buildVolume:s.build_volume,className:"w-full h-full"}):r==="gcode"&&s?l.jsx(lFe,{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 uFe({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}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),c=_t({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(kt,{className:"w-full max-w-md",children:l.jsxs(Dt,{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(Ie,{variant:"ghost",size:"sm",onClick:n,children:l.jsx(Gt,{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(Ea,{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(Ie,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Ie,{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(Ea,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function dFe({onClose:t,initialFiles:e}){const n=En(),{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}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),x=_t({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="")},[]),w=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(kt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:l.jsxs(Dt,{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(Gt,{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(ba,{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(Ie,{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:()=>w(I),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:l.jsx(Gt,{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(ps,{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(Io,{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(Ie,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&l.jsx(Ie,{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(ba,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const hFe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"];function fFe({archive:t,onClose:e,existingTags:n=[]}){M.useEffect(()=>{const U=z=>{z.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const r=En(),[i,s]=M.useState(t.print_name||""),[a,o]=M.useState(t.printer_id),[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,w]=M.useState(!1),[A,T]=M.useState(!1),k=M.useRef(null),N=M.useRef(null),I=M.useRef(null),{data:C}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:D}=vt({queryKey:["projects"],queryFn:()=>ke.getProjects()}),{data:F}=vt({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(ee=>ee!==U).join(", ");m(z)},V=_t({mutationFn:U=>ke.updateArchive(t.id,U),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),te=async U=>{const z=U.target.files?.[0];if(z){w(!0);try{const ee=await ke.uploadArchivePhoto(t.id,z);b(ee.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ee){console.error("Failed to upload photo:",ee)}finally{w(!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)}},Z=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"&&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(Gt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:Z,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(E0,{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(Gt,{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"&&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..."}),hFe.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(x0,{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(kn,{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:te,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(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Ie,{type:"submit",disabled:V.isPending,className:"flex-1",children:[l.jsx(ko,{className:"w-4 h-4"}),V.isPending?"Saving...":"Save"]})]})]})]})})}function pFe({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,w=e;t+x.width>y-b&&(E=Math.max(b,y-x.width-b)),E<b&&(E=b),e+x.height>v-b&&(w=Math.max(b,v-x.height-b)),w<b&&(w=b);const A=180,T=y-E-x.width,k=E;f(T<A&&k>A),u({x:E,y:w,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 mFe({selectedIds:t,existingTags:e,onClose:n}){const r=En(),{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=_t({mutationFn:async()=>{const y=Array.from(o);let v=0;for(const b of t)try{const E=await ke.getArchive(b),w=E.tags?E.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...w,...y])]:A=w.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(kt,{className:"w-full max-w-md",children:l.jsxs(Dt,{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(E0,{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(Gt,{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(Ie,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),l.jsx(Ie,{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(Ie,{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(Gt,{className:"w-3 h-3"})})]},y))})]})]}),l.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Ie,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Ie,{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(E0,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function gFe(t,e){return new Date(t,e+1,0).getDate()}function xFe(t,e){return new Date(t,e,1).getDay()}const bFe=["January","February","March","April","May","June","July","August","September","October","November","December"],vFe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function yFe({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 w=new Date(E.completed_at||E.created_at),A=`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}-${String(w.getDate()).padStart(2,"0")}`,T=b.get(A)||[];T.push(E),b.set(A,T)}),b},[t]),d=gFe(s,r),f=xFe(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:[bFe[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:vFe.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 w=`${s}-${String(r+1).padStart(2,"0")}-${String(b).padStart(2,"0")}`,A=u.get(w)||[],T=A.length>0,k=b===n.getDate()&&r===n.getMonth()&&s===n.getFullYear(),N=w===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:w),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,w)=>l.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},w))})]})]})]},b.id))}):l.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):l.jsx("div",{className:"text-center py-8",children:l.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function _Fe({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(Gt,{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(Ie,{onClick:i,className:"w-full",children:[l.jsx(Sa,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function wFe({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(Ie,{variant:"secondary",size:"sm",onClick:f,children:[l.jsx(Sa,{className:"w-4 h-4"}),"Download"]}),i&&l.jsx(Ie,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:l.jsx(kn,{className:"w-4 h-4"})}),l.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:l.jsx(Gt,{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 Xi(t){this.content=t}Xi.prototype={constructor:Xi,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 Xi(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 Xi(n)},addToStart:function(t,e){return new Xi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Xi(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 Xi(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=Xi.from(t),t.size?new Xi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Xi.from(t),t.size?new Xi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Xi.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}};Xi.from=function(t){if(t instanceof Xi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Xi(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 O_(0,e);if(e==this.size)return O_(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?O_(n+1,s):O_(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 O_(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 Ct{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=aQ(this.content,e+this.openStart,n);return r&&new Ct(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ct(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 Ct.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ct(pt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Ct(e,r,i)}}Ct.empty=new Ct(pt.empty,0,0);function 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 SFe(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}=EFe(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 Qx(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 Qx(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),Qx(e,n,i,o),a&&Rh(Dh(a,$w(n,r,i+1)),o)),Qx(r,null,i,o),new pt(o)}function $w(t,e,n){let r=[];if(Qx(null,t,n,r),t.depth>n){let i=FP(t,e,n+1);Rh(Dh(i,$w(t,e,n+1)),r)}return Qx(e,null,n,r),new pt(r)}function EFe(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 Q0{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 Q0(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 MFe);let i=r.elts[r.i]=Q0.resolve(e,n);return r.i=(r.i+1)%AFe,i}}class MFe{constructor(){this.elts=[],this.i=0}}const AFe=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 TFe=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||TFe)&&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 Ct.empty;let i=this.resolve(e),s=this.resolve(n),a=r?0:i.sharedDepth(n),o=i.start(a),u=i.node(a).content.cut(i.pos-o,s.pos-o);return new Ct(u,i.depth-a,s.depth-a)}replace(e,n,r){return SFe(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 Q0.resolveCached(this,e)}resolveNoCache(e){return Q0.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 CFe(e,n);if(r.next==null)return sf.empty;let i=dQ(r);r.next&&r.err("Unexpected trailing text");let s=jFe(OFe(i));return LFe(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 CFe{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(NFe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function NFe(t){let e=[];do e.push(kFe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function kFe(t){let e=DFe(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=PFe(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 PFe(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 RFe(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 DFe(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=RFe(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 OFe(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 jFe(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 LFe(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 UFe(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 IFe(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 UFe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?IFe(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=Xi.from(e.nodes),n.marks=Xi.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 FFe(t){return t.tag!=null}function zFe(t){return t.style!=null}let Jx=class BP{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(FFe(i))this.tags.push(i);else if(zFe(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),Ct.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if($Fe(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},BFe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},yQ={ol:!0,ul:!0},J0=1,HP=2,e0=4;function DV(t,e,n){return e!=null?(e?J0:0)|(e==="full"?HP:0):t&&t.whitespace=="pre"?J0|HP:n&~e0}class j_{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&e0?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&J0)){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?e0:0);i?s=new j_(i.type,i.attrs,tr.none,!0,n.topMatch||i.type.contentMatch,a):r?s=new j_(null,null,tr.none,!0,null,a):s=new j_(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&J0)>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&&HFe(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(c?c.ignore:BFe.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&e0&&a.content.length==0&&(o|=e0);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 j_(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|=J0)}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 HFe(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 $Fe(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}=p1(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&&p1(DN(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return p1(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 VFe(t){let e=UV.get(t);return e===void 0&&UV.set(t,e=GFe(t)),e}function GFe(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 p1(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=VFe(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}=p1(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 WFe(t,e){return t+e*wQ}function FV(t){return t&_Q}function qFe(t){return(t-(t&_Q))/wQ}const SQ=1,EQ=2,m1=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|m1))>0}get deletedAfter(){return(this.delInfo&(EQ|m1))>0}get deletedAcross(){return(this.delInfo&m1)>0}}class ga{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ga.empty)return ga.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+qFe(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:WFe(o/3,e-c),y=e==c?EQ:e==f?SQ:m1;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 ga(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ga.empty:new ga(e<0?[0,-e,0]:[0,0,e])}}ga.empty=new ga([]);class eb{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 eb(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 eb;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 ga.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 Ct(_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 Do(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 Do 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 Ct(_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 Do(n.pos,r.pos,this.mark)}merge(e){return e instanceof Do&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Do(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 Do(n.from,n.to,e.markFromJSON(n.mark))}}bs.jsonID("removeMark",Do);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 Ct(pt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new 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 Ct(pt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new 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 Oi 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 ga([this.from,this.to-this.from,this.slice.size])}invert(e){return new Oi(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Oi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Oi)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Ct.empty:new Ct(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Oi(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Ct.empty:new Ct(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Oi(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Oi(n.from,n.to,Ct.fromJSON(e,n.slice),!!n.structure)}}bs.jsonID("replace",Oi);class Li 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 ga([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 Li(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 Li(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 Li(n.from,n.to,n.gapFrom,n.gapTo,Ct.fromJSON(e,n.slice),n.insert,!!n.structure)}}bs.jsonID("replaceAround",Li);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 KFe(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 Do(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 XFe(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 Do(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 Oi(o,d,Ct.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new Do(o,d,u.marks[g]));if(i&&u.isText&&n.whitespace!="pre"){let g,m=/\r?\n|\r/g,x;for(;g=m.exec(u.text);)x||(x=new Ct(pt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),a.push(new Oi(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 Ct(c,0,0))}for(let c=a.length-1;c>=0;c--)t.step(a[c])}function YFe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function dg(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||!YFe(a,o,c))break;o&&(i=1),c<a.childCount&&(s=1)}return null}function ZFe(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 Li(c,u,a,o,new Ct(d.append(g),f,m),d.size-f,!0))}function Sj(t,e,n=null,r=t){let i=QFe(t,e),s=i&&JFe(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 QFe(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 JFe(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 eze(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 Li(i,s,i,s,new Ct(r,0,0),n.length,!0))}function tze(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)&&nze(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 Li(f,g,f+1,g-1,new Ct(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 nze(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function rze(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 Li(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Ct(pt.from(a),0,0),1,!0))}function Ec(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 ize(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 Oi(e,e,new Ct(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 sze(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let 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&&sze(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 aze(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 Oi(u,c.map(e+n,-1),Ct.empty,!0)),r===!0){let d=t.doc.resolve(u);AQ(t,d.node(),d.before(),t.steps.length)}return t}function oze(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=Ct.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return kQ(i,s,r)?new Oi(e,n,r):new lze(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 lze{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 Ct(s,a,o);return e>-1?new Li(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Oi(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let 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 Ct(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=jN(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Ct(Fx(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Ct(Fx(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=zx(this.placed,n,pt.from(d)),this.frontier[n].match=f,x&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,v=o;y<m;y++){let b=v.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),v=b.content}this.unplaced=x?e==0?Ct.empty:new Ct(Fx(a.content,e-1,1),e-1,m<0?a.openEnd:e-1):new Ct(Fx(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=zx(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=zx(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=zx(this.placed,this.frontier.length,n))}}function Fx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Fx(t.firstChild.content,e-1,n)))}function zx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(zx(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&&!cze(n,s.content,a)?o:null}function cze(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function uze(t){return t.spec.defining||t.spec.definingForContent}function dze(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 Oi(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=uze(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),w=i.index(v-1);if(E.canReplaceWith(w,w,x.type,x.marks))return t.replace(i.before(v),b?s.after(v):n,new Ct(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 hze(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=oze(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ct(pt.from(r),0,0))}function fze(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 Ct(pt.from(i),0,n.isLeaf?0:1))}getMap(){return ga.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 tb 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 ga.empty}invert(e){return new tb(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 tb(n.attr,n.value)}}bs.jsonID("docAttr",tb);let jm=class extends Error{};jm=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};jm.prototype=Object.create(Error.prototype);jm.prototype.constructor=jm;jm.prototype.name="TransformError";class OQ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new eb}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new jm(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Ct.empty){let i=XE(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ct(pt.from(r),0,0))}delete(e,n){return this.replace(e,n,Ct.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return dze(this,e,n,r),this}replaceRangeWith(e,n,r){return hze(this,e,n,r),this}deleteRange(e,n){return fze(this,e,n),this}lift(e,n){return ZFe(this,e,n),this}join(e,n=1){return aze(this,e,n),this}wrap(e,n){return eze(this,e,n),this}setBlockType(e,n=e,r,i=null){return tze(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return rze(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 tb(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 ize(this,e,n,r),this}addMark(e,n,r){return KFe(this,e,n,r),this}removeMark(e,n,r){return XFe(this,e,n,r),this}clearIncompatible(e,n,r){return wj(this,e,n,r),this}}const IN=Object.create(null);class ln{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new pze(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=Ct.empty){let r=n.content.lastChild,i=null;for(let o=0;o<n.openEnd;o++)i=r,r=r.lastChild;let s=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:c,$to:u}=a[o],d=e.mapping.slice(s);e.replaceRange(d.map(c.pos),d.map(u.pos),o?Ct.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 qt(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 wa(e.node(0))}static atStart(e){return zp(e,e,0,0,1)||new wa(e)}static atEnd(e){return zp(e,e,e.content.size,e.childCount,-1)||new wa(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 qt.between(this.$anchor,this.$head).getBookmark()}}ln.prototype.visible=!0;class pze{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 qt extends ln{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 ln.near(r);let i=e.resolve(n.map(this.anchor));return new qt(i.parent.inlineContent?i:r,r)}replace(e,n=Ct.empty){if(super.replace(e,n),n==Ct.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof qt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new 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 qt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=ln.findFrom(n,r,!0)||ln.findFrom(n,-r,!0);if(s)n=s.$head;else return ln.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(ln.findFrom(e,-r,!0)||ln.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new qt(e,n)}}ln.jsonID("text",qt);class 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 qt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ht extends ln{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?ln.near(s):new Ht(s)}content(){return new Ct(pt.from(this.node),0,0)}eq(e){return e instanceof Ht&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new 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;ln.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):ln.near(n)}}class wa extends ln{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ct.empty){if(n==Ct.empty){e.delete(0,e.doc.content.size);let r=ln.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new wa(e)}map(e){return new wa(e)}eq(e){return e instanceof wa}getBookmark(){return mze}}ln.jsonID("all",wa);const mze={map(){return this},resolve(t){return new wa(t)}};function zp(t,e,n,r,i,s=!1){if(e.inlineContent)return qt.create(t,n);for(let a=r-(i>0?0:1);i>0?a<e.childCount:a>=0;a+=i){let o=e.child(a);if(o.isAtom){if(!s&&Ht.isSelectable(o))return Ht.create(t,n-(i<0?o.nodeSize:0))}else{let 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 Oi||i instanceof Li))return;let s=t.mapping.maps[r],a;s.forEach((o,c,u,d)=>{a==null&&(a=d)}),t.setSelection(ln.near(t.doc.resolve(a),n))}const VV=1,L_=2,GV=4;class gze 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)&~L_,this.storedMarks=null,this}get selectionSet(){return(this.updated&VV)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=L_,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&L_)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~L_,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||tr.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let a=this.doc.resolve(n);s=r==n?a.marks():a.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ln.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=GV,this}get scrolledIntoView(){return(this.updated&GV)>0}}function WV(t,e){return!e||!t?t:t.bind(e)}class Bx{constructor(e,n,r){this.name=e,this.init=WV(n.init,r),this.apply=WV(n.apply,r)}}const xze=[new Bx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Bx("selection",{init(t,e){return t.selection||ln.atStart(e.doc)},apply(t){return t.selection}}),new Bx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Bx("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=xze.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 Bx(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 gze(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=ln.fromJSON(s.doc,n.selection);else if(a.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let o in r){let 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 wi{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&&dg(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&&(Lm(s,"end")||Ht.isSelectable(s)))for(let a=r.depth;;a--){let o=XE(t.doc,r.before(a),r.after(a),Ct.empty);if(o&&o.slice.size<o.to-o.from){if(e){let c=t.tr.step(o);c.setSelection(Lm(s,"end")?ln.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},bze=(t,e,n)=>{let r=IQ(t,n);if(!r)return!1;let i=Aj(r);return i?FQ(t,i,e):!1},vze=(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,Ct.empty);if(!u||u.from!=s||u instanceof Oi&&u.slice.size>=c-s)return!1;if(n){let d=t.tr.step(u);d.setSelection(qt.create(d.doc,s)),n(d.scrollIntoView())}return!0}function Lm(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const 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&&(Lm(s,"start")||Ht.isSelectable(s))){let a=XE(t.doc,r.before(),r.after(),Ct.empty);if(a&&a.slice.size<a.to-a.from){if(e){let o=t.tr.step(a);o.setSelection(Lm(s,"start")?ln.findFrom(o.doc.resolve(o.mapping.map(i.pos)),1):Ht.create(o.doc,o.mapping.map(i.pos))),e(o.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},$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 yze=(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},_ze=(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},wze=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&dg(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 Sze=(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(ln.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 wa||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(qt.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(Ec(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&dg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Eze(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ht&&e.selection.node.isBlock)return!r.parentOffset||!Ec(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 qt||e.selection instanceof wa)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=Ec(d.doc,f,s.length,s);if(g||(s[0]=o?{type:o}:null,g=Ec(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 Mze=Eze(),Aze=(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 Tze(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&&Tze(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 Li(e.pos-1,m,e.pos,m,new Ct(x,1,0),a.length,!0)),v=y.doc.resolve(m+2*a.length);v.nodeAfter&&v.nodeAfter.type==i.type&&Sd(y.doc,v.pos)&&y.join(v.pos),n(y.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&c?null:ln.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),g=f&&dg(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&Lm(s,"start",!0)&&Lm(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 w=x.length-1;w>=0;w--)b=pt.from(x[w].copy(b));let E=t.tr.step(new Li(e.pos-x.length,e.pos+s.nodeSize,e.pos+v,e.pos+s.nodeSize-v,new Ct(b,x.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function 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(qt.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const Cze=KQ(-1),Nze=KQ(1);function kze(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,Mze);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Pze(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 Rze(o,a,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function Rze(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&&Dze(t,e,o,i,n),!0):!1}function Dze(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 Li(e.start-(r?2:0),e.end,e.start,e.end,new Ct(s,0,0),n.length,!0));let a=0;for(let d=0;d<n.length;d++)n[d].type==i&&(a=d+1);let o=n.length-a,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&&Ec(t.doc,c,o)&&(t.split(c,o),c+=2*o),c+=u.child(d).nodeSize;return t}function Oze(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?jze(e,n,t,s):Lze(e,n,s):!0:!1}}function jze(t,e,n,r){let i=t.tr,s=r.end,a=r.$to.end(r.depth);s<a&&(i.step(new Li(s-1,a,s,a,new Ct(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=dg(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 Lze(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 Li(f-(o?1:0),g+(c?1:0),f+1,g-1,new Ct((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 Ize(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 Ct(pt.from(t.create(null,pt.from(o.type.create(null,d)))),u?3:1,0),g=s.start,m=s.end;n(e.tr.step(new Li(g-(u?3:1),m,g,m,f,1,!0)).scrollIntoView())}return!0}}const Ji=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Im=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let GP=null;const ac=function(t,e,n){let r=GP||(GP=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Uze=function(){GP=null},of=function(t,e,n,r){return n&&(KV(t,e,n,r,-1)||KV(t,e,n,r,1))},Fze=/^(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:Qa(t))){let a=t.parentNode;if(!a||a.nodeType!=1||Xb(t)||Fze.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ji(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?Qa(t):0}else return!1}}function Qa(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function zze(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=Qa(t)}else if(t.parentNode&&!Xb(t))e=Ji(t),t=t.parentNode;else return null}}function Bze(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&&!Xb(t))e=Ji(t)+1,t=t.parentNode;else return null}}function Hze(t,e,n){for(let r=e==0,i=e==Qa(t);r||i;){if(t==n)return!0;let s=Ji(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==Qa(t)}}function Xb(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 $ze(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Vze(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Qa(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Qa(r.startContainer),r.startOffset)}}}const xl=typeof navigator<"u"?navigator:null,XV=typeof document<"u"?document:null,Ed=xl&&xl.userAgent||"",WP=/Edge\/(\d+)/.exec(Ed),XQ=/MSIE \d/.exec(Ed),qP=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ed),Ys=!!(XQ||qP||WP),ed=XQ?document.documentMode:qP?+qP[1]:WP?+WP[1]:0,io=!Ys&&/gecko\/(\d+)/i.test(Ed);io&&+(/Firefox\/(\d+)/.exec(Ed)||[0,0])[1];const KP=!Ys&&/Chrome\/(\d+)/.exec(Ed),fs=!!KP,YQ=KP?+KP[1]:0,Ps=!Ys&&!!xl&&/Apple Computer/.test(xl.vendor),Um=Ps&&(/Mobile\/\w+/.test(Ed)||!!xl&&xl.maxTouchPoints>2),Wa=Um||(xl?/Mac/.test(xl.platform):!1),Gze=xl?/Win/.test(xl.platform):!1,xc=/Android \d/.test(Ed),Yb=!!XV&&"webkitFontSmoothing"in XV.documentElement.style,Wze=Yb?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function qze(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 ec(t,e){return typeof t=="number"?t:t[e]}function Kze(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=Im(a);continue}let o=a,c=o==s.body,u=c?qze(s):Kze(o),d=0,f=0;if(e.top<u.top+ec(r,"top")?f=-(u.top-e.top+ec(i,"top")):e.bottom>u.bottom-ec(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+ec(i,"top")-u.top:e.bottom-u.bottom+ec(i,"bottom")),e.left<u.left+ec(r,"left")?d=-(u.left-e.left+ec(i,"left")):e.right>u.right-ec(r,"right")&&(d=e.right-u.right+ec(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:Im(a)}}function Xze(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=Im(r));return e}function Yze({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 Zze(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=ac(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?Qze(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:JQ(n,i)}function Qze(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 Jze(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function eBe(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 tBe(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 nBe(t,e){let n=t.dom.ownerDocument,r,i=0,s=Vze(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=Im(u))u.draggable&&(r=void 0);if(a=Jze(a,e),r){if(io&&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;Yb&&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=tBe(t,r,i,e))}o==null&&(o=eBe(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 rBe=/[\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=Yb||io;if(r.nodeType==3)if(a&&(rBe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Au(ac(r,i,i),n);if(io&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Au(ac(r,i-1,i-1),-1);if(u.top==c.top){let d=Au(ac(r,i,i+1),-1);if(d.top!=c.top)return Cx(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++,Cx(Au(ac(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Qa(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return zN(c.getBoundingClientRect(),!1)}if(s==null&&i<Qa(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==Qa(r))){let c=r.childNodes[i-1],u=c.nodeType==3?ac(c,Qa(c)-(a?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Cx(Au(u,1),!1)}if(s==null&&i<Qa(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?ac(c,0,a?0:1):c.nodeType==1?c:null:null;if(u)return Cx(Au(u,-1),!0)}return Cx(Au(r.nodeType==3?ac(r):r,-n),n>=0)}function Cx(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 iBe(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=ac(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 sBe=/[\u0590-\u08ac]/;function aBe(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?!sBe.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 oBe(t,e,n){return QV==e&&JV==n?e9:(QV=e,JV=n,e9=n=="up"||n=="down"?iBe(t,e,n):aBe(t,e,n))}const so=0,t9=1,xh=2,bl=3;class Zb{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=so,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>Ji(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?Ji(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?Ji(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=Ji(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=Ji(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((io||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:Ji(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(io&&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&&io)){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=bl:s.markDirty(e-o,n-o);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?xh:bl}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 Zb{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==so&&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 lBe extends Zb{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 Zb{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&bl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=bl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=so){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=so}}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 Zb{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 cBe(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==so&&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 dBe(this,a&&a.node,e);pBe(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),Um&&mBe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof qt)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,o=gBe(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 lBe(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==bl||!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=so}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==bl||this.dirty!=so&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=so||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=so,!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=bl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class iJ extends Zb{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==so&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class cBe 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==bl)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 t0=function(t){t&&(this.nodeName=t)};t0.prototype=Object.create(null);const bh=[new t0];function XP(t,e,n){if(t.length==0)return bh;let r=n?bh[0]:new t0,i=[r];for(let s=0;s<t.length;s++){let a=t[s].type.attrs;if(a){a.nodeName&&i.push(r=new t0(a.nodeName));for(let o in a){let c=a[o];c!=null&&(n&&i.length==1&&i.push(r=new t0(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}uBe(i,o||bh[0],a)}return i}function uBe(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 dBe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=hBe(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=so,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==bl&&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!=bl&&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=so),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||fs)&&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 hBe(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 fBe(t,e){return t.type.side-e.type.side}function pBe(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(fBe);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 mBe(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 gBe(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&&Hze(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 Mc(t,e=!1){let n=t.state.selection;if(cJ(t,n),!!lJ(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&fs){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)bBe(t);else{let{anchor:r,head:i}=n,s,a;i9&&!(n instanceof qt)&&(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&&xBe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const i9=Ps||fs&&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 xBe(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 bBe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ji(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ys&&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))||qt.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 vBe(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&&ln.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 qt)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let a=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Pu(t,new qt(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(!(Wa&&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)):Yb?Pu(t,new qt(t.state.doc.resolve(e<0?o:o+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ht&&r.node.isInline)return Pu(t,new qt(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 n0(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?yBe(t):_Be(t)}function yBe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,a=!1;for(io&&n.nodeType==1&&r<qw(n)&&n0(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(n0(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&&n0(o,-1);)i=n.parentNode,s=Ji(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 _Be(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(n0(o,1))s=n,a=++r;else break}else{if(dJ(n))break;{let o=n.nextSibling;for(;o&&n0(o,1);)s=o.parentNode,a=Ji(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 wBe(t,e){for(;t&&e==t.childNodes.length&&!Xb(t);)e=Ji(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 SBe(t,e){for(;t&&!e&&!Xb(t);)e=Ji(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=wBe(e,n))?(e=a,n=0):(s=SBe(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&&Mc(t)},50)}function u9(t,e){let n=t.state.doc.resolve(e);if(!(fs||Gze)&&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 qt&&!r.empty||n.indexOf("s")>-1||Wa&&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 wa?ln.near(a,e):ln.findFrom(a,e);return o?Pu(t,o):!1}return!1}function h9(t,e){if(!(t.state.selection instanceof qt))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let a=t.state.tr;return e<0?a.delete(n.pos-s.nodeSize,n.pos):a.delete(n.pos,n.pos+s.nodeSize),t.dispatch(a),!0}return!1}function f9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function EBe(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 MBe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function ABe(t,e){let n=e.keyCode,r=MBe(e);if(n==8||Wa&&n==72&&r=="c")return h9(t,-1)||jp(t,-1);if(n==46&&!e.shiftKey||Wa&&n==68&&r=="c")return h9(t,1)||jp(t,1);if(n==13||n==27)return!0;if(n==37||Wa&&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||Wa&&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||Wa&&n==80&&r=="c")return d9(t,-1,r)||jp(t,-1);if(n==40||Wa&&n==78&&r=="c")return EBe(t)||d9(t,1,r)||jp(t,1);if(r==(Wa?"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 Ct(pt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",g=>{o=g(o,t,!0)}),o;let f=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(f)o=f;else{let g=i.marks(),{schema:m}=t.state,x=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=kBe(n),Yb&&PBe(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")||Jx.fromSchema(t.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!TBe.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)o=RBe(p9(o,+d[1],+d[2]),d[4]);else if(o=Ct.maxOpen(CBe(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 TBe=/^(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 CBe(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 Ct(JP(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ct(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 NBe(t){let e=window.trustedTypes;return e?(HN||(HN=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),HN.createHTML(t)):t}function kBe(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=NBe(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function PBe(t){let e=t.querySelectorAll(fs?"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 RBe(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 Ct(i,s,a)}const Rs={},Ds={},DBe={touchstart:!0,touchmove:!0};class OBe{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 jBe(t){for(let e in Rs){let n=Rs[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{IBe(t,r)&&!Oj(t,r)&&(t.editable||!(r.type in Ds))&&n(t,r)},DBe[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 LBe(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 IBe(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 UBe(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(),!(xc&&fs&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Um&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,dh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||ABe(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||Wa&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof qt)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",a=>a(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function JE(t){return{left:t.clientX,top:t.clientY}}function FBe(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 zBe(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 BBe(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 HBe(t,e,n,r,i){return jj(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?BBe(t,n):zBe(t,n))}function $Be(t,e,n,r){return jj(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function VBe(t,e,n,r){return jj(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||GBe(t,n,r)}function GBe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(um(t,qt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let a=s>i.depth?i.nodeAfter:i.node(s),o=i.before(s);if(a.inlineContent)um(t,qt.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=Wa?"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&&FBe(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 WBe(t,a,n,!!r)):(s=="doubleClick"?$Be:VBe)(t,a.pos,a.inside,n)?n.preventDefault():Gu(t,"pointer"))};class WBe{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&&io&&!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(()=>Mc(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(JE(e))),this.updateAllowDefault(e),this.allowDefault||!n?Gu(this.view,"pointer"):HBe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ps&&this.mightDrag&&!this.mightDrag.node.isAtom||fs&&!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,ln.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 qBe=xc?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 qt&&(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),io&&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,qBe)};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=XBe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function KBe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=zze(e.focusNode,e.focusOffset),r=Bze(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 XBe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Kw(t,e=!1){if(!(xc&&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 YBe(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 nb=Ys&&ed<15||Um&&Wze<604;Rs.copy=Ds.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=nb?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)):YBe(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ZBe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function QBe(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?rb(t,r.value,null,i,e):rb(t,r.textContent,r.innerHTML,i,e)},50)}function rb(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||Ct.empty)))return!0;if(!s)return!1;let a=ZBe(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&&!xc)return;let r=nb?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&rb(t,wJ(r),r.getData("text/html"),i,n)?n.preventDefault():QBe(t,n)};class SJ{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const JBe=Wa?"altKey":"ctrlKey";function EJ(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[JBe]}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||!fs||YQ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(nb?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",nb||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),nb?null:n.dataTransfer.getData("text/html"),!1,s);let o=!!(r&&EJ(t,n));if(t.someProp("handleDrop",x=>x(t,n,a||Ct.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())&&Mc(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(fs&&xc&&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 ib(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&&ib(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&&ib(this.attrs,e.attrs)&&ib(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&&ib(this.attrs,e.attrs)&&ib(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):ds}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==ds||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?e6e(this.children,a||[],e,n,r,i,s):a?new vr(a.sort(jh),Bp):ds}add(e,n){return n.length?this==ds?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==ds?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!=ds?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):ds}forChild(e,n){if(this==ds)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||ds}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==ds)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 ds=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!=ds&&(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 ds;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 e6e(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 w=o[b]+d-f;m>=w?o[b+1]=g<=w?-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!=ds?(o[u]=f,o[u+1]=m,o[u+2]=b):(o[u+1]=-2,c=!0)}else c=!0}if(c){let u=t6e(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 t6e(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!=ds&&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):ds}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!=ds&&e.push(r)}),t.cursorWrapper&&e.push(vr.create(t.state.doc,[t.cursorWrapper.deco])),Iu.from(e)}const n6e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},r6e=Ys&&ed<=11;class i6e{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 s6e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new i6e,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]);Ys&&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()}),r6e&&(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,n6e)),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 Mc(this.view);if(Ys&&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=Im(s))n.add(s);for(let s=e.anchorNode;s;s=Im(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(io&&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||l6e(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(ln.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Mc(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,a),a6e(e)),this.handleDOMChange(s,a,o,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Mc(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let 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(Ys&&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?Ji(i)+1:0,o=r.localPosFromDOM(e.target,a,-1),c=s&&s.parentNode==e.target?Ji(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 a6e(t){if(!x9.has(t)&&(x9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=io,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 o6e(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 l6e(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 c6e(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})),fs&&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")||Jx.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:u6e,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 u6e(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 d6e=/^(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 h6e(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(fs&&xc&&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=c6e(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=m6e(f.content,u.doc.content,u.from,g,m);if(x&&t.input.domChangeCount++,(Um&&t.input.lastIOSEnter>Date.now()-225||xc)&&i.some(N=>N.nodeType==1&&!d6e.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 qt&&!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 qt&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),Ys&&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((Um&&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&&p6e(d,x.start,x.endA,y,v)&&t.someProp("handleKeyDown",N=>N(t,dh(8,"Backspace")))){xc&&fs&&t.domObserver.suppressSelectionUpdates();return}fs&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),xc&&!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 w=x.start,A=x.endA,T=N=>{let I=N||t.state.tr.replace(w,A,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let C=y9(t,I.doc,u.sel);C&&!(fs&&t.composing&&C.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==w||C.head==I.mapping.map(A)-1)||Ys&&C.empty&&C.head==w)&&I.setSelection(C)}return s&&I.setMeta("composition",s),I.scrollIntoView()},k;if(E)if(y.pos==v.pos){Ys&&ed<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Mc(t),20));let N=T(t.state.tr.delete(w,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=f6e(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(w,A,k.mark):N.removeMark(w,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,w,A));t.someProp("handleTextInput",C=>C(t,w,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 f6e(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 p6e(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 m6e(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 OBe,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 s6e(this,(r,i,s,a)=>h6e(this,r,i,s,a)),this.domObserver.start(),jBe(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);x6e(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&&Xze(this);if(a){this.domObserver.stop();let m=f&&(Ys||fs)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&g6e(i.selection,e.selection);if(f){let x=fs?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=KBe(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())&&vBe(this))?Mc(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&&Yze(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(Ys){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&&Zze(this.dom),Mc(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return nBe(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 oBe(this,n||this.state,e)}pasteHTML(e,n){return rb(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return rb(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Dj(this,e)}destroy(){this.docView&&(LBe(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,Uze())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return UBe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ps&&this.root.nodeType===11&&$ze(this.dom.ownerDocument)==this.dom&&o6e(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 g6e(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 x6e(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:'"'},b6e=typeof navigator<"u"&&/Mac/.test(navigator.platform),v6e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var es=0;es<10;es++)md[48+es]=md[96+es]=String(es);for(var es=1;es<=24;es++)md[es+111]="F"+es;for(var es=65;es<=90;es++)md[es]=String.fromCharCode(es+32),Zw[es]=String.fromCharCode(es);for(var GN in md)Zw.hasOwnProperty(GN)||(Zw[GN]=md[GN]);function y6e(t){var e=b6e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||v6e&&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 _6e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),w6e=typeof navigator<"u"&&/Win/.test(navigator.platform);function S6e(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))_6e?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 E6e(t){let e=Object.create(null);for(let n in t)e[S6e(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 M6e(t){return new Mr({props:{handleKeyDown:NJ(t)}})}function NJ(t){let e=E6e(t);return function(n,r){let i=y6e(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)&&!(w6e&&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 A6e=Object.defineProperty,Fj=(t,e)=>{for(var n in e)A6e(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:()=>T6e,clearContent:()=>C6e,clearNodes:()=>N6e,command:()=>k6e,createParagraphNear:()=>P6e,cut:()=>R6e,deleteCurrentNode:()=>D6e,deleteNode:()=>O6e,deleteRange:()=>j6e,deleteSelection:()=>L6e,enter:()=>I6e,exitCode:()=>U6e,extendMarkRange:()=>F6e,first:()=>z6e,focus:()=>H6e,forEach:()=>$6e,insertContent:()=>V6e,insertContentAt:()=>q6e,joinBackward:()=>Y6e,joinDown:()=>X6e,joinForward:()=>Z6e,joinItemBackward:()=>Q6e,joinItemForward:()=>J6e,joinTextblockBackward:()=>e8e,joinTextblockForward:()=>t8e,joinUp:()=>K6e,keyboardShortcut:()=>r8e,lift:()=>i8e,liftEmptyBlock:()=>s8e,liftListItem:()=>a8e,newlineInCode:()=>o8e,resetAttributes:()=>l8e,scrollIntoView:()=>c8e,selectAll:()=>u8e,selectNodeBackward:()=>d8e,selectNodeForward:()=>h8e,selectParentNode:()=>f8e,selectTextblockEnd:()=>p8e,selectTextblockStart:()=>m8e,setContent:()=>g8e,setMark:()=>O8e,setMeta:()=>j8e,setNode:()=>L8e,setNodeSelection:()=>I8e,setTextDirection:()=>U8e,setTextSelection:()=>F8e,sinkListItem:()=>z8e,splitBlock:()=>B8e,splitListItem:()=>H8e,toggleList:()=>$8e,toggleMark:()=>V8e,toggleNode:()=>G8e,toggleWrap:()=>W8e,undoInputRule:()=>q8e,unsetAllMarks:()=>K8e,unsetMark:()=>X8e,unsetTextDirection:()=>Y8e,updateAttributes:()=>Z8e,wrapIn:()=>Q8e,wrapInList:()=>J8e});var T6e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),C6e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),N6e=()=>({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=dg(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},k6e=t=>e=>t(e),P6e=()=>({state:t,dispatch:e})=>GQ(t,e),R6e=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const a=r.mapping.map(e);return r.insert(a,s.content),r.setSelection(new qt(r.doc.resolve(Math.max(a-1,0)))),!0},D6e=()=>({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 O6e=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},j6e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},L6e=()=>({state:t,dispatch:e})=>Mj(t,e),I6e=()=>({commands:t})=>t.keyboardShortcut("Enter"),U6e=()=>({state:t,dispatch:e})=>Sze(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 F6e=(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=qt.create(a,f.from,f.to);n.setSelection(g)}}return!0},z6e=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 qt}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=ln.atStart(t),r=ln.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?qt.create(t,vh(0,i,s),vh(t.content.size,i,s)):qt.create(t,vh(e,i,s),vh(e,i,s))}function B6e(){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 H6e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const a=()=>{(Hj()||B6e())&&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},$6e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),V6e=(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 I_(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 sb(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),sb("",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?Jx.fromSchema(c).parseSlice(I_(t),n.parseOptions):Jx.fromSchema(c).parse(I_(t),n.parseOptions),n.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const s=Jx.fromSchema(e);return n.slice?s.parseSlice(I_(t),n.parseOptions).content:s.parse(I_(t),n.parseOptions)}return sb("",e,n)}function G6e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Oi||i instanceof Li))return;const s=t.mapping.maps[r];let a=0;s.forEach((o,c,u,d)=>{a===0&&(a=d)}),t.setSelection(ln.near(t.doc.resolve(a),n))}var W6e=t=>!("type"in t),q6e=(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{sb(e,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(v){c(v)}try{o=sb(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((W6e(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,w=b.isText||b.isTextblock,A=b.content.size>0;E&&w&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&G6e(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},K6e=()=>({state:t,dispatch:e})=>yze(t,e),X6e=()=>({state:t,dispatch:e})=>_ze(t,e),Y6e=()=>({state:t,dispatch:e})=>UQ(t,e),Z6e=()=>({state:t,dispatch:e})=>HQ(t,e),Q6e=()=>({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}},J6e=()=>({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}},e8e=()=>({state:t,dispatch:e})=>bze(t,e),t8e=()=>({state:t,dispatch:e})=>vze(t,e);function jJ(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function n8e(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 r8e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=n8e(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 i8e=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return gd(n,i,e)?wze(n,r):!1},s8e=()=>({state:t,dispatch:e})=>WQ(t,e),a8e=t=>({state:e,dispatch:n})=>{const r=ii(t,e.schema);return Oze(r)(e,n)},o8e=()=>({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 l8e=(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},c8e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),u8e=()=>({tr:t,dispatch:e})=>{if(e){const n=new wa(t.doc);t.setSelection(n)}return!0},d8e=()=>({state:t,dispatch:e})=>zQ(t,e),h8e=()=>({state:t,dispatch:e})=>$Q(t,e),f8e=()=>({state:t,dispatch:e})=>Aze(t,e),p8e=()=>({state:t,dispatch:e})=>Nze(t,e),m8e=()=>({state:t,dispatch:e})=>Cze(t,e);function tR(t,e,n={},r={}){return sb(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var g8e=(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 x8e(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 b8e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function v8e(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=>v8e(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 In(t,e=void 0,...n){return UJ(t)?e?t.bind(e)(...n):t(...n):t}function y8e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Fm(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}=Fm(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 _8e(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):_8e(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"&&y8e(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 w8e(t,e){var n;const r=FJ(t),{nodeExtensions:i,markExtensions:s}=Fm(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 w=Bt(E,"extendNodeSchema",f);return{...b,...w?w(u):{}}},{}),m=k9({...g,content:In(Bt(u,"content",f)),marks:In(Bt(u,"marks",f)),group:In(Bt(u,"group",f)),inline:In(Bt(u,"inline",f)),atom:In(Bt(u,"atom",f)),selectable:In(Bt(u,"selectable",f)),draggable:In(Bt(u,"draggable",f)),code:In(Bt(u,"code",f)),whitespace:In(Bt(u,"whitespace",f)),linebreakReplacement:In(Bt(u,"linebreakReplacement",f)),defining:In(Bt(u,"defining",f)),isolating:In(Bt(u,"isolating",f)),attrs:Object.fromEntries(d.map(P9))}),x=In(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:In(Bt(u,"inclusive",f)),excludes:In(Bt(u,"excludes",f)),group:In(Bt(u,"group",f)),spanning:In(Bt(u,"spanning",f)),code:In(Bt(u,"code",f)),attrs:Object.fromEntries(d.map(P9))}),x=In(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 S8e(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=S8e(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 E8e(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 M8e(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"?M8e(t,e):n==="mark"?LJ(t,e):{}}function A8e(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 T8e(t){const e=A8e(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}})})}),T8e(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 C8e=(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 g1(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 N8e=(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),w=E-b;a+=w,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 k8e(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 P8e=(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)},R8e=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}=Fm(e),r=n.find(a=>a.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=In(Bt(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function 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 D8e(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 O8e=(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 D8e(r,n,c)},j8e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),L8e=(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)},I8e=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},U8e=(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},F8e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,a=qt.atStart(r).from,o=qt.atEnd(r).to,c=vh(i,a,o),u=vh(s,a,o),d=qt.create(r,c,u);e.setSelection(d)}return!0},z8e=t=>({state:e,dispatch:n})=>{const r=ii(t,e.schema);return Ize(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 B8e=({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=g1(u,o.node().type.name,o.node().attrs);if(s instanceof Ht&&s.node.isBlock)return!o.parentOffset||!Ec(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:x8e(o.node(-1).contentMatchAt(o.indexAfter(-1)));let m=f&&g?[{type:g,attrs:d}]:void 0,x=Ec(e.doc,e.mapping.map(o.pos),1,m);if(!m&&!x&&Ec(e.doc,e.mapping.map(o.pos),1,g?[{type:g}]:void 0)&&(x=!0,m=g?[{type:g,attrs:d}]:void 0),r){if(x&&(s instanceof qt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,m),g&&!f&&!o.parentOffset&&o.parent.type!==g)){const y=e.mapping.map(o.before()),v=e.doc.resolve(y);o.node(-1).canReplaceWith(v.index(),v.index()+1,g)&&e.setNodeMarkup(e.mapping.map(o.before()),g)}t&&O9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},H8e=(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 w=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...g1(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(-w),new Ct(b,4-E,0));let N=-1;n.doc.nodesBetween(k,n.doc.content.size,(I,C)=>{if(N>-1)return!1;I.isTextblock&&I.content.size===0&&(N=C+1)}),N>-1&&n.setSelection(qt.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const m=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...g1(g,f.type.name,f.attrs),...e},y={...g1(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(!Ec(n.doc,c.pos,2))return!1;if(i){const{selection:b,storedMarks:E}=r,{splittableMarks:w}=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=>w.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},$8e=(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,w=b.blockRange(E),A=v||y.$to.parentOffset&&y.$from.marks();if(!w)return!1;const T=rM(k=>D9(k.type.name,f))(y);if(w.depth>=1&&T&&w.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()},V8e=(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)},G8e=(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})},W8e=(t,e={})=>({state:n,commands:r})=>{const i=ii(t,n.schema);return gd(n,i,e)?r.lift(i):r.wrapIn(i,e)},q8e=()=>({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},K8e=()=>({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},X8e=(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},Y8e=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},Z8e=(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 w=Math.max(b,d),A=Math.min(b+v.nodeSize,f);n.addMark(w,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},Q8e=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return kze(i,e)(n,r)},J8e=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return Pze(i,e)(n,r)},eHe=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}},tHe=(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 U_(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=N8e(u)+s;return a.forEach(g=>{if(d)return;const m=tHe(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:w}=new tM({editor:n,state:y});g.handler({state:y,range:v,match:m,commands:b,chain:E,can:w})===null||!x.steps.length||(g.undoable&&x.setMeta(o,{transform:x,from:r,to:i,text:s}),c.dispatch(x),d=!0)}),d}function nHe(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;U_({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 U_({editor:e,from:s,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&U_({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?U_({editor:e,from:a.pos,to:a.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function rHe(t){return Object.prototype.toString.call(t).slice(8,-1)}function F_(t){return rHe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function WJ(t,e){const n={...t};return F_(t)&&F_(e)&&Object.keys(e).forEach(r=>{F_(e[r])&&F_(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{...In(Bt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...In(Bt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>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 iHe(t){return typeof t=="number"}var sHe=class{constructor(t){this.find=t.find,this.handler=t.handler}},aHe=(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 oHe(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,w;if((v=(y=m.type)==null?void 0:y.spec)!=null&&v.code||!(m.isText||m.isTextblock||m.isInline))return;const A=(w=(E=(b=m.content)==null?void 0:b.size)!=null?E:m.nodeSize)!=null?w: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,"");aHe(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 z_=null,lHe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function cHe(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(!(!oHe({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&&(z_=e)},m=()=>{z_&&(z_=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=z_;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=lHe(T);return c({rule:d,state:m,from:k,to:{b:N},pasteEvt:I})}const w=g.doc.content.findDiffStart(m.doc.content),A=g.doc.content.findDiffEnd(m.doc.content);if(!(!iHe(w)||!A||w===A.b))return c({rule:d,state:m,from:w,to:A,pasteEvt:a})}}))}var aM=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=zJ(t),this.schema=w8e(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=M6e(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=nHe({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=cHe({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}=Fm(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}=Fm(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=>{EHe(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=In(Bt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Bt(e,"onBeforeCreate",r),s=Bt(e,"onCreate",r),a=Bt(e,"onUpdate",r),o=Bt(e,"onSelectionUpdate",r),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 uHe={};Fj(uHe,{ClipboardTextSerializer:()=>XJ,Commands:()=>YJ,Delete:()=>ZJ,Drop:()=>QJ,Editable:()=>JJ,FocusEvents:()=>tee,Keymap:()=>nee,Paste:()=>ree,Tabindex:()=>iee,TextDirection:()=>see,focusEventsPluginKey:()=>eee});var Zn=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=Zn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Mr({key:new wi("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=Zn.create({name:"commands",addCommands(){return{...kJ}}}),ZJ=Zn.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 Do){const b=g.slice(x).map(m.from,-1),E=g.slice(x).map(m.to),w=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:w,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=Zn.create({name:"drop",addProseMirrorPlugins(){return[new Mr({key:new wi("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),JJ=Zn.create({name:"editable",addProseMirrorPlugins(){return[new Mr({key:new wi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),eee=new wi("focusEvents"),tee=Zn.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=Zn.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:ln.atStart(u).from===g;return!d||!m.type.isTextblock||m.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Hj()||jJ()?s:i},addProseMirrorPlugins(){return[new Mr({key:new wi("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=ln.atStart(e.doc).from,u=ln.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=Zn.create({name:"paste",addProseMirrorPlugins(){return[new Mr({key:new wi("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),iee=Zn.create({name:"tabindex",addProseMirrorPlugins(){return[new Mr({key:new wi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),see=Zn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Fm(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 wi("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),dHe=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)}},hHe=`.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 fHe(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 pHe=class extends eHe{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=fHe(hHe,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 k8e(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 E8e(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 dHe(e,this)}get $doc(){return this.$pos(0)}};function zm(t){return new sM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=In(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,a=r[r.length-1],o=r[0];if(a){const 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=In(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=In(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function Bm(t){return new sM({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=In(t.getAttributes,void 0,r)||{},a=e.tr.delete(n.from,n.to),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 mHe=t=>"touches"in t,gHe=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,mHe(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 xHe(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 bHe={};Fj(bHe,{createAtomBlockMarkdownSpec:()=>vHe,createBlockMarkdownSpec:()=>yHe,createInlineMarkdownSpec:()=>SHe,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 vHe(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 yHe(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,w=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:w,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 _He(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 wHe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function SHe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=_He,serializeAttributes:s=wHe,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 w=i(E.trim());return{type:e,raw:v[0],content:b.trim(),attributes:w}}},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 w=b.slice(1);if(w.length>0){const T=w.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 EHe(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 Js=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 sHe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=In(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:a}=e,o=r[r.length-1],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 MHe(){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 AHe=MHe();const THe=uo(AHe);var CHe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},NHe=({contentComponent:t})=>{const e=ER.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return l.jsx(l.Fragment,{children:Object.values(e)})};function kHe(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]: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 PHe=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=kHe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:CHe(e,this.editorContentRef),...n}),t?.contentComponent&&l.jsx(NHe,{contentComponent:t.contentComponent})]})}},RHe=M.forwardRef((t,e)=>{const n=mr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return mr.createElement(PHe,{key:n,innerRef:e,...t})}),DHe=mr.memo(RHe),OHe=typeof window<"u"?M.useLayoutEffect:M.useEffect,jHe=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function LHe(t){var e;const[n]=M.useState(()=>new jHe(t.editor)),r=sW.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:THe);return OHe(()=>n.watch(t.editor),[t.editor,n]),M.useDebugValue(r),r}var IHe=!1,sR=typeof window>"u",UHe=sR||!!(typeof window<"u"&&window.next),FHe=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||UHe?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 pHe(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 zHe(t={},e=[]){const n=M.useRef(t);n.current=t;const[r]=M.useState(()=>new FHe(n)),i=ER.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return M.useDebugValue(i),M.useEffect(r.onRender(e)),LHe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var BHe=M.createContext({editor:null});BHe.Consumer;var HHe=M.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),$He=()=>M.useContext(HHe);mr.forwardRef((t,e)=>{const{onDragStart:n}=$He(),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]},VHe=/^\s*>\s$/,GHe=Js.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[Bm({find:VHe,type:this.type})]}}),WHe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,qHe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,KHe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,XHe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,YHe=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[zm({find:WHe,type:this.type}),zm({find:KHe,type:this.type})]},addPasteRules(){return[cf({find:qHe,type:this.type}),cf({find:XHe,type:this.type})]}}),ZHe=/(^|[^`])`([^`]+)`(?!`)$/,QHe=/(^|[^`])`([^`]+)`(?!`)/g,JHe=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[zm({find:ZHe,type:this.type})]},addPasteRules(){return[cf({find:QHe,type:this.type})]}}),ZN=4,e$e=/^```([a-z]+)?[\s\n]$/,t$e=/^~~~([a-z]+)?[\s\n]$/,n$e=Js.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])||"",w=Math.min(E.length,n);if(w===0)return!0;let A=d;for(let k=0;k<x;k+=1)A+=m[k].length+1;return o.delete(A,A+w),u-A<=w&&o.setSelection(qt.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(ln.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[rR({find:e$e,type:this.type,getAttributes:t=>({language:t[1]})}),rR({find:t$e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Mr({key:new wi("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(qt.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),t.dispatch(a),!0}}})]}}),r$e=Js.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),i$e=Js.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()}}}),s$e=Js.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}}))}}),a$e=Js.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(!xHe(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(qt.create(a.doc,c.pos+1)):c.nodeAfter.isBlock?a.setSelection(Ht.create(a.doc,c.pos)):a.setSelection(qt.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(qt.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[aee({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),o$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,l$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,c$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,u$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,d$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[zm({find:o$e,type:this.type}),zm({find:c$e,type:this.type})]},addPasteRules(){return[cf({find:l$e,type:this.type}),cf({find:u$e,type:this.type})]}});const h$e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",f$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",r0="asciinumeric",Hx="alphanumeric",cR="domain",cee="emoji",p$e="scheme",m$e="slashscheme",QN="whitespace";function g$e(t,e){return t in e||(e[t]=[]),e[t]}function yh(t,e,n){e[aR]&&(e[r0]=!0,e[Hx]=!0),e[oR]&&(e[r0]=!0,e[lR]=!0),e[r0]&&(e[Hx]=!0),e[lR]&&(e[Hx]=!0),e[Hx]&&(e[cR]=!0),e[cee]&&(e[cR]=!0);for(const r in e){const i=g$e(r,n);i.indexOf(t)<0&&i.push(t)}}function x$e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Gs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Gs.groups={};Gs.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||Gs.groups;let i;return e&&e.j?i=e:(i=new Gs(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||Gs.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 Gs,Object.assign(a.j,o.j),a.jr.push.apply(a.jr,o.jr),a.jd=o.jd,a.t=o.t):a=new Gs,s){if(r)if(a.t&&typeof a.t=="string"){const c=Object.assign(x$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 rn=(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),sc="WORD",uR="UWORD",uee="ASCIINUMERICAL",dee="ALPHANUMERICAL",ab="LOCALHOST",dR="TLD",hR="UTLD",x1="SCHEME",$p="SLASH_SCHEME",Zj="NUM",fR="WS",Qj="NL",i0="OPENBRACE",s0="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",Zo="DOT",wS="EQUALS",eL="EXCLAMATION",Ha="HYPHEN",a0="PERCENT",SS="PIPE",ES="PLUS",MS="POUND",o0="QUERY",tL="QUOTE",hee="FULLWIDTHMIDDLEDOT",nL="SEMI",Qo="SLASH",l0="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:s0,CLOSEBRACKET:nS,CLOSEPAREN:iS,COLON:Uu,COMMA:Jj,DOLLAR:_S,DOT:Zo,EMOJI:fee,EQUALS:wS,EXCLAMATION:eL,FULLWIDTHGREATERTHAN:pS,FULLWIDTHLEFTPAREN:oS,FULLWIDTHLESSTHAN:fS,FULLWIDTHMIDDLEDOT:hee,FULLWIDTHRIGHTPAREN:lS,HYPHEN:Ha,LEFTCORNERBRACKET:cS,LEFTWHITECORNERBRACKET:dS,LOCALHOST:ab,NL:Qj,NUM:Zj,OPENANGLEBRACKET:sS,OPENBRACE:i0,OPENBRACKET:tS,OPENPAREN:rS,PERCENT:a0,PIPE:SS,PLUS:ES,POUND:MS,QUERY:o0,QUOTE:tL,RIGHTCORNERBRACKET:uS,RIGHTWHITECORNERBRACKET:hS,SCHEME:x1,SEMI:nL,SLASH:Qo,SLASH_SCHEME:$p,SYM:TS,TILDE:l0,TLD:dR,UNDERSCORE:AS,UTLD:hR,UWORD:uR,WORD:sc,WS:fR});const tc=/[a-z]/,Nx=new RegExp("\\p{L}","u"),JN=new RegExp("\\p{Emoji}","u"),nc=/\d/,e3=/\s/,I9="\r",t3=`
- `,b$e="️",v$e="",n3="";let B_=null,H_=null;function y$e(t=[]){const e={};Gs.groups=e;const n=new Gs;B_==null&&(B_=U9(h$e)),H_==null&&(H_=U9(f$e)),gt(n,"'",gS),gt(n,"{",i0),gt(n,"}",s0),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,".",Zo),gt(n,"=",wS),gt(n,"!",eL),gt(n,"-",Ha),gt(n,"%",a0),gt(n,"|",SS),gt(n,"+",ES),gt(n,"#",MS),gt(n,"?",o0),gt(n,'"',tL),gt(n,"/",Qo),gt(n,";",nL),gt(n,"~",l0),gt(n,"_",AS),gt(n,"\\",bS),gt(n,"・",hee);const r=Nr(n,nc,Zj,{[aR]:!0});Nr(r,nc,r);const i=Nr(r,tc,uee,{[r0]:!0}),s=Nr(r,Nx,dee,{[Hx]:!0}),a=Nr(n,tc,sc,{[oR]:!0});Nr(a,nc,i),Nr(a,tc,a),Nr(i,nc,i),Nr(i,tc,i);const o=Nr(n,Nx,uR,{[lR]:!0});Nr(o,tc),Nr(o,nc,s),Nr(o,Nx,o),Nr(s,nc,s),Nr(s,tc),Nr(s,Nx,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,b$e,f);const g=gt(f,v$e);gt(g,"#"),Nr(g,JN,f);const m=[[tc,a],[nc,i]],x=[[tc,null],[Nx,o],[nc,s]];for(let y=0;y<B_.length;y++)Mu(n,B_[y],dR,sc,m);for(let y=0;y<H_.length;y++)Mu(n,H_[y],hR,uR,x);yh(dR,{tld:!0,ascii:!0},e),yh(hR,{utld:!0,alpha:!0},e),Mu(n,"file",x1,sc,m),Mu(n,"mailto",x1,sc,m),Mu(n,"http",$p,sc,m),Mu(n,"https",$p,sc,m),Mu(n,"ftp",$p,sc,m),Mu(n,"ftps",$p,sc,m),yh(x1,{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]?{[p$e]:!0}:{[m$e]:!0};v.indexOf("-")>=0?E[cR]=!0:tc.test(v)?nc.test(v)?E[r0]=!0:E[oR]=!0:E[aR]=!0,L9(n,v,v,E)}return L9(n,"localhost",ab,{ascii:!0}),n.jd=new Gs(TS),{start:n,tokens:Object.assign({groups:e},pee)}}function mee(t,e){const n=_$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 _$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 Gs(r),s.jr=i.slice(),t.j[c]=s),t=s}return s=new Gs(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 ob={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({},ob);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:ob,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]:ob[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=ob.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"),w$e=oM("nl"),$_=oM("url",{isLink:!0,toHref(t=ob.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==ab&&t[1].t===Uu}}),Fa=t=>new Gs(t);function S$e({groups:t}){const e=t.domain.concat([mS,xS,Ru,bS,vS,yS,_S,wS,Ha,Zj,a0,SS,ES,MS,Qo,TS,l0,AS]),n=[gS,Uu,Jj,Zo,eL,a0,o0,tL,nL,sS,aS,i0,s0,nS,tS,rS,iS,oS,lS,cS,uS,dS,hS,fS,pS],r=[mS,gS,xS,bS,vS,yS,_S,wS,Ha,i0,s0,a0,SS,ES,MS,o0,Qo,TS,l0,AS],i=Fa(),s=gt(i,l0);rn(s,r,s),rn(s,t.domain,s);const a=Fa(),o=Fa(),c=Fa();rn(i,t.domain,a),rn(i,t.scheme,o),rn(i,t.slashscheme,c),rn(a,r,s),rn(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,Zo);rn(d,r,s),rn(d,t.domain,s);const f=Fa();rn(u,t.domain,f),rn(f,t.domain,f);const g=gt(f,Zo);rn(g,t.domain,f);const m=Fa(z9);rn(g,t.tld,m),rn(g,t.utld,m),gt(u,ab,m);const x=gt(f,Ha);gt(x,Ha,x),rn(x,t.domain,f),rn(m,t.domain,f),gt(m,Zo,g),gt(m,Ha,x);const y=gt(m,Uu);rn(y,t.numeric,z9);const v=gt(a,Ha),b=gt(a,Zo);gt(v,Ha,v),rn(v,t.domain,a),rn(b,r,s),rn(b,t.domain,a);const E=Fa($_);rn(b,t.tld,E),rn(b,t.utld,E),rn(E,t.domain,a),rn(E,r,s),gt(E,Zo,b),gt(E,Ha,v),gt(E,Ru,u);const w=gt(E,Uu),A=Fa($_);rn(w,t.numeric,A);const T=Fa($_),k=Fa();rn(T,e,T),rn(T,n,k),rn(k,e,T),rn(k,n,k),gt(E,Qo,T),gt(A,Qo,T);const N=gt(o,Uu),I=gt(c,Uu),C=gt(I,Qo),D=gt(C,Qo);rn(o,t.domain,a),gt(o,Zo,b),gt(o,Ha,v),rn(c,t.domain,a),gt(c,Zo,b),gt(c,Ha,v),rn(N,t.domain,T),gt(N,Qo,T),gt(N,o0,T),rn(D,t.domain,T),rn(D,e,T),gt(D,Qo,T);const F=[[i0,s0],[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=Fa($_);rn(W,e,K);const V=Fa();rn(W,n),rn(K,e,K),rn(K,n,V),rn(V,e,K),rn(V,n,V),gt(K,R,T),gt(V,R,T)}return gt(i,ab,E),gt(i,Qj,w$e),{start:i,tokens:pee}}function E$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 M$e=typeof console<"u"&&console&&console.warn||(()=>{}),A$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 T$e(){return Gs.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&&M$e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${A$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 C$e(){cr.scanner=y$e(cr.customSchemes);for(let t=0;t<cr.tokenQueue.length;t++)cr.tokenQueue[t][1]({scanner:cr.scanner});cr.parser=S$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||C$e(),E$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 ]",N$e=new RegExp(sL),k$e=new RegExp(`${sL}$`),P$e=new RegExp(sL,"g");function R$e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function D$e(t){return new Mr({key:new wi("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=b8e(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(!k$e.test(m))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const m=g.split(N$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(!R$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 O$e(t){return new Mr({key:new wi("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 j$e(t){return new Mr({key:new wi("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(P$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(){T$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(D$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(O$e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(j$e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),L$e=bee,I$e=Object.defineProperty,U$e=(t,e)=>{for(var n in e)I$e(t,n,{get:e[n],enumerable:!0})},F$e="listItem",$9="textStyle",V9=/^\s*([-+*])\s$/,vee=Js.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(F$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=Bm({find:V9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Bm({find:V9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes($9),editor:this.editor})),[t]}}),yee=Js.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)}}}),z$e={};U$e(z$e,{findListItemPos:()=>Qb,getNextListDepth:()=>aL,handleBackspace:()=>pR,handleDelete:()=>mR,hasListBefore:()=>_ee,hasListItemAfter:()=>B$e,hasListItemBefore:()=>wee,listItemHasSubList:()=>See,nextListIsDeeper:()=>Eee,nextListIsHigher:()=>Mee});var Qb=(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=Qb(t,e);if(!n)return!1;const[,r]=C8e(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)||!R8e(t.state))return!1;const r=Qb(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=Qb(t,e);return!r||!n?!1:n>r.depth},Mee=(t,e)=>{const n=aL(t,e),r=Qb(t,e);return!r||!n?!1:n<r.depth},mR=(t,e)=>{if(!gd(t.state,e)||!P8e(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()},B$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=Zn.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&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+(.*)$/,H$e=/^\s/;function $$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(H$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 V$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 G$e="listItem",W9="textStyle",q9=/^(\d+)\.\s$/,Cee=Js.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?V$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]=$$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(G$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=Bm({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=Bm({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]}}),W$e=/^\s*(\[([( |x])?\])\s$/,q$e=Js.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[Bm({find:W$e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),K$e=Js.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()}}});Zn.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(q$e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(K$e.configure(this.options.taskList)),t}});var X$e=Js.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()}}}),Y$e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Z$e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Q$e=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[zm({find:Y$e,type:this.type})]},addPasteRules(){return[cf({find:Z$e,type:this.type})]}}),J$e=Js.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()}}}),eVe=Nee;function tVe(t={}){return new Mr({view(e){return new nVe(e,t)}})}class nVe{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 ln{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Pr.valid(r)?new Pr(r):ln.near(r)}content(){return Ct.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||!rVe(e)||!iVe(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;ln.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):ln.near(n)}}function kee(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function rVe(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 iVe(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 sVe(){return new Mr({props:{decorations:cVe,createSelectionBetween(t,e,n){return e.pos==n.pos&&Pr.valid(n)?new Pr(n):null},handleClick:oVe,handleKeyDown:aVe,handleDOMEvents:{beforeinput:lVe}}})}const aVe=NJ({ArrowLeft:V_("horiz",-1),ArrowRight:V_("horiz",1),ArrowUp:V_("vert",-1),ArrowDown:V_("vert",1)});function V_(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 qt){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 oVe(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 lVe(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 Ct(i,0,0));return s.setSelection(qt.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function cVe(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,Ii=function(){};Ii.prototype.append=function(e){return e.length?(e=Ii.from(e),!this.length&&e||e.length<CS&&this.leafAppend(e)||this.length<CS&&e.leafPrepend(this)||this.appendInner(e)):this};Ii.prototype.prepend=function(e){return e.length?Ii.from(e).append(this):this};Ii.prototype.appendInner=function(e){return new uVe(this,e)};Ii.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ii.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ii.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ii.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)};Ii.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};Ii.from=function(e){return e instanceof Ii?e:e&&e.length?new Pee(e):Ii.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})(Ii);Ii.empty=new Pee([]);var uVe=(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})(Ii);const dVe=500;class No{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 Jo(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 Jo(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 No(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 Jo(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>fVe&&(o=hVe(o,u),a-=u),new No(o.append(s),a)}remapping(e,n){let r=new eb;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 No(this.items.append(e.map(n=>new Jo(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 Jo(x,y,v))}else r.push(new Jo(x))},i);let u=[];for(let g=n;g<a;g++)u.push(new Jo(s.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new No(d,o);return f.emptyItemCount()>dVe&&(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 Jo(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 No(Ii.from(i.reverse()),s)}}No.empty=new No(Ii.empty,0);function hVe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Jo{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 Jo(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 fVe=20;function pVe(t,e,n,r){let i=n.getMeta(Lh),s;if(i)return i.historyState;n.getMeta(xVe)&&(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,b1(e)),t.undone,K9(n.mapping.maps),t.prevTime,t.prevComposition):new Du(t.done,t.undone.addTransform(n,void 0,r,b1(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||!mVe(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,b1(e)),No.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 mVe(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 gVe(t,e,n){let r=b1(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 b1(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 wi("history"),xVe=new wi("closeHistory");function bVe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Mr({key:Lh,state:{init(){return new Du(No.empty,No.empty,null,0,-1)},apply(e,n,r){return pVe(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=gVe(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const Dee=Ree(!1,!0),Oee=Ree(!0,!0);Zn.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Mr({key:new wi("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 vVe=Zn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[tVe(this.options)]}});Zn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Mr({key:new wi("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 yVe=Zn.create({name:"gapCursor",addProseMirrorPlugins(){return[sVe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=In(Bt(t,"allowGapCursor",n)))!=null?e:null}}});Zn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Mr({key:new wi("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)}}})]}});Zn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Mr({key:new wi("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 _Ve=Zn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new wi(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})}}})]}}),wVe=Zn.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[bVe(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()}}}),SVe=Zn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(YHe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(GHe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(vee.configure(this.options.bulletList)),this.options.code!==!1&&i.push(JHe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(n$e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(r$e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(vVe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(yVe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(i$e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(s$e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(wVe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(a$e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(d$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(X$e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(Q$e.configure(this.options.strike)),this.options.text!==!1&&i.push(J$e.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(_Ve.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),EVe=SVe,MVe=Zn.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),AVe=MVe,TVe=20,jee=(t,e=0)=>{const n=[];return!t.children.length||e>TVe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...jee(r,e+1))}),n},CVe=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&&CVe(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}}}}),NVe=Zn.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const a=s[0].trim().toLowerCase(),o=s.slice(1).join(":").trim();if(a==="background-color")return o.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Iee=Zn.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const a=s[0].trim().toLowerCase(),o=s.slice(1).join(":").trim();if(a==="color")return o.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),kVe=Zn.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),PVe=Zn.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),RVe=Zn.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});Zn.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(NVe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Iee.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(kVe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(PVe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(RVe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Lee.configure(this.options.textStyle)),t}});var DVe=Iee,OVe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,jVe=Js.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 gHe({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:OVe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),LVe=jVe;function Z9({content:t,onChange:e,placeholder:n}){const r=zHe({extensions:[EVe.configure({heading:!1,codeBlock:!1,code:!1}),eVe,L$e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),AVe.configure({types:["paragraph"]}),Lee,DVe,LVe.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(wue,{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(pue,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:l.jsx(uue,{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(hue,{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(DHe,{editor:r})]})}function IVe({archiveId:t,archiveName:e,onClose:n}){const r=En(),[i,s]=M.useState(!1),[a,o]=M.useState(null),[c,u]=M.useState({}),{data:d,isLoading:f,error:g}=vt({queryKey:["archive-project-page",t],queryFn:()=>ke.getArchiveProjectPage(t)}),m=_t({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("")},w=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),A=T=>{T.target===T.currentTarget&&n()};return l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(Ja,{className:"w-5 h-5 text-bambu-green"}),l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&l.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&l.jsxs(Ie,{variant:"ghost",size:"sm",onClick:y,children:[l.jsx(w0,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&l.jsxs(l.Fragment,{children:[l.jsx(Ie,{variant:"ghost",size:"sm",onClick:b,children:"Cancel"}),l.jsxs(Ie,{variant:"primary",size:"sm",onClick:v,disabled:m.isPending,children:[l.jsx(ko,{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(Gt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&l.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!w&&l.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[l.jsx(Ja,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"No project page data found in this 3MF file."}),l.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&w&&l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"space-y-4",children:[i?l.jsx("input",{type:"text",value:c.title||"",onChange:T=>u({...c,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&l.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),l.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(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(ao,{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(Ja,{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(Ja,{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(mb,{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(ao,{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(Gt,{className:"w-6 h-6 text-white"})}),l.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[a+1," / ",x.length]})]})]})}const UVe=[.25,.5,.75,1,1.5,2,3,4];function FVe({src:t,title:e,downloadFilename:n,onClose:r}){const i=M.useRef(null),[s,a]=M.useState(!0),[o,c]=M.useState(.5),[u,d]=M.useState(0),[f,g]=M.useState(0);M.useEffect(()=>{const w=i.current;w&&(w.playbackRate=o)},[o]),M.useEffect(()=>{const w=A=>{A.key==="Escape"&&r()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[r]),M.useEffect(()=>{const w=i.current;if(!w)return;const A=()=>d(w.currentTime),T=()=>g(w.duration),k=()=>a(!0),N=()=>a(!1);return w.addEventListener("timeupdate",A),w.addEventListener("durationchange",T),w.addEventListener("play",k),w.addEventListener("pause",N),()=>{w.removeEventListener("timeupdate",A),w.removeEventListener("durationchange",T),w.removeEventListener("play",k),w.removeEventListener("pause",N)}},[]);const m=()=>{const w=i.current;w&&(s?w.pause():w.play())},x=w=>{const A=i.current;A&&(A.currentTime=parseFloat(w.target.value))},y=()=>{const w=i.current;w&&(w.currentTime=Math.max(0,w.currentTime-5))},v=()=>{const w=i.current;w&&(w.currentTime=Math.min(f,w.currentTime+5))},b=w=>{const A=Math.floor(w/60),T=Math.floor(w%60);return`${A}:${T.toString().padStart(2,"0")}`},E=()=>{const w=document.createElement("a");w.href=t,w.download=n,w.click()};return l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:l.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Zp,{className:"w-5 h-5 text-bambu-green"}),e]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Ie,{variant:"secondary",size:"sm",onClick:E,children:[l.jsx(Sa,{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(Gt,{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(Zce,{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:UVe.map(w=>l.jsxs("button",{onClick:()=>c(w),className:`px-2 py-1 text-xs rounded transition-colors ${o===w?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[w,"x"]},w))})]})]})]})]})]})})}function zVe({archiveId:t,archiveName:e,onClose:n}){const r=En(),{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}=vt({queryKey:["printers"],queryFn:()=>ke.getPrinters()});M.useEffect(()=>{y?.length===1&&!s&&a(y[0].id)},[y,s]),M.useEffect(()=>{const w=A=>{A.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]);const v=_t({mutationFn:w=>ke.addToQueue(w),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:w=>{i(w.message||"Failed to add to queue","error")}}),b=w=>{if(w.preventDefault(),!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 w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:l.jsx(kt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:l.jsxs(Dt,{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(Gt,{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(Io,{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:w=>a(w.target.value?Number(w.target.value):null),required:!0,children:[l.jsx("option",{value:"",children:"Select printer..."}),y?.map(w=>l.jsx("option",{value:w.id,children:w.name},w.id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[l.jsx(_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:w=>d(w.target.value),min:E(),required:!0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:w=>x(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[l.jsx(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(Ie,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Ie,{type:"submit",className:"flex-1",disabled:v.isPending||!s||y?.length===0,children:v.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function BVe({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}=vt({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(Gt,{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(HVe,{comparison:n}):null}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsx(Ie,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function HVe({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 kx(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 $Ve({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s}){const a=En(),{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),[w,A]=M.useState(!1),[T,k]=M.useState([]),[N,I]=M.useState(!1),[C,D]=M.useState(!1),[F,j]=M.useState(!1),[q,R]=M.useState(!1),[W,K]=M.useState(!1),[V,te]=M.useState(null),Y=M.useRef(null),Z=_t({mutationFn:re=>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=_t({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=_t({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")}}),ee=_t({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")}}),ae=_t({mutationFn:()=>ke.deleteArchive(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),o("Archive deleted")},onError:()=>{o("Failed to delete archive","error")}}),fe=_t({mutationFn:()=>ke.toggleFavorite(t.id),onSuccess:re=>{a.invalidateQueries({queryKey:["archives"]}),o(re.is_favorite?"Added to favorites":"Removed from favorites")}}),de=_t({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(),te({x:re.clientX,y:re.clientY})},ye=[{label:"Print",icon:l.jsx(Ea,{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(ao,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",ve=`${window.location.origin}${ke.getArchiveForSlicer(t.id,re)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`}},{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(W5,{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(ba,{className:"w-4 h-4"}),onClick:()=>Y.current?.click()},{label:"Remove Source 3MF",icon:l.jsx(kn,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:l.jsx(Sa,{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(x0,{className:"w-4 h-4"}),onClick:()=>D(!0),disabled:!t.photos?.length},{label:"Project Page",icon:l.jsx(Ja,{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(gm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>fe.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(Gt,{className:"w-4 h-4"}),onClick:()=>de.mutate(null)}),!s)re.push({label:"Loading...",icon:l.jsx(At,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const ve=s.filter(je=>je.status==="active");ve.length===0?re.push({label:"No projects available",icon:l.jsx(qu,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):ve.forEach(je=>{re.push({label:je.name,icon:l.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:je.color||"#888"}}),onClick:()=>de.mutate(je.id),disabled:t.project_id===je.id})})}return re})()},{label:n?"Deselect":"Select",icon:n?l.jsx(Vh,{className:"w-4 h-4"}):l.jsx(mm,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:l.jsx(kn,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return l.jsxs(kt,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:xe,onClick:i?()=>r(t.id):void 0,children:[i&&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(mm,{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(mb,{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 ve=re.currentTarget.getBoundingClientRect();te({x:ve.left,y:ve.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(),fe.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:l.jsx(gm,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),t.status==="failed"&&l.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:"failed"}),t.duplicate_count>0&&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 ve=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",je=`${window.location.origin}${ke.getSource3mfForSlicer(t.id,ve)}`;window.location.href=`bambustudioopen://${encodeURIComponent(je)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:l.jsx(W5,{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(x0,{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(Dt,{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: ${kx(t.print_time_seconds||0)}
- Actual: ${kx(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${kx(t.actual_time_seconds)}`:`Estimated: ${kx(t.print_time_seconds||0)}`,children:[l.jsx(_r,{className:"w-3 h-3"}),kx(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(_0,{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,ve)=>l.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:re},title:re},ve))})]})]}),(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,ve)=>l.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:re.trim()},ve))]}),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(Ie,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>g(!0),children:[l.jsx(Ea,{className:"w-3 h-3 flex-shrink-0"}),l.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),l.jsx(Ie,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=t.print_name||t.filename||"model",ve=`${window.location.origin}${ke.getArchiveForSlicer(t.id,re)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`},title:"Open in Bambu Studio",children:l.jsx(ao,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Ie,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url,title:t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"Not from MakerWorld",children:l.jsx(v0,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),l.jsx(Ie,{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(Ie,{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(Sa,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Ie,{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(Ie,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:l.jsx(kn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),y&&l.jsx(fFe,{archive:t,onClose:()=>v(!1)}),u&&l.jsx(cFe,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>d(!1)}),f&&l.jsx(uFe,{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:()=>{ae.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(pFe,{x:V.x,y:V.y,items:ye,onClose:()=>te(null)}),b&&t.timelapse_path&&l.jsx(FVe,{src:ke.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,onClose:()=>E(!1)}),w&&T.length>0&&l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),l.jsx("button",{onClick:()=>{A(!1),k([])},className:"text-gray-400 hover:text-white p-1",children:l.jsx(Gt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(re=>l.jsxs("button",{onClick:()=>ee.mutate(re.name),disabled:ee.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[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(Ie,{variant:"secondary",onClick:()=>{A(!1),k([])},className:"w-full",children:"Cancel"})})]})}),N&&l.jsx(_Fe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),C&&t.photos&&t.photos.length>0&&l.jsx(wFe,{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(IVe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),q&&l.jsx(zVe,{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 ve=re.target.files?.[0];ve&&Z.mutate(ve),re.target.value=""}})]})}const VVe=[{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(gm,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:l.jsx(Io,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:l.jsx(Hh,{className:"w-4 h-4"})}];function GVe(){const t=En(),{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(null),[b,E]=M.useState(!1),[w,A]=M.useState([]),[T,k]=M.useState(!1),[N,I]=M.useState(new Set),[C,D]=M.useState(!1),[F,j]=M.useState(!1),[q,R]=M.useState(!1),[W,K]=M.useState("grid"),[V,te]=M.useState("date-desc"),[Y,Z]=M.useState("all"),[U,z]=M.useState(!1),[ee,ae]=M.useState(!1),[fe,de]=M.useState(!1),{data:xe,isLoading:ye}=vt({queryKey:["archives",s],queryFn:()=>ke.getArchives(s||void 0)}),{data:re}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:ve}=vt({queryKey:["projects"],queryFn:()=>ke.getProjects()}),je=_t({mutationFn:async me=>(await Promise.all(me.map(Ae=>ke.deleteArchive(Ae))),me.length),onSuccess:me=>{t.invalidateQueries({queryKey:["archives"]}),I(new Set),e(`${me} archive${me!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}}),ue=new Map(re?.map(me=>[me.id,me.name])||[]),ut=[...new Set(xe?.flatMap(me=>me.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),$=[...new Set(xe?.flatMap(me=>me.filament_color?.split(",")||[]).filter(Boolean)||[])],H=[...new Set(xe?.flatMap(me=>me.tags?.split(",").map(Ae=>Ae.trim())||[]).filter(Boolean)||[])].sort(),ie=xe?.filter(me=>{const Ae=new Date,ze=new Date(me.created_at);let st=!0;switch(Y){case"recent":st=Ae.getTime()-ze.getTime()<1440*60*1e3;break;case"this-week":st=Ae.getTime()-ze.getTime()<10080*60*1e3;break;case"this-month":st=ze.getMonth()===Ae.getMonth()&&ze.getFullYear()===Ae.getFullYear();break;case"favorites":st=me.is_favorite===!0;break;case"failed":st=me.status==="failed";break;case"duplicates":st=me.duplicate_count>0;break}const Ve=(me.print_name||me.filename).toLowerCase().includes(r.toLowerCase()),ce=!o||me.filament_type?.split(", ").includes(o),Ye=me.filament_color?.split(",")||[],$e=u.size===0||(f==="or"?Ye.some(Fe=>u.has(Fe)):[...u].every(Fe=>Ye.includes(Fe))),Ze=Y==="favorites"||!m||me.is_favorite,at=me.tags?.split(",").map(Fe=>Fe.trim())||[],Q=!y||at.includes(y);return st&&Ve&&ce&&$e&&Ze&&Q}).sort((me,Ae)=>{switch(V){case"date-desc":return new Date(Ae.created_at).getTime()-new Date(me.created_at).getTime();case"date-asc":return new Date(me.created_at).getTime()-new Date(Ae.created_at).getTime();case"name-asc":return(me.print_name||me.filename).localeCompare(Ae.print_name||Ae.filename);case"name-desc":return(Ae.print_name||Ae.filename).localeCompare(me.print_name||me.filename);case"size-desc":return Ae.file_size-me.file_size;case"size-asc":return me.file_size-Ae.file_size;default:return 0}}),G=C||N.size>0,J=me=>{I(Ae=>{const ze=new Set(Ae);return ze.has(me)?ze.delete(me):ze.add(me),ze})},le=()=>{ie&&I(new Set(ie.map(me=>me.id)))},Pe=()=>{I(new Set),D(!1)},Ne=me=>{d(Ae=>{const ze=new Set(Ae);return ze.has(me)?ze.delete(me):ze.add(me),ze})},Se=()=>{d(new Set)},B=()=>{i(""),a(null),c(null),x(!1),v(null)},L=r||s||o||m||y,ne=M.useCallback(me=>{me.preventDefault(),me.dataTransfer.types.includes("Files")&&k(!0)},[]),be=M.useCallback(me=>{me.preventDefault(),me.currentTarget===me.target&&k(!1)},[]),we=M.useCallback(me=>{me.preventDefault(),k(!1);const Ae=Array.from(me.dataTransfer.files).filter(ze=>ze.name.endsWith(".3mf"));Ae.length>0?(A(Ae),E(!0)):me.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ge=M.useCallback(me=>{const Ae=me.target;if(Ae.tagName==="INPUT"||Ae.tagName==="TEXTAREA"||Ae.isContentEditable){me.key==="Escape"&&Ae.blur();return}switch(me.key){case"/":me.preventDefault(),n.current?.focus();break;case"u":case"U":!me.metaKey&&!me.ctrlKey&&(me.preventDefault(),E(!0));break;case"Escape":G&&Pe();break}},[G]);return M.useEffect(()=>(document.addEventListener("keydown",ge),()=>document.removeEventListener("keydown",ge)),[ge]),l.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:ne,onDragLeave:be,onDrop:we,children:[T&&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(ba,{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"})]})}),G&&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(Ie,{variant:"secondary",size:"sm",onClick:Pe,children:[l.jsx(Gt,{className:"w-4 h-4"}),"Close"]}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs("span",{className:"text-white font-medium",children:[N.size," selected"]}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsx(Ie,{variant:"secondary",size:"sm",onClick:le,children:"Select All"}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>R(!0),children:[l.jsx(E0,{className:"w-4 h-4"}),"Tags"]}),l.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>{const me=Array.from(N);Promise.all(me.map(Ae=>ke.toggleFavorite(Ae))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${me.length} archive${me.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[l.jsx(gm,{className:"w-4 h-4"}),"Favorite"]}),l.jsxs(Ie,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>j(!0),children:[l.jsx(kn,{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:Y,onChange:me=>Z(me.target.value),children:VVe.map(me=>l.jsx("option",{value:me.id,children:me.label},me.id))})]}),l.jsxs("p",{className:"text-bambu-gray",children:[ie?.length||0," of ",xe?.length||0," prints"]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"relative",children:[l.jsxs(Ie,{variant:"secondary",onClick:()=>z(!U),disabled:ee,children:[ee?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(A1,{className:"w-4 h-4"}),"Export"]}),U&&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()=>{z(!1),ae(!0);try{const{blob:me,filename:Ae}=await ke.exportArchives({format:"csv",printerId:s||void 0,status:Y==="failed"?"failed":void 0,search:r||void 0}),ze=URL.createObjectURL(me),st=document.createElement("a");st.href=ze,st.download=Ae,st.click(),URL.revokeObjectURL(ze),e("Export downloaded")}catch{e("Export failed","error")}finally{ae(!1)}},children:[l.jsx(Ja,{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()=>{z(!1),ae(!0);try{const{blob:me,filename:Ae}=await ke.exportArchives({format:"xlsx",printerId:s||void 0,status:Y==="failed"?"failed":void 0,search:r||void 0}),ze=URL.createObjectURL(me),st=document.createElement("a");st.href=ze,st.download=Ae,st.click(),URL.revokeObjectURL(ze),e("Export downloaded")}catch{e("Export failed","error")}finally{ae(!1)}},children:[l.jsx(A1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),N.size>=2&&N.size<=5&&l.jsxs(Ie,{variant:"secondary",onClick:()=>de(!0),children:[l.jsx(Qp,{className:"w-4 h-4"}),"Compare (",N.size,")"]}),!G&&l.jsxs(Ie,{variant:"secondary",onClick:()=>D(!0),children:[l.jsx(Vh,{className:"w-4 h-4"}),"Select"]}),l.jsxs(Ie,{onClick:()=>E(!0),children:[l.jsx(ba,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),l.jsx(kt,{className:"mb-6",children:l.jsxs(Dt,{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:me=>i(me.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:me=>a(me.target.value?Number(me.target.value):null),children:[l.jsx("option",{value:"",children:"All Printers"}),re?.map(me=>l.jsx("option",{value:me.id,children:me.name},me.id))]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(_0,{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:me=>c(me.target.value||null),children:[l.jsx("option",{value:"",children:"All Materials"}),ut.map(me=>l.jsx("option",{value:me,children:me},me))]})]}),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(gm,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),l.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),H.length>0&&l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(E0,{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:me=>v(me.target.value||null),children:[l.jsx("option",{value:"",children:"All Tags"}),H.map(me=>l.jsx("option",{value:me,children:me},me))]})]}),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:V,onChange:me=>te(me.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 ${W==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("grid"),title:"Grid view",children:l.jsx(o7,{className:"w-4 h-4"})}),l.jsx("button",{className:`p-2 ${W==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("list"),title:"List view",children:l.jsx(zR,{className:"w-4 h-4"})}),l.jsx("button",{className:`p-2 ${W==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("calendar"),title:"Calendar view",children:l.jsx(coe,{className:"w-4 h-4"})})]})]}),L&&l.jsxs(Ie,{variant:"ghost",size:"sm",onClick:B,className:"text-bambu-gray hover:text-white",children:[l.jsx(Gt,{className:"w-4 h-4"}),"Reset"]})]}),$.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(me=>me==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),l.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:$.map(me=>l.jsx("button",{onClick:()=>Ne(me),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(me)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:me},title:me},me))}),u.size>0&&l.jsxs("button",{onClick:Se,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[l.jsx(Gt,{className:"w-3 h-3"}),"Clear"]})]})]})}),ye?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):ie?.length===0?l.jsx(kt,{children:l.jsxs(Dt,{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"})]})}):W==="calendar"?l.jsx(kt,{className:"p-6",children:l.jsx(yFe,{archives:ie||[],onArchiveClick:me=>{i(me.print_name||me.filename),K("grid")}})}):W==="grid"?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:ie?.map(me=>l.jsx($Ve,{archive:me,printerName:me.printer_id?ue.get(me.printer_id)||"Unknown":"No Printer",isSelected:N.has(me.id),onSelect:J,selectionMode:G,projects:ve},me.id))}):W==="list"?l.jsx(kt,{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"})]}),ie?.map(me=>l.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${N.has(me.id)?"bg-bambu-green/10":""}`,children:[l.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[G&&l.jsx("button",{onClick:()=>J(me.id),children:N.has(me.id)?l.jsx(Vh,{className:"w-4 h-4 text-bambu-green"}):l.jsx(mm,{className:"w-4 h-4 text-bambu-gray"})}),me.thumbnail_path?l.jsx("img",{src:ke.getArchiveThumbnail(me.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(mb,{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:me.print_name||me.filename}),me.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"})})]}),me.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:me.filament_type}),me.filament_color&&l.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:me.filament_color.split(",").map((Ae,ze)=>l.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:Ae},title:Ae},ze))})]})]}),l.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:me.printer_id?ue.get(me.printer_id)||"Unknown":"No Printer"}),l.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(me.created_at).toLocaleDateString()}),l.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:gR(me.file_size)}),l.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[l.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{const Ae=me.print_name||me.filename||"model",ze=`${window.location.origin}${ke.getArchiveForSlicer(me.id,Ae)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ze)}`},title:"Open in Slicer",children:l.jsx(ao,{className:"w-4 h-4"})}),me.makerworld_url&&l.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>window.open(me.makerworld_url,"_blank"),title:"MakerWorld",children:l.jsx(v0,{className:"w-4 h-4"})}),l.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{const Ae=document.createElement("a");Ae.href=ke.getArchiveDownload(me.id),Ae.download=`${me.print_name||me.filename}.3mf`,Ae.click()},title:"Download",children:l.jsx(Sa,{className:"w-4 h-4"})})]})]},me.id))]})}):null,b&&l.jsx(dFe,{onClose:()=>{E(!1),A([])},initialFiles:w}),F&&l.jsx(Qr,{title:"Delete Archives",message:`Are you sure you want to delete ${N.size} archive${N.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${N.size}`,variant:"danger",onConfirm:()=>{je.mutate(Array.from(N)),j(!1)},onCancel:()=>j(!1)}),q&&l.jsx(mFe,{selectedIds:Array.from(N),existingTags:H,onClose:()=>R(!1)}),fe&&N.size>=2&&N.size<=5&&l.jsx(BVe,{archiveIds:Array.from(N),onClose:()=>{de(!1),I(new Set),D(!1)}})]})}function WVe(){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 hg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function lL(t){return"nodeType"in t}function ea(t){var e,n;return t?hg(t)?t:lL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function cL(t){const{Document:e}=ea(t);return t instanceof e}function Jb(t){return hg(t)?!1:t instanceof ea(t).HTMLElement}function Uee(t){return t instanceof ea(t).SVGElement}function fg(t){return t?hg(t)?t.document:lL(t)?cL(t)?t:Jb(t)||Uee(t)?t.ownerDocument:document:document:document}const vl=lM?M.useLayoutEffect:M.useEffect;function uL(t){const e=M.useRef(t);return vl(()=>{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 qVe(){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 lb(t,e){e===void 0&&(e=[t]);const n=M.useRef(t);return vl(()=>{n.current!==t&&(n.current=t)},e),n}function ev(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 tv(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),cb=Fee(-1);function KVe(t){return"clientX"in t&&"clientY"in t}function dL(t){if(!t)return!1;const{KeyboardEvent:e}=ea(t.target);return e&&t instanceof e}function XVe(t){if(!t)return!1;const{TouchEvent:e}=ea(t.target);return e&&t instanceof e}function bR(t){if(XVe(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 KVe(t)?{x:t.clientX,y:t.clientY}:null}const Hm=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[Hm.Translate.toString(t),Hm.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 YVe(t){return t.matches(J9)?t:t.querySelector(J9)}const ZVe={display:"none"};function QVe(t){let{id:e,value:n}=t;return mr.createElement("div",{id:e,style:ZVe},n)}function JVe(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 e9e(){const[t,e]=M.useState("");return{announce:M.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const zee=M.createContext(null);function t9e(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 n9e(){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 r9e={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.
- `},i9e={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 s9e(t){let{announcements:e=i9e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=r9e}=t;const{announce:s,announcement:a}=e9e(),o=tv("DndLiveRegion"),[c,u]=M.useState(!1);if(M.useEffect(()=>{u(!0)},[]),t9e(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(QVe,{id:r,value:i.draggable}),mr.createElement(JVe,{id:o,announcement:a}));return n?dc.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 Fo=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 a9e(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)},o9e=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 l9e(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 c9e=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=l9e(o,e);c>0&&i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(a9e)};function u9e(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}:Fo}function d9e(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 h9e=d9e(1);function f9e(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 p9e(t,e,n){const r=f9e(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 m9e={ignoreTransform:!1};function pg(t,e){e===void 0&&(e=m9e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=ea(t).getComputedStyle(t);u&&(n=p9e(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 pg(t,{ignoreTransform:!0})}function g9e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function x9e(t,e){return e===void 0&&(e=ea(t).getComputedStyle(t)),e.position==="fixed"}function b9e(t,e){e===void 0&&(e=ea(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(!Jb(i)||Uee(i)||n.includes(i))return n;const s=ea(t).getComputedStyle(i);return i!==t&&b9e(i,s)&&n.push(i),x9e(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:hg(t)?t:lL(t)?cL(t)||t===fg(t).scrollingElement?window:Jb(t)?t:null:null}function Kee(t){return hg(t)?t.scrollX:t.scrollLeft}function Xee(t){return hg(t)?t.scrollY:t.scrollTop}function vR(t){return{x:Kee(t),y:Xee(t)}}var Di;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Di||(Di={}));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 v9e={x:.2,y:.2};function y9e(t,e,n,r,i){let{top:s,left:a,right:o,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=v9e);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=Di.Backward,x.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&c>=e.bottom-y.height&&(m.y=Di.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!g&&o>=e.right-y.width?(m.x=Di.Forward,x.x=r*Math.abs((e.right-y.width-o)/y.width)):!f&&a<=e.left+y.width&&(m.x=Di.Backward,x.x=r*Math.abs((e.left+y.width-a)/y.width)),{direction:m,speed:x}}function _9e(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)),Fo)}function w9e(t){return t.reduce((e,n)=>e+Kee(n),0)}function S9e(t){return t.reduce((e,n)=>e+Xee(n),0)}function E9e(t,e){if(e===void 0&&(e=pg),!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 M9e=[["x",["left","right"],w9e],["y",["top","bottom"],S9e]];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 M9e)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 c0{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 A9e(t){const{EventTarget:e}=ea(t);return t instanceof e?t:fg(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 qa;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(qa||(qa={}));function rG(t){t.preventDefault()}function T9e(t){t.stopPropagation()}var wn;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(wn||(wn={}));const Jee={start:[wn.Space,wn.Enter],cancel:[wn.Esc],end:[wn.Space,wn.Enter,wn.Tab]},C9e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case wn.Right:return{...n,x:n.x+25};case wn.Left:return{...n,x:n.x-25};case wn.Down:return{...n,y:n.y+25};case wn.Up:return{...n,y:n.y-25}}};class 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 c0(fg(n)),this.windowListeners=new c0(ea(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(qa.Resize,this.handleCancel),this.windowListeners.add(qa.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(qa.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&E9e(r),n(Fo)}handleKeyDown(e){if(dL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=Jee,coordinateGetter:a=C9e,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}:Fo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=a(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=cb(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:w,isBottom:A,maxScroll:T,minScroll:k}=Zee(y),N=_9e(y),I={x:Math.min(v===wn.Right?N.right-N.width/2:N.right,Math.max(v===wn.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(v===wn.Down?N.bottom-N.height/2:N.bottom,Math.max(v===wn.Down?N.top:N.top+N.height/2,f.y))},C=v===wn.Right&&!E||v===wn.Left&&!w,D=v===wn.Down&&!A||v===wn.Up&&!b;if(C&&I.x!==f.x){const F=y.scrollLeft+g.x,j=v===wn.Right&&F<=T.x||v===wn.Left&&F>=k.x;if(j&&!g.y){y.scrollTo({left:F,behavior:o});return}j?m.x=y.scrollLeft-F:m.x=v===wn.Right?y.scrollLeft-T.x:y.scrollLeft-k.x,m.x&&y.scrollBy({left:-m.x,behavior:o});break}else if(D&&I.y!==f.y){const F=y.scrollTop+g.y,j=v===wn.Down&&F<=T.y||v===wn.Up&&F>=k.y;if(j&&!g.x){y.scrollTo({top:F,behavior:o});return}j?m.y=y.scrollTop-F:m.y=v===wn.Down?y.scrollTop-T.y:y.scrollTop-k.y,m.y&&y.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,dm(cb(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=A9e(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=fg(a),this.documentListeners=new c0(this.document),this.listeners=new c0(r),this.windowListeners=new c0(ea(a)),this.initialCoordinates=(i=bR(s))!=null?i:Fo,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(qa.Resize,this.handleCancel),this.windowListeners.add(qa.DragStart,rG),this.windowListeners.add(qa.VisibilityChange,this.handleCancel),this.windowListeners.add(qa.ContextMenu,rG),this.documentListeners.add(qa.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(qa.Click,T9e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(qa.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:Fo,u=cb(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===wn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const N9e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class dM extends fL{constructor(e){const{event:n}=e,r=fg(n.target);super(e,N9e,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 k9e={move:{name:"mousemove"},end:{name:"mouseup"}};var yR;(function(t){t[t.RightClick=2]="RightClick"})(yR||(yR={}));class P9e extends fL{constructor(e){super(e,k9e,fg(e.event.target))}}P9e.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 R9e 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(){}}}R9e.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 u0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(u0||(u0={}));var RS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(RS||(RS={}));function D9e(t){let{acceleration:e,activator:n=u0.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=j9e({delta:f,disabled:!s}),[x,y]=qVe(),v=M.useRef({x:0,y:0}),b=M.useRef({x:0,y:0}),E=M.useMemo(()=>{switch(n){case u0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case u0.DraggableRect:return i}},[n,i,c]),w=M.useRef(null),A=M.useCallback(()=>{const k=w.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}=y9e(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(),w.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 O9e={x:{[Di.Backward]:!1,[Di.Forward]:!1},y:{[Di.Backward]:!1,[Di.Forward]:!1}};function j9e(t){let{delta:e,disabled:n}=t;const r=xR(e);return ev(i=>{if(n||!r||!i)return O9e;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Di.Backward]:i.x[Di.Backward]||s.x===-1,[Di.Forward]:i.x[Di.Forward]||s.x===1},y:{[Di.Backward]:i.y[Di.Backward]||s.y===-1,[Di.Forward]:i.y[Di.Forward]||s.y===1}}},[n,e,r])}function L9e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return ev(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function I9e(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 ub;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(ub||(ub={}));var _R;(function(t){t.Optimized="optimized"})(_R||(_R={}));const aG=new Map;function U9e(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=lb(f),m=M.useCallback(function(b){b===void 0&&(b=[]),!g.current&&a(E=>E===null?b:E.concat(b.filter(w=>!E.includes(w))))},[g]),x=M.useRef(null),y=ev(b=>{if(f&&!n)return aG;if(!b||b===aG||d.current!==t||s!=null){const E=new Map;for(let w of t){if(!w)continue;if(s&&s.length>0&&!s.includes(w.id)&&w.rect.current){E.set(w.id,w.rect.current);continue}const A=w.node.current,T=A?new hL(c(A),A):null;w.rect.current=T,T&&E.set(w.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 ub.Always:return!1;case ub.BeforeDragging:return n;default:return!n}}}function ete(t,e){return ev(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function F9e(t,e){return ete(t,e)}function z9e(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 B9e(t){return new hL(pg(t),t)}function oG(t,e,n){e===void 0&&(e=B9e);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=z9e({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 vl(()=>{s(),t?(o?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),a?.disconnect())},[t]),r}function H9e(t){const e=ete(t);return Wee(t,e)}const lG=[];function $9e(t){const e=M.useRef(t),n=ev(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 V9e(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),Fo):Qee(t):Fo,[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!==Fo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?cb(t,n.current):Fo}function G9e(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 W9e(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?g9e(t):null,[t])}const uG=[];function q9e(t,e){e===void 0&&(e=pg);const[n]=t,r=tte(n?ea(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 vl(()=>{o?.disconnect(),a(),t.forEach(c=>o?.observe(c))},[t]),i}function K9e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Jb(e)?e:t}function X9e(t){let{measure:e}=t;const[n,r]=M.useState(null),i=M.useCallback(u=>{for(const{target:d}of u)if(Jb(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=K9e(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 Y9e=[{sensor:dM,options:{}},{sensor:uM,options:{}}],Z9e={current:{}},v1={draggable:{measure:nG},droppable:{measure:nG,strategy:ub.WhileDragging,frequency:_R.Optimized},dragOverlay:{measure:pg}};class d0 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 Q9e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new d0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:kS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:v1,measureDroppableContainers:kS,windowRect:null,measuringScheduled:!1},J9e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:kS,draggableNodes:new Map,over:null,measureDroppableContainers:kS},fM=M.createContext(J9e),nte=M.createContext(Q9e);function eGe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new d0}}}function tGe(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 d0(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 d0(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 d0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function nGe(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=YVe(d);if(f){f.focus();break}}})}},[r,e,i,a,s]),null}function rGe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function iGe(t){return M.useMemo(()=>({draggable:{...v1.draggable,...t?.draggable},droppable:{...v1.droppable,...t?.droppable},dragOverlay:{...v1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function sGe(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;vl(()=>{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({...Fo,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=Y9e,collisionDetection:f=c9e,measuring:g,modifiers:m,...x}=e;const y=M.useReducer(tGe,void 0,eGe),[v,b]=y,[E,w]=n9e(),[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 Ue;return N!=null?{id:N,data:(Ue=F?.data)!=null?Ue:Z9e,rect:j}:null},[N,F]),R=M.useRef(null),[W,K]=M.useState(null),[V,te]=M.useState(null),Y=lb(x,Object.values(x)),Z=tv("DndDescribedBy",a),U=M.useMemo(()=>D.getEnabled(),[D]),z=iGe(g),{droppableRects:ee,measureDroppableContainers:ae,measuringScheduled:fe}=U9e(U,{dragging:k,dependencies:[C.x,C.y],config:z.droppable}),de=L9e(I,N),xe=M.useMemo(()=>V?bR(V):null,[V]),ye=pe(),re=F9e(de,z.draggable.measure);sGe({activeNode:N!=null?I.get(N):null,config:ye.layoutShiftCompensation,initialRect:re,measure:z.draggable.measure});const ve=oG(de,z.draggable.measure,re),je=oG(de?de.parentElement:null),ue=M.useRef({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:I,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ut=D.getNodeFor((n=ue.current.over)==null?void 0:n.id),$=X9e({measure:z.dragOverlay.measure}),H=(r=$.nodeRef.current)!=null?r:de,ie=k?(i=$.rect)!=null?i:ve:null,G=!!($.nodeRef.current&&$.rect),J=H9e(G?null:ve),le=tte(H?ea(H):null),Pe=$9e(k?ut??de:null),Ne=q9e(Pe),Se=rGe(m,{transform:{x:C.x-J.x,y:C.y-J.y,scaleX:1,scaleY:1},activatorEvent:V,active:q,activeNodeRect:ve,containerNodeRect:je,draggingNodeRect:ie,over:ue.current.over,overlayNodeRect:$.rect,scrollableAncestors:Pe,scrollableAncestorRects:Ne,windowRect:le}),B=xe?dm(xe,C):null,L=V9e(Pe),ne=cG(L),be=cG(L,[ve]),we=dm(Se,ne),ge=ie?h9e(ie,Se):null,me=q&&ge?f({active:q,collisionRect:ge,droppableRects:ee,droppableContainers:U,pointerCoordinates:B}):null,Ae=Vee(me,"id"),[ze,st]=M.useState(null),Ve=G?Se:dm(Se,be),ce=u9e(Ve,(s=ze?.rect)!=null?s:null,ve),Ye=M.useRef(null),$e=M.useCallback((Ue,Ce)=>{let{sensor:_e,options:He}=Ce;if(R.current==null)return;const ht=I.get(R.current);if(!ht)return;const wt=Ue.nativeEvent,Ot=new _e({active:R.current,activeNode:ht,event:wt,options:He,context:ue,onAbort(It){if(!I.get(It))return;const{onDragAbort:Qn}=Y.current,Si={id:It};Qn?.(Si),E({type:"onDragAbort",event:Si})},onPending(It,Dn,Qn,Si){if(!I.get(It))return;const{onDragPending:Ei}=Y.current,Fi={id:It,constraint:Dn,initialCoordinates:Qn,offset:Si};Ei?.(Fi),E({type:"onDragPending",event:Fi})},onStart(It){const Dn=R.current;if(Dn==null)return;const Qn=I.get(Dn);if(!Qn)return;const{onDragStart:Si}=Y.current,ai={activatorEvent:wt,active:{id:Dn,data:Qn.data,rect:j}};dc.unstable_batchedUpdates(()=>{Si?.(ai),T(Ou.Initializing),b({type:di.DragStart,initialCoordinates:It,active:Dn}),E({type:"onDragStart",event:ai}),K(Ye.current),te(wt)})},onMove(It){b({type:di.DragMove,coordinates:It})},onEnd:cn(di.DragEnd),onCancel:cn(di.DragCancel)});Ye.current=Ot;function cn(It){return async function(){const{active:Qn,collisions:Si,over:ai,scrollAdjustedTranslate:Ei}=ue.current;let Fi=null;if(Qn&&Ei){const{cancelDrop:ns}=Y.current;Fi={activatorEvent:wt,active:Qn,collisions:Si,delta:Ei,over:ai},It===di.DragEnd&&typeof ns=="function"&&await Promise.resolve(ns(Fi))&&(It=di.DragCancel)}R.current=null,dc.unstable_batchedUpdates(()=>{b({type:It}),T(Ou.Uninitialized),st(null),K(null),te(null),Ye.current=null;const ns=It===di.DragEnd?"onDragEnd":"onDragCancel";if(Fi){const Hr=Y.current[ns];Hr?.(Fi),E({type:ns,event:Fi})}})}}},[I]),Ze=M.useCallback((Ue,Ce)=>(_e,He)=>{const ht=_e.nativeEvent,wt=I.get(He);if(R.current!==null||!wt||ht.dndKit||ht.defaultPrevented)return;const Ot={active:wt};Ue(_e,Ce.options,Ot)===!0&&(ht.dndKit={capturedBy:Ce.sensor},R.current=He,$e(_e,Ce))},[I,$e]),at=I9e(d,Ze);G9e(d),vl(()=>{ve&&A===Ou.Initializing&&T(Ou.Initialized)},[ve,A]),M.useEffect(()=>{const{onDragMove:Ue}=Y.current,{active:Ce,activatorEvent:_e,collisions:He,over:ht}=ue.current;if(!Ce||!_e)return;const wt={active:Ce,activatorEvent:_e,collisions:He,delta:{x:we.x,y:we.y},over:ht};dc.unstable_batchedUpdates(()=>{Ue?.(wt),E({type:"onDragMove",event:wt})})},[we.x,we.y]),M.useEffect(()=>{const{active:Ue,activatorEvent:Ce,collisions:_e,droppableContainers:He,scrollAdjustedTranslate:ht}=ue.current;if(!Ue||R.current==null||!Ce||!ht)return;const{onDragOver:wt}=Y.current,Ot=He.get(Ae),cn=Ot&&Ot.rect.current?{id:Ot.id,rect:Ot.rect.current,data:Ot.data,disabled:Ot.disabled}:null,It={active:Ue,activatorEvent:Ce,collisions:_e,delta:{x:ht.x,y:ht.y},over:cn};dc.unstable_batchedUpdates(()=>{st(cn),wt?.(It),E({type:"onDragOver",event:It})})},[Ae]),vl(()=>{ue.current={activatorEvent:V,active:q,activeNode:de,collisionRect:ge,collisions:me,droppableRects:ee,draggableNodes:I,draggingNode:H,draggingNodeRect:ie,droppableContainers:D,over:ze,scrollableAncestors:Pe,scrollAdjustedTranslate:we},j.current={initial:ie,translated:ge}},[q,de,me,ge,I,H,ie,ee,D,ze,Pe,we]),D9e({...ye,delta:C,draggingRect:ge,pointerCoordinates:B,scrollableAncestors:Pe,scrollableAncestorRects:Ne});const Q=M.useMemo(()=>({active:q,activeNode:de,activeNodeRect:ve,activatorEvent:V,collisions:me,containerNodeRect:je,dragOverlay:$,draggableNodes:I,droppableContainers:D,droppableRects:ee,over:ze,measureDroppableContainers:ae,scrollableAncestors:Pe,scrollableAncestorRects:Ne,measuringConfiguration:z,measuringScheduled:fe,windowRect:le}),[q,de,ve,V,me,je,$,I,D,ee,ze,ae,Pe,Ne,z,fe,le]),Fe=M.useMemo(()=>({activatorEvent:V,activators:at,active:q,activeNodeRect:ve,ariaDescribedById:{draggable:Z},dispatch:b,draggableNodes:I,over:ze,measureDroppableContainers:ae}),[V,at,q,ve,b,Z,I,ze,ae]);return mr.createElement(zee.Provider,{value:w},mr.createElement(fM.Provider,{value:Fe},mr.createElement(nte.Provider,{value:Q},mr.createElement(rte.Provider,{value:ce},u)),mr.createElement(nGe,{disabled:o?.restoreFocus===!1})),mr.createElement(s9e,{...o,hiddenTextDescribedById:Z}));function pe(){const Ue=W?.autoScrollEnabled===!1,Ce=typeof c=="object"?c.enabled===!1:c===!1,_e=k&&!Ue&&!Ce;return typeof c=="object"?{...c,enabled:_e}:{enabled:_e}}}),aGe=M.createContext(null),dG="button",oGe="Draggable";function lGe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=tv(oGe),{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:aGe),[E,w]=NS(),[A,T]=NS(),k=W9e(a,e),N=lb(n);vl(()=>(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:w,setActivatorNodeRef:T,transform:b}}function cGe(){return M.useContext(nte)}const uGe="Droppable",dGe={timeout:25};function hGe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=tv(uGe),{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}={...dGe,...i},b=lb(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]),w=hM({callback:E,disabled:x||!a}),A=M.useCallback((I,C)=>{w&&(C&&(w.unobserve(C),f.current=!1),I&&w.observe(I))},[w]),[T,k]=NS(A),N=lb(e);return M.useEffect(()=>{!w||!T.current||(w.disconnect(),f.current=!1,w.observe(T.current))},[T,w]),M.useEffect(()=>(o({type:di.RegisterDroppable,element:{id:r,key: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 fGe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function G_(t){return t!==null&&t>=0}function pGe(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 mGe(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}},W_={scaleX:1,scaleY:1},gGe=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,...W_}:null}const c=xGe(s,i,n);return i>n&&i<=a?{x:0,y:-o.height-c,...W_}:i<n&&i>=a?{x:0,y:o.height+c,...W_}:{x:0,y:0,...W_}};function xGe(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}=cGe(),f=tv(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=!pGe(m,b.current),w=v!==-1&&y===-1||E,A=mGe(s);vl(()=>{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:w,items:m,overIndex:v,useDragOverlay:g,sortedRects:fGe(m,c),strategy:i}),[y,f,A.draggable,A.droppable,w,m,v,c,g,i]);return mr.createElement(ate.Provider,{value:T},e)}const bGe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return pM(n,r,i).indexOf(e)},vGe=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},yGe={duration:200,easing:"ease"},lte="transform",_Ge=Hm.Transition.toString({property:lte,duration:0,easing:"linear"}),wGe={roleDescription:"sortable"};function SGe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,a]=M.useState(null),o=M.useRef(n);return vl(()=>{if(!e&&n!==o.current&&r.current){const c=i.current;if(c){const u=pg(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=vGe,attributes:n,disabled:r,data:i,getNewIndex:s=bGe,id:a,strategy:o,resizeObserverConfig:c,transition:u=yGe}=t;const{items:d,containerId:f,activeIndex:g,disabled:m,disableTransforms:x,sortedRects:y,overIndex:v,useDragOverlay:b,strategy:E}=M.useContext(ate),w=EGe(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}=hGe({id:a,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:F,activatorEvent:j,activeNodeRect:q,attributes:R,setNodeRef:W,listeners:K,isDragging:V,over:te,setActivatorNodeRef:Y,transform:Z}=lGe({id:a,data:T,attributes:{...wGe,...n},disabled:w.draggable}),U=WVe(D,W),z=!!F,ee=z&&!x&&G_(g)&&G_(v),ae=!b&&V,fe=ae&&ee?Z:null,xe=ee?fe??(o??E)({rects:y,activeNodeRect:q,activeIndex:g,overIndex:v,index:A}):null,ye=G_(g)&&G_(v)?s({id:a,items:d,activeIndex:g,overIndex:v}):A,re=F?.id,ve=M.useRef({activeId:re,items:d,newIndex:ye,containerId:f}),je=d!==ve.current.items,ue=e({active:F,containerId:f,isDragging:V,isSorting:z,id:a,index:A,items:d,newIndex:ve.current.newIndex,previousItems:ve.current.items,previousContainerId:ve.current.containerId,transition:u,wasDragging:ve.current.activeId!=null}),ut=SGe({disabled:!ue,index:A,node:I,rect:N});return M.useEffect(()=>{z&&ve.current.newIndex!==ye&&(ve.current.newIndex=ye),f!==ve.current.containerId&&(ve.current.containerId=f),d!==ve.current.items&&(ve.current.items=d)},[z,ye,f,d]),M.useEffect(()=>{if(re===ve.current.activeId)return;if(re!=null&&ve.current.activeId==null){ve.current.activeId=re;return}const H=setTimeout(()=>{ve.current.activeId=re},50);return()=>clearTimeout(H)},[re]),{active:F,activeIndex:g,attributes:R,data:T,rect:N,index:A,newIndex:ye,items:d,isOver:C,isSorting:z,isDragging:V,listeners:K,node:I,overIndex:v,over:te,setNodeRef:U,setActivatorNodeRef:Y,setDroppableNodeRef:D,setDraggableNodeRef:W,transform:ut??xe,transition:$()};function $(){if(ut||je&&ve.current.newIndex===A)return _Ge;if(!(ae&&!dL(j)||!u)&&(z||ue))return Hm.Transition.toString({...u,property:lte})}}function EGe(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 MGe=[wn.Down,wn.Right,wn.Up,wn.Left],ute=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:a,scrollableAncestors:o}}=e;if(MGe.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 wn.Down:r.top<g.top&&c.push(f);break;case wn.Up:r.top>g.top&&c.push(f);break;case wn.Left:r.left>g.left&&c.push(f);break;case wn.Right:r.left<g.left&&c.push(f);break}});const u=o9e({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=AGe(f,g),w=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 w.x&&w.y?A:cb(A,w)}}}};function dte(t,e){return!DS(t)||!DS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function AGe(t,e){return!DS(t)||!DS(e)||!dte(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function TGe({item:t,onClose:e}){const n=En(),{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}=vt({queryKey:["printers"],queryFn:()=>ke.getPrinters()});M.useEffect(()=>{const w=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e]);const v=_t({mutationFn:w=>ke.updateQueueItem(t.id,w),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:w=>{r(w.message||"Failed to update queue item","error")}}),b=w=>{w.preventDefault();const A={printer_id:i,require_previous_success:f,auto_off_after:m};o==="scheduled"&&u?A.scheduled_time=new Date(u).toISOString():A.scheduled_time=null,v.mutate(A)},E=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsx(kt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:l.jsxs(Dt,{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(Gt,{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(Io,{className:"w-4 h-4"}),"No printers configured"]}):l.jsx("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:w=>s(Number(w.target.value)),required:!0,children:y?.map(w=>l.jsx("option",{value:w.id,children:w.name},w.id))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[l.jsx(_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:w=>d(w.target.value),min:E(),required:!0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:w=>x(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[l.jsx(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(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsx(Ie,{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 CGe(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 NGe({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:ps,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:Lc,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:Gt,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:Hm.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(ao,{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(Ea,{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"}),CGe(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(Io,{className:"w-3 h-3"}),t.error_message]})]}),l.jsx(NGe,{status:t.status}),l.jsxs("div",{className:"flex items-center gap-1",children:[x&&l.jsx(Ie,{variant:"ghost",size:"sm",onClick:s,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:l.jsx(Toe,{className:"w-4 h-4"})}),y&&l.jsxs(l.Fragment,{children:[l.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:l.jsx(rd,{className:"w-4 h-4"})}),l.jsx(Ie,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:l.jsx(Gt,{className:"w-4 h-4"})})]}),v&&l.jsxs(l.Fragment,{children:[l.jsx(Ie,{variant:"ghost",size:"sm",onClick:a,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:l.jsx(Cs,{className:"w-4 h-4"})}),l.jsx(Ie,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:l.jsx(kn,{className:"w-4 h-4"})})]})]})]})})}function kGe(){const t=En(),{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,w]=M.useState(()=>{const Y=localStorage.getItem("queue.pendingSortAsc");return Y!==null?Y==="true":!0});M.useEffect(()=>{localStorage.setItem("queue.historySortBy",g)},[g]),M.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(x))},[x]),M.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",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}=vt({queryKey:["queue",n,i],queryFn:()=>ke.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:N}=vt({queryKey:["printers"],queryFn:()=>ke.getPrinters()}),I=_t({mutationFn:Y=>ke.cancelQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),C=_t({mutationFn:Y=>ke.removeFromQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),D=_t({mutationFn:Y=>ke.stopQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),F=_t({mutationFn:Y=>ke.reorderQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),j=_t({mutationFn:Y=>{const Z=new Date;return Z.setFullYear(Z.getFullYear()+1),ke.addToQueue({printer_id:Y.printer_id,archive_id:Y.archive_id,scheduled_time:Z.toISOString(),require_previous_success:!1,auto_off_after:!1})},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e("Added back to queue - please set schedule"),u(Y)},onError:Y=>e(Y.message||"Failed to re-queue item","error")}),q=_t({mutationFn:async()=>{const Y=T?.filter(Z=>["completed","failed","skipped","cancelled"].includes(Z.status))||[];for(const Z of Y)await ke.removeFromQueue(Z.id);return Y.length},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Y} history item${Y!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),R=M.useMemo(()=>{const Y=T?.filter(U=>U.status==="pending")||[],Z=U=>{if(!U.scheduled_time)return 0;const z=new Date(U.scheduled_time).getTime(),ee=Date.now()+4320*60*60*1e3;return z>ee?0:z};return[...Y].sort((U,z)=>{let ee;return v==="name"?ee=(U.archive_name||"").localeCompare(z.archive_name||""):v==="printer"?ee=(U.printer_name||"").localeCompare(z.printer_name||""):v==="time"?ee=Z(U)-Z(z):ee=U.position-z.position,E?ee:-ee})},[T,v,E]),W=T?.filter(Y=>Y.status==="printing")||[],K=M.useMemo(()=>[...T?.filter(Z=>["completed","failed","skipped","cancelled"].includes(Z.status))||[]].sort((Z,U)=>{let z;return g==="name"?z=(Z.archive_name||"").localeCompare(U.archive_name||""):g==="printer"?z=(Z.printer_name||"").localeCompare(U.printer_name||""):z=new Date(U.completed_at||U.created_at).getTime()-new Date(Z.completed_at||Z.created_at).getTime(),x?-z:z}),[T,g,x]),V=M.useMemo(()=>R.reduce((Y,Z)=>Y+(Z.print_time_seconds||0),0),[R]),te=Y=>{const{active:Z,over:U}=Y;if(!U||Z.id===U.id)return;const z=R.findIndex(ae=>ae.id===Z.id),ee=R.findIndex(ae=>ae.id===U.id);if(z!==-1&&ee!==-1){const fe=pM(R,z,ee).map((de,xe)=>({id:de.id,position:xe+1}));F.mutate(fe)}};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(kt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:l.jsx(Dt,{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(kt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:l.jsx(Dt,{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(kt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:l.jsx(Dt,{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(kt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:l.jsx(Dt,{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(ps,{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(Ie,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[l.jsx(kn,{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(kt,{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(Ie,{variant:"ghost",size:"sm",onClick:()=>w(!E),title:E?"Ascending":"Descending",className:"px-2",children:E?l.jsx(hm,{className:"w-4 h-4"}):l.jsx(g0,{className:"w-4 h-4"})})]})]}),l.jsx(ite,{sensors:A,collisionDetection:Gee,onDragEnd:te,children:l.jsx(ote,{items:R.map(Y=>Y.id),strategy:gGe,children:l.jsx("div",{className:"space-y-3",children:R.map((Y,Z)=>l.jsx(u3,{item:Y,position:Z+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(ps,{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(Ie,{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(g0,{className:"w-4 h-4"})})]})]}),l.jsx("div",{className:"space-y-3",children:K.slice(0,20).map((Y,Z)=>l.jsx(u3,{item:Y,position:Z+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>f({type:"remove",item:Y}),onStop:()=>{},onRequeue:()=>j.mutate(Y)},Y.id))})]})]}),c&&l.jsx(TGe,{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 PGe({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 q_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function RGe(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 DGe({archives:t,currency:e="$"}){const[n,r]=M.useState("30d"),i=M.useMemo(()=>{const g=RGe(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(w=>{const A=new Date(w.completed_at||w.created_at);return A>=y&&A<=v});m.push({month:b,filament:Math.round(E.reduce((w,A)=>w+(A.filament_used_grams||0),0)),cost:E.reduce((w,A)=>w+(A.cost||0),0),prints:E.length})}return 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(t1,{width:"100%",height:250,children:l.jsxs(ZTe,{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(r1,{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(t1,{width:160,height:160,children:l.jsxs(XTe,{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(Hb,{fill:q_[m%q_.length]},`cell-${m}`))}),l.jsx(r1,{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:q_[m%q_.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(t1,{width:"100%",height:200,children:l.jsxs(ITe,{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(r1,{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 OGe({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:Hm.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 jGe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i}){const s=()=>{const E={};return t.forEach(w=>{E[w.id]=w.defaultSize||4}),E},[a,o]=M.useState(()=>{const E=localStorage.getItem(e);if(E)try{const w=JSON.parse(E);return w.sizes||(w.sizes=s()),w}catch{}return{order:t.map(w=>w.id),hidden:t.filter(w=>w.defaultVisible===!1).map(w=>w.id),sizes:s()}}),[c,u]=M.useState(!1);M.useEffect(()=>{localStorage.setItem(e,JSON.stringify(a))},[a,e]),M.useEffect(()=>{const w=t.map(A=>A.id).filter(A=>!a.order.includes(A));w.length>0&&o(A=>({...A,order:[...A.order,...w]}))},[t,a.order]);const d=Bee(PS(dM,{activationConstraint:{distance:8}}),PS(uM,{coordinateGetter:ute})),f=E=>{const{active:w,over:A}=E;A&&w.id!==A.id&&o(T=>{const k=T.order.indexOf(w.id),N=T.order.indexOf(A.id);return{...T,order:pM(T.order,k,N)}})},g=E=>{o(w=>({...w,hidden:w.hidden.includes(E)?w.hidden.filter(A=>A!==E):[...w.hidden,E]}))},m=E=>{o(w=>{const A=w.sizes[E]||4,T=A===1?2:A===2?4:1;return{...w,sizes:{...w.sizes,[E]:T}}})},x=()=>{const E={order:t.map(w=>w.id),hidden:t.filter(w=>w.defaultVisible===!1).map(w=>w.id),sizes:s()};o(E),i?.()},y=a.order.map(E=>t.find(w=>w.id===E)).filter(Boolean),v=y.filter(E=>!a.hidden.includes(E.id)),b=y.filter(E=>a.hidden.includes(E.id));return l.jsxs("div",{className:"space-y-4",children:[!r&&l.jsxs("div",{className:"flex items-center justify-end gap-2",children:[b.length>0&&l.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>u(!c),children:[l.jsx(b0,{className:"w-4 h-4"}),b.length," Hidden"]}),l.jsxs(Ie,{variant:"secondary",size:"sm",onClick:x,children:[l.jsx(Km,{className:"w-4 h-4"}),"Reset Layout"]})]}),c&&b.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:b.map(E=>l.jsxs("button",{onClick:()=>g(E.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[l.jsx(b0,{className:"w-3 h-3"}),E.title]},E.id))})]}),l.jsx(ite,{sensors:d,collisionDetection:Gee,onDragEnd:f,children:l.jsx(ote,{items:v.map(E=>E.id),strategy:pL,children:l.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(E=>l.jsx(OGe,{id:E.id,title:E.title,isHidden:a.hidden.includes(E.id),size:a.sizes[E.id]||2,onToggleVisibility:()=>g(E.id),onToggleSize:()=>m(E.id),children:E.component},E.id))})})}),v.length===0&&l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx("p",{children:"All widgets are hidden."}),l.jsx(Ie,{className:"mt-4",onClick:x,children:"Reset Layout"})]})]})}function LGe({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(_0,{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(_0,{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(xm,{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 IGe({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(ps,{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(Lc,{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 UGe({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 FGe({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 zGe({printDates:t}){return l.jsx(PGe,{printDates:t,months:4})}function BGe({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(Ea,{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 HGe({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(DGe,{archives:t,currency:e})}function $Ge(){const{data:t,isLoading:e}=vt({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 VGe(){const{showToast:t}=si(),[e,n]=M.useState(!1),[r,i]=M.useState(!1),[s,a]=M.useState(0),{data:o,isLoading:c}=vt({queryKey:["archiveStats"],queryFn:ke.getArchiveStats}),{data:u}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:d}=vt({queryKey:["archives"],queryFn:()=>ke.getArchives(void 0,1e3,0)}),{data:f}=vt({queryKey:["settings"],queryFn:ke.getSettings}),g=async E=>{i(!1),n(!0);try{const{blob:w,filename:A}=await ke.exportStats({format:E,days:90}),T=URL.createObjectURL(w),k=document.createElement("a");k.href=T,k.download=A,k.click(),URL.revokeObjectURL(T),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},m=f?.currency||"$",x=new Map(u?.map(E=>[String(E.id),E.name])||[]),y=d?.map(E=>E.created_at)||[];if(c)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 v=[{id:"quick-stats",title:"Quick Stats",component:l.jsx(LGe,{stats:o,currency:m}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:l.jsx(IGe,{stats:o}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:l.jsx(UGe,{stats:o,printerMap:x}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:l.jsx(FGe,{stats:o}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:l.jsx($Ge,{}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:l.jsx(zGe,{printDates:y}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:l.jsx(BGe,{stats:o,printerMap:x}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:l.jsx(HGe,{archives:d||[],currency:m}),defaultSize:4}],b=()=>{localStorage.removeItem("bambusy-dashboard-layout"),a(E=>E+1),t("Layout reset")};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:[l.jsxs(Ie,{variant:"secondary",onClick:b,children:[l.jsx(Km,{className:"w-4 h-4"}),"Reset Layout"]}),l.jsxs("div",{className:"relative",children:[l.jsxs(Ie,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(A1,{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:()=>g("csv"),children:[l.jsx(Ja,{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:()=>g("xlsx"),children:[l.jsx(A1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),l.jsx(jGe,{widgets:v,storageKey:"bambusy-dashboard-layout",hideControls:!0},s)]})}function GGe({plug:t,onEdit:e}){const n=En(),[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}=vt({queryKey:["smart-plug-status",t.id],queryFn:()=>ke.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),y=x?.find(k=>k.id===t.printer_id),v=_t({mutationFn:k=>ke.controlSmartPlug(t.id,k),onSuccess:()=>{m()}}),b=_t({mutationFn:k=>ke.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=_t({mutationFn:()=>ke.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",A=f?.reachable??!1,T=v.isPending;return l.jsxs(l.Fragment,{children:[l.jsx(kt,{className:"relative",children:l.jsxs(Dt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${A?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:l.jsx(Jp,{className:`w-5 h-5 ${A?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),l.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),l.jsx("div",{className:"flex items-center gap-2",children:g?l.jsx(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:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):l.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[l.jsx(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(Ie,{size:"sm",variant:w?"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(Ie,{size:"sm",variant:w?"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(Ie,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[l.jsx(BR,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:l.jsx(kn,{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 WGe({plug:t,onClose:e}){const n=En(),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,w]=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}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:W}=vt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs});M.useEffect(()=>{const z=ee=>{ee.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[e]);const K=_t({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=_t({mutationFn:z=>ke.createSmartPlug(z),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:z=>{b(z.message)}}),te=_t({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(ae=>ae.printer_id===z.id&&ae.id!==t?.id)),Z=z=>{if(z.preventDefault(),b(null),!i.trim()){b("Name is required");return}if(!a.trim()){b("IP address is required");return}const ee={name:i.trim(),ip_address:a.trim(),username: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?te.mutate(ee):V.mutate(ee)},U=V.isPending||te.isPending;return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick: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(Gt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:Z,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(Ie,{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(ps,{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=>w(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(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Ie,{type:"submit",disabled:U,className:"flex-1",children:[U?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(ko,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Un({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return 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 qGe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function KGe({provider:t,onEdit:e}){const n=En(),[r,i]=M.useState(!1),[s,a]=M.useState(!1),[o,c]=M.useState(null),{data:u}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=_t({mutationFn:y=>ke.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=_t({mutationFn:()=>ke.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=_t({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(kt,{className:"relative",children:l.jsxs(Dt,{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:qGe[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(Un,{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:"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:"Temperature"}),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(Ie,{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(ps,{className:"w-4 h-4"}):l.jsx(Lc,{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(Un,{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(Un,{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(Un,{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(Un,{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(Un,{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(Un,{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(Un,{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(Un,{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(Un,{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(Un,{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:"Humidity High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when humidity exceeds threshold"})]}),l.jsx(Un,{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:"Temperature High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when temperature exceeds threshold"})]}),l.jsx(Un,{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.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(Un,{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(Un,{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(Ie,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[l.jsx(BR,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:l.jsx(kn,{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 XGe({provider:t,onClose:e}){const n=En(),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,w]=M.useState(t?.daily_digest_time||"08:00"),[A,T]=M.useState(t?.on_print_start??!1),[k,N]=M.useState(t?.on_print_complete??!0),[I,C]=M.useState(t?.on_print_failed??!0),[D,F]=M.useState(t?.on_print_stopped??!0),[j,q]=M.useState(t?.on_print_progress??!1),[R,W]=M.useState(t?.on_printer_offline??!1),[K,V]=M.useState(t?.on_printer_error??!1),[te,Y]=M.useState(t?.on_filament_low??!1),[Z,U]=M.useState(t?.on_maintenance_due??!1),[z,ee]=M.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([G,J])=>[G,String(J)])):{}),[ae,fe]=M.useState(null),[de,xe]=M.useState(null),{data:ye}=vt({queryKey:["printers"],queryFn:ke.getPrinters});M.useEffect(()=>{const G=J=>{J.key==="Escape"&&e()};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[e]);const re=_t({mutationFn:()=>ke.testNotificationConfig({provider_type:a,config:z}),onSuccess:G=>{fe(G),xe(null)},onError:G=>{fe({success:!1,message:G.message})}}),ve=_t({mutationFn:G=>ke.createNotificationProvider(G),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:G=>{xe(G.message)}}),je=_t({mutationFn:G=>ke.updateNotificationProvider(t.id,G),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:G=>{xe(G.message)}}),ue=G=>{if(G.preventDefault(),xe(null),!i.trim()){xe("Name is required");return}const J=H(a);for(const Pe of J)if(!z[Pe.key]?.trim()){xe(`${Pe.label} is required`);return}const le={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:te,on_maintenance_due:Z};r?je.mutate(le):ve.mutate(le)},ut=ve.isPending||je.isPending,$=G=>{switch(G){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},H=G=>$(G).filter(J=>J.required),ie=$(a);return 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(Gt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:ue,className:"p-6 space-y-4",children:[de&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:de}),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),ee({}),fe(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children: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"}),ie.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:J=>{ee({...z,[G.key]:J.target.value}),fe(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:G.options.map(J=>l.jsx("option",{value:J.value,children:J.label},J.value))}):l.jsx("input",{type:G.type,value:z[G.key]||"",onChange:J=>{ee({...z,[G.key]:J.target.value}),fe(null)},placeholder:G.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},G.key))]}),l.jsx("div",{className:"flex gap-2",children:l.jsxs(Ie,{type:"button",variant:"secondary",onClick:()=>{fe(null),re.mutate()},disabled:re.isPending||!z[H(a)[0]?.key],className:"flex-1",children:[re.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx($R,{className:"w-4 h-4"}),"Test Configuration"]})}),ae&&l.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ae.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:ae.success?l.jsxs(l.Fragment,{children:[l.jsx(ps,{className:"w-5 h-5"}),l.jsx("span",{children:ae.message})]}):l.jsxs(l.Fragment,{children:[l.jsx(Lc,{className:"w-5 h-5"}),l.jsx("span",{children:ae.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"}),ye?.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(Un,{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(Un,{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=>w(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(Un,{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(Un,{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(Un,{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(Un,{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(Un,{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(Un,{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(Un,{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(Un,{checked:te,onChange:Y})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),l.jsx(Un,{checked:Z,onChange:U})]})]})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Ie,{type:"submit",disabled:ut,className:"flex-1",children:[ut?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(ko,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function YGe({template:t,onClose:e}){const n=En(),r=M.useRef(null),[i,s]=M.useState(t.title_template),[a,o]=M.useState(t.body_template),[c,u]=M.useState(null),[d,f]=M.useState(!0),{data:g}=vt({queryKey:["template-variables"],queryFn:ke.getTemplateVariables}),m=g?.find(T=>T.event_type===t.event_type),{data:x,isLoading:y}=vt({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=_t({mutationFn:T=>ke.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),b=_t({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})},w=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(Gt,{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:()=>w(T),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[l.jsx(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(b0,{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(Ie,{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(Km,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),l.jsxs(Ie,{onClick:E,disabled:v.isPending||!A,children:[v.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin mr-2"}):l.jsx(ko,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const ZGe={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"},QGe={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 JGe({onClose:t}){const e=En(),{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}=vt({queryKey:["notification-logs",r,o],queryFn:()=>ke.getNotificationLogs({days:r,limit:100,success:o?!1:void 0})}),{data:m}=vt({queryKey:["notification-log-stats",r],queryFn:()=>ke.getNotificationLogStats(r)}),x=_t({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),w=new Date().getTime()-b.getTime();return w<6e4?"Just now":w<36e5?`${Math.floor(w/6e4)}m ago`:w<864e5?`${Math.floor(w/36e5)}h ago`:b.toLocaleDateString()+" "+b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[l.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(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(ps,{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(Lc,{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(Ie,{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(Ie,{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(kn,{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(e7e,{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 e7e({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(ps,{className:"w-4 h-4 text-bambu-green shrink-0"}):l.jsx(Lc,{className:"w-4 h-4 text-red-400 shrink-0"}),l.jsx("span",{className:`text-xs font-medium ${QGe[t.event_type]||"text-bambu-gray"}`,children:ZGe[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 K_=[{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(Ja,{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(Ea,{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 t7e({onClose:t,onExport:e}){const{t:n}=Vm(),[r,i]=M.useState(()=>{const x={};return K_.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={};K_.forEach(y=>{x[y.id]=!0}),i(x)},f=()=>{const x={};K_.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(kt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:l.jsxs(Dt,{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(Sa,{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(Gt,{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:K_.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(Un,{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(Ie,{variant:"secondary",onClick:t,disabled:o,children:n("common.cancel",{defaultValue:"Cancel"})}),l.jsx(Ie,{onClick:m,disabled:g===0||o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:o?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(Sa,{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 n7e({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 w=A=>{A.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[t,r]);const x=w=>{const A=w.target.files?.[0];A&&c(A)},y=async()=>{if(o){i("restoring");try{const w=await e(o,s);d(w),i("result"),w.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},v=w=>{g(A=>{const T=new Set(A);return T.has(w)?T.delete(w):T.add(w),T})},b=u?.restored?Object.values(u.restored).reduce((w,A)=>w+A,0)+(u.files_restored||0):0,E=u?.total_skipped||0;return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:w=>{w.target===w.currentTarget&&r!=="restoring"&&t()},children:l.jsx(kt,{className:"w-full max-w-lg",children:l.jsxs(Dt,{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(ps,{className:"w-5 h-5"}):r==="result"&&!u?.success?l.jsx(ti,{className:"w-5 h-5"}):l.jsx(ba,{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(Gt,{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(ps,{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(ba,{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(Un,{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(Ie,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),l.jsxs(Ie,{type:"button",onClick:y,disabled:!o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[l.jsx(ba,{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(([,w])=>w>0)&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(ps,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),l.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,w])=>w>0).map(([w,A])=>l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[l.jsx("span",{className:"text-white",children:fG[w]||w}),l.jsx("span",{className:"text-bambu-green font-medium",children:A})]},w)),(u.files_restored||0)>0&&l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[l.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),l.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,w])=>w>0)&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(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(([,w])=>w>0).map(([w,A])=>{const T=u.skipped_details?.[w]||[],k=f.has(w);return l.jsxs("div",{children:[l.jsxs("button",{onClick:()=>T.length>0&&v(w),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${T.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[l.jsxs("span",{className:"text-white flex items-center gap-2",children:[fG[w]||w,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"]})]})]},w)})})]}),b===0&&E===0&&l.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),l.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:l.jsx(Ie,{onClick:t,children:"Close"})})]})]})})})}async function r7e(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function i7e(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 s7e(){const t=En(),[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}=vt({queryKey:["spoolman-settings"],queryFn:r7e}),{data:y,isLoading:v,refetch:b}=vt({queryKey:["spoolman-status"],queryFn:ke.getSpoolmanStatus,refetchInterval:3e4}),{data:E}=vt({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(()=>{w.mutate()},500);return()=>clearTimeout(q)}},[e,r,s,f]);const w=_t({mutationFn:()=>i7e({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=_t({mutationFn:ke.connectSpoolman,onSuccess:()=>{b()}}),T=_t({mutationFn:ke.disconnectSpoolman,onSuccess:()=>{b()}}),k=_t({mutationFn:ke.syncAllPrintersAms,onSuccess:j=>{j.success}}),N=_t({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(kt,{children:[l.jsx($a,{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(Dt,{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(kt,{children:[l.jsx($a,{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"})]}),w.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(Dt,{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(Gt,{className:"w-4 h-4"}),"Disconnected"]})]}),l.jsx("div",{className:"flex gap-2",children:y?.connected?l.jsxs(Ie,{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(Ie,{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(Ie,{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 a7e({link:t,onClose:e}){const n=En(),{theme:r}=gb(),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,w]=M.useState(null);M.useEffect(()=>{const F=j=>{j.key==="Escape"&&e()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const A=_t({mutationFn:async F=>{const j=await ke.createExternalLink(F);return v?await ke.uploadExternalLinkIcon(j.id,v):j},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{w(F.message)}}),T=_t({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=>{w(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)){w("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(j.size>1024*1024){w("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(),w(null),!a.trim()){w("Name is required");return}if(!c.trim()){w("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){w("URL must start with http:// or https://");return}const 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(Gt,{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(kn,{className:"w-4 h-4"})})]}):l.jsxs(Ie,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[l.jsx(ba,{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($ue,{value:d,onChange:f})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Ie,{type:"submit",disabled:C,className:"flex-1",children:[C?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(ko,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function o7e(){const t=En(),[e,n]=M.useState(!1),[r,i]=M.useState(null),[s,a]=M.useState(null),[o,c]=M.useState(null),{data:u,isLoading:d}=vt({queryKey:["external-links"],queryFn:ke.getExternalLinks}),f=_t({mutationFn:E=>ke.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=_t({mutationFn:E=>ke.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=(E,w)=>{c(w),E.dataTransfer.effectAllowed="move"},x=E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},y=(E,w)=>{if(E.preventDefault(),o===null||o===w||!u)return;const A=u.map(I=>I.id),T=A.indexOf(o),k=A.indexOf(w);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(kt,{children:[l.jsx($a,{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(Ie,{size:"sm",onClick:()=>n(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Link"]})]})}),l.jsxs(Dt,{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 w=$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(w,{className:"w-4 h-4"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-white font-medium truncate",children:E.name}),l.jsx(ao,{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(kn,{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(a7e,{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 l7e(){const t=En(),{t:e,i18n:n}=Vm(),{showToast:r}=si(),[i,s]=M.useState(null),[a,o]=M.useState(!1),[c,u]=M.useState(null),[d,f]=M.useState(!1),[g,m]=M.useState(null),[x,y]=M.useState(null),[v,b]=M.useState(!1),[E,w]=M.useState(_7()),[A,T]=M.useState("general"),[k,N]=M.useState(!1),[I,C]=M.useState(""),[D,F]=M.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[j,q]=M.useState(null),[R,W]=M.useState(null),[K,V]=M.useState(!1),[te,Y]=M.useState(!1),[Z,U]=M.useState(null),[z,ee]=M.useState(!1),[ae,fe]=M.useState(!1),de=Q=>{w(Q),Wue(Q)},xe=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:ye,isLoading:re}=vt({queryKey:["settings"],queryFn:ke.getSettings}),{data:ve,isLoading:je}=vt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs}),{data:ue,isLoading:ut}=vt({queryKey:["smart-plugs-energy",ve?.map(Q=>Q.id)],queryFn:async()=>{if(!ve||ve.length===0)return null;const Q=await Promise.all(ve.filter(He=>He.enabled).map(async He=>{try{const ht=await ke.getSmartPlugStatus(He.id);return{plug:He,status:ht}}catch{return{plug:He,status:null}}}));let Fe=0,pe=0,Ue=0,Ce=0,_e=0;for(const{status:He}of Q)He?.reachable&&He.energy&&(_e++,He.energy.power!=null&&(Fe+=He.energy.power),He.energy.today!=null&&(pe+=He.energy.today),He.energy.yesterday!=null&&(Ue+=He.energy.yesterday),He.energy.total!=null&&(Ce+=He.energy.total));return{totalPower:Fe,totalToday:pe,totalYesterday:Ue,totalLifetime:Ce,reachableCount:_e,totalPlugs:ve.filter(He=>He.enabled).length}},enabled:A==="plugs"&&!!ve&&ve.length>0,refetchInterval:A==="plugs"?1e4:!1}),{data:$,isLoading:H}=vt({queryKey:["notification-providers"],queryFn:ke.getNotificationProviders}),{data:ie,isLoading:G}=vt({queryKey:["api-keys"],queryFn:ke.getAPIKeys,enabled:A==="apikeys"}),J=_t({mutationFn:Q=>ke.createAPIKey(Q),onSuccess:Q=>{q(Q.key||null),N(!1),C(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:Q=>{r(`Failed to create API key: ${Q.message}`,"error")}}),le=_t({mutationFn:Q=>ke.deleteAPIKey(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:Q=>{r(`Failed to delete API key: ${Q.message}`,"error")}}),{data:Pe}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:Ne,isLoading:Se}=vt({queryKey:["notification-templates"],queryFn:ke.getNotificationTemplates}),{data:B}=vt({queryKey:["ffmpeg-status"],queryFn:ke.checkFfmpeg}),{data:L}=vt({queryKey:["version"],queryFn:ke.getVersion}),{data:ne,refetch:be,isRefetching:we}=vt({queryKey:["updateCheck"],queryFn:ke.checkForUpdates,staleTime:300*1e3}),{data:ge,refetch:me}=vt({queryKey:["updateStatus"],queryFn:ke.getUpdateStatus,refetchInterval:Q=>{const Fe=Q.state.data;return Fe?.status==="downloading"||Fe?.status==="installing"?1e3:!1}}),Ae=_t({mutationFn:ke.applyUpdate,onSuccess:()=>{me()}}),[ze,st]=M.useState(null),Ve=_t({mutationFn:ke.testAllNotificationProviders,onSuccess:Q=>{st(Q),t.invalidateQueries({queryKey:["notification-providers"]}),Q.failed===0?r(`All ${Q.tested} providers tested successfully!`,"success"):r(`${Q.success}/${Q.tested} providers succeeded`,Q.failed>0?"error":"success")},onError:Q=>{r(`Failed to test providers: ${Q.message}`,"error")}}),ce=_t({mutationFn:async Q=>{if(!ve)return{success:0,failed:0};const Fe=ve.filter(Ue=>Ue.enabled),pe=await Promise.all(Fe.map(async Ue=>{try{return await ke.controlSmartPlug(Ue.id,Q),{success:!0}}catch{return{success:!1}}}));return{success:pe.filter(Ue=>Ue.success).length,failed:pe.filter(Ue=>!Ue.success).length}},onSuccess:(Q,Fe)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),Q.failed===0?r(`All ${Q.success} plugs turned ${Fe}`,"success"):r(`${Q.success} plugs turned ${Fe}, ${Q.failed} failed`,"error")},onError:Q=>{r(`Failed: ${Q.message}`,"error")}}),Ye=M.useRef(null),$e=M.useRef(!0);M.useEffect(()=>{ye&&!i&&(s(ye),setTimeout(()=>{$e.current=!1},100))},[ye,i]);const Ze=_t({mutationFn:ke.updateSettings,onSuccess:Q=>{t.setQueryData(["settings"],Q),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:Q=>{r(`Failed to save: ${Q.message}`,"error")}});M.useEffect(()=>{if(!($e.current||!i||!ye||!(ye.auto_archive!==i.auto_archive||ye.save_thumbnails!==i.save_thumbnails||ye.capture_finish_photo!==i.capture_finish_photo||ye.default_filament_cost!==i.default_filament_cost||ye.currency!==i.currency||ye.energy_cost_per_kwh!==i.energy_cost_per_kwh||ye.energy_tracking_mode!==i.energy_tracking_mode||ye.check_updates!==i.check_updates||ye.notification_language!==i.notification_language||ye.ams_humidity_good!==i.ams_humidity_good||ye.ams_humidity_fair!==i.ams_humidity_fair||ye.ams_temp_good!==i.ams_temp_good||ye.ams_temp_fair!==i.ams_temp_fair||ye.ams_history_retention_days!==i.ams_history_retention_days||ye.date_format!==i.date_format||ye.time_format!==i.time_format||ye.default_printer_id!==i.default_printer_id)))return Ye.current&&clearTimeout(Ye.current),Ye.current=setTimeout(()=>{Ze.mutate(i)},500),()=>{Ye.current&&clearTimeout(Ye.current)}},[i,ye,Ze]);const at=M.useCallback((Q,Fe)=>{s(pe=>pe?{...pe,[Q]:Fe}:null)},[]);return re||!i?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:()=>T("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${A==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),l.jsxs("button",{onClick:()=>T("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(Jp,{className:"w-4 h-4"}),"Smart Plugs",ve&&ve.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ve.length})]}),l.jsxs("button",{onClick:()=>T("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(wh,{className:"w-4 h-4"}),"Notifications",$&&$.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:$.length})]}),l.jsxs("button",{onClick:()=>T("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(Vp,{className:"w-4 h-4"}),"API Keys",ie&&ie.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ie.length})]})]}),A==="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(kt,{children:[l.jsx($a,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),l.jsxs(Dt,{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:Q=>n.changeLanguage(Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:T5.map(Q=>l.jsxs("option",{value:Q.code,children:[Q.nativeName," (",Q.name,")"]},Q.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:E,onChange:Q=>de(Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:M0.map(Q=>l.jsx("option",{value:Q.to,children:e(Q.labelKey)},Q.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:i.date_format||"system",onChange:Q=>at("date_format",Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[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:i.time_format||"system",onChange:Q=>at("time_format",Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[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:i.default_printer_id??"",onChange:Q=>at("default_printer_id",Q.target.value?Number(Q.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"No default (ask each time)"}),Pe?.map(Q=>l.jsx("option",{value:Q.id,children:Q.name},Q.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(Ie,{variant:"secondary",size:"sm",onClick:xe,children:[l.jsx(Km,{className:"w-4 h-4"}),"Reset"]})]})]})]}),l.jsxs(kt,{children:[l.jsx($a,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),l.jsxs(Dt,{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:i.auto_archive,onChange:Q=>at("auto_archive",Q.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:i.save_thumbnails,onChange:Q=>at("save_thumbnails",Q.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:i.capture_finish_photo,onChange:Q=>at("capture_finish_photo",Q.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.capture_finish_photo&&B&&!B.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(kt,{children:[l.jsx($a,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),l.jsxs(Dt,{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:i.default_filament_cost,onChange:Q=>at("default_filament_cost",parseFloat(Q.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),l.jsxs("select",{value:i.currency,onChange:Q=>at("currency",Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[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:i.energy_cost_per_kwh,onChange:Q=>at("energy_cost_per_kwh",parseFloat(Q.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),l.jsxs("select",{value:i.energy_tracking_mode||"total",onChange:Q=>at("energy_tracking_mode",Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[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:i.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(kt,{children:[l.jsx($a,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),l.jsxs(Dt,{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:i.ams_humidity_good??40,onChange:Q=>at("ams_humidity_good",parseInt(Q.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),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:i.ams_humidity_fair??60,onChange:Q=>at("ams_humidity_fair",parseInt(Q.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),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:i.ams_temp_good??28,onChange:Q=>at("ams_temp_good",parseFloat(Q.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),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:i.ams_temp_fair??35,onChange:Q=>at("ams_temp_fair",parseFloat(Q.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),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:i.ams_history_retention_days??30,onChange:Q=>at("ams_history_retention_days",parseInt(Q.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),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(s7e,{}),l.jsx(o7e,{})]}),l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[l.jsxs(kt,{children:[l.jsx($a,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),l.jsxs(Dt,{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:i.check_updates,onChange:Q=>at("check_updates",Q.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",L?.version||"..."]})]}),l.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>be(),disabled:we,children:[we?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Cs,{className:"w-4 h-4"}),"Check now"]})]}),ne?.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",ne.latest_version]}),ne.release_name&&ne.release_name!==ne.latest_version&&l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:ne.release_name}),ne.release_notes&&l.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:ne.release_notes})]}),ne.release_url&&l.jsx("a",{href:ne.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:l.jsx(ao,{className:"w-4 h-4"})})]}),ge?.status==="downloading"||ge?.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:ge.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:`${ge.progress}%`}})})]}):ge?.status==="complete"?l.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:ge.message}):ge?.status==="error"?l.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:ge.error||ge.message}):l.jsxs(Ie,{className:"mt-3",onClick:()=>Ae.mutate(),disabled:Ae.isPending,children:[Ae.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Sa,{className:"w-4 h-4"}),"Install Update"]})]}):ne?.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: ",ne.error]}):ne&&!ne.update_available?l.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),l.jsxs(kt,{children:[l.jsx($a,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),l.jsxs(Dt,{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(Ie,{variant:"secondary",size:"sm",onClick:()=>ee(!0),children:[l.jsx(Sa,{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(Ie,{variant:"secondary",size:"sm",onClick:()=>fe(!0),children:[l.jsx(ba,{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(Ie,{variant:"secondary",size:"sm",onClick:()=>V(!0),children:[l.jsx(kn,{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(Ie,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[l.jsx(kn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),A==="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:[ve&&ve.filter(Q=>Q.enabled).length>1&&l.jsxs(l.Fragment,{children:[l.jsxs(Ie,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>U("on"),disabled:ce.isPending,title:"Turn all plugs on",children:[ce.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(Ie,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>U("off"),disabled:ce.isPending,title:"Turn all plugs off",children:[ce.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(Ie,{className:"whitespace-nowrap",onClick:()=>{u(null),o(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ve&&ve.length>0&&l.jsxs(kt,{className:"mb-6",children:[l.jsx($a,{children:l.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[l.jsx(xm,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",ut&&l.jsx(At,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),l.jsx(Dt,{children:ue?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(xm,{className:"w-3 h-3"}),"Current Power"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[ue.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:[ue.reachableCount,"/",ue.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:[ue.totalToday.toFixed(2),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ue.totalToday*i.energy_cost_per_kwh).toFixed(2)," ",i.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:[ue.totalYesterday.toFixed(2),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ue.totalYesterday*i.energy_cost_per_kwh).toFixed(2)," ",i.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:[ue.totalLifetime.toFixed(1),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ue.totalLifetime*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]})]}):ut?null:l.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),je?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ve&&ve.length>0?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ve.map(Q=>l.jsx(GGe,{plug:Q,onEdit:Fe=>{u(Fe),o(!0)}},Q.id))}):l.jsx(kt,{children:l.jsx(Dt,{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(Ie,{onClick:()=>{u(null),o(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),A==="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(Ie,{size:"sm",variant:"secondary",onClick:()=>b(!0),children:[l.jsx(N3,{className:"w-4 h-4"}),"Log"]}),$&&$.length>0&&l.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>{st(null),Ve.mutate()},disabled:Ve.isPending,children:[Ve.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx($R,{className:"w-4 h-4"}),"Test All"]}),l.jsxs(Ie,{size:"sm",onClick:()=>{m(null),f(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add"]})]})]}),l.jsx(kt,{className:"mb-4",children:l.jsx(Dt,{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:i.notification_language||"en",onChange:Q=>at("notification_language",Q.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:T5.map(Q=>l.jsx("option",{value:Q.code,children:Q.nativeName},Q.code))})]})})}),ze&&l.jsx(kt,{className:"mb-4",children:l.jsxs(Dt,{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:()=>st(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(ps,{className:"w-4 h-4"}),ze.success," passed"]}),ze.failed>0&&l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(Lc,{className:"w-4 h-4"}),ze.failed," failed"]})]}),ze.results.filter(Q=>!Q.success).length>0&&l.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:ze.results.filter(Q=>!Q.success).map(Q=>l.jsxs("div",{className:"text-xs text-red-400",children:[l.jsxs("span",{className:"font-medium",children:[Q.provider_name,":"]})," ",Q.message]},Q.provider_id))})]})}),H?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):$&&$.length>0?l.jsx("div",{className:"space-y-3",children:$.map(Q=>l.jsx(KGe,{provider:Q,onEdit:Fe=>{m(Fe),f(!0)}},Q.id))}):l.jsx(kt,{children:l.jsx(Dt,{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(Ie,{size:"sm",onClick:()=>{m(null),f(!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(Ja,{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."}),Se?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Ne&&Ne.length>0?l.jsx("div",{className:"space-y-2",children:Ne.map(Q=>l.jsx(kt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>y(Q),children:l.jsx(Dt,{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:Q.name}),l.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:Q.title_template})]}),l.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:Fe=>{Fe.stopPropagation(),y(Q)},children:l.jsx(BR,{className:"w-4 h-4 text-bambu-gray"})})]})})},Q.id))}):l.jsx(kt,{children:l.jsx(Dt,{className:"py-8",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(Ja,{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."})]})})})]})]}),A==="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(Ie,{size:"sm",onClick:()=>N(!0),className:"flex-shrink-0",children:[l.jsx(pr,{className:"w-4 h-4"}),"Create Key"]})]}),j&&l.jsx(kt,{className:"mb-6 border-bambu-green",children:l.jsx(Dt,{className:"py-4",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(ps,{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:j}),l.jsx(Ie,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(j);else{const Q=document.createElement("textarea");Q.value=j,Q.style.position="fixed",Q.style.left="-999999px",document.body.appendChild(Q),Q.select(),document.execCommand("copy"),document.body.removeChild(Q)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:l.jsx(Hh,{className:"w-4 h-4"})})]}),l.jsx(Ie,{variant:"secondary",size:"sm",className:"mt-3",onClick:()=>q(null),children:"Dismiss"})]})]})})}),k&&l.jsxs(kt,{className:"mb-6",children:[l.jsx($a,{children:l.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),l.jsxs(Dt,{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:I,onChange:Q=>C(Q.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),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:D.can_read_status,onChange:Q=>F(Fe=>({...Fe,can_read_status:Q.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),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:D.can_queue,onChange:Q=>F(Fe=>({...Fe,can_queue:Q.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),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:D.can_control_printer,onChange:Q=>F(Fe=>({...Fe,can_control_printer:Q.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),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(Ie,{onClick:()=>J.mutate({name:I||"Unnamed Key",...D}),disabled:J.isPending,children:[J.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(pr,{className:"w-4 h-4"}),"Create Key"]}),l.jsx(Ie,{variant:"secondary",onClick:()=>N(!1),children:"Cancel"})]})]})]}),G?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ie&&ie.length>0?l.jsx("div",{className:"space-y-3",children:ie.map(Q=>l.jsx(kt,{children:l.jsx(Dt,{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 ${Q.enabled?"text-bambu-green":"text-bambu-gray"}`}),l.jsxs("div",{children:[l.jsx("p",{className:"text-white font-medium",children:Q.name}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[Q.key_prefix,"••••••••",Q.last_used&&` · Last used: ${new Date(Q.last_used).toLocaleDateString()}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex gap-1 text-xs",children:[Q.can_read_status&&l.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),Q.can_queue&&l.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),Q.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(Ie,{variant:"secondary",size:"sm",onClick:()=>W(Q.id),children:l.jsx(kn,{className:"w-4 h-4 text-red-400"})})]})]})})},Q.id))}):l.jsx(kt,{children:l.jsx(Dt,{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(Ie,{onClick:()=>N(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),l.jsxs(kt,{className:"mt-6",children:[l.jsx($a,{children:l.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),l.jsxs(Dt,{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"})]})]})]})]})]}),R!==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:()=>{le.mutate(R),W(null)},onCancel:()=>W(null)}),a&&l.jsx(WGe,{plug:c,onClose:()=>{o(!1),u(null)}}),d&&l.jsx(XGe,{provider:g,onClose:()=>{f(!1),m(null)}}),x&&l.jsx(YGe,{template:x,onClose:()=>y(null)}),v&&l.jsx(JGe,{onClose:()=>b(!1)}),K&&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()=>{V(!1);try{const Q=await ke.clearNotificationLogs(30);r(Q.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>V(!1)}),te&&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:()=>{Y(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>Y(!1)}),Z&&l.jsx(Qr,{title:`Turn All Plugs ${Z==="on"?"On":"Off"}`,message:`This will turn ${Z==="on"?"ON":"OFF"} all ${ve?.filter(Q=>Q.enabled).length||0} enabled smart plugs. ${Z==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${Z==="on"?"On":"Off"}`,variant:Z==="off"?"danger":"warning",onConfirm:()=>{const Q=Z;U(null),ce.mutate(Q)},onCancel:()=>U(null)}),z&&l.jsx(t7e,{onClose:()=>ee(!1),onExport:async Q=>{ee(!1);try{const{blob:Fe,filename:pe}=await ke.exportBackup(Q),Ue=URL.createObjectURL(Fe),Ce=document.createElement("a");Ce.href=Ue,Ce.download=pe,Ce.click(),URL.revokeObjectURL(Ue),r("Backup downloaded","success")}catch{r("Failed to create backup","error")}}}),ae&&l.jsx(n7e,{onClose:()=>fe(!1),onRestore:async(Q,Fe)=>await ke.importBackup(Q,Fe),onSuccess:()=>{t.invalidateQueries()}})]})}const fte=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},c7e=t=>t.startsWith("HH")?"HF":"S",u7e=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=c7e(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(mm,{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?u7e(t.nozzle_id):"HH00"),[w,A]=M.useState(t?.nozzle_diameter||n),[T,k]=M.useState(t?[t.extruder_id]:i?[0,1]:[0]),[N,I]=M.useState(!1),[C,D]=M.useState({current:0,total:0}),[F,j]=M.useState(s),q=mr.useMemo(()=>{const Z=new Map;for(const U of r)if(U.filament_id&&!Z.has(U.filament_id)){const z=wR(U.name||"");Z.set(U.filament_id,{id:U.filament_id,name:z||U.filament_id})}return Array.from(Z.values()).sort((U,z)=>U.name.localeCompare(z.name))},[r]),R=_t({mutationFn:Z=>(console.log("[KProfile] Calling API..."),ke.setKProfile(e,Z)),onSuccess:Z=>{if(console.log("[KProfile] Save success:",Z),d("K-profile saved"),u&&F!==s){let U;F===""&&a?U=a:t&&t.slot_id>0?U=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:U=`name_${f}_${y}`,u(U,F)}I(!0),setTimeout(()=>{I(!1),c()},2500)},onError:Z=>{console.error("[KProfile] Save error:",Z),d(Z.message,"error"),I(!1)}}),W=_t({mutationFn:Z=>(console.log("[KProfile] Deleting profile..."),ke.deleteKProfile(e,Z)),onSuccess:Z=>{console.log("[KProfile] Delete success:",Z),d("K-profile deleted"),I(!0),setTimeout(()=>{I(!1),o()},4e3)},onError:Z=>{console.error("[KProfile] Delete error:",Z),d(Z.message,"error"),I(!1)}}),[K,V]=M.useState(!1),te=()=>{t&&W.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},Y=async Z=>{if(Z.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const U=parseFloat(m).toFixed(6),z=`${b}-${w}`;if(t||T.length===1){const ae={name:f,k_value:U,filament_id:y,nozzle_id:z,nozzle_diameter:w,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ae),R.mutate(ae);return}I(!0),D({current:1,total:T.length});const ee=T.map(ae=>({name:f,k_value:U,filament_id:y,nozzle_id:z,nozzle_diameter:w,extruder_id:ae,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ee.length} profiles in batch:`,ee);try{if(await ke.setKProfilesBatch(e,ee),d(`K-profile saved to ${T.length} extruders`),u&&F){const ae=`name_${f}_${y}`;u(ae,F)}}catch(ae){console.error("[KProfile] Failed to save batch:",ae),d("Failed to save K-profiles","error"),I(!1),D({current:0,total:0});return}D({current:T.length,total:T.length}),setTimeout(()=>{I(!1),D({current:0,total:0}),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(kt,{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(Dt,{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(Gt,{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:Z=>g(Z.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),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:Z=>{const U=Z.target.value;(U===""||/^\d*\.?\d*$/.test(U))&&x(U)},onBlur:Z=>{const U=parseFloat(Z.target.value);isNaN(U)||x((Math.trunc(U*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),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:Z=>{const U=Z.target.value;if(v(U),!t&&U&&!f){const z=q.find(ee=>ee.id===U);z&&g(`${b==="HH00"?"HF":"S"} ${z.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[l.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&l.jsx("option",{value:t.filament_id,children:q.find(Z=>Z.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(Z=>l.jsx("option",{value:Z.id,children:Z.name},Z.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:Z=>{const U=Z.target.value;if(E(U),!t&&y&&!f){const z=q.find(ee=>ee.id===y);z&&g(`${U==="HS00"?"HF":"S"} ${z.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[l.jsx("option",{value:"HH00",children:"High Flow"}),l.jsx("option",{value:"HS00",children:"Standard"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),l.jsxs("select",{value:w,onChange:Z=>A(Z.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[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:Z=>{Z.target.checked?k([...T,1]):k(T.filter(U=>U!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),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:Z=>{Z.target.checked?k([...T,0]):k(T.filter(U=>U!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),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:Z=>j(Z.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),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(Ie,{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(kn,{className:"w-4 h-4"})}),l.jsx(Ie,{type:"button",variant:"secondary",onClick:o,disabled:N,className:"flex-1",children:"Cancel"}),l.jsxs(Ie,{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(kt,{className:"w-full max-w-sm",children:l.jsxs(Dt,{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(kn,{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(Ie,{variant:"secondary",onClick:()=>V(!1),className:"flex-1",children:"Cancel"}),l.jsxs(Ie,{onClick:()=>{V(!1),te()},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(kn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const X_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function d7e(){const{showToast:t}=si(),[e,n]=M.useState(null),[r,i]=M.useState(()=>localStorage.getItem(X_.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(X_.SORT_OPTION)||"name"),[w,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(X_.NOZZLE_DIAMETER,r)},[r]),M.useEffect(()=>{localStorage.setItem(X_.SORT_OPTION,b)},[b]);const{data:j,isLoading:q}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:R,isLoading:W,isFetching:K,error:V,refetch:te}=vt({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}=vt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>ke.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:Z,refetch:U}=vt({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(J=>J.is_active);G&&n(G.id)}},[e,j]),M.useEffect(()=>{if(e){const G=setTimeout(()=>{te()},150);return()=>clearTimeout(G)}},[e,r]);const ee=j?.filter(G=>G.is_active)||[],ae=mr.useMemo(()=>R?.profiles?R.profiles.filter(J=>{const le=f.toLowerCase(),Pe=!le||J.name.toLowerCase().includes(le)||J.filament_id.toLowerCase().includes(le),Ne=m==="all"||m==="left"&&J.extruder_id===1||m==="right"&&J.extruder_id===0,Se=y==="all"||y==="hf"&&J.nozzle_id.startsWith("HH")||y==="s"&&J.nozzle_id.startsWith("HS");return Pe&&Ne&&Se}).sort((J,le)=>{switch(b){case"k_value":return parseFloat(J.k_value)-parseFloat(le.k_value);case"filament":return wR(J.name).localeCompare(wR(le.name));case"name":default:return J.name.localeCompare(le.name)}}):[],[R?.profiles,f,m,y,b]),fe=j?.find(G=>G.id===e),de=fe?.nozzle_count===2;M.useEffect(()=>{const G=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||s||o||u||(J.key==="r"||J.key==="R"?(J.preventDefault(),te()):J.key==="n"||J.key==="N"?(J.preventDefault(),c(!0)):J.key==="Escape"&&w&&(J.preventDefault(),A(!1),k(new Set)))};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[s,o,u,w,te]);const xe=M.useCallback(()=>{if(!R?.profiles||R.profiles.length===0){t("No profiles to export","error");return}const G={version:1,exported_at:new Date().toISOString(),printer:fe?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(Ne=>({name:Ne.name,k_value:Ne.k_value,filament_id:Ne.filament_id,nozzle_id:Ne.nozzle_id,nozzle_diameter:Ne.nozzle_diameter,extruder_id:Ne.extruder_id}))},J=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),le=URL.createObjectURL(J),Pe=document.createElement("a");Pe.href=le,Pe.download=`kprofiles_${fe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Pe),Pe.click(),document.body.removeChild(Pe),URL.revokeObjectURL(le),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,fe,r,t]),ye=M.useCallback(()=>{const G=document.createElement("input");G.type="file",G.accept=".json",G.onchange=async J=>{const le=J.target.files?.[0];if(le)try{const Pe=await le.text(),Ne=JSON.parse(Pe);if(!Ne.profiles||!Array.isArray(Ne.profiles)){t("Invalid file format","error");return}let Se=0;for(const B of Ne.profiles)if(!(!B.name||!B.k_value||!B.filament_id))try{await 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 ${Ne.profiles.length} profiles`),te()}catch(Pe){console.error("Import error:",Pe),t("Failed to parse import file","error")}},G.click()},[e,r,t,te]),re=M.useCallback(G=>{k(J=>{const le=new Set(J);return le.has(G)?le.delete(G):le.add(G),le})},[]),ve=M.useCallback(()=>{k(new Set(ae.map(G=>F(G))))},[ae,F]),je=M.useCallback(()=>{T.size!==0&&I(!0)},[T.size]),ue=M.useCallback(async()=>{const G=ae.filter(le=>T.has(F(le)));D(!0);let J=0;for(const le of G)try{await ke.deleteKProfile(e,{slot_id:le.slot_id,extruder_id:le.extruder_id,nozzle_id:le.nozzle_id,nozzle_diameter:le.nozzle_diameter,filament_id:le.filament_id,setting_id:le.setting_id}),J++,await new Promise(Pe=>setTimeout(Pe,300))}catch(Pe){console.error("Failed to delete profile:",le.name,Pe)}t(`Deleted ${J} profiles`),D(!1),I(!1),A(!1),k(new Set),te()},[e,T,ae,t,te,F]),ut=M.useCallback(G=>{const J=[];return G.setting_id&&J.push(G.setting_id),J.push(`slot_${G.slot_id}_${G.filament_id}_${G.extruder_id}`),J.push(`name_${G.name}_${G.filament_id}`),J},[]),$=M.useCallback(async(G,J)=>{if(e)try{await ke.setKProfileNote(e,G,J),U()}catch(le){console.error("Failed to save note:",le),t("Failed to save note","error")}},[e,U,t]),H=M.useCallback(G=>{if(!Z?.notes)return{note:"",key:null};const J=ut(G);for(const le of J)if(Z.notes[le])return{note:Z.notes[le],key:le};return{note:"",key:null}},[Z,ut]),ie=M.useCallback(G=>H(G).note,[H]);return q?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(kt,{children:l.jsxs(Dt,{className:"py-12 text-center",children:[l.jsx(Io,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),l.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ee.length===0?l.jsx(kt,{children:l.jsxs(Dt,{className:"py-12 text-center",children:[l.jsx(Ea,{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:ee.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(Ie,{variant:"secondary",onClick:()=>te(),disabled:K,children:[l.jsx(Cs,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),l.jsxs(Ie,{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"})]}),de&&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(Ie,{variant:"secondary",onClick:xe,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[l.jsx(Sa,{className:"w-4 h-4"}),"Export"]}),l.jsxs(Ie,{variant:"secondary",onClick:ye,title:"Import profiles from JSON",children:[l.jsx(ba,{className:"w-4 h-4"}),"Import"]}),l.jsx("div",{className:"flex-1"}),w?l.jsxs(l.Fragment,{children:[l.jsxs(Ie,{variant:"secondary",onClick:ve,title:"Select all visible profiles",children:[l.jsx(Vh,{className:"w-4 h-4"}),"Select All"]}),l.jsxs(Ie,{variant:"secondary",onClick:je,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[l.jsx(kn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),l.jsxs(Ie,{variant:"secondary",onClick:()=>{A(!1),k(new Set)},children:[l.jsx(Gt,{className:"w-4 h-4"}),"Cancel"]})]}):l.jsxs(Ie,{variant:"secondary",onClick:()=>A(!0),disabled:!ae.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(kt,{children:l.jsxs(Dt,{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(Ie,{variant:"secondary",onClick:()=>te(),children:[l.jsx(Cs,{className:"w-4 h-4"}),"Retry"]})]})}):ae.length>0?de?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:ae.filter(G=>G.extruder_id===1).map(G=>l.jsx(d3,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:w,isSelected:T.has(F(G)),onToggleSelect:()=>re(F(G)),note:ie(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:ae.filter(G=>G.extruder_id===0).map(G=>l.jsx(d3,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:w,isSelected:T.has(F(G)),onToggleSelect:()=>re(F(G)),note:ie(G)},F(G)))})]})]}):l.jsx("div",{className:"space-y-1",children:ae.map(G=>l.jsx(d3,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:w,isSelected:T.has(F(G)),onToggleSelect:()=>re(F(G)),note:ie(G)},F(G)))}):f||m!=="all"||y!=="all"?l.jsx(kt,{children:l.jsxs(Dt,{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(kt,{children:l.jsxs(Dt,{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(Ie,{onClick:()=>c(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),s&&e&&(()=>{const{note:G,key:J}=H(s);return l.jsx(h3,{profile:s,printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:de,initialNote:G,initialNoteKey:J,onSaveNote:$,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),a(null),te()},onSave:()=>{a(null),te()}})})(),o&&e&&l.jsx(h3,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:de,onSaveNote:$,onClose:()=>{c(!1),te()},onSave:()=>{c(!1),te()}}),u&&e&&l.jsx(h3,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:de,onSaveNote:$,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),te()},onSave:()=>{d(null),te()}}),N&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(kt,{className:"w-full max-w-sm",children:l.jsxs(Dt,{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(kn,{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(Ie,{variant:"secondary",onClick:()=>I(!1),disabled:C,className:"flex-1",children:"Cancel"}),l.jsxs(Ie,{onClick:ue,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(kn,{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 db(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function h7e(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 f7e({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=_t({mutationFn:()=>ke.cloudLogin(i,a,g),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),r("code")):e(w.message,"error")},onError:w=>e(w.message,"error")}),y=_t({mutationFn:()=>ke.cloudVerify(i,c),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),v=_t({mutationFn:()=>ke.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),b=w=>{w.preventDefault(),n==="email"?x.mutate():n==="code"?y.mutate():n==="token"&&v.mutate()},E=x.isPending||y.isPending||v.isPending;return l.jsx(kt,{className:"max-w-md mx-auto",children:l.jsxs(Dt,{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:w=>s(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),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:w=>o(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),l.jsxs("select",{value:g,onChange:w=>m(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"global",children:"Global"}),l.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),l.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),l.jsx("input",{type:"text",value:c,onChange:w=>u(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),l.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),l.jsx("textarea",{value:d,onChange:w=>f(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),l.jsxs("div",{className:"flex gap-2",children:[n==="code"&&l.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),l.jsxs(Ie,{type:"submit",disabled:E,className:"flex-1",children:[E?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(K5,{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(K5,{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 p7e(){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=db(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 m7e({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:s}=si(),a=En(),[o,c]=M.useState(!1),{data:u,isLoading:d}=vt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ke.getCloudSettingDetail(t.setting_id)}),f=_t({mutationFn:()=>ke.deleteCloudSetting(t.setting_id),onSuccess:()=>{s("Preset deleted"),a.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>s(x.message,"error")}),g=db(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(kt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:l.jsxs(Dt,{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(Gt,{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(Ie,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),l.jsxs(Ie,{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(kn,{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(Ie,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),l.jsxs(Ie,{variant:"secondary",onClick:r,children:[l.jsx(Hh,{className:"w-4 h-4"}),"Duplicate"]}),g&&l.jsxs(l.Fragment,{children:[l.jsxs(Ie,{variant:"secondary",onClick:i,disabled:d||!u,children:[l.jsx(rd,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Ie,{variant:"danger",onClick:()=>c(!0),children:l.jsx(kn,{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 g7e({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),w=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:Ea,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(kt,{className:"w-full max-w-md",children:l.jsxs(Dt,{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(Ie,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),l.jsxs(Ie,{onClick:()=>T(b),className:"flex-1 bg-red-500 hover:bg-red-600",children:[l.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),l.jsx(kt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:l.jsxs(Dt,{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(S0,{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(Gt,{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:w.length===0?l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(S0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),l.jsx("p",{children:"No templates yet"}),l.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):l.jsx("div",{className:"space-y-2",children:w.map(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(Ie,{size:"sm",onClick:N,disabled:!u.trim(),children:[l.jsx(ko,{className:"w-4 h-4"}),"Save"]}),l.jsx(Ie,{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(b0,{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(kn,{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,w=y in n;let A;!E&&w?A="added":E&&!w?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(kt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:l.jsxs(Dt,{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(Gt,{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 x7e({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=si(),i=En(),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,w]=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),[te,Y]=M.useState(""),[Z,U]=M.useState(""),[z,ee]=M.useState(!0),[ae,fe]=M.useState(null),[de,xe]=M.useState(!1),ye=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),re=M.useMemo(()=>ye.filter(ce=>db(ce.setting_id)),[ye]),{data:ve}=vt({queryKey:["cloudFields",c],queryFn:()=>ke.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:je}=vt({queryKey:["allPresetDetails",c,re.map(ce=>ce.setting_id).join(",")],queryFn:async()=>{const ce={};for(let $e=0;$e<re.length;$e+=5){const Ze=re.slice($e,$e+5);(await Promise.all(Ze.map(async Q=>{try{const Fe=await ke.getCloudSettingDetail(Q.setting_id);return{id:Q.setting_id,detail:Fe}}catch{return null}}))).forEach(Q=>{Q&&(ce[Q.id]=Q.detail)})}return ce},enabled:re.length>0,staleTime:1e3*60*10}),{data:ue,isLoading:ut}=vt({queryKey:["cloudSettingDetail",g],queryFn:()=>ke.getCloudSettingDetail(g),enabled:!!g});M.useEffect(()=>{a!=="json"&&w(JSON.stringify(v,null,2))},[v,a]);const $=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(Ye=>!db(Ye.setting_id)).sort((Ye,$e)=>Ye.name.localeCompare($e.name)),[n,c]);M.useEffect(()=>{if(!g)return;const ce=$.find(Ye=>Ye.setting_id===g);ce&&(y(ce.name),s||(b({inherits:ce.name}),w(JSON.stringify({inherits:ce.name},null,2))))},[g,$,s]);const H=M.useMemo(()=>{const ce=ve?.fields||[],Ye=new Set(ce.map(Q=>Q.key)),$e=new Set,Ze=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);je&&Object.values(je).forEach(Q=>{Q?.setting&&Object.keys(Q.setting).forEach(Fe=>{!Ye.has(Fe)&&!Ze.has(Fe)&&$e.add(Fe)})}),Object.keys(v).forEach(Q=>{!Ye.has(Q)&&!Ze.has(Q)&&$e.add(Q)});const at=Array.from($e).sort().map(Q=>({key:Q,label:Q.replace(/_/g," ").replace(/\b\w/g,Fe=>Fe.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ce,...at]},[ve,je,v]),ie=H.filter(ce=>ce.label.toLowerCase().includes(k.toLowerCase())||ce.key.toLowerCase().includes(k.toLowerCase())),G=()=>{if(D.trim()){const ce=D.trim().toLowerCase().replace(/\s+/g,"_");J(ce,""),F(""),q(!1),r(`Field "${ce}" added`)}},J=(ce,Ye)=>{b($e=>{const Ze={...$e};return Ye===""||Ye===void 0?delete Ze[ce]:Ze[ce]=Ye,Ze})},le=ce=>{b(Ye=>({...Ye,...ce.settings})),fe(ce.name),r("Template applied")},Pe=()=>{if(!te.trim())return;const ce={...v};if(delete ce.inherits,Object.keys(ce).length===0){r("No overrides to save","error");return}const Ye={id:Date.now().toString(),name:te.trim(),description:Z.trim()||"Custom template",type:c,settings:ce,showInModal:z},$e=[...R,Ye];W($e),mte($e),V(!1),Y(""),U(""),ee(!0),r("Template saved")},Ne=M.useMemo(()=>R.filter(ce=>ce.type===c&&ce.showInModal),[c,R]),Se=ce=>{w(ce);try{const Ye=JSON.parse(ce);b(Ye),T(null)}catch(Ye){T(Ye.message)}},B=ce=>{ce.preventDefault(),C(!1);const Ye=ce.dataTransfer.files[0];if(Ye&&Ye.name.endsWith(".json")){const $e=new FileReader;$e.onload=Ze=>{try{const at=Ze.target?.result,Q=JSON.parse(at),Fe=Q.setting||Q;b(pe=>({...pe,...Fe})),w(JSON.stringify({...v,...Fe},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},$e.readAsText(Ye)}},L=_t({mutationFn:()=>{const ce={...v},Ye=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";ce[Ye]=`"${d}"`;const $e={type:c,name:d,base_id:g,setting:ce};return ke.createCloudSetting($e)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ce=>r(ce.message,"error")}),ne=_t({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return 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:ce=>r(ce.message,"error")}),be=s?ne:L,we=ue?.setting?.inherits,ge=we?$.find(ce=>ce.name===we):void 0,{data:me}=vt({queryKey:["cloudSettingDetail",ge?.setting_id],queryFn:()=>ke.getCloudSettingDetail(ge.setting_id),enabled:!!ge?.setting_id}),Ae=M.useMemo(()=>{const ce=me?.setting||{},Ye=ue?.setting||{},$e=g&&je?.[g]?.setting?je[g].setting:{};return{...ce,...Ye,...$e}},[g,ue,me,je]),ze=ce=>{if(ce==null)return"";if(Array.isArray(ce)){const Ye=[...new Set(ce.map($e=>String($e)))];return Ye.length===1?Ye[0]:ce.join(", ")}return String(ce)},st=ce=>{const Ye=v[ce.key],$e=Ae[ce.key],Ze=ze($e),at=ut?"Loading...":Ze||"",Q="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(ce.type==="boolean"){const Fe=Ye==="1"||Ye===void 0&&$e==="1";return l.jsx("button",{type:"button",onClick:()=>J(ce.key,Ye==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Fe?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:l.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Fe?"translate-x-3.5":"translate-x-0.5"}`})})}return ce.type==="select"?l.jsxs("select",{value:Ye||"",onChange:Fe=>J(ce.key,Fe.target.value),className:Q,children:[l.jsx("option",{value:"",children:at}),ce.options?.map(Fe=>l.jsx("option",{value:Fe.value,children:Fe.label},Fe.value))]}):l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:ce.type==="number"?"number":"text",value:Ye!==void 0?String(Ye):"",onChange:Fe=>J(ce.key,Fe.target.value),step:ce.step,min:ce.min,max:ce.max,placeholder:at,className:Q}),ce.unit&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ce.unit})]})},Ve=M.useMemo(()=>ue?.setting?ue.setting:{},[ue]);return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ce=>{ce.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:B,children:[de&&g&&l.jsx(gte,{onClose:()=>xe(!1),leftPreset:Ve,rightPreset:v,leftLabel:`Base: ${x||g}`,rightLabel:`Current: ${d||"New Preset"}`}),l.jsx(kt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:l.jsxs(Dt,{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(Gt,{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(ba,{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:ce=>{u(ce.target.value),m("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[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:ce=>m(ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"Select base preset..."}),$.map(ce=>l.jsx("option",{value:ce.setting_id,children:ce.name},ce.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:ce=>f(ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&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}),ut&&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(X5,{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(Io,{className:"w-3 h-3 text-red-400"})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("button",{onClick:()=>{const ce={name:d,type:c,base_id:g,setting:v},Ye=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),$e=URL.createObjectURL(Ye),Ze=document.createElement("a");Ze.href=$e,Ze.download=`${d||"preset"}.json`,document.body.appendChild(Ze),Ze.click(),document.body.removeChild(Ze),URL.revokeObjectURL($e),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[l.jsx(Sa,{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(ba,{className:"w-4 h-4"}),"Import"]}),l.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ce=>{const Ye=ce.target.files?.[0];if(Ye){const $e=new FileReader;$e.onload=Ze=>{try{const at=JSON.parse(Ze.target?.result),Q=at.setting||at;b(Fe=>({...Fe,...Q})),r("File imported")}catch{r("Invalid JSON","error")}},$e.readAsText(Ye)}}})]}),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(S0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(v).filter(ce=>ce!=="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(ko,{className:"w-3 h-3"}),"Save as template"]})]}),K&&l.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[l.jsx("input",{type:"text",value:te,onChange:ce=>Y(ce.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx("input",{type:"text",value:Z,onChange:ce=>U(ce.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Ie,{size:"sm",onClick:Pe,disabled:!te.trim(),children:[l.jsx(ko,{className:"w-3 h-3"}),"Save"]}),l.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]}),l.jsxs("button",{onClick:()=>ee(!z),className:`flex items-center gap-1.5 text-xs transition-colors ${z?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[z?l.jsx(b0,{className:"w-3.5 h-3.5"}):l.jsx(LR,{className:"w-3.5 h-3.5"}),z?"Show in modals":"Hidden in modals"]})]})]}),ae&&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:ae})]}),l.jsx("button",{onClick:()=>fe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:l.jsx(Gt,{className:"w-4 h-4"})})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ne.map(ce=>l.jsxs("button",{onClick:()=>le(ce),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[l.jsx("p",{className:"text-sm font-medium text-white",children:ce.name}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ce.description})]},ce.id)),Ne.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(ce=>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:ce.label}),l.jsx("div",{className:"w-48",children:st(ce)})]},ce.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(([ce])=>ce!=="inherits").map(([ce,Ye])=>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:[ce,": ",String(Ye).slice(0,20),l.jsx("button",{onClick:()=>J(ce,void 0),className:"hover:text-white",children:l.jsx(Gt,{className:"w-3 h-3"})})]},ce))})]})]}),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:je?`${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:ce=>N(ce.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[ie.filter(ce=>!(ce.key in v)).map(ce=>{const Ye=Ae[ce.key],$e=ze(Ye);return l.jsxs("div",{onClick:()=>{b(Ze=>({...Ze,[ce.key]:$e||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-sm text-white truncate",children:ce.label}),l.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ce.key})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[$e&&l.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:$e,children:[$e.slice(0,20),$e.length>20?"...":""]}),l.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:l.jsx(pr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ce.key)}),ie.filter(ce=>!(ce.key in v)).length===0&&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:ce=>F(ce.target.value),onKeyDown:ce=>ce.key==="Enter"&&G(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx(Ie,{size:"sm",onClick:G,disabled:!D.trim(),children:l.jsx(pr,{className:"w-4 h-4"})}),l.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>{q(!1),F("")},children:l.jsx(Gt,{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(ce=>ce!=="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(([ce])=>ce!=="inherits").map(([ce,Ye])=>{const $e=H.find(Ze=>Ze.key===ce);return l.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-white",children:$e?.label||ce}),l.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ce})]}),l.jsx("button",{onClick:()=>J(ce,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(Gt,{className:"w-4 h-4"})})]}),$e?st($e):l.jsx("input",{type:"text",value:String(Ye),onChange:Ze=>J(ce,Ze.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},ce)}),Object.keys(v).filter(ce=>ce!=="inherits").length===0&&l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(X5,{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(ce=>ce!=="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(ko,{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(Io,{className:"w-4 h-4"}),A]}),l.jsx("textarea",{value:E,onChange:ce=>Se(ce.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),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(Ie,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),l.jsxs(Ie,{onClick:()=>be.mutate(),disabled:be.isPending||!d.trim()||!s&&!g||!!A,className:"flex-1",children:[be.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):s?l.jsx(ko,{className:"w-4 h-4"}):l.jsx(pr,{className:"w-4 h-4"}),s?"Save":e?"Duplicate":"Create"]})]})]})})]})}function b7e({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"),[w,A]=M.useState(null),[T,k]=M.useState(!1),[N,I]=M.useState(!1),[C,D]=M.useState(null),[F,j]=M.useState(null),[q,R]=M.useState(null),[W,K]=M.useState(!1),[V,te]=M.useState([null,null]),[Y,Z]=M.useState(!1),[U,z]=M.useState(null),ee=En(),ae=M.useMemo(()=>[...t.filament.map(ie=>({...ie,type:"filament"})),...t.printer.map(ie=>({...ie,type:"printer"})),...t.process.map(ie=>({...ie,type:"process"}))].map(ie=>({...ie,meta:mL(ie.name)})),[t]),fe=M.useMemo(()=>{const H=new Set,ie=new Set,G=new Set;return ae.forEach(J=>{J.meta.nozzle&&H.add(J.meta.nozzle),J.meta.filamentType&&ie.add(J.meta.filamentType),J.meta.layerHeight&&G.add(J.meta.layerHeight)}),{printers:i.map(J=>({id:J.id.toString(),name:J.name})),nozzles:Array.from(H).sort((J,le)=>parseFloat(J)-parseFloat(le)),filaments:Array.from(ie).sort(),layerHeights:Array.from(G).sort((J,le)=>parseFloat(J)-parseFloat(le))}},[ae,i]),de=M.useMemo(()=>f==="all"?null:i.find(ie=>ie.id.toString()===f)?.model||null,[f,i]),xe=M.useMemo(()=>ae.filter(H=>o==="all"||H.type===o).filter(H=>{if(u==="all")return!0;const ie=db(H.setting_id);return u==="custom"?ie:!ie}).filter(H=>{if(f==="all"||!de)return!0;const ie=H.meta.printer?.toLowerCase()||"",G=de.toLowerCase();return ie.includes(G)||G.includes(ie)}).filter(H=>m==="all"||H.meta.nozzle===m).filter(H=>y==="all"||H.meta.filamentType===y).filter(H=>b==="all"||H.meta.layerHeight===b).filter(H=>s===""||H.name.toLowerCase().includes(s.toLowerCase())).sort((H,ie)=>H.name.localeCompare(ie.name)),[ae,o,u,f,de,m,y,b,s]),ye=H=>{if(W){const ie=V[0]?.setting_id===H.setting_id,G=V[1]?.setting_id===H.setting_id;if(ie)te([V[1],null]);else if(G)te([V[0],null]);else if(!V[0])te([H,null]);else if(V[1]){if(V[0].type!==H.type)return;te([V[0],H])}else{if(V[0].type!==H.type)return;te([V[0],H])}}else A(H)},re=H=>{if(V[0]?.setting_id===H.setting_id)return 0;if(V[1]?.setting_id===H.setting_id)return 1},ve=async H=>{try{const ie=await ke.getCloudSettingDetail(H.setting_id),G=H.type==="process"?"print":H.type;D({type:G,name:H.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{}}),A(null)}catch(ie){console.error("Failed to fetch preset details for duplication:",ie)}},je=async H=>{try{ee.removeQueries({queryKey:["cloudSettingDetail",H.setting_id]});const ie=await ke.getCloudSettingDetail(H.setting_id),G=H.type==="process"?"print":H.type;j({type:G,name:H.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{},setting_id:H.setting_id}),A(null)}catch(ie){console.error("Failed to fetch preset details for editing:",ie)}},ue=()=>{c("all"),d("all"),g("all"),x("all"),v("all"),E("all"),a("")},ut=o!=="all"||u!=="all"||f!=="all"||m!=="all"||y!=="all"||b!=="all"||s!=="",$=t.filament.length+t.printer.length+t.process.length;return 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(Ie,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),te([null,null])):K(!0)},children:[l.jsx(Qp,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),l.jsxs(Ie,{variant:"secondary",onClick:()=>I(!0),children:[l.jsx(S0,{className:"w-4 h-4"}),"Templates"]}),l.jsxs(Ie,{variant:"secondary",onClick:n,disabled:r,children:[l.jsx(Cs,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),l.jsxs(Ie,{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)}),fe.printers.length>0&&l.jsx(Lp,{label:"Printer",value:f,options:[{value:"all",label:"All"},...fe.printers.map(H=>({value:H.id,label:H.name}))],onChange:g}),fe.nozzles.length>0&&l.jsx(Lp,{label:"Nozzle",value:m,options:[{value:"all",label:"All"},...fe.nozzles.map(H=>({value:H,label:H}))],onChange:x}),fe.filaments.length>0&&(o==="all"||o==="filament")&&l.jsx(Lp,{label:"Filament",value:y,options:[{value:"all",label:"All"},...fe.filaments.map(H=>({value:H,label:H}))],onChange:v}),fe.layerHeights.length>0&&(o==="all"||o==="process")&&l.jsx(Lp,{label:"Layer",value:b,options:[{value:"all",label:"All"},...fe.layerHeights.map(H=>({value:H,label:H}))],onChange:E}),ut&&l.jsx("button",{onClick:ue,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(Ie,{size:"sm",onClick:async()=>{try{const[H,ie]=await Promise.all([ke.getCloudSettingDetail(V[0].setting_id),ke.getCloudSettingDetail(V[1].setting_id)]);z([H.setting||{},ie.setting||{}]),Z(!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: ",h7e(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"}),ut&&l.jsx("button",{onClick:ue,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:()=>ye(H),onDuplicate:()=>ve(H),compareMode:W,isCompareSelected:re(H)!==void 0,compareIndex:re(H),compareDisabled:W&&!!V[0]&&V[0].type!==H.type},H.setting_id)),xe.filter(H=>H.type==="filament").length===0&&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:()=>ye(H),onDuplicate:()=>ve(H),compareMode:W,isCompareSelected:re(H)!==void 0,compareIndex:re(H),compareDisabled:W&&!!V[0]&&V[0].type!==H.type},H.setting_id)),xe.filter(H=>H.type==="process").length===0&&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(Ea,{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:()=>ye(H),onDuplicate:()=>ve(H),compareMode:W,isCompareSelected:re(H)!==void 0,compareIndex:re(H),compareDisabled:W&&!!V[0]&&V[0].type!==H.type},H.setting_id)),xe.filter(H=>H.type==="printer").length===0&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),w&&l.jsx(m7e,{setting:w,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>ve(w),onEdit:()=>je(w)}),(T||C||F||q)&&l.jsx(x7e,{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(g7e,{onClose:()=>I(!1),onApply:H=>{R({type:H.type,setting:H.settings}),I(!1)}}),Y&&U&&V[0]&&V[1]&&l.jsx(gte,{onClose:()=>{Z(!1),z(null)},leftPreset:U[0],rightPreset:U[1],leftLabel:V[0].name,rightLabel:V[1].name})]})}function v7e(){const t=En(),{showToast:e}=si(),[n,r]=M.useState("cloud"),[i,s]=M.useState(),{data:a,isLoading:o}=vt({queryKey:["cloudStatus"],queryFn:ke.getCloudStatus}),{data:c=[]}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=vt({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=_t({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(Ie,{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(b7e,{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(Ie,{onClick:()=>f(),children:"Retry"})]}):l.jsx(f7e,{onSuccess:x})]}),n==="kprofiles"&&l.jsx(d7e,{}),l.jsx(p7e,{})]})}const $x={Droplet:jR,Flame:ule,Ruler:Ice,Sparkles:S0,Square:mm,Cable:ooe,Wrench:sd,Calendar:Zr,Timer:Fu,Cog:Ioe,Fan:Joe,Zap:xm,Wind:Rue,Thermometer:Sh,Layers:$h,Box:fm,Target:d7,RefreshCw:Cs,Settings:VR,Filter:IR,CircleDot:Moe};function h0(t){return t&&$x[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 y7e({item:t,onPerform:e,onToggle:n}){const r=h0(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(Un,{checked:t.enabled,onChange:f=>n(t.id,f)}),l.jsxs(Ie,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[l.jsx(Km,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function _7e({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(kt,{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(Ie,{size:"sm",onClick:g,children:"Save"}),l.jsx(Ie,{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(w0,{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=h0(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(Dt,{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(y7e,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function w7e({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,w]=M.useState("hours"),[A,T]=M.useState("Wrench"),[k,N]=M.useState(null),[I,C]=M.useState(""),[D,F]=M.useState(""),[j,q]=M.useState("hours"),[R,W]=M.useState("Wrench"),K=ee=>{N(ee),C(ee.name),F(ee.default_interval_hours.toString()),q(ee.interval_type||"hours"),W(ee.icon||"Wrench")},V=()=>{k&&I.trim()&&parseFloat(D)>0&&(i(k.id,{name:I.trim(),default_interval_hours:parseFloat(D),interval_type:j,icon:R}),N(null))},te=(ee,ae,fe)=>{const de=parseFloat(c);if(!isNaN(de)&&de>0){const xe=Math.abs(de-ae)<.01?null:de;n(ee,{custom_interval_hours:xe,custom_interval_type:d!==fe?d:null})}o(null)},Y=ee=>{ee.preventDefault(),x.trim()&&parseFloat(v)>0&&(r({name:x.trim(),default_interval_hours:parseFloat(v),interval_type:E,icon:A}),y(""),b("100"),w("hours"),m(!1))},Z=t?.map(ee=>({printerId:ee.printer_id,printerName:ee.printer_name,items:ee.maintenance_items.sort((ae,fe)=>ae.maintenance_type_id-fe.maintenance_type_id)})).sort((ee,ae)=>ee.printerName.localeCompare(ae.printerName))||[],U=e.filter(ee=>ee.is_system),z=e.filter(ee=>!ee.is_system);return 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(Ie,{onClick:()=>m(!g),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),g&&l.jsx(kt,{className:"mb-6",children:l.jsx(Dt,{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:ee=>y(ee.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),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:ee=>{w(ee.target.value),ee.target.value==="days"?b("30"):b("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[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:ee=>b(ee.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),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($x).map(ee=>{const ae=$x[ee];return l.jsx("button",{type:"button",onClick:()=>T(ee),className:`p-2 rounded-lg transition-colors ${A===ee?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:l.jsx(ae,{className:"w-4 h-4"})},ee)})})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),l.jsx(Ie,{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(ee=>{const ae=h0(ee.icon),fe=ee.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(ae,{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:ee.name}),l.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[fe==="days"?l.jsx(Zr,{className:"w-3 h-3"}):l.jsx(Fu,{className:"w-3 h-3"}),p3(ee.default_interval_hours,fe)]})]})]})},ee.id)}),z.map(ee=>{const ae=h0(ee.icon),fe=ee.interval_type||"hours";return k?.id===ee.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($x).map(xe=>{const ye=$x[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(ye,{className:"w-3.5 h-3.5"})},xe)})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ie,{size:"sm",onClick:V,disabled:!I.trim(),children:"Save"}),l.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>N(null),children:"Cancel"})]})]})},ee.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(ae,{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:ee.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:[fe==="days"?l.jsx(Zr,{className:"w-3 h-3"}):l.jsx(Fu,{className:"w-3 h-3"}),p3(ee.default_interval_hours,fe)]})]}),l.jsx("button",{onClick:()=>K(ee),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:l.jsx(w0,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>{confirm(`Delete "${ee.name}"?`)&&s(ee.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(kn,{className:"w-4 h-4"})})]})},ee.id)})]})]}),Z.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:Z.map(ee=>l.jsx(kt,{children:l.jsxs(Dt,{className:"py-4",children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:ee.printerName}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:ee.items.map(ae=>{const fe=h0(ae.maintenance_type_icon),de=e.find(je=>je.id===ae.maintenance_type_id),xe=de?.default_interval_hours||ae.interval_hours,ye=de?.interval_type||"hours",re=ae.interval_type||"hours",ve=a===ae.id;return l.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[l.jsx(fe,{className:"w-4 h-4 text-bambu-gray shrink-0"}),l.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:ae.maintenance_type_name}),ve?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:je=>f(je.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]}),l.jsx("input",{type:"number",value:c,onChange:je=>u(je.target.value),onKeyDown:je=>{je.key==="Enter"&&te(ae.id,xe,ye),je.key==="Escape"&&o(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),l.jsx(Ie,{size:"sm",onClick:()=>te(ae.id,xe,ye),children:"OK"})]}):l.jsxs("button",{onClick:()=>{o(ae.id),u(ae.interval_hours.toString()),f(re)},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors flex items-center gap-1",children:[re==="days"?l.jsx(Zr,{className:"w-3 h-3"}):l.jsx(Fu,{className:"w-3 h-3"}),p3(ae.interval_hours,re),l.jsx(w0,{className:"w-3 h-3 text-bambu-gray"})]})]},ae.id)})})]})},ee.printerId))})]}),Z.length===0&&l.jsx(kt,{children:l.jsxs(Dt,{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 S7e(){const t=En(),{showToast:e}=si(),[n,r]=M.useState("status"),{data:i,isLoading:s}=vt({queryKey:["maintenanceOverview"],queryFn:ke.getMaintenanceOverview}),{data:a}=vt({queryKey:["maintenanceTypes"],queryFn:ke.getMaintenanceTypes}),o=_t({mutationFn:({id:E,notes:w})=>ke.performMaintenance(E,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:E=>{e(E.message,"error")}}),c=_t({mutationFn:({id:E,data:w})=>ke.updateMaintenanceItem(E,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:E=>{e(E.message,"error")}}),u=_t({mutationFn:ke.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:E=>{e(E.message,"error")}}),d=_t({mutationFn:({id:E,data:w})=>ke.updateMaintenanceType(E,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:E=>{e(E.message,"error")}}),f=_t({mutationFn:ke.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:E=>{e(E.message,"error")}}),g=_t({mutationFn:({printerId:E,hours:w})=>ke.setPrinterHours(E,w),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,w)=>{c.mutate({id:E,data:{enabled:w}})},y=(E,w)=>{g.mutate({printerId:E,hours:w})};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,w)=>E+w.due_count,0)||0,b=i?.reduce((E,w)=>E+w.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,w)=>{const A=E.due_count*10+E.warning_count,T=w.due_count*10+w.warning_count;return A!==T?T-A:E.printer_name.localeCompare(w.printer_name)}).map(E=>l.jsx(_7e,{overview:E,onPerform:m,onToggle:x,onSetHours:y},E.printer_id)):l.jsx(kt,{children:l.jsxs(Dt,{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(w7e,{overview:i,types:a||[],onUpdateInterval:(E,w)=>c.mutate({id:E,data:w}),onAddType:E=>u.mutate(E),onUpdateType:(E,w)=>d.mutate({id:E,data:w}),onDeleteType:E=>f.mutate(E)})]})}const pG=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function E7e({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(Ie,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),l.jsx(Ie,{type:"submit",disabled:!i.trim()||r,children:r?l.jsx(At,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function M7e({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(kt,{className:"hover:border-bambu-gray/30 transition-colors cursor-pointer",onClick:e,children:l.jsxs(Dt,{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(Ie,{variant:"ghost",size:"sm",onClick:n,className:"p-1",children:l.jsx(w0,{className:"w-4 h-4"})}),l.jsx(Ie,{variant:"ghost",size:"sm",onClick:r,className:"p-1 text-red-400 hover:text-red-300",children:l.jsx(kn,{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(_0,{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 A7e(){const t=En(),{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}=vt({queryKey:["projects",a==="all"?void 0:a],queryFn:()=>ke.getProjects(a==="all"?void 0:a)}),g=_t({mutationFn:A=>ke.createProject(A),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),e("Project created","success")},onError:A=>{e(A.message,"error")}}),m=_t({mutationFn:({id:A,data:T})=>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=_t({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)},w=()=>{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(Ie,{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(kt,{children:l.jsxs(Dt,{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(M7e,{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:w,onCancel:()=>u(null)}),n&&l.jsx(E7e,{project:i,onClose:()=>{r(!1),s(void 0)},onSave:y,isLoading:g.isPending||m.isPending})]})}function T7e(){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}=vt({queryKey:["printer",e],queryFn:()=>ke.getPrinter(e),enabled:e>0});M.useEffect(()=>(v&&(document.title=`${v.name} - Camera`),()=>{document.title="Bambuddy"}),[v]),M.useEffect(()=>()=>{x.current&&(x.current.src="")},[]),M.useEffect(()=>{if(a&&!d){const C=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(C)}},[n,a,c,d]),M.useEffect(()=>{const I=()=>{m(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",I),()=>document.removeEventListener("fullscreenchange",I)},[]);const b=()=>{s(!0),o(!1)},E=()=>{o(!1),s(!1)},w=I=>{n===I||d||(f(!0),o(!0),s(!1),x.current&&(x.current.src=""),setTimeout(()=>{r(I),u(Date.now()),f(!1)},100))},A=()=>{d||(f(!0),o(!0),s(!1),x.current&&(x.current.src=""),setTimeout(()=>{u(Date.now()),f(!1)},100))},T=()=>{y.current&&(document.fullscreenElement?document.exitFullscreen():y.current.requestFullscreen())},k=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,N=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(x0,{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:()=>w("stream"),disabled:N,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),l.jsx("button",{onClick:()=>w("snapshot"),disabled:N,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),l.jsx("button",{onClick:A,disabled:N,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:l.jsx(Cs,{className:`w-4 h-4 text-bambu-gray ${N?"animate-spin":""}`})}),l.jsx("button",{onClick:T,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:A,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),l.jsx("img",{ref:x,src:k,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:k?b:void 0,onLoad:k?E:void 0},c)]})})]}):l.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:l.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function C7e(){const{id:t}=LG(),{theme:e}=gb(),{data:n,isLoading:r,error:i}=vt({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(kt,{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 N7e(){const{t}=Vm(),{data:e,isLoading:n,refetch:r,isFetching:i}=vt({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:Lc,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:Ea,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:Ea,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:my,children:l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsx(Ur,{icon:my,label:t("system.cores","Cores"),value:e.cpu.count,subValue:`${e.cpu.count_logical} logical`}),l.jsx(Ur,{icon:my,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:my,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 k7e(){const t=M.useRef(null),e=M.useRef(null),n=En(),[r,i]=M.useState(!1),s=M.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const u=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,d=new WebSocket(u);let f=null;d.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),f=window.setInterval(()=>{d.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"}))},3e4)},d.onmessage=g=>{try{const m=JSON.parse(g.data);a(m)}catch{}},d.onclose=g=>{console.log("[WebSocket] Closed",g.code,g.reason),f&&(clearInterval(f),f=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{s()},3e3)},d.onerror=g=>{console.error("[WebSocket] Error",g),d.close()},t.current=d},[]),a=M.useCallback(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}},[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 P7e=new Cae({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function R7e({children:t}){return k7e(),l.jsx(l.Fragment,{children:t})}function D7e(){return l.jsx(zue,{children:l.jsx(Yue,{children:l.jsx(Nae,{client:P7e,children:l.jsx(R7e,{children:l.jsx(Yse,{children:l.jsxs(Tse,{children:[l.jsx(ha,{path:"/camera/:printerId",element:l.jsx(T7e,{})}),l.jsxs(ha,{path:"/",element:l.jsx(que,{}),children:[l.jsx(ha,{index:!0,element:l.jsx(vCe,{})}),l.jsx(ha,{path:"archives",element:l.jsx(GVe,{})}),l.jsx(ha,{path:"queue",element:l.jsx(kGe,{})}),l.jsx(ha,{path:"stats",element:l.jsx(VGe,{})}),l.jsx(ha,{path:"profiles",element:l.jsx(v7e,{})}),l.jsx(ha,{path:"maintenance",element:l.jsx(S7e,{})}),l.jsx(ha,{path:"projects",element:l.jsx(A7e,{})}),l.jsx(ha,{path:"settings",element:l.jsx(l7e,{})}),l.jsx(ha,{path:"system",element:l.jsx(N7e,{})}),l.jsx(ha,{path:"external/:id",element:l.jsx(C7e,{})})]})]})})})})})})}Pre.createRoot(document.getElementById("root")).render(l.jsx(M.StrictMode,{children:l.jsx(D7e,{})}));
|