| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611 |
- function wre(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var hv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function fo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var yA={exports:{}},rx={};var Q5;function Sre(){if(Q5)return rx;Q5=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var s=null;if(a!==void 0&&(s=""+a),i.key!==void 0&&(s=""+i.key),"key"in i){a={};for(var o in i)o!=="key"&&(a[o]=i[o])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:s,ref:i!==void 0?i:null,props:a}}return rx.Fragment=e,rx.jsx=n,rx.jsxs=n,rx}var J5;function Mre(){return J5||(J5=1,yA.exports=Sre()),yA.exports}var l=Mre(),vA={exports:{}},en={};var eF;function Ere(){if(eF)return en;eF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function 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(){}},v=Object.assign,y={};function b(U,$,X){this.props=U,this.context=$,this.refs=y,this.updater=X||x}b.prototype.isReactComponent={},b.prototype.setState=function(U,$){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,$,"setState")},b.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function M(){}M.prototype=b.prototype;function S(U,$,X){this.props=U,this.context=$,this.refs=y,this.updater=X||x}var A=S.prototype=new M;A.constructor=S,v(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,$,X){var te=X.ref;return{$$typeof:t,type:U,key:$,ref:te!==void 0?te:null,props:X}}function D(U,$){return C(U.type,$,U.props)}function F(U){return typeof U=="object"&&U!==null&&U.$$typeof===t}function O(U){var $={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(X){return $[X]})}var q=/\/+/g;function R(U,$){return typeof U=="object"&&U!==null&&U.key!=null?O(""+U.key):$.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($){U.status==="pending"&&(U.status="fulfilled",U.value=$)},function($){U.status==="pending"&&(U.status="rejected",U.reason=$)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function K(U,$,X,te,fe){var pe=typeof U;(pe==="undefined"||pe==="boolean")&&(U=null);var xe=!1;if(U===null)xe=!0;else switch(pe){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),$,X,te,fe)}}if(xe)return fe=fe(U),xe=te===""?"."+R(U,0):te,T(fe)?(X="",xe!=null&&(X=xe.replace(q,"$&/")+"/"),K(fe,$,X,"",function(be){return be})):fe!=null&&(F(fe)&&(fe=D(fe,X+(fe.key==null||U&&U.key===fe.key?"":(""+fe.key).replace(q,"$&/")+"/")+xe)),$.push(fe)),1;xe=0;var Ne=te===""?".":te+":";if(T(U))for(var ie=0;ie<U.length;ie++)te=U[ie],pe=Ne+R(te,ie),xe+=K(te,$,X,pe,fe);else if(ie=m(U),typeof ie=="function")for(U=ie.call(U),ie=0;!(te=U.next()).done;)te=te.value,pe=Ne+R(te,ie++),xe+=K(te,$,X,pe,fe);else if(pe==="object"){if(typeof U.then=="function")return K(W(U),$,X,te,fe);throw $=String(U),Error("Objects are not valid as a React child (found: "+($==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":$)+"). If you meant to render a collection of children, use an array instead.")}return xe}function G(U,$,X){if(U==null)return U;var te=[],fe=0;return K(U,te,"","",function(pe){return $.call(X,pe,fe++)}),te}function ee(U){if(U._status===-1){var $=U._result;$=$(),$.then(function(X){(U._status===0||U._status===-1)&&(U._status=1,U._result=X)},function(X){(U._status===0||U._status===-1)&&(U._status=2,U._result=X)}),U._status===-1&&(U._status=0,U._result=$)}if(U._status===1)return U._result.default;throw U._result}var Z=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var $=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($))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",U);return}console.error(U)},Q={map:G,forEach:function(U,$,X){G(U,function(){$.apply(this,arguments)},X)},count:function(U){var $=0;return G(U,function(){$++}),$},toArray:function(U){return G(U,function($){return $})||[]},only:function(U){if(!F(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return en.Activity=f,en.Children=Q,en.Component=b,en.Fragment=n,en.Profiler=i,en.PureComponent=S,en.StrictMode=r,en.Suspense=c,en.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,en.__COMPILER_RUNTIME={__proto__:null,c:function(U){return N.H.useMemoCache(U)}},en.cache=function(U){return function(){return U.apply(null,arguments)}},en.cacheSignal=function(){return null},en.cloneElement=function(U,$,X){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var te=v({},U.props),fe=U.key;if($!=null)for(pe in $.key!==void 0&&(fe=""+$.key),$)!I.call($,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&$.ref===void 0||(te[pe]=$[pe]);var pe=arguments.length-2;if(pe===1)te.children=X;else if(1<pe){for(var xe=Array(pe),Ne=0;Ne<pe;Ne++)xe[Ne]=arguments[Ne+2];te.children=xe}return C(U.type,fe,te)},en.createContext=function(U){return U={$$typeof:s,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:a,_context:U},U},en.createElement=function(U,$,X){var te,fe={},pe=null;if($!=null)for(te in $.key!==void 0&&(pe=""+$.key),$)I.call($,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(fe[te]=$[te]);var xe=arguments.length-2;if(xe===1)fe.children=X;else if(1<xe){for(var Ne=Array(xe),ie=0;ie<xe;ie++)Ne[ie]=arguments[ie+2];fe.children=Ne}if(U&&U.defaultProps)for(te in xe=U.defaultProps,xe)fe[te]===void 0&&(fe[te]=xe[te]);return C(U,pe,fe)},en.createRef=function(){return{current:null}},en.forwardRef=function(U){return{$$typeof:o,render:U}},en.isValidElement=F,en.lazy=function(U){return{$$typeof:d,_payload:{_status:-1,_result:U},_init:ee}},en.memo=function(U,$){return{$$typeof:u,type:U,compare:$===void 0?null:$}},en.startTransition=function(U){var $=N.T,X={};N.T=X;try{var te=U(),fe=N.S;fe!==null&&fe(X,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(k,Z)}catch(pe){Z(pe)}finally{$!==null&&X.types!==null&&($.types=X.types),N.T=$}},en.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},en.use=function(U){return N.H.use(U)},en.useActionState=function(U,$,X){return N.H.useActionState(U,$,X)},en.useCallback=function(U,$){return N.H.useCallback(U,$)},en.useContext=function(U){return N.H.useContext(U)},en.useDebugValue=function(){},en.useDeferredValue=function(U,$){return N.H.useDeferredValue(U,$)},en.useEffect=function(U,$){return N.H.useEffect(U,$)},en.useEffectEvent=function(U){return N.H.useEffectEvent(U)},en.useId=function(){return N.H.useId()},en.useImperativeHandle=function(U,$,X){return N.H.useImperativeHandle(U,$,X)},en.useInsertionEffect=function(U,$){return N.H.useInsertionEffect(U,$)},en.useLayoutEffect=function(U,$){return N.H.useLayoutEffect(U,$)},en.useMemo=function(U,$){return N.H.useMemo(U,$)},en.useOptimistic=function(U,$){return N.H.useOptimistic(U,$)},en.useReducer=function(U,$,X){return N.H.useReducer(U,$,X)},en.useRef=function(U){return N.H.useRef(U)},en.useState=function(U){return N.H.useState(U)},en.useSyncExternalStore=function(U,$,X){return N.H.useSyncExternalStore(U,$,X)},en.useTransition=function(){return N.H.useTransition()},en.version="19.2.0",en}var tF;function Vm(){return tF||(tF=1,vA.exports=Ere()),vA.exports}var E=Vm();const mr=fo(E),Are=wre({__proto__:null,default:mr},[E]);var _A={exports:{}},ix={},wA={exports:{}},SA={};var nF;function Tre(){return nF||(nF=1,(function(t){function e(K,G){var ee=K.length;K.push(G);e:for(;0<ee;){var Z=ee-1>>>1,Q=K[Z];if(0<i(Q,G))K[Z]=G,K[ee]=Q,ee=Z;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var G=K[0],ee=K.pop();if(ee!==G){K[0]=ee;e:for(var Z=0,Q=K.length,U=Q>>>1;Z<U;){var $=2*(Z+1)-1,X=K[$],te=$+1,fe=K[te];if(0>i(X,ee))te<Q&&0>i(fe,X)?(K[Z]=fe,K[te]=ee,Z=te):(K[Z]=X,K[$]=ee,Z=$);else if(te<Q&&0>i(fe,ee))K[Z]=fe,K[te]=ee,Z=te;else break e}}return G}function i(K,G){var ee=K.sortIndex-G.sortIndex;return ee!==0?ee:K.id-G.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var s=Date,o=s.now();t.unstable_now=function(){return s.now()-o}}var c=[],u=[],d=1,f=null,g=3,m=!1,x=!1,v=!1,y=!1,b=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function A(K){for(var G=n(u);G!==null;){if(G.callback===null)r(u);else if(G.startTime<=K)r(u),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(u)}}function T(K){if(v=!1,A(K),!x)if(n(c)!==null)x=!0,k||(k=!0,O());else{var G=n(u);G!==null&&W(T,G.startTime-K)}}var k=!1,N=-1,I=5,C=-1;function D(){return y?!0:!(t.unstable_now()-C<I)}function F(){if(y=!1,k){var K=t.unstable_now();C=K;var G=!0;try{e:{x=!1,v&&(v=!1,M(N),N=-1),m=!0;var ee=g;try{t:{for(A(K),f=n(c);f!==null&&!(f.expirationTime>K&&D());){var Z=f.callback;if(typeof Z=="function"){f.callback=null,g=f.priorityLevel;var Q=Z(f.expirationTime<=K);if(K=t.unstable_now(),typeof Q=="function"){f.callback=Q,A(K),G=!0;break t}f===n(c)&&r(c),A(K)}else r(c);f=n(c)}if(f!==null)G=!0;else{var U=n(u);U!==null&&W(T,U.startTime-K),G=!1}}break e}finally{f=null,g=ee,m=!1}G=void 0}}finally{G?O():k=!1}}}var O;if(typeof S=="function")O=function(){S(F)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,R=q.port2;q.port1.onmessage=F,O=function(){R.postMessage(null)}}else O=function(){b(F,0)};function W(K,G){N=b(function(){K(t.unstable_now())},G)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):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 G=3;break;default:G=g}var ee=g;g=G;try{return K()}finally{g=ee}},t.unstable_requestPaint=function(){y=!0},t.unstable_runWithPriority=function(K,G){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var ee=g;g=K;try{return G()}finally{g=ee}},t.unstable_scheduleCallback=function(K,G,ee){var Z=t.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?Z+ee:Z):ee=Z,K){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=ee+Q,K={id:d++,callback:G,priorityLevel:K,startTime:ee,expirationTime:Q,sortIndex:-1},ee>Z?(K.sortIndex=ee,e(u,K),n(c)===null&&K===n(u)&&(v?(M(N),N=-1):v=!0,W(T,ee-Z))):(K.sortIndex=Q,e(c,K),x||m||(x=!0,k||(k=!0,O()))),K},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(K){var G=g;return function(){var ee=g;g=G;try{return K.apply(this,arguments)}finally{g=ee}}}})(SA)),SA}var rF;function Cre(){return rF||(rF=1,wA.exports=Tre()),wA.exports}var MA={exports:{}},ia={};var iF;function Nre(){if(iF)return ia;iF=1;var t=Vm();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return ia.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ia.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return a(c,u,null,d)},ia.flushSync=function(c){var u=s.T,d=r.p;try{if(s.T=null,r.p=2,c)return c()}finally{s.T=u,r.p=d,r.d.f()}},ia.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},ia.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ia.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin),g=typeof u.integrity=="string"?u.integrity:void 0,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})}},ia.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=o(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},ia.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},ia.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=o(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},ia.requestFormReset=function(c){r.d.r(c)},ia.unstable_batchedUpdates=function(c,u){return c(u)},ia.useFormState=function(c,u,d){return s.H.useFormState(c,u,d)},ia.useFormStatus=function(){return s.H.useHostTransitionStatus()},ia.version="19.2.0",ia}var aF;function b9(){if(aF)return MA.exports;aF=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),MA.exports=Nre(),MA.exports}var sF;function kre(){if(sF)return ix;sF=1;var t=Cre(),e=Vm(),n=b9();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 a(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 s(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(a(h)!==h)throw Error(r(188))}function u(h){var p=h.alternate;if(!p){if(p=a(h),p===null)throw Error(r(188));return p!==h?null:h}for(var _=h,w=p;;){var P=_.return;if(P===null)break;var j=P.alternate;if(j===null){if(w=P.return,w!==null){_=w;continue}break}if(P.child===j.child){for(j=P.child;j;){if(j===_)return c(P),h;if(j===w)return c(P),p;j=j.sibling}throw Error(r(188))}if(_.return!==w.return)_=P,w=j;else{for(var Y=!1,le=P.child;le;){if(le===_){Y=!0,_=P,w=j;break}if(le===w){Y=!0,w=P,_=j;break}le=le.sibling}if(!Y){for(le=j.child;le;){if(le===_){Y=!0,_=j,w=P;break}if(le===w){Y=!0,w=j,_=P;break}le=le.sibling}if(!Y)throw Error(r(189))}}if(_.alternate!==w)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:p}function d(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h;for(h=h.child;h!==null;){if(p=d(h),p!==null)return p;h=h.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),S=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function O(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 v:return"Fragment";case b:return"Profiler";case y:return"StrictMode";case T:return"Suspense";case k:return"SuspenseList";case C:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case S:return h.displayName||"Context";case M: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,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee={pending:!1,data:null,method:null,action:null},Z=[],Q=-1;function U(h){return{current:h}}function $(h){0>Q||(h.current=Z[Q],Z[Q]=null,Q--)}function X(h,p){Q++,Z[Q]=h.current,h.current=p}var te=U(null),fe=U(null),pe=U(null),xe=U(null);function Ne(h,p){switch(X(pe,p),X(fe,h),X(te,null),p.nodeType){case 9:case 11:h=(h=p.documentElement)&&(h=h.namespaceURI)?_5(h):0;break;default:if(h=p.tagName,p=p.namespaceURI)p=_5(p),h=w5(p,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}$(te),X(te,h)}function ie(){$(te),$(fe),$(pe)}function be(h){h.memoizedState!==null&&X(xe,h);var p=te.current,_=w5(p,h.type);p!==_&&(X(fe,h),X(te,_))}function je(h){fe.current===h&&($(te),$(fe)),xe.current===h&&($(xe),Jg._currentValue=ee)}var he,ht;function H(h){if(he===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);he=p&&p[1]||"",ht=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+he+h+ht}var B=!1;function re(h,p){if(!h||B)return"";B=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var w={DetermineComponentFrameRoot:function(){try{if(p){var dt=function(){throw Error()};if(Object.defineProperty(dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(dt,[])}catch(at){var Ze=at}Reflect.construct(h,[],dt)}else{try{dt.call()}catch(at){Ze=at}h.call(dt.prototype)}}else{try{throw Error()}catch(at){Ze=at}(dt=h())&&typeof dt.catch=="function"&&dt.catch(function(){})}}catch(at){if(at&&Ze&&typeof at.stack=="string")return[at.stack,Ze.stack]}return[null,null]}};w.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(w.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(w.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=w.DetermineComponentFrameRoot(),Y=j[0],le=j[1];if(Y&&le){var Ee=Y.split(`
- `),Xe=le.split(`
- `);for(P=w=0;w<Ee.length&&!Ee[w].includes("DetermineComponentFrameRoot");)w++;for(;P<Xe.length&&!Xe[P].includes("DetermineComponentFrameRoot");)P++;if(w===Ee.length||P===Xe.length)for(w=Ee.length-1,P=Xe.length-1;1<=w&&0<=P&&Ee[w]!==Xe[P];)P--;for(;1<=w&&0<=P;w--,P--)if(Ee[w]!==Xe[P]){if(w!==1||P!==1)do if(w--,P--,0>P||Ee[w]!==Xe[P]){var lt=`
- `+Ee[w].replace(" at new "," at ");return h.displayName&<.includes("<anonymous>")&&(lt=lt.replace("<anonymous>",h.displayName)),lt}while(1<=w&&0<=P);break}}}finally{B=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?H(_):""}function V(h,p){switch(h.tag){case 26:case 27:case 5:return H(h.type);case 16:return H("Lazy");case 13:return h.child!==p&&p!==null?H("Suspense Fallback"):H("Suspense");case 19:return H("SuspenseList");case 0:case 15:return re(h.type,!1);case 11:return re(h.type.render,!1);case 1:return re(h.type,!0);case 31:return H("Activity");default:return""}}function J(h){try{var p="",_=null;do p+=V(h,_),_=h,h=h.return;while(h);return p}catch(w){return`
- Error generating stack: `+w.message+`
- `+w.stack}}var se=Object.prototype.hasOwnProperty,Ae=t.unstable_scheduleCallback,Pe=t.unstable_cancelCallback,Se=t.unstable_shouldYield,z=t.unstable_requestPaint,L=t.unstable_now,ne=t.unstable_getCurrentPriorityLevel,ve=t.unstable_ImmediatePriority,we=t.unstable_UserBlockingPriority,ye=t.unstable_NormalPriority,nt=t.unstable_LowPriority,Be=t.unstable_IdlePriority,ue=t.log,Ve=t.unstable_setDisableYieldValue,Fe=null,oe=null;function Je(h){if(typeof ue=="function"&&Ve(h),oe&&typeof oe.setStrictMode=="function")try{oe.setStrictMode(Fe,h)}catch{}}var He=Math.clz32?Math.clz32:de,Ke=Math.log,ct=Math.LN2;function de(h){return h>>>=0,h===0?32:31-(Ke(h)/ct|0)|0}var Ye=256,ge=262144,Ue=4194304;function Ce(h){var p=h&42;if(p!==0)return p;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function _e(h,p,_){var w=h.pendingLanes;if(w===0)return 0;var P=0,j=h.suspendedLanes,Y=h.pingedLanes;h=h.warmLanes;var le=w&134217727;return le!==0?(w=le&~j,w!==0?P=Ce(w):(Y&=le,Y!==0?P=Ce(Y):_||(_=le&~h,_!==0&&(P=Ce(_))))):(le=w&~j,le!==0?P=Ce(le):Y!==0?P=Ce(Y):_||(_=w&~h,_!==0&&(P=Ce(_)))),P===0?0:p!==0&&p!==P&&(p&j)===0&&(j=P&-P,_=p&-p,j>=_||j===32&&(_&4194048)!==0)?p:P}function ce(h,p){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&p)===0}function st(h,p){switch(h){case 1:case 2:case 4:case 8:case 64:return p+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return p+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function xt(){var h=Ue;return Ue<<=1,(Ue&62914560)===0&&(Ue=4194304),h}function St(h){for(var p=[],_=0;31>_;_++)p.push(h);return p}function Qt(h,p){h.pendingLanes|=p,p!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Ot(h,p,_,w,P,j){var Y=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var le=h.entanglements,Ee=h.expirationTimes,Xe=h.hiddenUpdates;for(_=Y&~_;0<_;){var lt=31-He(_),dt=1<<lt;le[lt]=0,Ee[lt]=-1;var Ze=Xe[lt];if(Ze!==null)for(Xe[lt]=null,lt=0;lt<Ze.length;lt++){var at=Ze[lt];at!==null&&(at.lane&=-536870913)}_&=~dt}w!==0&&Vt(h,w,0),j!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=j&~(Y&~p))}function Vt(h,p,_){h.pendingLanes|=p,h.suspendedLanes&=~p;var w=31-He(p);h.entangledLanes|=p,h.entanglements[w]=h.entanglements[w]|1073741824|_&261930}function On(h,p){var _=h.entangledLanes|=p;for(h=h.entanglements;_;){var w=31-He(_),P=1<<w;P&p|h[w]&p&&(h[w]|=p),_&=~P}}function Mi(h,p){var _=p&-p;return _=(_&42)!==0?1:si(_),(_&(h.suspendedLanes|p))!==0?0:_}function si(h){switch(h){case 2:h=1;break;case 8:h=4;break;case 32:h=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:h=128;break;case 268435456:h=134217728;break;default:h=0}return h}function Ei(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function zi(){var h=G.p;return h!==0?h:(h=window.event,h===void 0?32:G5(h.type))}function ra(h,p){var _=G.p;try{return G.p=h,p()}finally{G.p=_}}var Hr=Math.random().toString(36).slice(2),br="__reactFiber$"+Hr,jr="__reactProps$"+Hr,mo="__reactContainer$"+Hr,Hc="__reactEvents$"+Hr,me="__reactListeners$"+Hr,$e="__reactHandles$"+Hr,rt="__reactResources$"+Hr,it="__reactMarker$"+Hr;function et(h){delete h[br],delete h[jr],delete h[Hc],delete h[me],delete h[$e]}function Mt(h){var p=h[br];if(p)return p;for(var _=h.parentNode;_;){if(p=_[mo]||_[br]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(h=N5(h);h!==null;){if(_=h[br])return _;h=N5(h)}return p}h=_,_=h.parentNode}return null}function ae(h){if(h=h[br]||h[mo]){var p=h.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return h}return null}function Me(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h.stateNode;throw Error(r(33))}function Ie(h){var p=h[rt];return p||(p=h[rt]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Oe(h){h[it]=!0}var Te=new Set,ot={};function ft(h,p){yt(h,p),yt(h+"Capture",p)}function yt(h,p){for(ot[h]=p,h=0;h<p.length;h++)Te.add(p[h])}var bt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Lt={},Tt={};function mt(h){return se.call(Tt,h)?!0:se.call(Lt,h)?!1:bt.test(h)?Tt[h]=!0:(Lt[h]=!0,!1)}function Xt(h,p,_){if(mt(p))if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(p);return;case"boolean":var w=p.toLowerCase().slice(0,5);if(w!=="data-"&&w!=="aria-"){h.removeAttribute(p);return}}h.setAttribute(p,""+_)}}function Ut(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 an(h,p,_,w){if(w===null)h.removeAttribute(_);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(p,_,""+w)}}function hn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function bn(h){var p=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Ft(h,p,_){var w=Object.getOwnPropertyDescriptor(h.constructor.prototype,p);if(!h.hasOwnProperty(p)&&typeof w<"u"&&typeof w.get=="function"&&typeof w.set=="function"){var P=w.get,j=w.set;return Object.defineProperty(h,p,{configurable:!0,get:function(){return P.call(this)},set:function(Y){_=""+Y,j.call(this,Y)}}),Object.defineProperty(h,p,{enumerable:w.enumerable}),{getValue:function(){return _},setValue:function(Y){_=""+Y},stopTracking:function(){h._valueTracker=null,delete h[p]}}}}function Jt(h){if(!h._valueTracker){var p=bn(h)?"checked":"value";h._valueTracker=Ft(h,p,""+h[p])}}function tn(h){if(!h)return!1;var p=h._valueTracker;if(!p)return!0;var _=p.getValue(),w="";return h&&(w=bn(h)?h.checked?"true":"false":h.value),h=w,h!==_?(p.setValue(h),!0):!1}function Ar(h){if(h=h||(typeof document<"u"?document:void 0),typeof h>"u")return null;try{return h.activeElement||h.body}catch{return h.body}}var Or=/[\n"\\]/g;function Dn(h){return h.replace(Or,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function go(h,p,_,w,P,j,Y,le){h.name="",Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?h.type=Y:h.removeAttribute("type"),p!=null?Y==="number"?(p===0&&h.value===""||h.value!=p)&&(h.value=""+hn(p)):h.value!==""+hn(p)&&(h.value=""+hn(p)):Y!=="submit"&&Y!=="reset"||h.removeAttribute("value"),p!=null?Ai(h,Y,hn(p)):_!=null?Ai(h,Y,hn(_)):w!=null&&h.removeAttribute("value"),P==null&&j!=null&&(h.defaultChecked=!!j),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),le!=null&&typeof le!="function"&&typeof le!="symbol"&&typeof le!="boolean"?h.name=""+hn(le):h.removeAttribute("name")}function Ln(h,p,_,w,P,j,Y,le){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(h.type=j),p!=null||_!=null){if(!(j!=="submit"&&j!=="reset"||p!=null)){Jt(h);return}_=_!=null?""+hn(_):"",p=p!=null?""+hn(p):_,le||p===h.value||(h.value=p),h.defaultValue=p}w=w??P,w=typeof w!="function"&&typeof w!="symbol"&&!!w,h.checked=le?h.checked:!!w,h.defaultChecked=!!w,Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"&&(h.name=Y),Jt(h)}function Ai(h,p,_){p==="number"&&Ar(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function oi(h,p,_,w){if(h=h.options,p){p={};for(var P=0;P<_.length;P++)p["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=p.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&w&&(h[_].defaultSelected=!0)}else{for(_=""+hn(_),p=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,w&&(h[P].defaultSelected=!0);return}p!==null||h[P].disabled||(p=h[P])}p!==null&&(p.selected=!0)}}function Ti(h,p,_){if(p!=null&&(p=""+hn(p),p!==h.value&&(h.value=p),_==null)){h.defaultValue!==p&&(h.defaultValue=p);return}h.defaultValue=_!=null?""+hn(_):""}function Bi(h,p,_,w){if(p==null){if(w!=null){if(_!=null)throw Error(r(92));if(W(w)){if(1<w.length)throw Error(r(93));w=w[0]}_=w}_==null&&(_=""),p=_}_=hn(p),h.defaultValue=_,w=h.textContent,w===_&&w!==""&&w!==null&&(h.value=w),Jt(h)}function Vo(h,p){if(p){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=p;return}}h.textContent=p}var Al=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function bL(h,p,_){var w=p.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?w?h.setProperty(p,""):p==="float"?h.cssFloat="":h[p]="":w?h.setProperty(p,_):typeof _!="number"||_===0||Al.has(p)?p==="float"?h.cssFloat=_:h[p]=(""+_).trim():h[p]=_+"px"}function yL(h,p,_){if(p!=null&&typeof p!="object")throw Error(r(62));if(h=h.style,_!=null){for(var w in _)!_.hasOwnProperty(w)||p!=null&&p.hasOwnProperty(w)||(w.indexOf("--")===0?h.setProperty(w,""):w==="float"?h.cssFloat="":h[w]="");for(var P in p)w=p[P],p.hasOwnProperty(P)&&_[P]!==w&&bL(h,P,w)}else for(var j in p)p.hasOwnProperty(j)&&bL(h,j,p[j])}function mE(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 bte=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"]]),yte=/^[\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 ry(h){return yte.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Tl(){}var gE=null;function xE(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var bf=null,yf=null;function vL(h){var p=ae(h);if(p&&(h=p.stateNode)){var _=h[jr]||null;e:switch(h=p.stateNode,p.type){case"input":if(go(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Dn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var w=_[p];if(w!==h&&w.form===h.form){var P=w[jr]||null;if(!P)throw Error(r(90));go(w,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(p=0;p<_.length;p++)w=_[p],w.form===h.form&&tn(w)}break e;case"textarea":Ti(h,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&oi(h,!!_.multiple,p,!1)}}}var bE=!1;function _L(h,p,_){if(bE)return h(p,_);bE=!0;try{var w=h(p);return w}finally{if(bE=!1,(bf!==null||yf!==null)&&(Vy(),bf&&(p=bf,h=yf,yf=bf=null,vL(p),h)))for(p=0;p<h.length;p++)vL(h[p])}}function gg(h,p){var _=h.stateNode;if(_===null)return null;var w=_[jr]||null;if(w===null)return null;_=w[p];e:switch(p){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(h=h.type,w=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!w;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,p,typeof _));return _}var Cl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),yE=!1;if(Cl)try{var xg={};Object.defineProperty(xg,"passive",{get:function(){yE=!0}}),window.addEventListener("test",xg,xg),window.removeEventListener("test",xg,xg)}catch{yE=!1}var $c=null,vE=null,iy=null;function wL(){if(iy)return iy;var h,p=vE,_=p.length,w,P="value"in $c?$c.value:$c.textContent,j=P.length;for(h=0;h<_&&p[h]===P[h];h++);var Y=_-h;for(w=1;w<=Y&&p[_-w]===P[j-w];w++);return iy=P.slice(h,1<w?1-w:void 0)}function ay(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 sy(){return!0}function SL(){return!1}function ja(h){function p(_,w,P,j,Y){this._reactName=_,this._targetInst=P,this.type=w,this.nativeEvent=j,this.target=Y,this.currentTarget=null;for(var le in h)h.hasOwnProperty(le)&&(_=h[le],this[le]=_?_(j):j[le]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?sy:SL,this.isPropagationStopped=SL,this}return f(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=sy)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=sy)},persist:function(){},isPersistent:sy}),p}var Ad={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},oy=ja(Ad),bg=f({},Ad,{view:0,detail:0}),vte=ja(bg),_E,wE,yg,ly=f({},bg,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ME,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!==yg&&(yg&&h.type==="mousemove"?(_E=h.screenX-yg.screenX,wE=h.screenY-yg.screenY):wE=_E=0,yg=h),_E)},movementY:function(h){return"movementY"in h?h.movementY:wE}}),ML=ja(ly),_te=f({},ly,{dataTransfer:0}),wte=ja(_te),Ste=f({},bg,{relatedTarget:0}),SE=ja(Ste),Mte=f({},Ad,{animationName:0,elapsedTime:0,pseudoElement:0}),Ete=ja(Mte),Ate=f({},Ad,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),Tte=ja(Ate),Cte=f({},Ad,{data:0}),EL=ja(Cte),Nte={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},kte={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"},Pte={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Rte(h){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(h):(h=Pte[h])?!!p[h]:!1}function ME(){return Rte}var Dte=f({},bg,{key:function(h){if(h.key){var p=Nte[h.key]||h.key;if(p!=="Unidentified")return p}return h.type==="keypress"?(h=ay(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?kte[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ME,charCode:function(h){return h.type==="keypress"?ay(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?ay(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),jte=ja(Dte),Ote=f({},ly,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),AL=ja(Ote),Lte=f({},bg,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ME}),Ite=ja(Lte),Fte=f({},Ad,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ute=ja(Fte),zte=f({},ly,{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}),Bte=ja(zte),Hte=f({},Ad,{newState:0,oldState:0}),$te=ja(Hte),Vte=[9,13,27,32],EE=Cl&&"CompositionEvent"in window,vg=null;Cl&&"documentMode"in document&&(vg=document.documentMode);var Gte=Cl&&"TextEvent"in window&&!vg,TL=Cl&&(!EE||vg&&8<vg&&11>=vg),CL=" ",NL=!1;function kL(h,p){switch(h){case"keyup":return Vte.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function PL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var vf=!1;function Wte(h,p){switch(h){case"compositionend":return PL(p);case"keypress":return p.which!==32?null:(NL=!0,CL);case"textInput":return h=p.data,h===CL&&NL?null:h;default:return null}}function qte(h,p){if(vf)return h==="compositionend"||!EE&&kL(h,p)?(h=wL(),iy=vE=$c=null,vf=!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 TL&&p.locale!=="ko"?null:p.data;default:return null}}var Kte={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 RL(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p==="input"?!!Kte[h.type]:p==="textarea"}function DL(h,p,_,w){bf?yf?yf.push(w):yf=[w]:bf=w,p=Zy(p,"onChange"),0<p.length&&(_=new oy("onChange","change",null,_,w),h.push({event:_,listeners:p}))}var _g=null,wg=null;function Xte(h){m5(h,0)}function cy(h){var p=Me(h);if(tn(p))return h}function jL(h,p){if(h==="change")return p}var OL=!1;if(Cl){var AE;if(Cl){var TE="oninput"in document;if(!TE){var LL=document.createElement("div");LL.setAttribute("oninput","return;"),TE=typeof LL.oninput=="function"}AE=TE}else AE=!1;OL=AE&&(!document.documentMode||9<document.documentMode)}function IL(){_g&&(_g.detachEvent("onpropertychange",FL),wg=_g=null)}function FL(h){if(h.propertyName==="value"&&cy(wg)){var p=[];DL(p,wg,h,xE(h)),_L(Xte,p)}}function Yte(h,p,_){h==="focusin"?(IL(),_g=p,wg=_,_g.attachEvent("onpropertychange",FL)):h==="focusout"&&IL()}function Zte(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return cy(wg)}function Qte(h,p){if(h==="click")return cy(p)}function Jte(h,p){if(h==="input"||h==="change")return cy(p)}function ene(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var ts=typeof Object.is=="function"?Object.is:ene;function Sg(h,p){if(ts(h,p))return!0;if(typeof h!="object"||h===null||typeof p!="object"||p===null)return!1;var _=Object.keys(h),w=Object.keys(p);if(_.length!==w.length)return!1;for(w=0;w<_.length;w++){var P=_[w];if(!se.call(p,P)||!ts(h[P],p[P]))return!1}return!0}function UL(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function zL(h,p){var _=UL(h);h=0;for(var w;_;){if(_.nodeType===3){if(w=h+_.textContent.length,h<=p&&w>=p)return{node:_,offset:p-h};h=w}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=UL(_)}}function BL(h,p){return h&&p?h===p?!0:h&&h.nodeType===3?!1:p&&p.nodeType===3?BL(h,p.parentNode):"contains"in h?h.contains(p):h.compareDocumentPosition?!!(h.compareDocumentPosition(p)&16):!1:!1}function HL(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 CE(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 tne=Cl&&"documentMode"in document&&11>=document.documentMode,_f=null,NE=null,Mg=null,kE=!1;function $L(h,p,_){var w=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;kE||_f==null||_f!==Ar(w)||(w=_f,"selectionStart"in w&&CE(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),Mg&&Sg(Mg,w)||(Mg=w,w=Zy(NE,"onSelect"),0<w.length&&(p=new oy("onSelect","select",null,p,_),h.push({event:p,listeners:w}),p.target=_f)))}function Td(h,p){var _={};return _[h.toLowerCase()]=p.toLowerCase(),_["Webkit"+h]="webkit"+p,_["Moz"+h]="moz"+p,_}var wf={animationend:Td("Animation","AnimationEnd"),animationiteration:Td("Animation","AnimationIteration"),animationstart:Td("Animation","AnimationStart"),transitionrun:Td("Transition","TransitionRun"),transitionstart:Td("Transition","TransitionStart"),transitioncancel:Td("Transition","TransitionCancel"),transitionend:Td("Transition","TransitionEnd")},PE={},VL={};Cl&&(VL=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(PE[h])return PE[h];if(!wf[h])return h;var p=wf[h],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in VL)return PE[h]=p[_];return h}var GL=Cd("animationend"),WL=Cd("animationiteration"),qL=Cd("animationstart"),nne=Cd("transitionrun"),rne=Cd("transitionstart"),ine=Cd("transitioncancel"),KL=Cd("transitionend"),XL=new Map,RE="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(" ");RE.push("scrollEnd");function xo(h,p){XL.set(h,p),ft(p,[h])}var uy=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)},ks=[],Sf=0,DE=0;function dy(){for(var h=Sf,p=DE=Sf=0;p<h;){var _=ks[p];ks[p++]=null;var w=ks[p];ks[p++]=null;var P=ks[p];ks[p++]=null;var j=ks[p];if(ks[p++]=null,w!==null&&P!==null){var Y=w.pending;Y===null?P.next=P:(P.next=Y.next,Y.next=P),w.pending=P}j!==0&&YL(_,P,j)}}function hy(h,p,_,w){ks[Sf++]=h,ks[Sf++]=p,ks[Sf++]=_,ks[Sf++]=w,DE|=w,h.lanes|=w,h=h.alternate,h!==null&&(h.lanes|=w)}function jE(h,p,_,w){return hy(h,p,_,w),fy(h)}function Nd(h,p){return hy(h,null,null,p),fy(h)}function YL(h,p,_){h.lanes|=_;var w=h.alternate;w!==null&&(w.lanes|=_);for(var P=!1,j=h.return;j!==null;)j.childLanes|=_,w=j.alternate,w!==null&&(w.childLanes|=_),j.tag===22&&(h=j.stateNode,h===null||h._visibility&1||(P=!0)),h=j,j=j.return;return h.tag===3?(j=h.stateNode,P&&p!==null&&(P=31-He(_),h=j.hiddenUpdates,w=h[P],w===null?h[P]=[p]:w.push(p),p.lane=_|536870912),j):null}function fy(h){if(50<Wg)throw Wg=0,$2=null,Error(r(185));for(var p=h.return;p!==null;)h=p,p=h.return;return h.tag===3?h.stateNode:null}var Mf={};function ane(h,p,_,w){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ns(h,p,_,w){return new ane(h,p,_,w)}function OE(h){return h=h.prototype,!(!h||!h.isReactComponent)}function Nl(h,p){var _=h.alternate;return _===null?(_=ns(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 ZL(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 py(h,p,_,w,P,j){var Y=0;if(w=h,typeof h=="function")OE(h)&&(Y=1);else if(typeof h=="string")Y=ure(h,_,te.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case C:return h=ns(31,_,p,P),h.elementType=C,h.lanes=j,h;case v:return kd(_.children,P,j,p);case y:Y=8,P|=24;break;case b:return h=ns(12,_,p,P|2),h.elementType=b,h.lanes=j,h;case T:return h=ns(13,_,p,P),h.elementType=T,h.lanes=j,h;case k:return h=ns(19,_,p,P),h.elementType=k,h.lanes=j,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case S:Y=10;break e;case M:Y=9;break e;case A:Y=11;break e;case N:Y=14;break e;case I:Y=16,w=null;break e}Y=29,_=Error(r(130,h===null?"null":typeof h,"")),w=null}return p=ns(Y,_,p,P),p.elementType=h,p.type=w,p.lanes=j,p}function kd(h,p,_,w){return h=ns(7,h,w,p),h.lanes=_,h}function LE(h,p,_){return h=ns(6,h,null,p),h.lanes=_,h}function QL(h){var p=ns(18,null,null,0);return p.stateNode=h,p}function IE(h,p,_){return p=ns(4,h.children!==null?h.children:[],h.key,p),p.lanes=_,p.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},p}var JL=new WeakMap;function Ps(h,p){if(typeof h=="object"&&h!==null){var _=JL.get(h);return _!==void 0?_:(p={value:h,source:p,stack:J(p)},JL.set(h,p),p)}return{value:h,source:p,stack:J(p)}}var Ef=[],Af=0,my=null,Eg=0,Rs=[],Ds=0,Vc=null,Go=1,Wo="";function kl(h,p){Ef[Af++]=Eg,Ef[Af++]=my,my=h,Eg=p}function e4(h,p,_){Rs[Ds++]=Go,Rs[Ds++]=Wo,Rs[Ds++]=Vc,Vc=h;var w=Go;h=Wo;var P=32-He(w)-1;w&=~(1<<P),_+=1;var j=32-He(p)+P;if(30<j){var Y=P-P%5;j=(w&(1<<Y)-1).toString(32),w>>=Y,P-=Y,Go=1<<32-He(p)+P|_<<P|w,Wo=j+h}else Go=1<<j|_<<P|w,Wo=h}function FE(h){h.return!==null&&(kl(h,1),e4(h,1,0))}function UE(h){for(;h===my;)my=Ef[--Af],Ef[Af]=null,Eg=Ef[--Af],Ef[Af]=null;for(;h===Vc;)Vc=Rs[--Ds],Rs[Ds]=null,Wo=Rs[--Ds],Rs[Ds]=null,Go=Rs[--Ds],Rs[Ds]=null}function t4(h,p){Rs[Ds++]=Go,Rs[Ds++]=Wo,Rs[Ds++]=Vc,Go=p.id,Wo=p.overflow,Vc=h}var Hi=null,sr=null,wn=!1,Gc=null,js=!1,zE=Error(r(519));function Wc(h){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ag(Ps(p,h)),zE}function n4(h){var p=h.stateNode,_=h.type,w=h.memoizedProps;switch(p[br]=h,p[jr]=w,_){case"dialog":mn("cancel",p),mn("close",p);break;case"iframe":case"object":case"embed":mn("load",p);break;case"video":case"audio":for(_=0;_<Kg.length;_++)mn(Kg[_],p);break;case"source":mn("error",p);break;case"img":case"image":case"link":mn("error",p),mn("load",p);break;case"details":mn("toggle",p);break;case"input":mn("invalid",p),Ln(p,w.value,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name,!0);break;case"select":mn("invalid",p);break;case"textarea":mn("invalid",p),Bi(p,w.value,w.defaultValue,w.children)}_=w.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||w.suppressHydrationWarning===!0||y5(p.textContent,_)?(w.popover!=null&&(mn("beforetoggle",p),mn("toggle",p)),w.onScroll!=null&&mn("scroll",p),w.onScrollEnd!=null&&mn("scrollend",p),w.onClick!=null&&(p.onclick=Tl),p=!0):p=!1,p||Wc(h,!0)}function r4(h){for(Hi=h.return;Hi;)switch(Hi.tag){case 5:case 31:case 13:js=!1;return;case 27:case 3:js=!0;return;default:Hi=Hi.return}}function Tf(h){if(h!==Hi)return!1;if(!wn)return r4(h),wn=!0,!1;var p=h.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||iA(h.type,h.memoizedProps)),_=!_),_&&sr&&Wc(h),r4(h),p===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));sr=C5(h)}else if(p===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));sr=C5(h)}else p===27?(p=sr,su(h.type)?(h=cA,cA=null,sr=h):sr=p):sr=Hi?Ls(h.stateNode.nextSibling):null;return!0}function Pd(){sr=Hi=null,wn=!1}function BE(){var h=Gc;return h!==null&&(Fa===null?Fa=h:Fa.push.apply(Fa,h),Gc=null),h}function Ag(h){Gc===null?Gc=[h]:Gc.push(h)}var HE=U(null),Rd=null,Pl=null;function qc(h,p,_){X(HE,p._currentValue),p._currentValue=_}function Rl(h){h._currentValue=HE.current,$(HE)}function $E(h,p,_){for(;h!==null;){var w=h.alternate;if((h.childLanes&p)!==p?(h.childLanes|=p,w!==null&&(w.childLanes|=p)):w!==null&&(w.childLanes&p)!==p&&(w.childLanes|=p),h===_)break;h=h.return}}function VE(h,p,_,w){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var j=P.dependencies;if(j!==null){var Y=P.child;j=j.firstContext;e:for(;j!==null;){var le=j;j=P;for(var Ee=0;Ee<p.length;Ee++)if(le.context===p[Ee]){j.lanes|=_,le=j.alternate,le!==null&&(le.lanes|=_),$E(j.return,_,h),w||(Y=null);break e}j=le.next}}else if(P.tag===18){if(Y=P.return,Y===null)throw Error(r(341));Y.lanes|=_,j=Y.alternate,j!==null&&(j.lanes|=_),$E(Y,_,h),Y=null}else Y=P.child;if(Y!==null)Y.return=P;else for(Y=P;Y!==null;){if(Y===h){Y=null;break}if(P=Y.sibling,P!==null){P.return=Y.return,Y=P;break}Y=Y.return}P=Y}}function Cf(h,p,_,w){h=null;for(var P=p,j=!1;P!==null;){if(!j){if((P.flags&524288)!==0)j=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var Y=P.alternate;if(Y===null)throw Error(r(387));if(Y=Y.memoizedProps,Y!==null){var le=P.type;ts(P.pendingProps.value,Y.value)||(h!==null?h.push(le):h=[le])}}else if(P===xe.current){if(Y=P.alternate,Y===null)throw Error(r(387));Y.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Jg):h=[Jg])}P=P.return}h!==null&&VE(p,h,_,w),p.flags|=262144}function gy(h){for(h=h.firstContext;h!==null;){if(!ts(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Dd(h){Rd=h,Pl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function $i(h){return i4(Rd,h)}function xy(h,p){return Rd===null&&Dd(h),i4(h,p)}function i4(h,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},Pl===null){if(h===null)throw Error(r(308));Pl=p,h.dependencies={lanes:0,firstContext:p},h.flags|=524288}else Pl=Pl.next=p;return _}var sne=typeof AbortController<"u"?AbortController:function(){var h=[],p=this.signal={aborted:!1,addEventListener:function(_,w){h.push(w)}};this.abort=function(){p.aborted=!0,h.forEach(function(_){return _()})}},one=t.unstable_scheduleCallback,lne=t.unstable_NormalPriority,$r={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function GE(){return{controller:new sne,data:new Map,refCount:0}}function Tg(h){h.refCount--,h.refCount===0&&one(lne,function(){h.controller.abort()})}var Cg=null,WE=0,Nf=0,kf=null;function cne(h,p){if(Cg===null){var _=Cg=[];WE=0,Nf=X2(),kf={status:"pending",value:void 0,then:function(w){_.push(w)}}}return WE++,p.then(a4,a4),p}function a4(){if(--WE===0&&Cg!==null){kf!==null&&(kf.status="fulfilled");var h=Cg;Cg=null,Nf=0,kf=null;for(var p=0;p<h.length;p++)(0,h[p])()}}function une(h,p){var _=[],w={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){w.status="fulfilled",w.value=p;for(var P=0;P<_.length;P++)(0,_[P])(p)},function(P){for(w.status="rejected",w.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),w}var s4=K.S;K.S=function(h,p){$I=L(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&cne(h,p),s4!==null&&s4(h,p)};var jd=U(null);function qE(){var h=jd.current;return h!==null?h:Jn.pooledCache}function by(h,p){p===null?X(jd,jd.current):X(jd,p.pool)}function o4(){var h=qE();return h===null?null:{parent:$r._currentValue,pool:h}}var Pf=Error(r(460)),KE=Error(r(474)),yy=Error(r(542)),vy={then:function(){}};function l4(h){return h=h.status,h==="fulfilled"||h==="rejected"}function c4(h,p,_){switch(_=h[_],_===void 0?h.push(p):_!==p&&(p.then(Tl,Tl),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,d4(h),h;default:if(typeof p.status=="string")p.then(Tl,Tl);else{if(h=Jn,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=p,h.status="pending",h.then(function(w){if(p.status==="pending"){var P=p;P.status="fulfilled",P.value=w}},function(w){if(p.status==="pending"){var P=p;P.status="rejected",P.reason=w}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,d4(h),h}throw Ld=p,Pf}}function Od(h){try{var p=h._init;return p(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Ld=_,Pf):_}}var Ld=null;function u4(){if(Ld===null)throw Error(r(459));var h=Ld;return Ld=null,h}function d4(h){if(h===Pf||h===yy)throw Error(r(483))}var Rf=null,Ng=0;function _y(h){var p=Ng;return Ng+=1,Rf===null&&(Rf=[]),c4(Rf,h,p)}function kg(h,p){p=p.props.ref,h.ref=p!==void 0?p:null}function wy(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 h4(h){function p(ze,Re){if(h){var We=ze.deletions;We===null?(ze.deletions=[Re],ze.flags|=16):We.push(Re)}}function _(ze,Re){if(!h)return null;for(;Re!==null;)p(ze,Re),Re=Re.sibling;return null}function w(ze){for(var Re=new Map;ze!==null;)ze.key!==null?Re.set(ze.key,ze):Re.set(ze.index,ze),ze=ze.sibling;return Re}function P(ze,Re){return ze=Nl(ze,Re),ze.index=0,ze.sibling=null,ze}function j(ze,Re,We){return ze.index=We,h?(We=ze.alternate,We!==null?(We=We.index,We<Re?(ze.flags|=67108866,Re):We):(ze.flags|=67108866,Re)):(ze.flags|=1048576,Re)}function Y(ze){return h&&ze.alternate===null&&(ze.flags|=67108866),ze}function le(ze,Re,We,ut){return Re===null||Re.tag!==6?(Re=LE(We,ze.mode,ut),Re.return=ze,Re):(Re=P(Re,We),Re.return=ze,Re)}function Ee(ze,Re,We,ut){var zt=We.type;return zt===v?lt(ze,Re,We.props.children,ut,We.key):Re!==null&&(Re.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&Od(zt)===Re.type)?(Re=P(Re,We.props),kg(Re,We),Re.return=ze,Re):(Re=py(We.type,We.key,We.props,null,ze.mode,ut),kg(Re,We),Re.return=ze,Re)}function Xe(ze,Re,We,ut){return Re===null||Re.tag!==4||Re.stateNode.containerInfo!==We.containerInfo||Re.stateNode.implementation!==We.implementation?(Re=IE(We,ze.mode,ut),Re.return=ze,Re):(Re=P(Re,We.children||[]),Re.return=ze,Re)}function lt(ze,Re,We,ut,zt){return Re===null||Re.tag!==7?(Re=kd(We,ze.mode,ut,zt),Re.return=ze,Re):(Re=P(Re,We),Re.return=ze,Re)}function dt(ze,Re,We){if(typeof Re=="string"&&Re!==""||typeof Re=="number"||typeof Re=="bigint")return Re=LE(""+Re,ze.mode,We),Re.return=ze,Re;if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case m:return We=py(Re.type,Re.key,Re.props,null,ze.mode,We),kg(We,Re),We.return=ze,We;case x:return Re=IE(Re,ze.mode,We),Re.return=ze,Re;case I:return Re=Od(Re),dt(ze,Re,We)}if(W(Re)||O(Re))return Re=kd(Re,ze.mode,We,null),Re.return=ze,Re;if(typeof Re.then=="function")return dt(ze,_y(Re),We);if(Re.$$typeof===S)return dt(ze,xy(ze,Re),We);wy(ze,Re)}return null}function Ze(ze,Re,We,ut){var zt=Re!==null?Re.key:null;if(typeof We=="string"&&We!==""||typeof We=="number"||typeof We=="bigint")return zt!==null?null:le(ze,Re,""+We,ut);if(typeof We=="object"&&We!==null){switch(We.$$typeof){case m:return We.key===zt?Ee(ze,Re,We,ut):null;case x:return We.key===zt?Xe(ze,Re,We,ut):null;case I:return We=Od(We),Ze(ze,Re,We,ut)}if(W(We)||O(We))return zt!==null?null:lt(ze,Re,We,ut,null);if(typeof We.then=="function")return Ze(ze,Re,_y(We),ut);if(We.$$typeof===S)return Ze(ze,Re,xy(ze,We),ut);wy(ze,We)}return null}function at(ze,Re,We,ut,zt){if(typeof ut=="string"&&ut!==""||typeof ut=="number"||typeof ut=="bigint")return ze=ze.get(We)||null,le(Re,ze,""+ut,zt);if(typeof ut=="object"&&ut!==null){switch(ut.$$typeof){case m:return ze=ze.get(ut.key===null?We:ut.key)||null,Ee(Re,ze,ut,zt);case x:return ze=ze.get(ut.key===null?We:ut.key)||null,Xe(Re,ze,ut,zt);case I:return ut=Od(ut),at(ze,Re,We,ut,zt)}if(W(ut)||O(ut))return ze=ze.get(We)||null,lt(Re,ze,ut,zt,null);if(typeof ut.then=="function")return at(ze,Re,We,_y(ut),zt);if(ut.$$typeof===S)return at(ze,Re,We,xy(Re,ut),zt);wy(Re,ut)}return null}function jt(ze,Re,We,ut){for(var zt=null,An=null,It=Re,rn=Re=0,vn=null;It!==null&&rn<We.length;rn++){It.index>rn?(vn=It,It=null):vn=It.sibling;var Tn=Ze(ze,It,We[rn],ut);if(Tn===null){It===null&&(It=vn);break}h&&It&&Tn.alternate===null&&p(ze,It),Re=j(Tn,Re,rn),An===null?zt=Tn:An.sibling=Tn,An=Tn,It=vn}if(rn===We.length)return _(ze,It),wn&&kl(ze,rn),zt;if(It===null){for(;rn<We.length;rn++)It=dt(ze,We[rn],ut),It!==null&&(Re=j(It,Re,rn),An===null?zt=It:An.sibling=It,An=It);return wn&&kl(ze,rn),zt}for(It=w(It);rn<We.length;rn++)vn=at(It,ze,rn,We[rn],ut),vn!==null&&(h&&vn.alternate!==null&&It.delete(vn.key===null?rn:vn.key),Re=j(vn,Re,rn),An===null?zt=vn:An.sibling=vn,An=vn);return h&&It.forEach(function(du){return p(ze,du)}),wn&&kl(ze,rn),zt}function Gt(ze,Re,We,ut){if(We==null)throw Error(r(151));for(var zt=null,An=null,It=Re,rn=Re=0,vn=null,Tn=We.next();It!==null&&!Tn.done;rn++,Tn=We.next()){It.index>rn?(vn=It,It=null):vn=It.sibling;var du=Ze(ze,It,Tn.value,ut);if(du===null){It===null&&(It=vn);break}h&&It&&du.alternate===null&&p(ze,It),Re=j(du,Re,rn),An===null?zt=du:An.sibling=du,An=du,It=vn}if(Tn.done)return _(ze,It),wn&&kl(ze,rn),zt;if(It===null){for(;!Tn.done;rn++,Tn=We.next())Tn=dt(ze,Tn.value,ut),Tn!==null&&(Re=j(Tn,Re,rn),An===null?zt=Tn:An.sibling=Tn,An=Tn);return wn&&kl(ze,rn),zt}for(It=w(It);!Tn.done;rn++,Tn=We.next())Tn=at(It,ze,rn,Tn.value,ut),Tn!==null&&(h&&Tn.alternate!==null&&It.delete(Tn.key===null?rn:Tn.key),Re=j(Tn,Re,rn),An===null?zt=Tn:An.sibling=Tn,An=Tn);return h&&It.forEach(function(_re){return p(ze,_re)}),wn&&kl(ze,rn),zt}function Gn(ze,Re,We,ut){if(typeof We=="object"&&We!==null&&We.type===v&&We.key===null&&(We=We.props.children),typeof We=="object"&&We!==null){switch(We.$$typeof){case m:e:{for(var zt=We.key;Re!==null;){if(Re.key===zt){if(zt=We.type,zt===v){if(Re.tag===7){_(ze,Re.sibling),ut=P(Re,We.props.children),ut.return=ze,ze=ut;break e}}else if(Re.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&Od(zt)===Re.type){_(ze,Re.sibling),ut=P(Re,We.props),kg(ut,We),ut.return=ze,ze=ut;break e}_(ze,Re);break}else p(ze,Re);Re=Re.sibling}We.type===v?(ut=kd(We.props.children,ze.mode,ut,We.key),ut.return=ze,ze=ut):(ut=py(We.type,We.key,We.props,null,ze.mode,ut),kg(ut,We),ut.return=ze,ze=ut)}return Y(ze);case x:e:{for(zt=We.key;Re!==null;){if(Re.key===zt)if(Re.tag===4&&Re.stateNode.containerInfo===We.containerInfo&&Re.stateNode.implementation===We.implementation){_(ze,Re.sibling),ut=P(Re,We.children||[]),ut.return=ze,ze=ut;break e}else{_(ze,Re);break}else p(ze,Re);Re=Re.sibling}ut=IE(We,ze.mode,ut),ut.return=ze,ze=ut}return Y(ze);case I:return We=Od(We),Gn(ze,Re,We,ut)}if(W(We))return jt(ze,Re,We,ut);if(O(We)){if(zt=O(We),typeof zt!="function")throw Error(r(150));return We=zt.call(We),Gt(ze,Re,We,ut)}if(typeof We.then=="function")return Gn(ze,Re,_y(We),ut);if(We.$$typeof===S)return Gn(ze,Re,xy(ze,We),ut);wy(ze,We)}return typeof We=="string"&&We!==""||typeof We=="number"||typeof We=="bigint"?(We=""+We,Re!==null&&Re.tag===6?(_(ze,Re.sibling),ut=P(Re,We),ut.return=ze,ze=ut):(_(ze,Re),ut=LE(We,ze.mode,ut),ut.return=ze,ze=ut),Y(ze)):_(ze,Re)}return function(ze,Re,We,ut){try{Ng=0;var zt=Gn(ze,Re,We,ut);return Rf=null,zt}catch(It){if(It===Pf||It===yy)throw It;var An=ns(29,It,null,ze.mode);return An.lanes=ut,An.return=ze,An}finally{}}}var Id=h4(!0),f4=h4(!1),Kc=!1;function XE(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function YE(h,p){h=h.updateQueue,p.updateQueue===h&&(p.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function Xc(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Yc(h,p,_){var w=h.updateQueue;if(w===null)return null;if(w=w.shared,(kn&2)!==0){var P=w.pending;return P===null?p.next=p:(p.next=P.next,P.next=p),w.pending=p,p=fy(h),YL(h,null,_),p}return hy(h,w,p,_),fy(h)}function Pg(h,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var w=p.lanes;w&=h.pendingLanes,_|=w,p.lanes=_,On(h,_)}}function ZE(h,p){var _=h.updateQueue,w=h.alternate;if(w!==null&&(w=w.updateQueue,_===w)){var P=null,j=null;if(_=_.firstBaseUpdate,_!==null){do{var Y={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};j===null?P=j=Y:j=j.next=Y,_=_.next}while(_!==null);j===null?P=j=p:j=j.next=p}else P=j=p;_={baseState:w.baseState,firstBaseUpdate:P,lastBaseUpdate:j,shared:w.shared,callbacks:w.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=p:h.next=p,_.lastBaseUpdate=p}var QE=!1;function Rg(){if(QE){var h=kf;if(h!==null)throw h}}function Dg(h,p,_,w){QE=!1;var P=h.updateQueue;Kc=!1;var j=P.firstBaseUpdate,Y=P.lastBaseUpdate,le=P.shared.pending;if(le!==null){P.shared.pending=null;var Ee=le,Xe=Ee.next;Ee.next=null,Y===null?j=Xe:Y.next=Xe,Y=Ee;var lt=h.alternate;lt!==null&&(lt=lt.updateQueue,le=lt.lastBaseUpdate,le!==Y&&(le===null?lt.firstBaseUpdate=Xe:le.next=Xe,lt.lastBaseUpdate=Ee))}if(j!==null){var dt=P.baseState;Y=0,lt=Xe=Ee=null,le=j;do{var Ze=le.lane&-536870913,at=Ze!==le.lane;if(at?(yn&Ze)===Ze:(w&Ze)===Ze){Ze!==0&&Ze===Nf&&(QE=!0),lt!==null&&(lt=lt.next={lane:0,tag:le.tag,payload:le.payload,callback:null,next:null});e:{var jt=h,Gt=le;Ze=p;var Gn=_;switch(Gt.tag){case 1:if(jt=Gt.payload,typeof jt=="function"){dt=jt.call(Gn,dt,Ze);break e}dt=jt;break e;case 3:jt.flags=jt.flags&-65537|128;case 0:if(jt=Gt.payload,Ze=typeof jt=="function"?jt.call(Gn,dt,Ze):jt,Ze==null)break e;dt=f({},dt,Ze);break e;case 2:Kc=!0}}Ze=le.callback,Ze!==null&&(h.flags|=64,at&&(h.flags|=8192),at=P.callbacks,at===null?P.callbacks=[Ze]:at.push(Ze))}else at={lane:Ze,tag:le.tag,payload:le.payload,callback:le.callback,next:null},lt===null?(Xe=lt=at,Ee=dt):lt=lt.next=at,Y|=Ze;if(le=le.next,le===null){if(le=P.shared.pending,le===null)break;at=le,le=at.next,at.next=null,P.lastBaseUpdate=at,P.shared.pending=null}}while(!0);lt===null&&(Ee=dt),P.baseState=Ee,P.firstBaseUpdate=Xe,P.lastBaseUpdate=lt,j===null&&(P.shared.lanes=0),tu|=Y,h.lanes=Y,h.memoizedState=dt}}function p4(h,p){if(typeof h!="function")throw Error(r(191,h));h.call(p)}function m4(h,p){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)p4(_[h],p)}var Df=U(null),Sy=U(0);function g4(h,p){h=Bl,X(Sy,h),X(Df,p),Bl=h|p.baseLanes}function JE(){X(Sy,Bl),X(Df,Df.current)}function e2(){Bl=Sy.current,$(Df),$(Sy)}var rs=U(null),Os=null;function Zc(h){var p=h.alternate;X(Lr,Lr.current&1),X(rs,h),Os===null&&(p===null||Df.current!==null||p.memoizedState!==null)&&(Os=h)}function t2(h){X(Lr,Lr.current),X(rs,h),Os===null&&(Os=h)}function x4(h){h.tag===22?(X(Lr,Lr.current),X(rs,h),Os===null&&(Os=h)):Qc()}function Qc(){X(Lr,Lr.current),X(rs,rs.current)}function is(h){$(rs),Os===h&&(Os=null),$(Lr)}var Lr=U(0);function My(h){for(var p=h;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||oA(_)||lA(_)))return p}else if(p.tag===19&&(p.memoizedProps.revealOrder==="forwards"||p.memoizedProps.revealOrder==="backwards"||p.memoizedProps.revealOrder==="unstable_legacy-backwards"||p.memoizedProps.revealOrder==="together")){if((p.flags&128)!==0)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var Dl=0,nn=null,$n=null,Vr=null,Ey=!1,jf=!1,Fd=!1,Ay=0,jg=0,Of=null,dne=0;function Tr(){throw Error(r(321))}function n2(h,p){if(p===null)return!1;for(var _=0;_<p.length&&_<h.length;_++)if(!ts(h[_],p[_]))return!1;return!0}function r2(h,p,_,w,P,j){return Dl=j,nn=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,K.H=h===null||h.memoizedState===null?eI:b2,Fd=!1,j=_(w,P),Fd=!1,jf&&(j=y4(p,_,w,P)),b4(h),j}function b4(h){K.H=Ig;var p=$n!==null&&$n.next!==null;if(Dl=0,Vr=$n=nn=null,Ey=!1,jg=0,Of=null,p)throw Error(r(300));h===null||Gr||(h=h.dependencies,h!==null&&gy(h)&&(Gr=!0))}function y4(h,p,_,w){nn=h;var P=0;do{if(jf&&(Of=null),jg=0,jf=!1,25<=P)throw Error(r(301));if(P+=1,Vr=$n=null,h.updateQueue!=null){var j=h.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}K.H=tI,j=p(_,w)}while(jf);return j}function hne(){var h=K.H,p=h.useState()[0];return p=typeof p.then=="function"?Og(p):p,h=h.useState()[0],($n!==null?$n.memoizedState:null)!==h&&(nn.flags|=1024),p}function i2(){var h=Ay!==0;return Ay=0,h}function a2(h,p,_){p.updateQueue=h.updateQueue,p.flags&=-2053,h.lanes&=~_}function s2(h){if(Ey){for(h=h.memoizedState;h!==null;){var p=h.queue;p!==null&&(p.pending=null),h=h.next}Ey=!1}Dl=0,Vr=$n=nn=null,jf=!1,jg=Ay=0,Of=null}function ba(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Vr===null?nn.memoizedState=Vr=h:Vr=Vr.next=h,Vr}function Ir(){if($n===null){var h=nn.alternate;h=h!==null?h.memoizedState:null}else h=$n.next;var p=Vr===null?nn.memoizedState:Vr.next;if(p!==null)Vr=p,$n=h;else{if(h===null)throw nn.alternate===null?Error(r(467)):Error(r(310));$n=h,h={memoizedState:$n.memoizedState,baseState:$n.baseState,baseQueue:$n.baseQueue,queue:$n.queue,next:null},Vr===null?nn.memoizedState=Vr=h:Vr=Vr.next=h}return Vr}function Ty(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Og(h){var p=jg;return jg+=1,Of===null&&(Of=[]),h=c4(Of,h,p),p=nn,(Vr===null?p.memoizedState:Vr.next)===null&&(p=p.alternate,K.H=p===null||p.memoizedState===null?eI:b2),h}function Cy(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Og(h);if(h.$$typeof===S)return $i(h)}throw Error(r(438,String(h)))}function o2(h){var p=null,_=nn.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var w=nn.alternate;w!==null&&(w=w.updateQueue,w!==null&&(w=w.memoCache,w!=null&&(p={data:w.data.map(function(P){return P.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=Ty(),nn.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(h),w=0;w<h;w++)_[w]=D;return p.index++,_}function jl(h,p){return typeof p=="function"?p(h):p}function Ny(h){var p=Ir();return l2(p,$n,h)}function l2(h,p,_){var w=h.queue;if(w===null)throw Error(r(311));w.lastRenderedReducer=_;var P=h.baseQueue,j=w.pending;if(j!==null){if(P!==null){var Y=P.next;P.next=j.next,j.next=Y}p.baseQueue=P=j,w.pending=null}if(j=h.baseState,P===null)h.memoizedState=j;else{p=P.next;var le=Y=null,Ee=null,Xe=p,lt=!1;do{var dt=Xe.lane&-536870913;if(dt!==Xe.lane?(yn&dt)===dt:(Dl&dt)===dt){var Ze=Xe.revertLane;if(Ze===0)Ee!==null&&(Ee=Ee.next={lane:0,revertLane:0,gesture:null,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null}),dt===Nf&&(lt=!0);else if((Dl&Ze)===Ze){Xe=Xe.next,Ze===Nf&&(lt=!0);continue}else dt={lane:0,revertLane:Xe.revertLane,gesture:null,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null},Ee===null?(le=Ee=dt,Y=j):Ee=Ee.next=dt,nn.lanes|=Ze,tu|=Ze;dt=Xe.action,Fd&&_(j,dt),j=Xe.hasEagerState?Xe.eagerState:_(j,dt)}else Ze={lane:dt,revertLane:Xe.revertLane,gesture:Xe.gesture,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null},Ee===null?(le=Ee=Ze,Y=j):Ee=Ee.next=Ze,nn.lanes|=dt,tu|=dt;Xe=Xe.next}while(Xe!==null&&Xe!==p);if(Ee===null?Y=j:Ee.next=le,!ts(j,h.memoizedState)&&(Gr=!0,lt&&(_=kf,_!==null)))throw _;h.memoizedState=j,h.baseState=Y,h.baseQueue=Ee,w.lastRenderedState=j}return P===null&&(w.lanes=0),[h.memoizedState,w.dispatch]}function c2(h){var p=Ir(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var w=_.dispatch,P=_.pending,j=p.memoizedState;if(P!==null){_.pending=null;var Y=P=P.next;do j=h(j,Y.action),Y=Y.next;while(Y!==P);ts(j,p.memoizedState)||(Gr=!0),p.memoizedState=j,p.baseQueue===null&&(p.baseState=j),_.lastRenderedState=j}return[j,w]}function v4(h,p,_){var w=nn,P=Ir(),j=wn;if(j){if(_===void 0)throw Error(r(407));_=_()}else _=p();var Y=!ts(($n||P).memoizedState,_);if(Y&&(P.memoizedState=_,Gr=!0),P=P.queue,h2(S4.bind(null,w,P,h),[h]),P.getSnapshot!==p||Y||Vr!==null&&Vr.memoizedState.tag&1){if(w.flags|=2048,Lf(9,{destroy:void 0},w4.bind(null,w,P,_,p),null),Jn===null)throw Error(r(349));j||(Dl&127)!==0||_4(w,p,_)}return _}function _4(h,p,_){h.flags|=16384,h={getSnapshot:p,value:_},p=nn.updateQueue,p===null?(p=Ty(),nn.updateQueue=p,p.stores=[h]):(_=p.stores,_===null?p.stores=[h]:_.push(h))}function w4(h,p,_,w){p.value=_,p.getSnapshot=w,M4(p)&&E4(h)}function S4(h,p,_){return _(function(){M4(p)&&E4(h)})}function M4(h){var p=h.getSnapshot;h=h.value;try{var _=p();return!ts(h,_)}catch{return!0}}function E4(h){var p=Nd(h,2);p!==null&&Ua(p,h,2)}function u2(h){var p=ba();if(typeof h=="function"){var _=h;if(h=_(),Fd){Je(!0);try{_()}finally{Je(!1)}}}return p.memoizedState=p.baseState=h,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:jl,lastRenderedState:h},p}function A4(h,p,_,w){return h.baseState=_,l2(h,$n,typeof w=="function"?w:jl)}function fne(h,p,_,w,P){if(Ry(h))throw Error(r(485));if(h=p.action,h!==null){var j={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Y){j.listeners.push(Y)}};K.T!==null?_(!0):j.isTransition=!1,w(j),_=p.pending,_===null?(j.next=p.pending=j,T4(p,j)):(j.next=_.next,p.pending=_.next=j)}}function T4(h,p){var _=p.action,w=p.payload,P=h.state;if(p.isTransition){var j=K.T,Y={};K.T=Y;try{var le=_(P,w),Ee=K.S;Ee!==null&&Ee(Y,le),C4(h,p,le)}catch(Xe){d2(h,p,Xe)}finally{j!==null&&Y.types!==null&&(j.types=Y.types),K.T=j}}else try{j=_(P,w),C4(h,p,j)}catch(Xe){d2(h,p,Xe)}}function C4(h,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(w){N4(h,p,w)},function(w){return d2(h,p,w)}):N4(h,p,_)}function N4(h,p,_){p.status="fulfilled",p.value=_,k4(p),h.state=_,p=h.pending,p!==null&&(_=p.next,_===p?h.pending=null:(_=_.next,p.next=_,T4(h,_)))}function d2(h,p,_){var w=h.pending;if(h.pending=null,w!==null){w=w.next;do p.status="rejected",p.reason=_,k4(p),p=p.next;while(p!==w)}h.action=null}function k4(h){h=h.listeners;for(var p=0;p<h.length;p++)(0,h[p])()}function P4(h,p){return p}function R4(h,p){if(wn){var _=Jn.formState;if(_!==null){e:{var w=nn;if(wn){if(sr){t:{for(var P=sr,j=js;P.nodeType!==8;){if(!j){P=null;break t}if(P=Ls(P.nextSibling),P===null){P=null;break t}}j=P.data,P=j==="F!"||j==="F"?P:null}if(P){sr=Ls(P.nextSibling),w=P.data==="F!";break e}}Wc(w)}w=!1}w&&(p=_[0])}}return _=ba(),_.memoizedState=_.baseState=p,w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:P4,lastRenderedState:p},_.queue=w,_=Z4.bind(null,nn,w),w.dispatch=_,w=u2(!1),j=x2.bind(null,nn,!1,w.queue),w=ba(),P={state:p,dispatch:null,action:h,pending:null},w.queue=P,_=fne.bind(null,nn,P,j,_),P.dispatch=_,w.memoizedState=h,[p,_,!1]}function D4(h){var p=Ir();return j4(p,$n,h)}function j4(h,p,_){if(p=l2(h,p,P4)[0],h=Ny(jl)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var w=Og(p)}catch(Y){throw Y===Pf?yy:Y}else w=p;p=Ir();var P=p.queue,j=P.dispatch;return _!==p.memoizedState&&(nn.flags|=2048,Lf(9,{destroy:void 0},pne.bind(null,P,_),null)),[w,j,h]}function pne(h,p){h.action=p}function O4(h){var p=Ir(),_=$n;if(_!==null)return j4(p,_,h);Ir(),p=p.memoizedState,_=Ir();var w=_.queue.dispatch;return _.memoizedState=h,[p,w,!1]}function Lf(h,p,_,w){return h={tag:h,create:_,deps:w,inst:p,next:null},p=nn.updateQueue,p===null&&(p=Ty(),nn.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=h.next=h:(w=_.next,_.next=h,h.next=w,p.lastEffect=h),h}function L4(){return Ir().memoizedState}function ky(h,p,_,w){var P=ba();nn.flags|=h,P.memoizedState=Lf(1|p,{destroy:void 0},_,w===void 0?null:w)}function Py(h,p,_,w){var P=Ir();w=w===void 0?null:w;var j=P.memoizedState.inst;$n!==null&&w!==null&&n2(w,$n.memoizedState.deps)?P.memoizedState=Lf(p,j,_,w):(nn.flags|=h,P.memoizedState=Lf(1|p,j,_,w))}function I4(h,p){ky(8390656,8,h,p)}function h2(h,p){Py(2048,8,h,p)}function mne(h){nn.flags|=4;var p=nn.updateQueue;if(p===null)p=Ty(),nn.updateQueue=p,p.events=[h];else{var _=p.events;_===null?p.events=[h]:_.push(h)}}function F4(h){var p=Ir().memoizedState;return mne({ref:p,nextImpl:h}),function(){if((kn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function U4(h,p){return Py(4,2,h,p)}function z4(h,p){return Py(4,4,h,p)}function B4(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 H4(h,p,_){_=_!=null?_.concat([h]):null,Py(4,4,B4.bind(null,p,h),_)}function f2(){}function $4(h,p){var _=Ir();p=p===void 0?null:p;var w=_.memoizedState;return p!==null&&n2(p,w[1])?w[0]:(_.memoizedState=[h,p],h)}function V4(h,p){var _=Ir();p=p===void 0?null:p;var w=_.memoizedState;if(p!==null&&n2(p,w[1]))return w[0];if(w=h(),Fd){Je(!0);try{h()}finally{Je(!1)}}return _.memoizedState=[w,p],w}function p2(h,p,_){return _===void 0||(Dl&1073741824)!==0&&(yn&261930)===0?h.memoizedState=p:(h.memoizedState=_,h=GI(),nn.lanes|=h,tu|=h,_)}function G4(h,p,_,w){return ts(_,p)?_:Df.current!==null?(h=p2(h,_,w),ts(h,p)||(Gr=!0),h):(Dl&42)===0||(Dl&1073741824)!==0&&(yn&261930)===0?(Gr=!0,h.memoizedState=_):(h=GI(),nn.lanes|=h,tu|=h,p)}function W4(h,p,_,w,P){var j=G.p;G.p=j!==0&&8>j?j:8;var Y=K.T,le={};K.T=le,x2(h,!1,p,_);try{var Ee=P(),Xe=K.S;if(Xe!==null&&Xe(le,Ee),Ee!==null&&typeof Ee=="object"&&typeof Ee.then=="function"){var lt=une(Ee,w);Lg(h,p,lt,ls(h))}else Lg(h,p,w,ls(h))}catch(dt){Lg(h,p,{then:function(){},status:"rejected",reason:dt},ls())}finally{G.p=j,Y!==null&&le.types!==null&&(Y.types=le.types),K.T=Y}}function gne(){}function m2(h,p,_,w){if(h.tag!==5)throw Error(r(476));var P=q4(h).queue;W4(h,P,p,ee,_===null?gne:function(){return K4(h),_(w)})}function q4(h){var p=h.memoizedState;if(p!==null)return p;p={memoizedState:ee,baseState:ee,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jl,lastRenderedState:ee},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jl,lastRenderedState:_},next:null},h.memoizedState=p,h=h.alternate,h!==null&&(h.memoizedState=p),p}function K4(h){var p=q4(h);p.next===null&&(p=h.alternate.memoizedState),Lg(h,p.next.queue,{},ls())}function g2(){return $i(Jg)}function X4(){return Ir().memoizedState}function Y4(){return Ir().memoizedState}function xne(h){for(var p=h.return;p!==null;){switch(p.tag){case 24:case 3:var _=ls();h=Xc(_);var w=Yc(p,h,_);w!==null&&(Ua(w,p,_),Pg(w,p,_)),p={cache:GE()},h.payload=p;return}p=p.return}}function bne(h,p,_){var w=ls();_={lane:w,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Ry(h)?Q4(p,_):(_=jE(h,p,_,w),_!==null&&(Ua(_,h,w),J4(_,p,w)))}function Z4(h,p,_){var w=ls();Lg(h,p,_,w)}function Lg(h,p,_,w){var P={lane:w,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Ry(h))Q4(p,P);else{var j=h.alternate;if(h.lanes===0&&(j===null||j.lanes===0)&&(j=p.lastRenderedReducer,j!==null))try{var Y=p.lastRenderedState,le=j(Y,_);if(P.hasEagerState=!0,P.eagerState=le,ts(le,Y))return hy(h,p,P,0),Jn===null&&dy(),!1}catch{}finally{}if(_=jE(h,p,P,w),_!==null)return Ua(_,h,w),J4(_,p,w),!0}return!1}function x2(h,p,_,w){if(w={lane:2,revertLane:X2(),gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},Ry(h)){if(p)throw Error(r(479))}else p=jE(h,_,w,2),p!==null&&Ua(p,h,2)}function Ry(h){var p=h.alternate;return h===nn||p!==null&&p===nn}function Q4(h,p){jf=Ey=!0;var _=h.pending;_===null?p.next=p:(p.next=_.next,_.next=p),h.pending=p}function J4(h,p,_){if((_&4194048)!==0){var w=p.lanes;w&=h.pendingLanes,_|=w,p.lanes=_,On(h,_)}}var Ig={readContext:$i,use:Cy,useCallback:Tr,useContext:Tr,useEffect:Tr,useImperativeHandle:Tr,useLayoutEffect:Tr,useInsertionEffect:Tr,useMemo:Tr,useReducer:Tr,useRef:Tr,useState:Tr,useDebugValue:Tr,useDeferredValue:Tr,useTransition:Tr,useSyncExternalStore:Tr,useId:Tr,useHostTransitionStatus:Tr,useFormState:Tr,useActionState:Tr,useOptimistic:Tr,useMemoCache:Tr,useCacheRefresh:Tr};Ig.useEffectEvent=Tr;var eI={readContext:$i,use:Cy,useCallback:function(h,p){return ba().memoizedState=[h,p===void 0?null:p],h},useContext:$i,useEffect:I4,useImperativeHandle:function(h,p,_){_=_!=null?_.concat([h]):null,ky(4194308,4,B4.bind(null,p,h),_)},useLayoutEffect:function(h,p){return ky(4194308,4,h,p)},useInsertionEffect:function(h,p){ky(4,2,h,p)},useMemo:function(h,p){var _=ba();p=p===void 0?null:p;var w=h();if(Fd){Je(!0);try{h()}finally{Je(!1)}}return _.memoizedState=[w,p],w},useReducer:function(h,p,_){var w=ba();if(_!==void 0){var P=_(p);if(Fd){Je(!0);try{_(p)}finally{Je(!1)}}}else P=p;return w.memoizedState=w.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},w.queue=h,h=h.dispatch=bne.bind(null,nn,h),[w.memoizedState,h]},useRef:function(h){var p=ba();return h={current:h},p.memoizedState=h},useState:function(h){h=u2(h);var p=h.queue,_=Z4.bind(null,nn,p);return p.dispatch=_,[h.memoizedState,_]},useDebugValue:f2,useDeferredValue:function(h,p){var _=ba();return p2(_,h,p)},useTransition:function(){var h=u2(!1);return h=W4.bind(null,nn,h.queue,!0,!1),ba().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,p,_){var w=nn,P=ba();if(wn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Jn===null)throw Error(r(349));(yn&127)!==0||_4(w,p,_)}P.memoizedState=_;var j={value:_,getSnapshot:p};return P.queue=j,I4(S4.bind(null,w,j,h),[h]),w.flags|=2048,Lf(9,{destroy:void 0},w4.bind(null,w,j,_,p),null),_},useId:function(){var h=ba(),p=Jn.identifierPrefix;if(wn){var _=Wo,w=Go;_=(w&~(1<<32-He(w)-1)).toString(32)+_,p="_"+p+"R_"+_,_=Ay++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=dne++,p="_"+p+"r_"+_.toString(32)+"_";return h.memoizedState=p},useHostTransitionStatus:g2,useFormState:R4,useActionState:R4,useOptimistic:function(h){var p=ba();p.memoizedState=p.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=x2.bind(null,nn,!0,_),_.dispatch=p,[h,p]},useMemoCache:o2,useCacheRefresh:function(){return ba().memoizedState=xne.bind(null,nn)},useEffectEvent:function(h){var p=ba(),_={impl:h};return p.memoizedState=_,function(){if((kn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},b2={readContext:$i,use:Cy,useCallback:$4,useContext:$i,useEffect:h2,useImperativeHandle:H4,useInsertionEffect:U4,useLayoutEffect:z4,useMemo:V4,useReducer:Ny,useRef:L4,useState:function(){return Ny(jl)},useDebugValue:f2,useDeferredValue:function(h,p){var _=Ir();return G4(_,$n.memoizedState,h,p)},useTransition:function(){var h=Ny(jl)[0],p=Ir().memoizedState;return[typeof h=="boolean"?h:Og(h),p]},useSyncExternalStore:v4,useId:X4,useHostTransitionStatus:g2,useFormState:D4,useActionState:D4,useOptimistic:function(h,p){var _=Ir();return A4(_,$n,h,p)},useMemoCache:o2,useCacheRefresh:Y4};b2.useEffectEvent=F4;var tI={readContext:$i,use:Cy,useCallback:$4,useContext:$i,useEffect:h2,useImperativeHandle:H4,useInsertionEffect:U4,useLayoutEffect:z4,useMemo:V4,useReducer:c2,useRef:L4,useState:function(){return c2(jl)},useDebugValue:f2,useDeferredValue:function(h,p){var _=Ir();return $n===null?p2(_,h,p):G4(_,$n.memoizedState,h,p)},useTransition:function(){var h=c2(jl)[0],p=Ir().memoizedState;return[typeof h=="boolean"?h:Og(h),p]},useSyncExternalStore:v4,useId:X4,useHostTransitionStatus:g2,useFormState:O4,useActionState:O4,useOptimistic:function(h,p){var _=Ir();return $n!==null?A4(_,$n,h,p):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:o2,useCacheRefresh:Y4};tI.useEffectEvent=F4;function y2(h,p,_,w){p=h.memoizedState,_=_(w,p),_=_==null?p:f({},p,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var v2={enqueueSetState:function(h,p,_){h=h._reactInternals;var w=ls(),P=Xc(w);P.payload=p,_!=null&&(P.callback=_),p=Yc(h,P,w),p!==null&&(Ua(p,h,w),Pg(p,h,w))},enqueueReplaceState:function(h,p,_){h=h._reactInternals;var w=ls(),P=Xc(w);P.tag=1,P.payload=p,_!=null&&(P.callback=_),p=Yc(h,P,w),p!==null&&(Ua(p,h,w),Pg(p,h,w))},enqueueForceUpdate:function(h,p){h=h._reactInternals;var _=ls(),w=Xc(_);w.tag=2,p!=null&&(w.callback=p),p=Yc(h,w,_),p!==null&&(Ua(p,h,_),Pg(p,h,_))}};function nI(h,p,_,w,P,j,Y){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(w,j,Y):p.prototype&&p.prototype.isPureReactComponent?!Sg(_,w)||!Sg(P,j):!0}function rI(h,p,_,w){h=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(_,w),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(_,w),p.state!==h&&v2.enqueueReplaceState(p,p.state,null)}function Ud(h,p){var _=p;if("ref"in p){_={};for(var w in p)w!=="ref"&&(_[w]=p[w])}if(h=h.defaultProps){_===p&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function iI(h){uy(h)}function aI(h){console.error(h)}function sI(h){uy(h)}function Dy(h,p){try{var _=h.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(w){setTimeout(function(){throw w})}}function oI(h,p,_){try{var w=h.onCaughtError;w(_.value,{componentStack:_.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function _2(h,p,_){return _=Xc(_),_.tag=3,_.payload={element:null},_.callback=function(){Dy(h,p)},_}function lI(h){return h=Xc(h),h.tag=3,h}function cI(h,p,_,w){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var j=w.value;h.payload=function(){return P(j)},h.callback=function(){oI(p,_,w)}}var Y=_.stateNode;Y!==null&&typeof Y.componentDidCatch=="function"&&(h.callback=function(){oI(p,_,w),typeof P!="function"&&(nu===null?nu=new Set([this]):nu.add(this));var le=w.stack;this.componentDidCatch(w.value,{componentStack:le!==null?le:""})})}function yne(h,p,_,w,P){if(_.flags|=32768,w!==null&&typeof w=="object"&&typeof w.then=="function"){if(p=_.alternate,p!==null&&Cf(p,_,P,!0),_=rs.current,_!==null){switch(_.tag){case 31:case 13:return Os===null?Gy():_.alternate===null&&Cr===0&&(Cr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,w===vy?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([w]):p.add(w),W2(h,w,P)),!1;case 22:return _.flags|=65536,w===vy?_.flags|=16384:(p=_.updateQueue,p===null?(p={transitions:null,markerInstances:null,retryQueue:new Set([w])},_.updateQueue=p):(_=p.retryQueue,_===null?p.retryQueue=new Set([w]):_.add(w)),W2(h,w,P)),!1}throw Error(r(435,_.tag))}return W2(h,w,P),Gy(),!1}if(wn)return p=rs.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=P,w!==zE&&(h=Error(r(422),{cause:w}),Ag(Ps(h,_)))):(w!==zE&&(p=Error(r(423),{cause:w}),Ag(Ps(p,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,w=Ps(w,_),P=_2(h.stateNode,w,P),ZE(h,P),Cr!==4&&(Cr=2)),!1;var j=Error(r(520),{cause:w});if(j=Ps(j,_),Gg===null?Gg=[j]:Gg.push(j),Cr!==4&&(Cr=2),p===null)return!0;w=Ps(w,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=_2(_.stateNode,w,h),ZE(_,h),!1;case 1:if(p=_.type,j=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(nu===null||!nu.has(j))))return _.flags|=65536,P&=-P,_.lanes|=P,P=lI(P),cI(P,h,_,w),ZE(_,P),!1}_=_.return}while(_!==null);return!1}var w2=Error(r(461)),Gr=!1;function Vi(h,p,_,w){p.child=h===null?f4(p,null,_,w):Id(p,h.child,_,w)}function uI(h,p,_,w,P){_=_.render;var j=p.ref;if("ref"in w){var Y={};for(var le in w)le!=="ref"&&(Y[le]=w[le])}else Y=w;return Dd(p),w=r2(h,p,_,Y,j,P),le=i2(),h!==null&&!Gr?(a2(h,p,P),Ol(h,p,P)):(wn&&le&&FE(p),p.flags|=1,Vi(h,p,w,P),p.child)}function dI(h,p,_,w,P){if(h===null){var j=_.type;return typeof j=="function"&&!OE(j)&&j.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=j,hI(h,p,j,w,P)):(h=py(_.type,null,w,p,p.mode,P),h.ref=p.ref,h.return=p,p.child=h)}if(j=h.child,!k2(h,P)){var Y=j.memoizedProps;if(_=_.compare,_=_!==null?_:Sg,_(Y,w)&&h.ref===p.ref)return Ol(h,p,P)}return p.flags|=1,h=Nl(j,w),h.ref=p.ref,h.return=p,p.child=h}function hI(h,p,_,w,P){if(h!==null){var j=h.memoizedProps;if(Sg(j,w)&&h.ref===p.ref)if(Gr=!1,p.pendingProps=w=j,k2(h,P))(h.flags&131072)!==0&&(Gr=!0);else return p.lanes=h.lanes,Ol(h,p,P)}return S2(h,p,_,w,P)}function fI(h,p,_,w){var P=w.children,j=h!==null?h.memoizedState:null;if(h===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),w.mode==="hidden"){if((p.flags&128)!==0){if(j=j!==null?j.baseLanes|_:_,h!==null){for(w=p.child=h.child,P=0;w!==null;)P=P|w.lanes|w.childLanes,w=w.sibling;w=P&~j}else w=0,p.child=null;return pI(h,p,j,_,w)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},h!==null&&by(p,j!==null?j.cachePool:null),j!==null?g4(p,j):JE(),x4(p);else return w=p.lanes=536870912,pI(h,p,j!==null?j.baseLanes|_:_,_,w)}else j!==null?(by(p,j.cachePool),g4(p,j),Qc(),p.memoizedState=null):(h!==null&&by(p,null),JE(),Qc());return Vi(h,p,P,_),p.child}function Fg(h,p){return h!==null&&h.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function pI(h,p,_,w,P){var j=qE();return j=j===null?null:{parent:$r._currentValue,pool:j},p.memoizedState={baseLanes:_,cachePool:j},h!==null&&by(p,null),JE(),x4(p),h!==null&&Cf(h,p,w,!0),p.childLanes=P,null}function jy(h,p){return p=Ly({mode:p.mode,children:p.children},h.mode),p.ref=h.ref,h.child=p,p.return=h,p}function mI(h,p,_){return Id(p,h.child,null,_),h=jy(p,p.pendingProps),h.flags|=2,is(p),p.memoizedState=null,h}function vne(h,p,_){var w=p.pendingProps,P=(p.flags&128)!==0;if(p.flags&=-129,h===null){if(wn){if(w.mode==="hidden")return h=jy(p,w),p.lanes=536870912,Fg(null,h);if(t2(p),(h=sr)?(h=T5(h,js),h=h!==null&&h.data==="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Vc!==null?{id:Go,overflow:Wo}:null,retryLane:536870912,hydrationErrors:null},_=QL(h),_.return=p,p.child=_,Hi=p,sr=null)):h=null,h===null)throw Wc(p);return p.lanes=536870912,null}return jy(p,w)}var j=h.memoizedState;if(j!==null){var Y=j.dehydrated;if(t2(p),P)if(p.flags&256)p.flags&=-257,p=mI(h,p,_);else if(p.memoizedState!==null)p.child=h.child,p.flags|=128,p=null;else throw Error(r(558));else if(Gr||Cf(h,p,_,!1),P=(_&h.childLanes)!==0,Gr||P){if(w=Jn,w!==null&&(Y=Mi(w,_),Y!==0&&Y!==j.retryLane))throw j.retryLane=Y,Nd(h,Y),Ua(w,h,Y),w2;Gy(),p=mI(h,p,_)}else h=j.treeContext,sr=Ls(Y.nextSibling),Hi=p,wn=!0,Gc=null,js=!1,h!==null&&t4(p,h),p=jy(p,w),p.flags|=4096;return p}return h=Nl(h.child,{mode:w.mode,children:w.children}),h.ref=p.ref,p.child=h,h.return=p,h}function Oy(h,p){var _=p.ref;if(_===null)h!==null&&h.ref!==null&&(p.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(p.flags|=4194816)}}function S2(h,p,_,w,P){return Dd(p),_=r2(h,p,_,w,void 0,P),w=i2(),h!==null&&!Gr?(a2(h,p,P),Ol(h,p,P)):(wn&&w&&FE(p),p.flags|=1,Vi(h,p,_,P),p.child)}function gI(h,p,_,w,P,j){return Dd(p),p.updateQueue=null,_=y4(p,w,_,P),b4(h),w=i2(),h!==null&&!Gr?(a2(h,p,j),Ol(h,p,j)):(wn&&w&&FE(p),p.flags|=1,Vi(h,p,_,j),p.child)}function xI(h,p,_,w,P){if(Dd(p),p.stateNode===null){var j=Mf,Y=_.contextType;typeof Y=="object"&&Y!==null&&(j=$i(Y)),j=new _(w,j),p.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=v2,p.stateNode=j,j._reactInternals=p,j=p.stateNode,j.props=w,j.state=p.memoizedState,j.refs={},XE(p),Y=_.contextType,j.context=typeof Y=="object"&&Y!==null?$i(Y):Mf,j.state=p.memoizedState,Y=_.getDerivedStateFromProps,typeof Y=="function"&&(y2(p,_,Y,w),j.state=p.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(Y=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),Y!==j.state&&v2.enqueueReplaceState(j,j.state,null),Dg(p,w,j,P),Rg(),j.state=p.memoizedState),typeof j.componentDidMount=="function"&&(p.flags|=4194308),w=!0}else if(h===null){j=p.stateNode;var le=p.memoizedProps,Ee=Ud(_,le);j.props=Ee;var Xe=j.context,lt=_.contextType;Y=Mf,typeof lt=="object"&<!==null&&(Y=$i(lt));var dt=_.getDerivedStateFromProps;lt=typeof dt=="function"||typeof j.getSnapshotBeforeUpdate=="function",le=p.pendingProps!==le,lt||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(le||Xe!==Y)&&rI(p,j,w,Y),Kc=!1;var Ze=p.memoizedState;j.state=Ze,Dg(p,w,j,P),Rg(),Xe=p.memoizedState,le||Ze!==Xe||Kc?(typeof dt=="function"&&(y2(p,_,dt,w),Xe=p.memoizedState),(Ee=Kc||nI(p,_,Ee,w,Ze,Xe,Y))?(lt||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(p.flags|=4194308)):(typeof j.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=w,p.memoizedState=Xe),j.props=w,j.state=Xe,j.context=Y,w=Ee):(typeof j.componentDidMount=="function"&&(p.flags|=4194308),w=!1)}else{j=p.stateNode,YE(h,p),Y=p.memoizedProps,lt=Ud(_,Y),j.props=lt,dt=p.pendingProps,Ze=j.context,Xe=_.contextType,Ee=Mf,typeof Xe=="object"&&Xe!==null&&(Ee=$i(Xe)),le=_.getDerivedStateFromProps,(Xe=typeof le=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(Y!==dt||Ze!==Ee)&&rI(p,j,w,Ee),Kc=!1,Ze=p.memoizedState,j.state=Ze,Dg(p,w,j,P),Rg();var at=p.memoizedState;Y!==dt||Ze!==at||Kc||h!==null&&h.dependencies!==null&&gy(h.dependencies)?(typeof le=="function"&&(y2(p,_,le,w),at=p.memoizedState),(lt=Kc||nI(p,_,lt,w,Ze,at,Ee)||h!==null&&h.dependencies!==null&&gy(h.dependencies))?(Xe||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(w,at,Ee),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(w,at,Ee)),typeof j.componentDidUpdate=="function"&&(p.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof j.componentDidUpdate!="function"||Y===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||Y===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=1024),p.memoizedProps=w,p.memoizedState=at),j.props=w,j.state=at,j.context=Ee,w=lt):(typeof j.componentDidUpdate!="function"||Y===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||Y===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=1024),w=!1)}return j=w,Oy(h,p),w=(p.flags&128)!==0,j||w?(j=p.stateNode,_=w&&typeof _.getDerivedStateFromError!="function"?null:j.render(),p.flags|=1,h!==null&&w?(p.child=Id(p,h.child,null,P),p.child=Id(p,null,_,P)):Vi(h,p,_,P),p.memoizedState=j.state,h=p.child):h=Ol(h,p,P),h}function bI(h,p,_,w){return Pd(),p.flags|=256,Vi(h,p,_,w),p.child}var M2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function E2(h){return{baseLanes:h,cachePool:o4()}}function A2(h,p,_){return h=h!==null?h.childLanes&~_:0,p&&(h|=ss),h}function yI(h,p,_){var w=p.pendingProps,P=!1,j=(p.flags&128)!==0,Y;if((Y=j)||(Y=h!==null&&h.memoizedState===null?!1:(Lr.current&2)!==0),Y&&(P=!0,p.flags&=-129),Y=(p.flags&32)!==0,p.flags&=-33,h===null){if(wn){if(P?Zc(p):Qc(),(h=sr)?(h=T5(h,js),h=h!==null&&h.data!=="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Vc!==null?{id:Go,overflow:Wo}:null,retryLane:536870912,hydrationErrors:null},_=QL(h),_.return=p,p.child=_,Hi=p,sr=null)):h=null,h===null)throw Wc(p);return lA(h)?p.lanes=32:p.lanes=536870912,null}var le=w.children;return w=w.fallback,P?(Qc(),P=p.mode,le=Ly({mode:"hidden",children:le},P),w=kd(w,P,_,null),le.return=p,w.return=p,le.sibling=w,p.child=le,w=p.child,w.memoizedState=E2(_),w.childLanes=A2(h,Y,_),p.memoizedState=M2,Fg(null,w)):(Zc(p),T2(p,le))}var Ee=h.memoizedState;if(Ee!==null&&(le=Ee.dehydrated,le!==null)){if(j)p.flags&256?(Zc(p),p.flags&=-257,p=C2(h,p,_)):p.memoizedState!==null?(Qc(),p.child=h.child,p.flags|=128,p=null):(Qc(),le=w.fallback,P=p.mode,w=Ly({mode:"visible",children:w.children},P),le=kd(le,P,_,null),le.flags|=2,w.return=p,le.return=p,w.sibling=le,p.child=w,Id(p,h.child,null,_),w=p.child,w.memoizedState=E2(_),w.childLanes=A2(h,Y,_),p.memoizedState=M2,p=Fg(null,w));else if(Zc(p),lA(le)){if(Y=le.nextSibling&&le.nextSibling.dataset,Y)var Xe=Y.dgst;Y=Xe,w=Error(r(419)),w.stack="",w.digest=Y,Ag({value:w,source:null,stack:null}),p=C2(h,p,_)}else if(Gr||Cf(h,p,_,!1),Y=(_&h.childLanes)!==0,Gr||Y){if(Y=Jn,Y!==null&&(w=Mi(Y,_),w!==0&&w!==Ee.retryLane))throw Ee.retryLane=w,Nd(h,w),Ua(Y,h,w),w2;oA(le)||Gy(),p=C2(h,p,_)}else oA(le)?(p.flags|=192,p.child=h.child,p=null):(h=Ee.treeContext,sr=Ls(le.nextSibling),Hi=p,wn=!0,Gc=null,js=!1,h!==null&&t4(p,h),p=T2(p,w.children),p.flags|=4096);return p}return P?(Qc(),le=w.fallback,P=p.mode,Ee=h.child,Xe=Ee.sibling,w=Nl(Ee,{mode:"hidden",children:w.children}),w.subtreeFlags=Ee.subtreeFlags&65011712,Xe!==null?le=Nl(Xe,le):(le=kd(le,P,_,null),le.flags|=2),le.return=p,w.return=p,w.sibling=le,p.child=w,Fg(null,w),w=p.child,le=h.child.memoizedState,le===null?le=E2(_):(P=le.cachePool,P!==null?(Ee=$r._currentValue,P=P.parent!==Ee?{parent:Ee,pool:Ee}:P):P=o4(),le={baseLanes:le.baseLanes|_,cachePool:P}),w.memoizedState=le,w.childLanes=A2(h,Y,_),p.memoizedState=M2,Fg(h.child,w)):(Zc(p),_=h.child,h=_.sibling,_=Nl(_,{mode:"visible",children:w.children}),_.return=p,_.sibling=null,h!==null&&(Y=p.deletions,Y===null?(p.deletions=[h],p.flags|=16):Y.push(h)),p.child=_,p.memoizedState=null,_)}function T2(h,p){return p=Ly({mode:"visible",children:p},h.mode),p.return=h,h.child=p}function Ly(h,p){return h=ns(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 vI(h,p,_){h.lanes|=p;var w=h.alternate;w!==null&&(w.lanes|=p),$E(h.return,p,_)}function N2(h,p,_,w,P,j){var Y=h.memoizedState;Y===null?h.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:w,tail:_,tailMode:P,treeForkCount:j}:(Y.isBackwards=p,Y.rendering=null,Y.renderingStartTime=0,Y.last=w,Y.tail=_,Y.tailMode=P,Y.treeForkCount=j)}function _I(h,p,_){var w=p.pendingProps,P=w.revealOrder,j=w.tail;w=w.children;var Y=Lr.current,le=(Y&2)!==0;if(le?(Y=Y&1|2,p.flags|=128):Y&=1,X(Lr,Y),Vi(h,p,w,_),w=wn?Eg:0,!le&&h!==null&&(h.flags&128)!==0)e:for(h=p.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&vI(h,_,p);else if(h.tag===19)vI(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&&My(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=p.child,p.child=null):(P=_.sibling,_.sibling=null),N2(p,!1,P,_,j,w);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=p.child,p.child=null;P!==null;){if(h=P.alternate,h!==null&&My(h)===null){p.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}N2(p,!0,_,null,j,w);break;case"together":N2(p,!1,null,null,void 0,w);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,_=Nl(h,h.pendingProps),p.child=_,_.return=p;h.sibling!==null;)h=h.sibling,_=_.sibling=Nl(h,h.pendingProps),_.return=p;_.sibling=null}return p.child}function k2(h,p){return(h.lanes&p)!==0?!0:(h=h.dependencies,!!(h!==null&&gy(h)))}function _ne(h,p,_){switch(p.tag){case 3:Ne(p,p.stateNode.containerInfo),qc(p,$r,h.memoizedState.cache),Pd();break;case 27:case 5:be(p);break;case 4:Ne(p,p.stateNode.containerInfo);break;case 10:qc(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,t2(p),null;break;case 13:var w=p.memoizedState;if(w!==null)return w.dehydrated!==null?(Zc(p),p.flags|=128,null):(_&p.child.childLanes)!==0?yI(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(w=(_&p.childLanes)!==0,w||(Cf(h,p,_,!1),w=(_&p.childLanes)!==0),P){if(w)return _I(h,p,_);p.flags|=128}if(P=p.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),X(Lr,Lr.current),w)break;return null;case 22:return p.lanes=0,fI(h,p,_,p.pendingProps);case 24:qc(p,$r,h.memoizedState.cache)}return Ol(h,p,_)}function wI(h,p,_){if(h!==null)if(h.memoizedProps!==p.pendingProps)Gr=!0;else{if(!k2(h,_)&&(p.flags&128)===0)return Gr=!1,_ne(h,p,_);Gr=(h.flags&131072)!==0}else Gr=!1,wn&&(p.flags&1048576)!==0&&e4(p,Eg,p.index);switch(p.lanes=0,p.tag){case 16:e:{var w=p.pendingProps;if(h=Od(p.elementType),p.type=h,typeof h=="function")OE(h)?(w=Ud(h,w),p.tag=1,p=xI(null,p,h,w,_)):(p.tag=0,p=S2(null,p,h,w,_));else{if(h!=null){var P=h.$$typeof;if(P===A){p.tag=11,p=uI(null,p,h,w,_);break e}else if(P===N){p.tag=14,p=dI(null,p,h,w,_);break e}}throw p=R(h)||h,Error(r(306,p,""))}}return p;case 0:return S2(h,p,p.type,p.pendingProps,_);case 1:return w=p.type,P=Ud(w,p.pendingProps),xI(h,p,w,P,_);case 3:e:{if(Ne(p,p.stateNode.containerInfo),h===null)throw Error(r(387));w=p.pendingProps;var j=p.memoizedState;P=j.element,YE(h,p),Dg(p,w,null,_);var Y=p.memoizedState;if(w=Y.cache,qc(p,$r,w),w!==j.cache&&VE(p,[$r],_,!0),Rg(),w=Y.element,j.isDehydrated)if(j={element:w,isDehydrated:!1,cache:Y.cache},p.updateQueue.baseState=j,p.memoizedState=j,p.flags&256){p=bI(h,p,w,_);break e}else if(w!==P){P=Ps(Error(r(424)),p),Ag(P),p=bI(h,p,w,_);break e}else{switch(h=p.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(sr=Ls(h.firstChild),Hi=p,wn=!0,Gc=null,js=!0,_=f4(p,null,w,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Pd(),w===P){p=Ol(h,p,_);break e}Vi(h,p,w,_)}p=p.child}return p;case 26:return Oy(h,p),h===null?(_=D5(p.type,null,p.pendingProps,null))?p.memoizedState=_:wn||(_=p.type,h=p.pendingProps,w=Qy(pe.current).createElement(_),w[br]=p,w[jr]=h,Gi(w,_,h),Oe(w),p.stateNode=w):p.memoizedState=D5(p.type,h.memoizedProps,p.pendingProps,h.memoizedState),null;case 27:return be(p),h===null&&wn&&(w=p.stateNode=k5(p.type,p.pendingProps,pe.current),Hi=p,js=!0,P=sr,su(p.type)?(cA=P,sr=Ls(w.firstChild)):sr=P),Vi(h,p,p.pendingProps.children,_),Oy(h,p),h===null&&(p.flags|=4194304),p.child;case 5:return h===null&&wn&&((P=w=sr)&&(w=Zne(w,p.type,p.pendingProps,js),w!==null?(p.stateNode=w,Hi=p,sr=Ls(w.firstChild),js=!1,P=!0):P=!1),P||Wc(p)),be(p),P=p.type,j=p.pendingProps,Y=h!==null?h.memoizedProps:null,w=j.children,iA(P,j)?w=null:Y!==null&&iA(P,Y)&&(p.flags|=32),p.memoizedState!==null&&(P=r2(h,p,hne,null,null,_),Jg._currentValue=P),Oy(h,p),Vi(h,p,w,_),p.child;case 6:return h===null&&wn&&((h=_=sr)&&(_=Qne(_,p.pendingProps,js),_!==null?(p.stateNode=_,Hi=p,sr=null,h=!0):h=!1),h||Wc(p)),null;case 13:return yI(h,p,_);case 4:return Ne(p,p.stateNode.containerInfo),w=p.pendingProps,h===null?p.child=Id(p,null,w,_):Vi(h,p,w,_),p.child;case 11:return uI(h,p,p.type,p.pendingProps,_);case 7:return Vi(h,p,p.pendingProps,_),p.child;case 8:return Vi(h,p,p.pendingProps.children,_),p.child;case 12:return Vi(h,p,p.pendingProps.children,_),p.child;case 10:return w=p.pendingProps,qc(p,p.type,w.value),Vi(h,p,w.children,_),p.child;case 9:return P=p.type._context,w=p.pendingProps.children,Dd(p),P=$i(P),w=w(P),p.flags|=1,Vi(h,p,w,_),p.child;case 14:return dI(h,p,p.type,p.pendingProps,_);case 15:return hI(h,p,p.type,p.pendingProps,_);case 19:return _I(h,p,_);case 31:return vne(h,p,_);case 22:return fI(h,p,_,p.pendingProps);case 24:return Dd(p),w=$i($r),h===null?(P=qE(),P===null&&(P=Jn,j=GE(),P.pooledCache=j,j.refCount++,j!==null&&(P.pooledCacheLanes|=_),P=j),p.memoizedState={parent:w,cache:P},XE(p),qc(p,$r,P)):((h.lanes&_)!==0&&(YE(h,p),Dg(p,null,null,_),Rg()),P=h.memoizedState,j=p.memoizedState,P.parent!==w?(P={parent:w,cache:w},p.memoizedState=P,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=P),qc(p,$r,w)):(w=j.cache,qc(p,$r,w),w!==P.cache&&VE(p,[$r],_,!0))),Vi(h,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function Ll(h){h.flags|=4}function P2(h,p,_,w,P){if((p=(h.mode&32)!==0)&&(p=!1),p){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(XI())h.flags|=8192;else throw Ld=vy,KE}else h.flags&=-16777217}function SI(h,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!F5(p))if(XI())h.flags|=8192;else throw Ld=vy,KE}function Iy(h,p){p!==null&&(h.flags|=4),h.flags&16384&&(p=h.tag!==22?xt():536870912,h.lanes|=p,zf|=p)}function Ug(h,p){if(!wn)switch(h.tailMode){case"hidden":p=h.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var w=null;_!==null;)_.alternate!==null&&(w=_),_=_.sibling;w===null?p||h.tail===null?h.tail=null:h.tail.sibling=null:w.sibling=null}}function or(h){var p=h.alternate!==null&&h.alternate.child===h.child,_=0,w=0;if(p)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,w|=P.subtreeFlags&65011712,w|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,w|=P.subtreeFlags,w|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=w,h.childLanes=_,p}function wne(h,p,_){var w=p.pendingProps;switch(UE(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return or(p),null;case 1:return or(p),null;case 3:return _=p.stateNode,w=null,h!==null&&(w=h.memoizedState.cache),p.memoizedState.cache!==w&&(p.flags|=2048),Rl($r),ie(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Tf(p)?Ll(p):h===null||h.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,BE())),or(p),null;case 26:var P=p.type,j=p.memoizedState;return h===null?(Ll(p),j!==null?(or(p),SI(p,j)):(or(p),P2(p,P,null,w,_))):j?j!==h.memoizedState?(Ll(p),or(p),SI(p,j)):(or(p),p.flags&=-16777217):(h=h.memoizedProps,h!==w&&Ll(p),or(p),P2(p,P,h,w,_)),null;case 27:if(je(p),_=pe.current,P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==w&&Ll(p);else{if(!w){if(p.stateNode===null)throw Error(r(166));return or(p),null}h=te.current,Tf(p)?n4(p):(h=k5(P,w,_),p.stateNode=h,Ll(p))}return or(p),null;case 5:if(je(p),P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==w&&Ll(p);else{if(!w){if(p.stateNode===null)throw Error(r(166));return or(p),null}if(j=te.current,Tf(p))n4(p);else{var Y=Qy(pe.current);switch(j){case 1:j=Y.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:j=Y.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":j=Y.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":j=Y.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":j=Y.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof w.is=="string"?Y.createElement("select",{is:w.is}):Y.createElement("select"),w.multiple?j.multiple=!0:w.size&&(j.size=w.size);break;default:j=typeof w.is=="string"?Y.createElement(P,{is:w.is}):Y.createElement(P)}}j[br]=p,j[jr]=w;e:for(Y=p.child;Y!==null;){if(Y.tag===5||Y.tag===6)j.appendChild(Y.stateNode);else if(Y.tag!==4&&Y.tag!==27&&Y.child!==null){Y.child.return=Y,Y=Y.child;continue}if(Y===p)break e;for(;Y.sibling===null;){if(Y.return===null||Y.return===p)break e;Y=Y.return}Y.sibling.return=Y.return,Y=Y.sibling}p.stateNode=j;e:switch(Gi(j,P,w),P){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}w&&Ll(p)}}return or(p),P2(p,p.type,h===null?null:h.memoizedProps,p.pendingProps,_),null;case 6:if(h&&p.stateNode!=null)h.memoizedProps!==w&&Ll(p);else{if(typeof w!="string"&&p.stateNode===null)throw Error(r(166));if(h=pe.current,Tf(p)){if(h=p.stateNode,_=p.memoizedProps,w=null,P=Hi,P!==null)switch(P.tag){case 27:case 5:w=P.memoizedProps}h[br]=p,h=!!(h.nodeValue===_||w!==null&&w.suppressHydrationWarning===!0||y5(h.nodeValue,_)),h||Wc(p,!0)}else h=Qy(h).createTextNode(w),h[br]=p,p.stateNode=h}return or(p),null;case 31:if(_=p.memoizedState,h===null||h.memoizedState!==null){if(w=Tf(p),_!==null){if(h===null){if(!w)throw Error(r(318));if(h=p.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[br]=p}else Pd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;or(p),h=!1}else _=BE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return p.flags&256?(is(p),p):(is(p),null);if((p.flags&128)!==0)throw Error(r(558))}return or(p),null;case 13:if(w=p.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Tf(p),w!==null&&w.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=p.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[br]=p}else Pd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;or(p),P=!1}else P=BE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return p.flags&256?(is(p),p):(is(p),null)}return is(p),(p.flags&128)!==0?(p.lanes=_,p):(_=w!==null,h=h!==null&&h.memoizedState!==null,_&&(w=p.child,P=null,w.alternate!==null&&w.alternate.memoizedState!==null&&w.alternate.memoizedState.cachePool!==null&&(P=w.alternate.memoizedState.cachePool.pool),j=null,w.memoizedState!==null&&w.memoizedState.cachePool!==null&&(j=w.memoizedState.cachePool.pool),j!==P&&(w.flags|=2048)),_!==h&&_&&(p.child.flags|=8192),Iy(p,p.updateQueue),or(p),null);case 4:return ie(),h===null&&J2(p.stateNode.containerInfo),or(p),null;case 10:return Rl(p.type),or(p),null;case 19:if($(Lr),w=p.memoizedState,w===null)return or(p),null;if(P=(p.flags&128)!==0,j=w.rendering,j===null)if(P)Ug(w,!1);else{if(Cr!==0||h!==null&&(h.flags&128)!==0)for(h=p.child;h!==null;){if(j=My(h),j!==null){for(p.flags|=128,Ug(w,!1),h=j.updateQueue,p.updateQueue=h,Iy(p,h),p.subtreeFlags=0,h=_,_=p.child;_!==null;)ZL(_,h),_=_.sibling;return X(Lr,Lr.current&1|2),wn&&kl(p,w.treeForkCount),p.child}h=h.sibling}w.tail!==null&&L()>Hy&&(p.flags|=128,P=!0,Ug(w,!1),p.lanes=4194304)}else{if(!P)if(h=My(j),h!==null){if(p.flags|=128,P=!0,h=h.updateQueue,p.updateQueue=h,Iy(p,h),Ug(w,!0),w.tail===null&&w.tailMode==="hidden"&&!j.alternate&&!wn)return or(p),null}else 2*L()-w.renderingStartTime>Hy&&_!==536870912&&(p.flags|=128,P=!0,Ug(w,!1),p.lanes=4194304);w.isBackwards?(j.sibling=p.child,p.child=j):(h=w.last,h!==null?h.sibling=j:p.child=j,w.last=j)}return w.tail!==null?(h=w.tail,w.rendering=h,w.tail=h.sibling,w.renderingStartTime=L(),h.sibling=null,_=Lr.current,X(Lr,P?_&1|2:_&1),wn&&kl(p,w.treeForkCount),h):(or(p),null);case 22:case 23:return is(p),e2(),w=p.memoizedState!==null,h!==null?h.memoizedState!==null!==w&&(p.flags|=8192):w&&(p.flags|=8192),w?(_&536870912)!==0&&(p.flags&128)===0&&(or(p),p.subtreeFlags&6&&(p.flags|=8192)):or(p),_=p.updateQueue,_!==null&&Iy(p,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),w=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(w=p.memoizedState.cachePool.pool),w!==_&&(p.flags|=2048),h!==null&&$(jd),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),Rl($r),or(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function Sne(h,p){switch(UE(p),p.tag){case 1:return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 3:return Rl($r),ie(),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(is(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(is(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 $(Lr),null;case 4:return ie(),null;case 10:return Rl(p.type),null;case 22:case 23:return is(p),e2(),h!==null&&$(jd),h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 24:return Rl($r),null;case 25:return null;default:return null}}function MI(h,p){switch(UE(p),p.tag){case 3:Rl($r),ie();break;case 26:case 27:case 5:je(p);break;case 4:ie();break;case 31:p.memoizedState!==null&&is(p);break;case 13:is(p);break;case 19:$(Lr);break;case 10:Rl(p.type);break;case 22:case 23:is(p),e2(),h!==null&&$(jd);break;case 24:Rl($r)}}function zg(h,p){try{var _=p.updateQueue,w=_!==null?_.lastEffect:null;if(w!==null){var P=w.next;_=P;do{if((_.tag&h)===h){w=void 0;var j=_.create,Y=_.inst;w=j(),Y.destroy=w}_=_.next}while(_!==P)}}catch(le){Fn(p,p.return,le)}}function Jc(h,p,_){try{var w=p.updateQueue,P=w!==null?w.lastEffect:null;if(P!==null){var j=P.next;w=j;do{if((w.tag&h)===h){var Y=w.inst,le=Y.destroy;if(le!==void 0){Y.destroy=void 0,P=p;var Ee=_,Xe=le;try{Xe()}catch(lt){Fn(P,Ee,lt)}}}w=w.next}while(w!==j)}}catch(lt){Fn(p,p.return,lt)}}function EI(h){var p=h.updateQueue;if(p!==null){var _=h.stateNode;try{m4(p,_)}catch(w){Fn(h,h.return,w)}}}function AI(h,p,_){_.props=Ud(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(w){Fn(h,p,w)}}function Bg(h,p){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var w=h.stateNode;break;case 30:w=h.stateNode;break;default:w=h.stateNode}typeof _=="function"?h.refCleanup=_(w):_.current=w}}catch(P){Fn(h,p,P)}}function qo(h,p){var _=h.ref,w=h.refCleanup;if(_!==null)if(typeof w=="function")try{w()}catch(P){Fn(h,p,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Fn(h,p,P)}else _.current=null}function TI(h){var p=h.type,_=h.memoizedProps,w=h.stateNode;try{e:switch(p){case"button":case"input":case"select":case"textarea":_.autoFocus&&w.focus();break e;case"img":_.src?w.src=_.src:_.srcSet&&(w.srcset=_.srcSet)}}catch(P){Fn(h,h.return,P)}}function R2(h,p,_){try{var w=h.stateNode;Gne(w,h.type,_,p),w[jr]=p}catch(P){Fn(h,h.return,P)}}function CI(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&su(h.type)||h.tag===4}function D2(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||CI(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&&su(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 j2(h,p,_){var w=h.tag;if(w===5||w===6)h=h.stateNode,p?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,p):(p=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,p.appendChild(h),_=_._reactRootContainer,_!=null||p.onclick!==null||(p.onclick=Tl));else if(w!==4&&(w===27&&su(h.type)&&(_=h.stateNode,p=null),h=h.child,h!==null))for(j2(h,p,_),h=h.sibling;h!==null;)j2(h,p,_),h=h.sibling}function Fy(h,p,_){var w=h.tag;if(w===5||w===6)h=h.stateNode,p?_.insertBefore(h,p):_.appendChild(h);else if(w!==4&&(w===27&&su(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Fy(h,p,_),h=h.sibling;h!==null;)Fy(h,p,_),h=h.sibling}function NI(h){var p=h.stateNode,_=h.memoizedProps;try{for(var w=h.type,P=p.attributes;P.length;)p.removeAttributeNode(P[0]);Gi(p,w,_),p[br]=h,p[jr]=_}catch(j){Fn(h,h.return,j)}}var Il=!1,Wr=!1,O2=!1,kI=typeof WeakSet=="function"?WeakSet:Set,Ci=null;function Mne(h,p){if(h=h.containerInfo,nA=av,h=HL(h),CE(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var w=_.getSelection&&_.getSelection();if(w&&w.rangeCount!==0){_=w.anchorNode;var P=w.anchorOffset,j=w.focusNode;w=w.focusOffset;try{_.nodeType,j.nodeType}catch{_=null;break e}var Y=0,le=-1,Ee=-1,Xe=0,lt=0,dt=h,Ze=null;t:for(;;){for(var at;dt!==_||P!==0&&dt.nodeType!==3||(le=Y+P),dt!==j||w!==0&&dt.nodeType!==3||(Ee=Y+w),dt.nodeType===3&&(Y+=dt.nodeValue.length),(at=dt.firstChild)!==null;)Ze=dt,dt=at;for(;;){if(dt===h)break t;if(Ze===_&&++Xe===P&&(le=Y),Ze===j&&++lt===w&&(Ee=Y),(at=dt.nextSibling)!==null)break;dt=Ze,Ze=dt.parentNode}dt=at}_=le===-1||Ee===-1?null:{start:le,end:Ee}}else _=null}_=_||{start:0,end:0}}else _=null;for(rA={focusedElem:h,selectionRange:_},av=!1,Ci=p;Ci!==null;)if(p=Ci,h=p.child,(p.subtreeFlags&1028)!==0&&h!==null)h.return=p,Ci=h;else for(;Ci!==null;){switch(p=Ci,j=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&&j!==null){h=void 0,_=p,P=j.memoizedProps,j=j.memoizedState,w=_.stateNode;try{var jt=Ud(_.type,P);h=w.getSnapshotBeforeUpdate(jt,j),w.__reactInternalSnapshotBeforeUpdate=h}catch(Gt){Fn(_,_.return,Gt)}}break;case 3:if((h&1024)!==0){if(h=p.stateNode.containerInfo,_=h.nodeType,_===9)sA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":sA(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=p.sibling,h!==null){h.return=p.return,Ci=h;break}Ci=p.return}}function PI(h,p,_){var w=_.flags;switch(_.tag){case 0:case 11:case 15:Ul(h,_),w&4&&zg(5,_);break;case 1:if(Ul(h,_),w&4)if(h=_.stateNode,p===null)try{h.componentDidMount()}catch(Y){Fn(_,_.return,Y)}else{var P=Ud(_.type,p.memoizedProps);p=p.memoizedState;try{h.componentDidUpdate(P,p,h.__reactInternalSnapshotBeforeUpdate)}catch(Y){Fn(_,_.return,Y)}}w&64&&EI(_),w&512&&Bg(_,_.return);break;case 3:if(Ul(h,_),w&64&&(h=_.updateQueue,h!==null)){if(p=null,_.child!==null)switch(_.child.tag){case 27:case 5:p=_.child.stateNode;break;case 1:p=_.child.stateNode}try{m4(h,p)}catch(Y){Fn(_,_.return,Y)}}break;case 27:p===null&&w&4&&NI(_);case 26:case 5:Ul(h,_),p===null&&w&4&&TI(_),w&512&&Bg(_,_.return);break;case 12:Ul(h,_);break;case 31:Ul(h,_),w&4&&jI(h,_);break;case 13:Ul(h,_),w&4&&OI(h,_),w&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Dne.bind(null,_),Jne(h,_))));break;case 22:if(w=_.memoizedState!==null||Il,!w){p=p!==null&&p.memoizedState!==null||Wr,P=Il;var j=Wr;Il=w,(Wr=p)&&!j?zl(h,_,(_.subtreeFlags&8772)!==0):Ul(h,_),Il=P,Wr=j}break;case 30:break;default:Ul(h,_)}}function RI(h){var p=h.alternate;p!==null&&(h.alternate=null,RI(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,Oa=!1;function Fl(h,p,_){for(_=_.child;_!==null;)DI(h,p,_),_=_.sibling}function DI(h,p,_){if(oe&&typeof oe.onCommitFiberUnmount=="function")try{oe.onCommitFiberUnmount(Fe,_)}catch{}switch(_.tag){case 26:Wr||qo(_,p),Fl(h,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Wr||qo(_,p);var w=hr,P=Oa;su(_.type)&&(hr=_.stateNode,Oa=!1),Fl(h,p,_),Yg(_.stateNode),hr=w,Oa=P;break;case 5:Wr||qo(_,p);case 6:if(w=hr,P=Oa,hr=null,Fl(h,p,_),hr=w,Oa=P,hr!==null)if(Oa)try{(hr.nodeType===9?hr.body:hr.nodeName==="HTML"?hr.ownerDocument.body:hr).removeChild(_.stateNode)}catch(j){Fn(_,p,j)}else try{hr.removeChild(_.stateNode)}catch(j){Fn(_,p,j)}break;case 18:hr!==null&&(Oa?(h=hr,E5(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Kf(h)):E5(hr,_.stateNode));break;case 4:w=hr,P=Oa,hr=_.stateNode.containerInfo,Oa=!0,Fl(h,p,_),hr=w,Oa=P;break;case 0:case 11:case 14:case 15:Jc(2,_,p),Wr||Jc(4,_,p),Fl(h,p,_);break;case 1:Wr||(qo(_,p),w=_.stateNode,typeof w.componentWillUnmount=="function"&&AI(_,p,w)),Fl(h,p,_);break;case 21:Fl(h,p,_);break;case 22:Wr=(w=Wr)||_.memoizedState!==null,Fl(h,p,_),Wr=w;break;default:Fl(h,p,_)}}function jI(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Kf(h)}catch(_){Fn(p,p.return,_)}}}function OI(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(_){Fn(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 kI),p;case 22:return h=h.stateNode,p=h._retryCache,p===null&&(p=h._retryCache=new kI),p;default:throw Error(r(435,h.tag))}}function Uy(h,p){var _=Ene(h);p.forEach(function(w){if(!_.has(w)){_.add(w);var P=jne.bind(null,h,w);w.then(P,P)}})}function La(h,p){var _=p.deletions;if(_!==null)for(var w=0;w<_.length;w++){var P=_[w],j=h,Y=p,le=Y;e:for(;le!==null;){switch(le.tag){case 27:if(su(le.type)){hr=le.stateNode,Oa=!1;break e}break;case 5:hr=le.stateNode,Oa=!1;break e;case 3:case 4:hr=le.stateNode.containerInfo,Oa=!0;break e}le=le.return}if(hr===null)throw Error(r(160));DI(j,Y,P),hr=null,Oa=!1,j=P.alternate,j!==null&&(j.return=null),P.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)LI(p,h),p=p.sibling}var bo=null;function LI(h,p){var _=h.alternate,w=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:La(p,h),Ia(h),w&4&&(Jc(3,h,h.return),zg(3,h),Jc(5,h,h.return));break;case 1:La(p,h),Ia(h),w&512&&(Wr||_===null||qo(_,_.return)),w&64&&Il&&(h=h.updateQueue,h!==null&&(w=h.callbacks,w!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?w:_.concat(w))));break;case 26:var P=bo;if(La(p,h),Ia(h),w&512&&(Wr||_===null||qo(_,_.return)),w&4){var j=_!==null?_.memoizedState:null;if(w=h.memoizedState,_===null)if(w===null)if(h.stateNode===null){e:{w=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(w){case"title":j=P.getElementsByTagName("title")[0],(!j||j[it]||j[br]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=P.createElement(w),P.head.insertBefore(j,P.querySelector("head > title"))),Gi(j,w,_),j[br]=h,Oe(j),w=j;break e;case"link":var Y=L5("link","href",P).get(w+(_.href||""));if(Y){for(var le=0;le<Y.length;le++)if(j=Y[le],j.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&j.getAttribute("rel")===(_.rel==null?null:_.rel)&&j.getAttribute("title")===(_.title==null?null:_.title)&&j.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){Y.splice(le,1);break t}}j=P.createElement(w),Gi(j,w,_),P.head.appendChild(j);break;case"meta":if(Y=L5("meta","content",P).get(w+(_.content||""))){for(le=0;le<Y.length;le++)if(j=Y[le],j.getAttribute("content")===(_.content==null?null:""+_.content)&&j.getAttribute("name")===(_.name==null?null:_.name)&&j.getAttribute("property")===(_.property==null?null:_.property)&&j.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&j.getAttribute("charset")===(_.charSet==null?null:_.charSet)){Y.splice(le,1);break t}}j=P.createElement(w),Gi(j,w,_),P.head.appendChild(j);break;default:throw Error(r(468,w))}j[br]=h,Oe(j),w=j}h.stateNode=w}else I5(P,h.type,h.stateNode);else h.stateNode=O5(P,w,h.memoizedProps);else j!==w?(j===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):j.count--,w===null?I5(P,h.type,h.stateNode):O5(P,w,h.memoizedProps)):w===null&&h.stateNode!==null&&R2(h,h.memoizedProps,_.memoizedProps)}break;case 27:La(p,h),Ia(h),w&512&&(Wr||_===null||qo(_,_.return)),_!==null&&w&4&&R2(h,h.memoizedProps,_.memoizedProps);break;case 5:if(La(p,h),Ia(h),w&512&&(Wr||_===null||qo(_,_.return)),h.flags&32){P=h.stateNode;try{Vo(P,"")}catch(jt){Fn(h,h.return,jt)}}w&4&&h.stateNode!=null&&(P=h.memoizedProps,R2(h,P,_!==null?_.memoizedProps:P)),w&1024&&(O2=!0);break;case 6:if(La(p,h),Ia(h),w&4){if(h.stateNode===null)throw Error(r(162));w=h.memoizedProps,_=h.stateNode;try{_.nodeValue=w}catch(jt){Fn(h,h.return,jt)}}break;case 3:if(tv=null,P=bo,bo=Jy(p.containerInfo),La(p,h),bo=P,Ia(h),w&4&&_!==null&&_.memoizedState.isDehydrated)try{Kf(p.containerInfo)}catch(jt){Fn(h,h.return,jt)}O2&&(O2=!1,II(h));break;case 4:w=bo,bo=Jy(h.stateNode.containerInfo),La(p,h),Ia(h),bo=w;break;case 12:La(p,h),Ia(h);break;case 31:La(p,h),Ia(h),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Uy(h,w)));break;case 13:La(p,h),Ia(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(By=L()),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Uy(h,w)));break;case 22:P=h.memoizedState!==null;var Ee=_!==null&&_.memoizedState!==null,Xe=Il,lt=Wr;if(Il=Xe||P,Wr=lt||Ee,La(p,h),Wr=lt,Il=Xe,Ia(h),w&8192)e:for(p=h.stateNode,p._visibility=P?p._visibility&-2:p._visibility|1,P&&(_===null||Ee||Il||Wr||zd(h)),_=null,p=h;;){if(p.tag===5||p.tag===26){if(_===null){Ee=_=p;try{if(j=Ee.stateNode,P)Y=j.style,typeof Y.setProperty=="function"?Y.setProperty("display","none","important"):Y.display="none";else{le=Ee.stateNode;var dt=Ee.memoizedProps.style,Ze=dt!=null&&dt.hasOwnProperty("display")?dt.display:null;le.style.display=Ze==null||typeof Ze=="boolean"?"":(""+Ze).trim()}}catch(jt){Fn(Ee,Ee.return,jt)}}}else if(p.tag===6){if(_===null){Ee=p;try{Ee.stateNode.nodeValue=P?"":Ee.memoizedProps}catch(jt){Fn(Ee,Ee.return,jt)}}}else if(p.tag===18){if(_===null){Ee=p;try{var at=Ee.stateNode;P?A5(at,!0):A5(Ee.stateNode,!1)}catch(jt){Fn(Ee,Ee.return,jt)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===h)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break e;for(;p.sibling===null;){if(p.return===null||p.return===h)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}w&4&&(w=h.updateQueue,w!==null&&(_=w.retryQueue,_!==null&&(w.retryQueue=null,Uy(h,_))));break;case 19:La(p,h),Ia(h),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Uy(h,w)));break;case 30:break;case 21:break;default:La(p,h),Ia(h)}}function Ia(h){var p=h.flags;if(p&2){try{for(var _,w=h.return;w!==null;){if(CI(w)){_=w;break}w=w.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,j=D2(h);Fy(h,j,P);break;case 5:var Y=_.stateNode;_.flags&32&&(Vo(Y,""),_.flags&=-33);var le=D2(h);Fy(h,le,Y);break;case 3:case 4:var Ee=_.stateNode.containerInfo,Xe=D2(h);j2(h,Xe,Ee);break;default:throw Error(r(161))}}catch(lt){Fn(h,h.return,lt)}h.flags&=-3}p&4096&&(h.flags&=-4097)}function II(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var p=h;II(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;)PI(h,p.alternate,p),p=p.sibling}function zd(h){for(h=h.child;h!==null;){var p=h;switch(p.tag){case 0:case 11:case 14:case 15:Jc(4,p,p.return),zd(p);break;case 1:qo(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&AI(p,p.return,_),zd(p);break;case 27:Yg(p.stateNode);case 26:case 5:qo(p,p.return),zd(p);break;case 22:p.memoizedState===null&&zd(p);break;case 30:zd(p);break;default:zd(p)}h=h.sibling}}function zl(h,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var w=p.alternate,P=h,j=p,Y=j.flags;switch(j.tag){case 0:case 11:case 15:zl(P,j,_),zg(4,j);break;case 1:if(zl(P,j,_),w=j,P=w.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(Xe){Fn(w,w.return,Xe)}if(w=j,P=w.updateQueue,P!==null){var le=w.stateNode;try{var Ee=P.shared.hiddenCallbacks;if(Ee!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Ee.length;P++)p4(Ee[P],le)}catch(Xe){Fn(w,w.return,Xe)}}_&&Y&64&&EI(j),Bg(j,j.return);break;case 27:NI(j);case 26:case 5:zl(P,j,_),_&&w===null&&Y&4&&TI(j),Bg(j,j.return);break;case 12:zl(P,j,_);break;case 31:zl(P,j,_),_&&Y&4&&jI(P,j);break;case 13:zl(P,j,_),_&&Y&4&&OI(P,j);break;case 22:j.memoizedState===null&&zl(P,j,_),Bg(j,j.return);break;case 30:break;default:zl(P,j,_)}p=p.sibling}}function L2(h,p){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(h=p.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&Tg(_))}function I2(h,p){h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&Tg(h))}function yo(h,p,_,w){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)FI(h,p,_,w),p=p.sibling}function FI(h,p,_,w){var P=p.flags;switch(p.tag){case 0:case 11:case 15:yo(h,p,_,w),P&2048&&zg(9,p);break;case 1:yo(h,p,_,w);break;case 3:yo(h,p,_,w),P&2048&&(h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&Tg(h)));break;case 12:if(P&2048){yo(h,p,_,w),h=p.stateNode;try{var j=p.memoizedProps,Y=j.id,le=j.onPostCommit;typeof le=="function"&&le(Y,p.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ee){Fn(p,p.return,Ee)}}else yo(h,p,_,w);break;case 31:yo(h,p,_,w);break;case 13:yo(h,p,_,w);break;case 23:break;case 22:j=p.stateNode,Y=p.alternate,p.memoizedState!==null?j._visibility&2?yo(h,p,_,w):Hg(h,p):j._visibility&2?yo(h,p,_,w):(j._visibility|=2,If(h,p,_,w,(p.subtreeFlags&10256)!==0||!1)),P&2048&&L2(Y,p);break;case 24:yo(h,p,_,w),P&2048&&I2(p.alternate,p);break;default:yo(h,p,_,w)}}function If(h,p,_,w,P){for(P=P&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var j=h,Y=p,le=_,Ee=w,Xe=Y.flags;switch(Y.tag){case 0:case 11:case 15:If(j,Y,le,Ee,P),zg(8,Y);break;case 23:break;case 22:var lt=Y.stateNode;Y.memoizedState!==null?lt._visibility&2?If(j,Y,le,Ee,P):Hg(j,Y):(lt._visibility|=2,If(j,Y,le,Ee,P)),P&&Xe&2048&&L2(Y.alternate,Y);break;case 24:If(j,Y,le,Ee,P),P&&Xe&2048&&I2(Y.alternate,Y);break;default:If(j,Y,le,Ee,P)}p=p.sibling}}function Hg(h,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=h,w=p,P=w.flags;switch(w.tag){case 22:Hg(_,w),P&2048&&L2(w.alternate,w);break;case 24:Hg(_,w),P&2048&&I2(w.alternate,w);break;default:Hg(_,w)}p=p.sibling}}var $g=8192;function Ff(h,p,_){if(h.subtreeFlags&$g)for(h=h.child;h!==null;)UI(h,p,_),h=h.sibling}function UI(h,p,_){switch(h.tag){case 26:Ff(h,p,_),h.flags&$g&&h.memoizedState!==null&&dre(_,bo,h.memoizedState,h.memoizedProps);break;case 5:Ff(h,p,_);break;case 3:case 4:var w=bo;bo=Jy(h.stateNode.containerInfo),Ff(h,p,_),bo=w;break;case 22:h.memoizedState===null&&(w=h.alternate,w!==null&&w.memoizedState!==null?(w=$g,$g=16777216,Ff(h,p,_),$g=w):Ff(h,p,_));break;default:Ff(h,p,_)}}function zI(h){var p=h.alternate;if(p!==null&&(h=p.child,h!==null)){p.child=null;do p=h.sibling,h.sibling=null,h=p;while(h!==null)}}function Vg(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var w=p[_];Ci=w,HI(w,h)}zI(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)BI(h),h=h.sibling}function BI(h){switch(h.tag){case 0:case 11:case 15:Vg(h),h.flags&2048&&Jc(9,h,h.return);break;case 3:Vg(h);break;case 12:Vg(h);break;case 22:var p=h.stateNode;h.memoizedState!==null&&p._visibility&2&&(h.return===null||h.return.tag!==13)?(p._visibility&=-3,zy(h)):Vg(h);break;default:Vg(h)}}function zy(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var w=p[_];Ci=w,HI(w,h)}zI(h)}for(h=h.child;h!==null;){switch(p=h,p.tag){case 0:case 11:case 15:Jc(8,p,p.return),zy(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,zy(p));break;default:zy(p)}h=h.sibling}}function HI(h,p){for(;Ci!==null;){var _=Ci;switch(_.tag){case 0:case 11:case 15:Jc(8,_,p);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var w=_.memoizedState.cachePool.pool;w!=null&&w.refCount++}break;case 24:Tg(_.memoizedState.cache)}if(w=_.child,w!==null)w.return=_,Ci=w;else e:for(_=h;Ci!==null;){w=Ci;var P=w.sibling,j=w.return;if(RI(w),w===_){Ci=null;break e}if(P!==null){P.return=j,Ci=P;break e}Ci=j}}}var Ane={getCacheForType:function(h){var p=$i($r),_=p.data.get(h);return _===void 0&&(_=h(),p.data.set(h,_)),_},cacheSignal:function(){return $i($r).controller.signal}},Tne=typeof WeakMap=="function"?WeakMap:Map,kn=0,Jn=null,pn=null,yn=0,In=0,as=null,eu=!1,Uf=!1,F2=!1,Bl=0,Cr=0,tu=0,Bd=0,U2=0,ss=0,zf=0,Gg=null,Fa=null,z2=!1,By=0,$I=0,Hy=1/0,$y=null,nu=null,li=0,ru=null,Bf=null,Hl=0,B2=0,H2=null,VI=null,Wg=0,$2=null;function ls(){return(kn&2)!==0&&yn!==0?yn&-yn:K.T!==null?X2():zi()}function GI(){if(ss===0)if((yn&536870912)===0||wn){var h=ge;ge<<=1,(ge&3932160)===0&&(ge=262144),ss=h}else ss=536870912;return h=rs.current,h!==null&&(h.flags|=32),ss}function Ua(h,p,_){(h===Jn&&(In===2||In===9)||h.cancelPendingCommit!==null)&&(Hf(h,0),iu(h,yn,ss,!1)),Qt(h,_),((kn&2)===0||h!==Jn)&&(h===Jn&&((kn&2)===0&&(Bd|=_),Cr===4&&iu(h,yn,ss,!1)),Ko(h))}function WI(h,p,_){if((kn&6)!==0)throw Error(r(327));var w=!_&&(p&127)===0&&(p&h.expiredLanes)===0||ce(h,p),P=w?kne(h,p):G2(h,p,!0),j=w;do{if(P===0){Uf&&!w&&iu(h,p,0,!1);break}else{if(_=h.current.alternate,j&&!Cne(_)){P=G2(h,p,!1),j=!1;continue}if(P===2){if(j=p,h.errorRecoveryDisabledLanes&j)var Y=0;else Y=h.pendingLanes&-536870913,Y=Y!==0?Y:Y&536870912?536870912:0;if(Y!==0){p=Y;e:{var le=h;P=Gg;var Ee=le.current.memoizedState.isDehydrated;if(Ee&&(Hf(le,Y).flags|=256),Y=G2(le,Y,!1),Y!==2){if(F2&&!Ee){le.errorRecoveryDisabledLanes|=j,Bd|=j,P=4;break e}j=Fa,Fa=P,j!==null&&(Fa===null?Fa=j:Fa.push.apply(Fa,j))}P=Y}if(j=!1,P!==2)continue}}if(P===1){Hf(h,0),iu(h,p,0,!0);break}e:{switch(w=h,j=P,j){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:iu(w,p,ss,!eu);break e;case 2:Fa=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(P=By+300-L(),10<P)){if(iu(w,p,ss,!eu),_e(w,0,!0)!==0)break e;Hl=p,w.timeoutHandle=S5(qI.bind(null,w,_,Fa,$y,z2,p,ss,Bd,zf,eu,j,"Throttled",-0,0),P);break e}qI(w,_,Fa,$y,z2,p,ss,Bd,zf,eu,j,null,-0,0)}}break}while(!0);Ko(h)}function qI(h,p,_,w,P,j,Y,le,Ee,Xe,lt,dt,Ze,at){if(h.timeoutHandle=-1,dt=p.subtreeFlags,dt&8192||(dt&16785408)===16785408){dt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Tl},UI(p,j,dt);var jt=(j&62914560)===j?By-L():(j&4194048)===j?$I-L():0;if(jt=hre(dt,jt),jt!==null){Hl=j,h.cancelPendingCommit=jt(t5.bind(null,h,p,j,_,w,P,Y,le,Ee,lt,dt,null,Ze,at)),iu(h,j,Y,!Xe);return}}t5(h,p,j,_,w,P,Y,le,Ee)}function Cne(h){for(var p=h;;){var _=p.tag;if((_===0||_===11||_===15)&&p.flags&16384&&(_=p.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var w=0;w<_.length;w++){var P=_[w],j=P.getSnapshot;P=P.value;try{if(!ts(j(),P))return!1}catch{return!1}}if(_=p.child,p.subtreeFlags&16384&&_!==null)_.return=p,p=_;else{if(p===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function iu(h,p,_,w){p&=~U2,p&=~Bd,h.suspendedLanes|=p,h.pingedLanes&=~p,w&&(h.warmLanes|=p),w=h.expirationTimes;for(var P=p;0<P;){var j=31-He(P),Y=1<<j;w[j]=-1,P&=~Y}_!==0&&Vt(h,_,p)}function Vy(){return(kn&6)===0?(qg(0),!1):!0}function V2(){if(pn!==null){if(In===0)var h=pn.return;else h=pn,Pl=Rd=null,s2(h),Rf=null,Ng=0,h=pn;for(;h!==null;)MI(h.alternate,h),h=h.return;pn=null}}function Hf(h,p){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Kne(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Hl=0,V2(),Jn=h,pn=_=Nl(h.current,null),yn=p,In=0,as=null,eu=!1,Uf=ce(h,p),F2=!1,zf=ss=U2=Bd=tu=Cr=0,Fa=Gg=null,z2=!1,(p&8)!==0&&(p|=p&32);var w=h.entangledLanes;if(w!==0)for(h=h.entanglements,w&=p;0<w;){var P=31-He(w),j=1<<P;p|=h[P],w&=~j}return Bl=p,dy(),_}function KI(h,p){nn=null,K.H=Ig,p===Pf||p===yy?(p=u4(),In=3):p===KE?(p=u4(),In=4):In=p===w2?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,as=p,pn===null&&(Cr=1,Dy(h,Ps(p,h.current)))}function XI(){var h=rs.current;return h===null?!0:(yn&4194048)===yn?Os===null:(yn&62914560)===yn||(yn&536870912)!==0?h===Os:!1}function YI(){var h=K.H;return K.H=Ig,h===null?Ig:h}function ZI(){var h=K.A;return K.A=Ane,h}function Gy(){Cr=4,eu||(yn&4194048)!==yn&&rs.current!==null||(Uf=!0),(tu&134217727)===0&&(Bd&134217727)===0||Jn===null||iu(Jn,yn,ss,!1)}function G2(h,p,_){var w=kn;kn|=2;var P=YI(),j=ZI();(Jn!==h||yn!==p)&&($y=null,Hf(h,p)),p=!1;var Y=Cr;e:do try{if(In!==0&&pn!==null){var le=pn,Ee=as;switch(In){case 8:V2(),Y=6;break e;case 3:case 2:case 9:case 6:rs.current===null&&(p=!0);var Xe=In;if(In=0,as=null,$f(h,le,Ee,Xe),_&&Uf){Y=0;break e}break;default:Xe=In,In=0,as=null,$f(h,le,Ee,Xe)}}Nne(),Y=Cr;break}catch(lt){KI(h,lt)}while(!0);return p&&h.shellSuspendCounter++,Pl=Rd=null,kn=w,K.H=P,K.A=j,pn===null&&(Jn=null,yn=0,dy()),Y}function Nne(){for(;pn!==null;)QI(pn)}function kne(h,p){var _=kn;kn|=2;var w=YI(),P=ZI();Jn!==h||yn!==p?($y=null,Hy=L()+500,Hf(h,p)):Uf=ce(h,p);e:do try{if(In!==0&&pn!==null){p=pn;var j=as;t:switch(In){case 1:In=0,as=null,$f(h,p,j,1);break;case 2:case 9:if(l4(j)){In=0,as=null,JI(p);break}p=function(){In!==2&&In!==9||Jn!==h||(In=7),Ko(h)},j.then(p,p);break e;case 3:In=7;break e;case 4:In=5;break e;case 7:l4(j)?(In=0,as=null,JI(p)):(In=0,as=null,$f(h,p,j,7));break;case 5:var Y=null;switch(pn.tag){case 26:Y=pn.memoizedState;case 5:case 27:var le=pn;if(Y?F5(Y):le.stateNode.complete){In=0,as=null;var Ee=le.sibling;if(Ee!==null)pn=Ee;else{var Xe=le.return;Xe!==null?(pn=Xe,Wy(Xe)):pn=null}break t}}In=0,as=null,$f(h,p,j,5);break;case 6:In=0,as=null,$f(h,p,j,6);break;case 8:V2(),Cr=6;break e;default:throw Error(r(462))}}Pne();break}catch(lt){KI(h,lt)}while(!0);return Pl=Rd=null,K.H=w,K.A=P,kn=_,pn!==null?0:(Jn=null,yn=0,dy(),Cr)}function Pne(){for(;pn!==null&&!Se();)QI(pn)}function QI(h){var p=wI(h.alternate,h,Bl);h.memoizedProps=h.pendingProps,p===null?Wy(h):pn=p}function JI(h){var p=h,_=p.alternate;switch(p.tag){case 15:case 0:p=gI(_,p,p.pendingProps,p.type,void 0,yn);break;case 11:p=gI(_,p,p.pendingProps,p.type.render,p.ref,yn);break;case 5:s2(p);default:MI(_,p),p=pn=ZL(p,Bl),p=wI(_,p,Bl)}h.memoizedProps=h.pendingProps,p===null?Wy(h):pn=p}function $f(h,p,_,w){Pl=Rd=null,s2(p),Rf=null,Ng=0;var P=p.return;try{if(yne(h,P,p,_,yn)){Cr=1,Dy(h,Ps(_,h.current)),pn=null;return}}catch(j){if(P!==null)throw pn=P,j;Cr=1,Dy(h,Ps(_,h.current)),pn=null;return}p.flags&32768?(wn||w===1?h=!0:Uf||(yn&536870912)!==0?h=!1:(eu=h=!0,(w===2||w===9||w===3||w===6)&&(w=rs.current,w!==null&&w.tag===13&&(w.flags|=16384))),e5(p,h)):Wy(p)}function Wy(h){var p=h;do{if((p.flags&32768)!==0){e5(p,eu);return}h=p.return;var _=wne(p.alternate,p,Bl);if(_!==null){pn=_;return}if(p=p.sibling,p!==null){pn=p;return}pn=p=h}while(p!==null);Cr===0&&(Cr=5)}function e5(h,p){do{var _=Sne(h.alternate,h);if(_!==null){_.flags&=32767,pn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(h=h.sibling,h!==null)){pn=h;return}pn=h=_}while(h!==null);Cr=6,pn=null}function t5(h,p,_,w,P,j,Y,le,Ee){h.cancelPendingCommit=null;do qy();while(li!==0);if((kn&6)!==0)throw Error(r(327));if(p!==null){if(p===h.current)throw Error(r(177));if(j=p.lanes|p.childLanes,j|=DE,Ot(h,_,j,Y,le,Ee),h===Jn&&(pn=Jn=null,yn=0),Bf=p,ru=h,Hl=_,B2=j,H2=P,VI=w,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,One(ye,function(){return s5(),null})):(h.callbackNode=null,h.callbackPriority=0),w=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||w){w=K.T,K.T=null,P=G.p,G.p=2,Y=kn,kn|=4;try{Mne(h,p,_)}finally{kn=Y,G.p=P,K.T=w}}li=1,n5(),r5(),i5()}}function n5(){if(li===1){li=0;var h=ru,p=Bf,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var w=G.p;G.p=2;var P=kn;kn|=4;try{LI(p,h);var j=rA,Y=HL(h.containerInfo),le=j.focusedElem,Ee=j.selectionRange;if(Y!==le&&le&&le.ownerDocument&&BL(le.ownerDocument.documentElement,le)){if(Ee!==null&&CE(le)){var Xe=Ee.start,lt=Ee.end;if(lt===void 0&&(lt=Xe),"selectionStart"in le)le.selectionStart=Xe,le.selectionEnd=Math.min(lt,le.value.length);else{var dt=le.ownerDocument||document,Ze=dt&&dt.defaultView||window;if(Ze.getSelection){var at=Ze.getSelection(),jt=le.textContent.length,Gt=Math.min(Ee.start,jt),Gn=Ee.end===void 0?Gt:Math.min(Ee.end,jt);!at.extend&&Gt>Gn&&(Y=Gn,Gn=Gt,Gt=Y);var ze=zL(le,Gt),Re=zL(le,Gn);if(ze&&Re&&(at.rangeCount!==1||at.anchorNode!==ze.node||at.anchorOffset!==ze.offset||at.focusNode!==Re.node||at.focusOffset!==Re.offset)){var We=dt.createRange();We.setStart(ze.node,ze.offset),at.removeAllRanges(),Gt>Gn?(at.addRange(We),at.extend(Re.node,Re.offset)):(We.setEnd(Re.node,Re.offset),at.addRange(We))}}}}for(dt=[],at=le;at=at.parentNode;)at.nodeType===1&&dt.push({element:at,left:at.scrollLeft,top:at.scrollTop});for(typeof le.focus=="function"&&le.focus(),le=0;le<dt.length;le++){var ut=dt[le];ut.element.scrollLeft=ut.left,ut.element.scrollTop=ut.top}}av=!!nA,rA=nA=null}finally{kn=P,G.p=w,K.T=_}}h.current=p,li=2}}function r5(){if(li===2){li=0;var h=ru,p=Bf,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var w=G.p;G.p=2;var P=kn;kn|=4;try{PI(h,p.alternate,p)}finally{kn=P,G.p=w,K.T=_}}li=3}}function i5(){if(li===4||li===3){li=0,z();var h=ru,p=Bf,_=Hl,w=VI;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?li=5:(li=0,Bf=ru=null,a5(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(nu=null),Ei(_),p=p.stateNode,oe&&typeof oe.onCommitFiberRoot=="function")try{oe.onCommitFiberRoot(Fe,p,void 0,(p.current.flags&128)===128)}catch{}if(w!==null){p=K.T,P=G.p,G.p=2,K.T=null;try{for(var j=h.onRecoverableError,Y=0;Y<w.length;Y++){var le=w[Y];j(le.value,{componentStack:le.stack})}}finally{K.T=p,G.p=P}}(Hl&3)!==0&&qy(),Ko(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===$2?Wg++:(Wg=0,$2=h):Wg=0,qg(0)}}function a5(h,p){(h.pooledCacheLanes&=p)===0&&(p=h.pooledCache,p!=null&&(h.pooledCache=null,Tg(p)))}function qy(){return n5(),r5(),i5(),s5()}function s5(){if(li!==5)return!1;var h=ru,p=B2;B2=0;var _=Ei(Hl),w=K.T,P=G.p;try{G.p=32>_?32:_,K.T=null,_=H2,H2=null;var j=ru,Y=Hl;if(li=0,Bf=ru=null,Hl=0,(kn&6)!==0)throw Error(r(331));var le=kn;if(kn|=4,BI(j.current),FI(j,j.current,Y,_),kn=le,qg(0,!1),oe&&typeof oe.onPostCommitFiberRoot=="function")try{oe.onPostCommitFiberRoot(Fe,j)}catch{}return!0}finally{G.p=P,K.T=w,a5(h,p)}}function o5(h,p,_){p=Ps(_,p),p=_2(h.stateNode,p,2),h=Yc(h,p,2),h!==null&&(Qt(h,2),Ko(h))}function Fn(h,p,_){if(h.tag===3)o5(h,h,_);else for(;p!==null;){if(p.tag===3){o5(p,h,_);break}else if(p.tag===1){var w=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(nu===null||!nu.has(w))){h=Ps(_,h),_=lI(2),w=Yc(p,_,2),w!==null&&(cI(_,w,p,h),Qt(w,2),Ko(w));break}}p=p.return}}function W2(h,p,_){var w=h.pingCache;if(w===null){w=h.pingCache=new Tne;var P=new Set;w.set(p,P)}else P=w.get(p),P===void 0&&(P=new Set,w.set(p,P));P.has(_)||(F2=!0,P.add(_),h=Rne.bind(null,h,p,_),p.then(h,h))}function Rne(h,p,_){var w=h.pingCache;w!==null&&w.delete(p),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,Jn===h&&(yn&_)===_&&(Cr===4||Cr===3&&(yn&62914560)===yn&&300>L()-By?(kn&2)===0&&Hf(h,0):U2|=_,zf===yn&&(zf=0)),Ko(h)}function l5(h,p){p===0&&(p=xt()),h=Nd(h,p),h!==null&&(Qt(h,p),Ko(h))}function Dne(h){var p=h.memoizedState,_=0;p!==null&&(_=p.retryLane),l5(h,_)}function jne(h,p){var _=0;switch(h.tag){case 31:case 13:var w=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:w=h.stateNode;break;case 22:w=h.stateNode._retryCache;break;default:throw Error(r(314))}w!==null&&w.delete(p),l5(h,_)}function One(h,p){return Ae(h,p)}var Ky=null,Vf=null,q2=!1,Xy=!1,K2=!1,au=0;function Ko(h){h!==Vf&&h.next===null&&(Vf===null?Ky=Vf=h:Vf=Vf.next=h),Xy=!0,q2||(q2=!0,Ine())}function qg(h,p){if(!K2&&Xy){K2=!0;do for(var _=!1,w=Ky;w!==null;){if(h!==0){var P=w.pendingLanes;if(P===0)var j=0;else{var Y=w.suspendedLanes,le=w.pingedLanes;j=(1<<31-He(42|h)+1)-1,j&=P&~(Y&~le),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(_=!0,h5(w,j))}else j=yn,j=_e(w,w===Jn?j:0,w.cancelPendingCommit!==null||w.timeoutHandle!==-1),(j&3)===0||ce(w,j)||(_=!0,h5(w,j));w=w.next}while(_);K2=!1}}function Lne(){c5()}function c5(){Xy=q2=!1;var h=0;au!==0&&qne()&&(h=au);for(var p=L(),_=null,w=Ky;w!==null;){var P=w.next,j=u5(w,p);j===0?(w.next=null,_===null?Ky=P:_.next=P,P===null&&(Vf=_)):(_=w,(h!==0||(j&3)!==0)&&(Xy=!0)),w=P}li!==0&&li!==5||qg(h),au!==0&&(au=0)}function u5(h,p){for(var _=h.suspendedLanes,w=h.pingedLanes,P=h.expirationTimes,j=h.pendingLanes&-62914561;0<j;){var Y=31-He(j),le=1<<Y,Ee=P[Y];Ee===-1?((le&_)===0||(le&w)!==0)&&(P[Y]=st(le,p)):Ee<=p&&(h.expiredLanes|=le),j&=~le}if(p=Jn,_=yn,_=_e(h,h===p?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),w=h.callbackNode,_===0||h===p&&(In===2||In===9)||h.cancelPendingCommit!==null)return w!==null&&w!==null&&Pe(w),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||ce(h,_)){if(p=_&-_,p===h.callbackPriority)return p;switch(w!==null&&Pe(w),Ei(_)){case 2:case 8:_=we;break;case 32:_=ye;break;case 268435456:_=Be;break;default:_=ye}return w=d5.bind(null,h),_=Ae(_,w),h.callbackPriority=p,h.callbackNode=_,p}return w!==null&&w!==null&&Pe(w),h.callbackPriority=2,h.callbackNode=null,2}function d5(h,p){if(li!==0&&li!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(qy()&&h.callbackNode!==_)return null;var w=yn;return w=_e(h,h===Jn?w:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),w===0?null:(WI(h,w,p),u5(h,L()),h.callbackNode!=null&&h.callbackNode===_?d5.bind(null,h):null)}function h5(h,p){if(qy())return null;WI(h,p,!0)}function Ine(){Xne(function(){(kn&6)!==0?Ae(ve,Lne):c5()})}function X2(){if(au===0){var h=Nf;h===0&&(h=Ye,Ye<<=1,(Ye&261888)===0&&(Ye=256)),au=h}return au}function f5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:ry(""+h)}function p5(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 Fne(h,p,_,w,P){if(p==="submit"&&_&&_.stateNode===P){var j=f5((P[jr]||null).action),Y=w.submitter;Y&&(p=(p=Y[jr]||null)?f5(p.formAction):Y.getAttribute("formAction"),p!==null&&(j=p,Y=null));var le=new oy("action","action",null,w,P);h.push({event:le,listeners:[{instance:null,listener:function(){if(w.defaultPrevented){if(au!==0){var Ee=Y?p5(P,Y):new FormData(P);m2(_,{pending:!0,data:Ee,method:P.method,action:j},null,Ee)}}else typeof j=="function"&&(le.preventDefault(),Ee=Y?p5(P,Y):new FormData(P),m2(_,{pending:!0,data:Ee,method:P.method,action:j},j,Ee))},currentTarget:P}]})}}for(var Y2=0;Y2<RE.length;Y2++){var Z2=RE[Y2],Une=Z2.toLowerCase(),zne=Z2[0].toUpperCase()+Z2.slice(1);xo(Une,"on"+zne)}xo(GL,"onAnimationEnd"),xo(WL,"onAnimationIteration"),xo(qL,"onAnimationStart"),xo("dblclick","onDoubleClick"),xo("focusin","onFocus"),xo("focusout","onBlur"),xo(nne,"onTransitionRun"),xo(rne,"onTransitionStart"),xo(ine,"onTransitionCancel"),xo(KL,"onTransitionEnd"),yt("onMouseEnter",["mouseout","mouseover"]),yt("onMouseLeave",["mouseout","mouseover"]),yt("onPointerEnter",["pointerout","pointerover"]),yt("onPointerLeave",["pointerout","pointerover"]),ft("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ft("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ft("onBeforeInput",["compositionend","keypress","textInput","paste"]),ft("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Kg="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Bne=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Kg));function m5(h,p){p=(p&4)!==0;for(var _=0;_<h.length;_++){var w=h[_],P=w.event;w=w.listeners;e:{var j=void 0;if(p)for(var Y=w.length-1;0<=Y;Y--){var le=w[Y],Ee=le.instance,Xe=le.currentTarget;if(le=le.listener,Ee!==j&&P.isPropagationStopped())break e;j=le,P.currentTarget=Xe;try{j(P)}catch(lt){uy(lt)}P.currentTarget=null,j=Ee}else for(Y=0;Y<w.length;Y++){if(le=w[Y],Ee=le.instance,Xe=le.currentTarget,le=le.listener,Ee!==j&&P.isPropagationStopped())break e;j=le,P.currentTarget=Xe;try{j(P)}catch(lt){uy(lt)}P.currentTarget=null,j=Ee}}}}function mn(h,p){var _=p[Hc];_===void 0&&(_=p[Hc]=new Set);var w=h+"__bubble";_.has(w)||(g5(p,h,2,!1),_.add(w))}function Q2(h,p,_){var w=0;p&&(w|=4),g5(_,h,w,p)}var Yy="_reactListening"+Math.random().toString(36).slice(2);function J2(h){if(!h[Yy]){h[Yy]=!0,Te.forEach(function(_){_!=="selectionchange"&&(Bne.has(_)||Q2(_,!1,h),Q2(_,!0,h))});var p=h.nodeType===9?h:h.ownerDocument;p===null||p[Yy]||(p[Yy]=!0,Q2("selectionchange",!1,p))}}function g5(h,p,_,w){switch(G5(p)){case 2:var P=mre;break;case 8:P=gre;break;default:P=pA}_=P.bind(null,p,_,h),P=void 0,!yE||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(P=!0),w?P!==void 0?h.addEventListener(p,_,{capture:!0,passive:P}):h.addEventListener(p,_,!0):P!==void 0?h.addEventListener(p,_,{passive:P}):h.addEventListener(p,_,!1)}function eA(h,p,_,w,P){var j=w;if((p&1)===0&&(p&2)===0&&w!==null)e:for(;;){if(w===null)return;var Y=w.tag;if(Y===3||Y===4){var le=w.stateNode.containerInfo;if(le===P)break;if(Y===4)for(Y=w.return;Y!==null;){var Ee=Y.tag;if((Ee===3||Ee===4)&&Y.stateNode.containerInfo===P)return;Y=Y.return}for(;le!==null;){if(Y=Mt(le),Y===null)return;if(Ee=Y.tag,Ee===5||Ee===6||Ee===26||Ee===27){w=j=Y;continue e}le=le.parentNode}}w=w.return}_L(function(){var Xe=j,lt=xE(_),dt=[];e:{var Ze=XL.get(h);if(Ze!==void 0){var at=oy,jt=h;switch(h){case"keypress":if(ay(_)===0)break e;case"keydown":case"keyup":at=jte;break;case"focusin":jt="focus",at=SE;break;case"focusout":jt="blur",at=SE;break;case"beforeblur":case"afterblur":at=SE;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":at=ML;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":at=wte;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":at=Ite;break;case GL:case WL:case qL:at=Ete;break;case KL:at=Ute;break;case"scroll":case"scrollend":at=vte;break;case"wheel":at=Bte;break;case"copy":case"cut":case"paste":at=Tte;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":at=AL;break;case"toggle":case"beforetoggle":at=$te}var Gt=(p&4)!==0,Gn=!Gt&&(h==="scroll"||h==="scrollend"),ze=Gt?Ze!==null?Ze+"Capture":null:Ze;Gt=[];for(var Re=Xe,We;Re!==null;){var ut=Re;if(We=ut.stateNode,ut=ut.tag,ut!==5&&ut!==26&&ut!==27||We===null||ze===null||(ut=gg(Re,ze),ut!=null&&Gt.push(Xg(Re,ut,We))),Gn)break;Re=Re.return}0<Gt.length&&(Ze=new at(Ze,jt,null,_,lt),dt.push({event:Ze,listeners:Gt}))}}if((p&7)===0){e:{if(Ze=h==="mouseover"||h==="pointerover",at=h==="mouseout"||h==="pointerout",Ze&&_!==gE&&(jt=_.relatedTarget||_.fromElement)&&(Mt(jt)||jt[mo]))break e;if((at||Ze)&&(Ze=lt.window===lt?lt:(Ze=lt.ownerDocument)?Ze.defaultView||Ze.parentWindow:window,at?(jt=_.relatedTarget||_.toElement,at=Xe,jt=jt?Mt(jt):null,jt!==null&&(Gn=a(jt),Gt=jt.tag,jt!==Gn||Gt!==5&&Gt!==27&&Gt!==6)&&(jt=null)):(at=null,jt=Xe),at!==jt)){if(Gt=ML,ut="onMouseLeave",ze="onMouseEnter",Re="mouse",(h==="pointerout"||h==="pointerover")&&(Gt=AL,ut="onPointerLeave",ze="onPointerEnter",Re="pointer"),Gn=at==null?Ze:Me(at),We=jt==null?Ze:Me(jt),Ze=new Gt(ut,Re+"leave",at,_,lt),Ze.target=Gn,Ze.relatedTarget=We,ut=null,Mt(lt)===Xe&&(Gt=new Gt(ze,Re+"enter",jt,_,lt),Gt.target=We,Gt.relatedTarget=Gn,ut=Gt),Gn=ut,at&&jt)t:{for(Gt=Hne,ze=at,Re=jt,We=0,ut=ze;ut;ut=Gt(ut))We++;ut=0;for(var zt=Re;zt;zt=Gt(zt))ut++;for(;0<We-ut;)ze=Gt(ze),We--;for(;0<ut-We;)Re=Gt(Re),ut--;for(;We--;){if(ze===Re||Re!==null&&ze===Re.alternate){Gt=ze;break t}ze=Gt(ze),Re=Gt(Re)}Gt=null}else Gt=null;at!==null&&x5(dt,Ze,at,Gt,!1),jt!==null&&Gn!==null&&x5(dt,Gn,jt,Gt,!0)}}e:{if(Ze=Xe?Me(Xe):window,at=Ze.nodeName&&Ze.nodeName.toLowerCase(),at==="select"||at==="input"&&Ze.type==="file")var An=jL;else if(RL(Ze))if(OL)An=Jte;else{An=Zte;var It=Yte}else at=Ze.nodeName,!at||at.toLowerCase()!=="input"||Ze.type!=="checkbox"&&Ze.type!=="radio"?Xe&&mE(Xe.elementType)&&(An=jL):An=Qte;if(An&&(An=An(h,Xe))){DL(dt,An,_,lt);break e}It&&It(h,Ze,Xe),h==="focusout"&&Xe&&Ze.type==="number"&&Xe.memoizedProps.value!=null&&Ai(Ze,"number",Ze.value)}switch(It=Xe?Me(Xe):window,h){case"focusin":(RL(It)||It.contentEditable==="true")&&(_f=It,NE=Xe,Mg=null);break;case"focusout":Mg=NE=_f=null;break;case"mousedown":kE=!0;break;case"contextmenu":case"mouseup":case"dragend":kE=!1,$L(dt,_,lt);break;case"selectionchange":if(tne)break;case"keydown":case"keyup":$L(dt,_,lt)}var rn;if(EE)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 vf?kL(h,_)&&(vn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(vn="onCompositionStart");vn&&(TL&&_.locale!=="ko"&&(vf||vn!=="onCompositionStart"?vn==="onCompositionEnd"&&vf&&(rn=wL()):($c=lt,vE="value"in $c?$c.value:$c.textContent,vf=!0)),It=Zy(Xe,vn),0<It.length&&(vn=new EL(vn,h,null,_,lt),dt.push({event:vn,listeners:It}),rn?vn.data=rn:(rn=PL(_),rn!==null&&(vn.data=rn)))),(rn=Gte?Wte(h,_):qte(h,_))&&(vn=Zy(Xe,"onBeforeInput"),0<vn.length&&(It=new EL("onBeforeInput","beforeinput",null,_,lt),dt.push({event:It,listeners:vn}),It.data=rn)),Fne(dt,h,Xe,_,lt)}m5(dt,p)})}function Xg(h,p,_){return{instance:h,listener:p,currentTarget:_}}function Zy(h,p){for(var _=p+"Capture",w=[];h!==null;){var P=h,j=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||j===null||(P=gg(h,_),P!=null&&w.unshift(Xg(h,P,j)),P=gg(h,p),P!=null&&w.push(Xg(h,P,j))),h.tag===3)return w;h=h.return}return[]}function Hne(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function x5(h,p,_,w,P){for(var j=p._reactName,Y=[];_!==null&&_!==w;){var le=_,Ee=le.alternate,Xe=le.stateNode;if(le=le.tag,Ee!==null&&Ee===w)break;le!==5&&le!==26&&le!==27||Xe===null||(Ee=Xe,P?(Xe=gg(_,j),Xe!=null&&Y.unshift(Xg(_,Xe,Ee))):P||(Xe=gg(_,j),Xe!=null&&Y.push(Xg(_,Xe,Ee)))),_=_.return}Y.length!==0&&h.push({event:p,listeners:Y})}var $ne=/\r\n?/g,Vne=/\u0000|\uFFFD/g;function b5(h){return(typeof h=="string"?h:""+h).replace($ne,`
- `).replace(Vne,"")}function y5(h,p){return p=b5(p),b5(h)===p}function Vn(h,p,_,w,P,j){switch(_){case"children":typeof w=="string"?p==="body"||p==="textarea"&&w===""||Vo(h,w):(typeof w=="number"||typeof w=="bigint")&&p!=="body"&&Vo(h,""+w);break;case"className":Ut(h,"class",w);break;case"tabIndex":Ut(h,"tabindex",w);break;case"dir":case"role":case"viewBox":case"width":case"height":Ut(h,_,w);break;case"style":yL(h,w,j);break;case"data":if(p!=="object"){Ut(h,"data",w);break}case"src":case"href":if(w===""&&(p!=="a"||_!=="href")){h.removeAttribute(_);break}if(w==null||typeof w=="function"||typeof w=="symbol"||typeof w=="boolean"){h.removeAttribute(_);break}w=ry(""+w),h.setAttribute(_,w);break;case"action":case"formAction":if(typeof w=="function"){h.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof j=="function"&&(_==="formAction"?(p!=="input"&&Vn(h,p,"name",P.name,P,null),Vn(h,p,"formEncType",P.formEncType,P,null),Vn(h,p,"formMethod",P.formMethod,P,null),Vn(h,p,"formTarget",P.formTarget,P,null)):(Vn(h,p,"encType",P.encType,P,null),Vn(h,p,"method",P.method,P,null),Vn(h,p,"target",P.target,P,null)));if(w==null||typeof w=="symbol"||typeof w=="boolean"){h.removeAttribute(_);break}w=ry(""+w),h.setAttribute(_,w);break;case"onClick":w!=null&&(h.onclick=Tl);break;case"onScroll":w!=null&&mn("scroll",h);break;case"onScrollEnd":w!=null&&mn("scrollend",h);break;case"dangerouslySetInnerHTML":if(w!=null){if(typeof w!="object"||!("__html"in w))throw Error(r(61));if(_=w.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=w&&typeof w!="function"&&typeof w!="symbol";break;case"muted":h.muted=w&&typeof w!="function"&&typeof w!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(w==null||typeof w=="function"||typeof w=="boolean"||typeof w=="symbol"){h.removeAttribute("xlink:href");break}_=ry(""+w),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":w!=null&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,""+w):h.removeAttribute(_);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":w&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":w===!0?h.setAttribute(_,""):w!==!1&&w!=null&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,w):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":w!=null&&typeof w!="function"&&typeof w!="symbol"&&!isNaN(w)&&1<=w?h.setAttribute(_,w):h.removeAttribute(_);break;case"rowSpan":case"start":w==null||typeof w=="function"||typeof w=="symbol"||isNaN(w)?h.removeAttribute(_):h.setAttribute(_,w);break;case"popover":mn("beforetoggle",h),mn("toggle",h),Xt(h,"popover",w);break;case"xlinkActuate":an(h,"http://www.w3.org/1999/xlink","xlink:actuate",w);break;case"xlinkArcrole":an(h,"http://www.w3.org/1999/xlink","xlink:arcrole",w);break;case"xlinkRole":an(h,"http://www.w3.org/1999/xlink","xlink:role",w);break;case"xlinkShow":an(h,"http://www.w3.org/1999/xlink","xlink:show",w);break;case"xlinkTitle":an(h,"http://www.w3.org/1999/xlink","xlink:title",w);break;case"xlinkType":an(h,"http://www.w3.org/1999/xlink","xlink:type",w);break;case"xmlBase":an(h,"http://www.w3.org/XML/1998/namespace","xml:base",w);break;case"xmlLang":an(h,"http://www.w3.org/XML/1998/namespace","xml:lang",w);break;case"xmlSpace":an(h,"http://www.w3.org/XML/1998/namespace","xml:space",w);break;case"is":Xt(h,"is",w);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=bte.get(_)||_,Xt(h,_,w))}}function tA(h,p,_,w,P,j){switch(_){case"style":yL(h,w,j);break;case"dangerouslySetInnerHTML":if(w!=null){if(typeof w!="object"||!("__html"in w))throw Error(r(61));if(_=w.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof w=="string"?Vo(h,w):(typeof w=="number"||typeof w=="bigint")&&Vo(h,""+w);break;case"onScroll":w!=null&&mn("scroll",h);break;case"onScrollEnd":w!=null&&mn("scrollend",h);break;case"onClick":w!=null&&(h.onclick=Tl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ot.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),p=_.slice(2,P?_.length-7:void 0),j=h[jr]||null,j=j!=null?j[_]:null,typeof j=="function"&&h.removeEventListener(p,j,P),typeof w=="function")){typeof j!="function"&&j!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(p,w,P);break e}_ in h?h[_]=w:w===!0?h.setAttribute(_,""):Xt(h,_,w)}}}function Gi(h,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":mn("error",h),mn("load",h);var w=!1,P=!1,j;for(j in _)if(_.hasOwnProperty(j)){var Y=_[j];if(Y!=null)switch(j){case"src":w=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Vn(h,p,j,Y,_,null)}}P&&Vn(h,p,"srcSet",_.srcSet,_,null),w&&Vn(h,p,"src",_.src,_,null);return;case"input":mn("invalid",h);var le=j=Y=P=null,Ee=null,Xe=null;for(w in _)if(_.hasOwnProperty(w)){var lt=_[w];if(lt!=null)switch(w){case"name":P=lt;break;case"type":Y=lt;break;case"checked":Ee=lt;break;case"defaultChecked":Xe=lt;break;case"value":j=lt;break;case"defaultValue":le=lt;break;case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(r(137,p));break;default:Vn(h,p,w,lt,_,null)}}Ln(h,j,le,Ee,Xe,Y,P,!1);return;case"select":mn("invalid",h),w=Y=j=null;for(P in _)if(_.hasOwnProperty(P)&&(le=_[P],le!=null))switch(P){case"value":j=le;break;case"defaultValue":Y=le;break;case"multiple":w=le;default:Vn(h,p,P,le,_,null)}p=j,_=Y,h.multiple=!!w,p!=null?oi(h,!!w,p,!1):_!=null&&oi(h,!!w,_,!0);return;case"textarea":mn("invalid",h),j=P=w=null;for(Y in _)if(_.hasOwnProperty(Y)&&(le=_[Y],le!=null))switch(Y){case"value":w=le;break;case"defaultValue":P=le;break;case"children":j=le;break;case"dangerouslySetInnerHTML":if(le!=null)throw Error(r(91));break;default:Vn(h,p,Y,le,_,null)}Bi(h,w,P,j);return;case"option":for(Ee in _)if(_.hasOwnProperty(Ee)&&(w=_[Ee],w!=null))switch(Ee){case"selected":h.selected=w&&typeof w!="function"&&typeof w!="symbol";break;default:Vn(h,p,Ee,w,_,null)}return;case"dialog":mn("beforetoggle",h),mn("toggle",h),mn("cancel",h),mn("close",h);break;case"iframe":case"object":mn("load",h);break;case"video":case"audio":for(w=0;w<Kg.length;w++)mn(Kg[w],h);break;case"image":mn("error",h),mn("load",h);break;case"details":mn("toggle",h);break;case"embed":case"source":case"link":mn("error",h),mn("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Xe in _)if(_.hasOwnProperty(Xe)&&(w=_[Xe],w!=null))switch(Xe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Vn(h,p,Xe,w,_,null)}return;default:if(mE(p)){for(lt in _)_.hasOwnProperty(lt)&&(w=_[lt],w!==void 0&&tA(h,p,lt,w,_,void 0));return}}for(le in _)_.hasOwnProperty(le)&&(w=_[le],w!=null&&Vn(h,p,le,w,_,null))}function Gne(h,p,_,w){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,j=null,Y=null,le=null,Ee=null,Xe=null,lt=null;for(at in _){var dt=_[at];if(_.hasOwnProperty(at)&&dt!=null)switch(at){case"checked":break;case"value":break;case"defaultValue":Ee=dt;default:w.hasOwnProperty(at)||Vn(h,p,at,null,w,dt)}}for(var Ze in w){var at=w[Ze];if(dt=_[Ze],w.hasOwnProperty(Ze)&&(at!=null||dt!=null))switch(Ze){case"type":j=at;break;case"name":P=at;break;case"checked":Xe=at;break;case"defaultChecked":lt=at;break;case"value":Y=at;break;case"defaultValue":le=at;break;case"children":case"dangerouslySetInnerHTML":if(at!=null)throw Error(r(137,p));break;default:at!==dt&&Vn(h,p,Ze,at,w,dt)}}go(h,Y,le,Ee,Xe,lt,j,P);return;case"select":at=Y=le=Ze=null;for(j in _)if(Ee=_[j],_.hasOwnProperty(j)&&Ee!=null)switch(j){case"value":break;case"multiple":at=Ee;default:w.hasOwnProperty(j)||Vn(h,p,j,null,w,Ee)}for(P in w)if(j=w[P],Ee=_[P],w.hasOwnProperty(P)&&(j!=null||Ee!=null))switch(P){case"value":Ze=j;break;case"defaultValue":le=j;break;case"multiple":Y=j;default:j!==Ee&&Vn(h,p,P,j,w,Ee)}p=le,_=Y,w=at,Ze!=null?oi(h,!!_,Ze,!1):!!w!=!!_&&(p!=null?oi(h,!!_,p,!0):oi(h,!!_,_?[]:"",!1));return;case"textarea":at=Ze=null;for(le in _)if(P=_[le],_.hasOwnProperty(le)&&P!=null&&!w.hasOwnProperty(le))switch(le){case"value":break;case"children":break;default:Vn(h,p,le,null,w,P)}for(Y in w)if(P=w[Y],j=_[Y],w.hasOwnProperty(Y)&&(P!=null||j!=null))switch(Y){case"value":Ze=P;break;case"defaultValue":at=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==j&&Vn(h,p,Y,P,w,j)}Ti(h,Ze,at);return;case"option":for(var jt in _)if(Ze=_[jt],_.hasOwnProperty(jt)&&Ze!=null&&!w.hasOwnProperty(jt))switch(jt){case"selected":h.selected=!1;break;default:Vn(h,p,jt,null,w,Ze)}for(Ee in w)if(Ze=w[Ee],at=_[Ee],w.hasOwnProperty(Ee)&&Ze!==at&&(Ze!=null||at!=null))switch(Ee){case"selected":h.selected=Ze&&typeof Ze!="function"&&typeof Ze!="symbol";break;default:Vn(h,p,Ee,Ze,w,at)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Gt in _)Ze=_[Gt],_.hasOwnProperty(Gt)&&Ze!=null&&!w.hasOwnProperty(Gt)&&Vn(h,p,Gt,null,w,Ze);for(Xe in w)if(Ze=w[Xe],at=_[Xe],w.hasOwnProperty(Xe)&&Ze!==at&&(Ze!=null||at!=null))switch(Xe){case"children":case"dangerouslySetInnerHTML":if(Ze!=null)throw Error(r(137,p));break;default:Vn(h,p,Xe,Ze,w,at)}return;default:if(mE(p)){for(var Gn in _)Ze=_[Gn],_.hasOwnProperty(Gn)&&Ze!==void 0&&!w.hasOwnProperty(Gn)&&tA(h,p,Gn,void 0,w,Ze);for(lt in w)Ze=w[lt],at=_[lt],!w.hasOwnProperty(lt)||Ze===at||Ze===void 0&&at===void 0||tA(h,p,lt,Ze,w,at);return}}for(var ze in _)Ze=_[ze],_.hasOwnProperty(ze)&&Ze!=null&&!w.hasOwnProperty(ze)&&Vn(h,p,ze,null,w,Ze);for(dt in w)Ze=w[dt],at=_[dt],!w.hasOwnProperty(dt)||Ze===at||Ze==null&&at==null||Vn(h,p,dt,Ze,w,at)}function v5(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Wne(){if(typeof performance.getEntriesByType=="function"){for(var h=0,p=0,_=performance.getEntriesByType("resource"),w=0;w<_.length;w++){var P=_[w],j=P.transferSize,Y=P.initiatorType,le=P.duration;if(j&&le&&v5(Y)){for(Y=0,le=P.responseEnd,w+=1;w<_.length;w++){var Ee=_[w],Xe=Ee.startTime;if(Xe>le)break;var lt=Ee.transferSize,dt=Ee.initiatorType;lt&&v5(dt)&&(Ee=Ee.responseEnd,Y+=lt*(Ee<le?1:(le-Xe)/(Ee-Xe)))}if(--w,p+=8*(j+Y)/(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 Qy(h){return h.nodeType===9?h:h.ownerDocument}function _5(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 w5(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 aA=null;function qne(){var h=window.event;return h&&h.type==="popstate"?h===aA?!1:(aA=h,!0):(aA=null,!1)}var S5=typeof setTimeout=="function"?setTimeout:void 0,Kne=typeof clearTimeout=="function"?clearTimeout:void 0,M5=typeof Promise=="function"?Promise:void 0,Xne=typeof queueMicrotask=="function"?queueMicrotask:typeof M5<"u"?function(h){return M5.resolve(null).then(h).catch(Yne)}:S5;function Yne(h){setTimeout(function(){throw h})}function su(h){return h==="head"}function E5(h,p){var _=p,w=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(w===0){h.removeChild(P),Kf(p);return}w--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")w++;else if(_==="html")Yg(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Yg(_);for(var j=_.firstChild;j;){var Y=j.nextSibling,le=j.nodeName;j[it]||le==="SCRIPT"||le==="STYLE"||le==="LINK"&&j.rel.toLowerCase()==="stylesheet"||_.removeChild(j),j=Y}}else _==="body"&&Yg(h.ownerDocument.body);_=P}while(_);Kf(p)}function A5(h,p){var _=h;h=0;do{var w=_.nextSibling;if(_.nodeType===1?p?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(p?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),w&&w.nodeType===8)if(_=w.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=w}while(_)}function sA(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":sA(_),et(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Zne(h,p,_,w){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==p.toLowerCase()){if(!w&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(w){if(!h[it])switch(p){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(j=h.getAttribute("rel"),j==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(j!==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(j=h.getAttribute("src"),(j!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&j&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(p==="input"&&h.type==="hidden"){var j=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===j)return h}else return h;if(h=Ls(h.nextSibling),h===null)break}return null}function Qne(h,p,_){if(p==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=Ls(h.nextSibling),h===null))return null;return h}function T5(h,p){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!p||(h=Ls(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 Jne(h,p){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=p;else if(h.data!=="$?"||_.readyState!=="loading")p();else{var w=function(){p(),_.removeEventListener("DOMContentLoaded",w)};_.addEventListener("DOMContentLoaded",w),h._reactRetry=w}}function Ls(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 C5(h){h=h.nextSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(p===0)return Ls(h.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}h=h.nextSibling}return null}function N5(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 k5(h,p,_){switch(p=Qy(_),h){case"html":if(h=p.documentElement,!h)throw Error(r(452));return h;case"head":if(h=p.head,!h)throw Error(r(453));return h;case"body":if(h=p.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function Yg(h){for(var p=h.attributes;p.length;)h.removeAttributeNode(p[0]);et(h)}var Is=new Map,P5=new Set;function Jy(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var $l=G.d;G.d={f:ere,r:tre,D:nre,C:rre,L:ire,m:are,X:ore,S:sre,M:lre};function ere(){var h=$l.f(),p=Vy();return h||p}function tre(h){var p=ae(h);p!==null&&p.tag===5&&p.type==="form"?K4(p):$l.r(h)}var Gf=typeof document>"u"?null:document;function R5(h,p,_){var w=Gf;if(w&&typeof p=="string"&&p){var P=Dn(p);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),P5.has(P)||(P5.add(P),h={rel:h,crossOrigin:_,href:p},w.querySelector(P)===null&&(p=w.createElement("link"),Gi(p,"link",h),Oe(p),w.head.appendChild(p)))}}function nre(h){$l.D(h),R5("dns-prefetch",h,null)}function rre(h,p){$l.C(h,p),R5("preconnect",h,p)}function ire(h,p,_){$l.L(h,p,_);var w=Gf;if(w&&h&&p){var P='link[rel="preload"][as="'+Dn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+Dn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+Dn(_.imageSizes)+'"]')):P+='[href="'+Dn(h)+'"]';var j=P;switch(p){case"style":j=Wf(h);break;case"script":j=qf(h)}Is.has(j)||(h=f({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:h,as:p},_),Is.set(j,h),w.querySelector(P)!==null||p==="style"&&w.querySelector(Zg(j))||p==="script"&&w.querySelector(Qg(j))||(p=w.createElement("link"),Gi(p,"link",h),Oe(p),w.head.appendChild(p)))}}function are(h,p){$l.m(h,p);var _=Gf;if(_&&h){var w=p&&typeof p.as=="string"?p.as:"script",P='link[rel="modulepreload"][as="'+Dn(w)+'"][href="'+Dn(h)+'"]',j=P;switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=qf(h)}if(!Is.has(j)&&(h=f({rel:"modulepreload",href:h},p),Is.set(j,h),_.querySelector(P)===null)){switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Qg(j)))return}w=_.createElement("link"),Gi(w,"link",h),Oe(w),_.head.appendChild(w)}}}function sre(h,p,_){$l.S(h,p,_);var w=Gf;if(w&&h){var P=Ie(w).hoistableStyles,j=Wf(h);p=p||"default";var Y=P.get(j);if(!Y){var le={loading:0,preload:null};if(Y=w.querySelector(Zg(j)))le.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":p},_),(_=Is.get(j))&&uA(h,_);var Ee=Y=w.createElement("link");Oe(Ee),Gi(Ee,"link",h),Ee._p=new Promise(function(Xe,lt){Ee.onload=Xe,Ee.onerror=lt}),Ee.addEventListener("load",function(){le.loading|=1}),Ee.addEventListener("error",function(){le.loading|=2}),le.loading|=4,ev(Y,p,w)}Y={type:"stylesheet",instance:Y,count:1,state:le},P.set(j,Y)}}}function ore(h,p){$l.X(h,p);var _=Gf;if(_&&h){var w=Ie(_).hoistableScripts,P=qf(h),j=w.get(P);j||(j=_.querySelector(Qg(P)),j||(h=f({src:h,async:!0},p),(p=Is.get(P))&&dA(h,p),j=_.createElement("script"),Oe(j),Gi(j,"link",h),_.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},w.set(P,j))}}function lre(h,p){$l.M(h,p);var _=Gf;if(_&&h){var w=Ie(_).hoistableScripts,P=qf(h),j=w.get(P);j||(j=_.querySelector(Qg(P)),j||(h=f({src:h,async:!0,type:"module"},p),(p=Is.get(P))&&dA(h,p),j=_.createElement("script"),Oe(j),Gi(j,"link",h),_.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},w.set(P,j))}}function D5(h,p,_,w){var P=(P=pe.current)?Jy(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(p=Wf(_.href),_=Ie(P).hoistableStyles,w=_.get(p),w||(w={type:"style",instance:null,count:0,state:null},_.set(p,w)),w):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Wf(_.href);var j=Ie(P).hoistableStyles,Y=j.get(h);if(Y||(P=P.ownerDocument||P,Y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(h,Y),(j=P.querySelector(Zg(h)))&&!j._p&&(Y.instance=j,Y.state.loading=5),Is.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Is.set(h,_),j||cre(P,h,_,Y.state))),p&&w===null)throw Error(r(528,""));return Y}if(p&&w!==null)throw Error(r(529,""));return null;case"script":return p=_.async,_=_.src,typeof _=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=qf(_),_=Ie(P).hoistableScripts,w=_.get(p),w||(w={type:"script",instance:null,count:0,state:null},_.set(p,w)),w):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Wf(h){return'href="'+Dn(h)+'"'}function Zg(h){return'link[rel="stylesheet"]['+h+"]"}function j5(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function cre(h,p,_,w){h.querySelector('link[rel="preload"][as="style"]['+p+"]")?w.loading=1:(p=h.createElement("link"),w.preload=p,p.addEventListener("load",function(){return w.loading|=1}),p.addEventListener("error",function(){return w.loading|=2}),Gi(p,"link",_),Oe(p),h.head.appendChild(p))}function qf(h){return'[src="'+Dn(h)+'"]'}function Qg(h){return"script[async]"+h}function O5(h,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var w=h.querySelector('style[data-href~="'+Dn(_.href)+'"]');if(w)return p.instance=w,Oe(w),w;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return w=(h.ownerDocument||h).createElement("style"),Oe(w),Gi(w,"style",P),ev(w,_.precedence,h),p.instance=w;case"stylesheet":P=Wf(_.href);var j=h.querySelector(Zg(P));if(j)return p.state.loading|=4,p.instance=j,Oe(j),j;w=j5(_),(P=Is.get(P))&&uA(w,P),j=(h.ownerDocument||h).createElement("link"),Oe(j);var Y=j;return Y._p=new Promise(function(le,Ee){Y.onload=le,Y.onerror=Ee}),Gi(j,"link",w),p.state.loading|=4,ev(j,_.precedence,h),p.instance=j;case"script":return j=qf(_.src),(P=h.querySelector(Qg(j)))?(p.instance=P,Oe(P),P):(w=_,(P=Is.get(j))&&(w=f({},_),dA(w,P)),h=h.ownerDocument||h,P=h.createElement("script"),Oe(P),Gi(P,"link",w),h.head.appendChild(P),p.instance=P);case"void":return null;default:throw Error(r(443,p.type))}else p.type==="stylesheet"&&(p.state.loading&4)===0&&(w=p.instance,p.state.loading|=4,ev(w,_.precedence,h));return p.instance}function ev(h,p,_){for(var w=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=w.length?w[w.length-1]:null,j=P,Y=0;Y<w.length;Y++){var le=w[Y];if(le.dataset.precedence===p)j=le;else if(j!==P)break}j?j.parentNode.insertBefore(h,j.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 tv=null;function L5(h,p,_){if(tv===null){var w=new Map,P=tv=new Map;P.set(_,w)}else P=tv,w=P.get(_),w||(w=new Map,P.set(_,w));if(w.has(h))return w;for(w.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var j=_[P];if(!(j[it]||j[br]||h==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var Y=j.getAttribute(p)||"";Y=h+Y;var le=w.get(Y);le?le.push(j):w.set(Y,[j])}}return w}function I5(h,p,_){h=h.ownerDocument||h,h.head.insertBefore(_,p==="title"?h.querySelector("head > title"):null)}function ure(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 F5(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function dre(h,p,_,w){if(_.type==="stylesheet"&&(typeof w.media!="string"||matchMedia(w.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Wf(w.href),j=p.querySelector(Zg(P));if(j){p=j._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(h.count++,h=nv.bind(h),p.then(h,h)),_.state.loading|=4,_.instance=j,Oe(j);return}j=p.ownerDocument||p,w=j5(w),(P=Is.get(P))&&uA(w,P),j=j.createElement("link"),Oe(j);var Y=j;Y._p=new Promise(function(le,Ee){Y.onload=le,Y.onerror=Ee}),Gi(j,"link",w),_.instance=j}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=nv.bind(h),p.addEventListener("load",_),p.addEventListener("error",_))}}var hA=0;function hre(h,p){return h.stylesheets&&h.count===0&&iv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var w=setTimeout(function(){if(h.stylesheets&&iv(h,h.stylesheets),h.unsuspend){var j=h.unsuspend;h.unsuspend=null,j()}},6e4+p);0<h.imgBytes&&hA===0&&(hA=62500*Wne());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&iv(h,h.stylesheets),h.unsuspend)){var j=h.unsuspend;h.unsuspend=null,j()}},(h.imgBytes>hA?50:800)+p);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(w),clearTimeout(P)}}:null}function nv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)iv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var rv=null;function iv(h,p){h.stylesheets=null,h.unsuspend!==null&&(h.count++,rv=new Map,p.forEach(fre,h),rv=null,nv.call(h))}function fre(h,p){if(!(p.state.loading&4)){var _=rv.get(h);if(_)var w=_.get(null);else{_=new Map,rv.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<P.length;j++){var Y=P[j];(Y.nodeName==="LINK"||Y.getAttribute("media")!=="not all")&&(_.set(Y.dataset.precedence,Y),w=Y)}w&&_.set(null,w)}P=p.instance,Y=P.getAttribute("data-precedence"),j=_.get(Y)||w,j===w&&_.set(null,P),_.set(Y,P),this.count++,w=nv.bind(this),P.addEventListener("load",w),P.addEventListener("error",w),j?j.parentNode.insertBefore(P,j.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),p.state.loading|=4}}var Jg={$$typeof:S,Provider:null,Consumer:null,_currentValue:ee,_currentValue2:ee,_threadCount:0};function pre(h,p,_,w,P,j,Y,le,Ee){this.tag=1,this.containerInfo=h,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=St(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=St(0),this.hiddenUpdates=St(null),this.identifierPrefix=w,this.onUncaughtError=P,this.onCaughtError=j,this.onRecoverableError=Y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ee,this.incompleteTransitions=new Map}function U5(h,p,_,w,P,j,Y,le,Ee,Xe,lt,dt){return h=new pre(h,p,_,Y,Ee,Xe,lt,dt,le),p=1,j===!0&&(p|=24),j=ns(3,null,null,p),h.current=j,j.stateNode=h,p=GE(),p.refCount++,h.pooledCache=p,p.refCount++,j.memoizedState={element:w,isDehydrated:_,cache:p},XE(j),h}function z5(h){return h?(h=Mf,h):Mf}function B5(h,p,_,w,P,j){P=z5(P),w.context===null?w.context=P:w.pendingContext=P,w=Xc(p),w.payload={element:_},j=j===void 0?null:j,j!==null&&(w.callback=j),_=Yc(h,w,p),_!==null&&(Ua(_,h,p),Pg(_,h,p))}function H5(h,p){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<p?_:p}}function fA(h,p){H5(h,p),(h=h.alternate)&&H5(h,p)}function $5(h){if(h.tag===13||h.tag===31){var p=Nd(h,67108864);p!==null&&Ua(p,h,67108864),fA(h,67108864)}}function V5(h){if(h.tag===13||h.tag===31){var p=ls();p=si(p);var _=Nd(h,p);_!==null&&Ua(_,h,p),fA(h,p)}}var av=!0;function mre(h,p,_,w){var P=K.T;K.T=null;var j=G.p;try{G.p=2,pA(h,p,_,w)}finally{G.p=j,K.T=P}}function gre(h,p,_,w){var P=K.T;K.T=null;var j=G.p;try{G.p=8,pA(h,p,_,w)}finally{G.p=j,K.T=P}}function pA(h,p,_,w){if(av){var P=mA(w);if(P===null)eA(h,p,w,sv,_),W5(h,w);else if(bre(P,h,p,_,w))w.stopPropagation();else if(W5(h,w),p&4&&-1<xre.indexOf(h)){for(;P!==null;){var j=ae(P);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var Y=Ce(j.pendingLanes);if(Y!==0){var le=j;for(le.pendingLanes|=2,le.entangledLanes|=2;Y;){var Ee=1<<31-He(Y);le.entanglements[1]|=Ee,Y&=~Ee}Ko(j),(kn&6)===0&&(Hy=L()+500,qg(0))}}break;case 31:case 13:le=Nd(j,2),le!==null&&Ua(le,j,2),Vy(),fA(j,2)}if(j=mA(w),j===null&&eA(h,p,w,sv,_),j===P)break;P=j}P!==null&&w.stopPropagation()}else eA(h,p,w,null,_)}}function mA(h){return h=xE(h),gA(h)}var sv=null;function gA(h){if(sv=null,h=Mt(h),h!==null){var p=a(h);if(p===null)h=null;else{var _=p.tag;if(_===13){if(h=s(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 sv=h,null}function G5(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 ve:return 2;case we:return 8;case ye:case nt:return 32;case Be:return 268435456;default:return 32}default:return 32}}var xA=!1,ou=null,lu=null,cu=null,ex=new Map,tx=new Map,uu=[],xre="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 W5(h,p){switch(h){case"focusin":case"focusout":ou=null;break;case"dragenter":case"dragleave":lu=null;break;case"mouseover":case"mouseout":cu=null;break;case"pointerover":case"pointerout":ex.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":tx.delete(p.pointerId)}}function nx(h,p,_,w,P,j){return h===null||h.nativeEvent!==j?(h={blockedOn:p,domEventName:_,eventSystemFlags:w,nativeEvent:j,targetContainers:[P]},p!==null&&(p=ae(p),p!==null&&$5(p)),h):(h.eventSystemFlags|=w,p=h.targetContainers,P!==null&&p.indexOf(P)===-1&&p.push(P),h)}function bre(h,p,_,w,P){switch(p){case"focusin":return ou=nx(ou,h,p,_,w,P),!0;case"dragenter":return lu=nx(lu,h,p,_,w,P),!0;case"mouseover":return cu=nx(cu,h,p,_,w,P),!0;case"pointerover":var j=P.pointerId;return ex.set(j,nx(ex.get(j)||null,h,p,_,w,P)),!0;case"gotpointercapture":return j=P.pointerId,tx.set(j,nx(tx.get(j)||null,h,p,_,w,P)),!0}return!1}function q5(h){var p=Mt(h.target);if(p!==null){var _=a(p);if(_!==null){if(p=_.tag,p===13){if(p=s(_),p!==null){h.blockedOn=p,ra(h.priority,function(){V5(_)});return}}else if(p===31){if(p=o(_),p!==null){h.blockedOn=p,ra(h.priority,function(){V5(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function ov(h){if(h.blockedOn!==null)return!1;for(var p=h.targetContainers;0<p.length;){var _=mA(h.nativeEvent);if(_===null){_=h.nativeEvent;var w=new _.constructor(_.type,_);gE=w,_.target.dispatchEvent(w),gE=null}else return p=ae(_),p!==null&&$5(p),h.blockedOn=_,!1;p.shift()}return!0}function K5(h,p,_){ov(h)&&_.delete(p)}function yre(){xA=!1,ou!==null&&ov(ou)&&(ou=null),lu!==null&&ov(lu)&&(lu=null),cu!==null&&ov(cu)&&(cu=null),ex.forEach(K5),tx.forEach(K5)}function lv(h,p){h.blockedOn===p&&(h.blockedOn=null,xA||(xA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,yre)))}var cv=null;function X5(h){cv!==h&&(cv=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){cv===h&&(cv=null);for(var p=0;p<h.length;p+=3){var _=h[p],w=h[p+1],P=h[p+2];if(typeof w!="function"){if(gA(w||_)===null)continue;break}var j=ae(_);j!==null&&(h.splice(p,3),p-=3,m2(j,{pending:!0,data:P,method:_.method,action:w},w,P))}}))}function Kf(h){function p(Ee){return lv(Ee,h)}ou!==null&&lv(ou,h),lu!==null&&lv(lu,h),cu!==null&&lv(cu,h),ex.forEach(p),tx.forEach(p);for(var _=0;_<uu.length;_++){var w=uu[_];w.blockedOn===h&&(w.blockedOn=null)}for(;0<uu.length&&(_=uu[0],_.blockedOn===null);)q5(_),_.blockedOn===null&&uu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(w=0;w<_.length;w+=3){var P=_[w],j=_[w+1],Y=P[jr]||null;if(typeof j=="function")Y||X5(_);else if(Y){var le=null;if(j&&j.hasAttribute("formAction")){if(P=j,Y=j[jr]||null)le=Y.formAction;else if(gA(P)!==null)continue}else le=Y.action;typeof le=="function"?_[w+1]=le:(_.splice(w,3),w-=3),X5(_)}}}function Y5(){function h(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(Y){return P=Y})},focusReset:"manual",scroll:"manual"})}function p(){P!==null&&(P(),P=null),w||setTimeout(_,20)}function _(){if(!w&&!navigation.transition){var j=navigation.currentEntry;j&&j.url!=null&&navigation.navigate(j.url,{state:j.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var w=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(_,100),function(){w=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),P!==null&&(P(),P=null)}}}function bA(h){this._internalRoot=h}uv.prototype.render=bA.prototype.render=function(h){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,w=ls();B5(_,w,h,p,null,null)},uv.prototype.unmount=bA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var p=h.containerInfo;B5(h.current,2,null,h,null,null),Vy(),p[mo]=null}};function uv(h){this._internalRoot=h}uv.prototype.unstable_scheduleHydration=function(h){if(h){var p=zi();h={blockedOn:null,target:h,priority:p};for(var _=0;_<uu.length&&p!==0&&p<uu[_].priority;_++);uu.splice(_,0,h),_===0&&q5(h)}};var Z5=e.version;if(Z5!=="19.2.0")throw Error(r(527,Z5,"19.2.0"));G.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 dv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!dv.isDisabled&&dv.supportsFiber)try{Fe=dv.inject(vre),oe=dv}catch{}}return ix.createRoot=function(h,p){if(!i(h))throw Error(r(299));var _=!1,w="",P=iI,j=aI,Y=sI;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(w=p.identifierPrefix),p.onUncaughtError!==void 0&&(P=p.onUncaughtError),p.onCaughtError!==void 0&&(j=p.onCaughtError),p.onRecoverableError!==void 0&&(Y=p.onRecoverableError)),p=U5(h,1,!1,null,null,_,w,null,P,j,Y,Y5),h[mo]=p.current,J2(h),new bA(p)},ix.hydrateRoot=function(h,p,_){if(!i(h))throw Error(r(299));var w=!1,P="",j=iI,Y=aI,le=sI,Ee=null;return _!=null&&(_.unstable_strictMode===!0&&(w=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(j=_.onUncaughtError),_.onCaughtError!==void 0&&(Y=_.onCaughtError),_.onRecoverableError!==void 0&&(le=_.onRecoverableError),_.formState!==void 0&&(Ee=_.formState)),p=U5(h,1,!0,p,_??null,w,P,Ee,j,Y,le,Y5),p.context=z5(null),_=p.current,w=ls(),w=si(w),P=Xc(w),P.callback=null,Yc(_,P,w),_=w,p.current.lanes=_,Qt(p,_),Ko(p),h[mo]=p.current,J2(h),new uv(p)},ix.version="19.2.0",ix}var oF;function Pre(){if(oF)return _A.exports;oF=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=kre(),_A.exports}var Rre=Pre();const qt=t=>typeof t=="string",ax=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},lF=t=>t==null?"":""+t,Dre=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},jre=/###/g,cF=t=>t&&t.indexOf("###")>-1?t.replace(jre,"."):t,uF=t=>!t||qt(t),Gx=(t,e,n)=>{const r=qt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(uF(t))return{};const a=cF(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return uF(t)?{}:{obj:t,k:cF(r[i])}},dF=(t,e,n)=>{const{obj:r,k:i}=Gx(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],s=e.slice(0,e.length-1),o=Gx(t,s,Object);for(;o.obj===void 0&&s.length;)a=`${s[s.length-1]}.${a}`,s=s.slice(0,s.length-1),o=Gx(t,s,Object),o?.obj&&typeof o.obj[`${o.k}.${a}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${a}`]=n},Ore=(t,e,n,r)=>{const{obj:i,k:a}=Gx(t,e,Object);i[a]=i[a]||[],i[a].push(n)},_1=(t,e)=>{const{obj:n,k:r}=Gx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Lre=(t,e,n)=>{const r=_1(t,n);return r!==void 0?r:_1(e,n)},y9=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?qt(t[r])||t[r]instanceof String||qt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):y9(t[r],e[r],n):t[r]=e[r]);return t},Xf=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ire={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Fre=t=>qt(t)?t.replace(/[&<>"'\/]/g,e=>Ire[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 zre=[" ",",","?","!",";"],Bre=new Ure(20),Hre=(t,e,n)=>{e=e||"",n=n||"";const r=zre.filter(s=>e.indexOf(s)<0&&n.indexOf(s)<0);if(r.length===0)return!0;const i=Bre.getRegExp(`(${r.map(s=>s==="?"?"\\?":s).join("|")})`);let a=!i.test(t);if(!a){const s=t.indexOf(n);s>0&&!i.test(t.substring(0,s))&&(a=!0)}return a},mk=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let s,o="";for(let c=a;c<r.length;++c)if(c!==a&&(o+=n),o+=r[c],s=i[o],s!==void 0){if(["string","number","boolean"].indexOf(typeof s)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=s}return i},p0=t=>t?.replace("_","-"),$re={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class w1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||$re,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(qt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new w1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new w1(this.logger,e)}}var al=new w1;let jS=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,a])=>{for(let s=0;s<a;s++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let s=0;s<a;s++)i.apply(i,[e,...n])})}};class hF extends jS{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,s=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],r&&(Array.isArray(r)?o.push(...r):qt(r)&&a?o.push(...r.split(a)):o.push(r)));const c=_1(this.data,o);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),c||!s||!qt(r)?c:mk(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let o=[e,n];r&&(o=o.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(o=e.split("."),i=n,n=o[1]),this.addNamespaces(n),dF(this.data,o,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(qt(r[a])||Array.isArray(r[a]))&&this.addResource(e,n,a,r[a],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,a,s={silent:!1,skipCopy:!1}){let o=[e,n];e.indexOf(".")>-1&&(o=e.split("."),i=r,r=n,n=o[1]),this.addNamespaces(n);let c=_1(this.data,o)||{};s.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?y9(c,r,a):c={...c,...r},dF(this.data,o,c),s.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var v9={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(a=>{e=this.processors[a]?.process(e,n,r,i)??e}),e}};const _9=Symbol("i18next/PATH_KEY");function Vre(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===_9?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function gk(t,e){const{[_9]:n}=t(Vre());return n.join(e?.keySeparator??".")}const fF={},EA=t=>!qt(t)&&typeof t!="boolean"&&typeof t!="number";class S1 extends jS{constructor(e,n={}){super(),Dre(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=al.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=EA(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const s=r&&e.indexOf(r)>-1,o=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Hre(e,r,i);if(s&&!o){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:qt(a)?[a]:a};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(a=u.shift()),e=u.join(i)}return{key:e,namespaces:qt(a)?[a]:a}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=gk(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?a?{res:`${u}${d}${o}`,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${o}`:a?{res:o,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:o;const m=this.resolve(e,i);let x=m?.res;const v=m?.usedKey||o,y=m?.exactUsedKey||o,b=["[object Number]","[object Function]","[object RegExp]"],M=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!qt(i.count),T=S1.hasDefaultValue(i),k=A?this.pluralResolver.getSuffix(f,i.count,i):"",N=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",I=A&&!i.ordinal&&i.count===0,C=I&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${N}`]||i.defaultValue;let D=x;S&&!x&&T&&(D=C);const F=EA(D),O=Object.prototype.toString.apply(D);if(S&&D&&F&&b.indexOf(O)<0&&!(qt(M)&&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(v,D,{...i,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return a?(m.res=q,m.usedParams=this.getUsedParamsDetails(i),m):q}if(s){const q=Array.isArray(D),R=q?[]:{},W=q?y:v;for(const K in D)if(Object.prototype.hasOwnProperty.call(D,K)){const G=`${W}${s}${K}`;T&&!x?R[K]=this.translate(G,{...i,defaultValue:EA(C)?C[K]:void 0,joinArrays:!1,ns:c}):R[K]=this.translate(G,{...i,joinArrays:!1,ns:c}),R[K]===G&&(R[K]=D[K])}x=R}}else if(S&&qt(M)&&Array.isArray(x))x=x.join(M),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,G=T&&C!==x&&this.options.updateMissing;if(R||q||G){if(this.logger.log(G?"updateKey":"missingKey",f,u,o,G?C:x),s){const U=this.resolve(o,{...i,keySeparator:!1});U&&U.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let ee=[];const Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let U=0;U<Z.length;U++)ee.push(Z[U]);else this.options.saveMissingTo==="all"?ee=this.languageUtils.toResolveHierarchy(i.lng||this.language):ee.push(i.lng||this.language);const Q=(U,$,X)=>{const te=T&&X!==x?X:K;this.options.missingKeyHandler?this.options.missingKeyHandler(U,u,$,te,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(U,u,$,te,G,i),this.emit("missingKey",U,u,$,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?ee.forEach(U=>{const $=this.pluralResolver.getSuffixes(U,i);I&&i[`defaultValue${this.options.pluralSeparator}zero`]&&$.indexOf(`${this.options.pluralSeparator}zero`)<0&&$.push(`${this.options.pluralSeparator}zero`),$.forEach(X=>{Q([U],o+X,i[`defaultValue${X}`]||C)})}):Q(ee,o,C))}x=this.extendTranslation(x,e,i,m,r),R&&x===o&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${o}`),(R||q)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${o}`:o,q?x:void 0,i))}return a?(m.res=x,m.usedParams=this.getUsedParamsDetails(i),m):x}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=qt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!qt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),g=f&&f.length;u<g&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const s=r.postProcess||this.options.postProcess,o=qt(s)?[s]:s;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=v9.handle(o,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,s,o;return qt(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const g=n.count!==void 0&&!qt(n.count),m=g&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(qt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(y=>{this.isValidLookup(r)||(o=y,!fF[`${v[0]}-${y}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(fF[`${v[0]}-${y}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(b=>{if(this.isValidLookup(r))return;s=b;const M=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(M,d,b,y,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&&M.push(d+A.replace(k,this.options.pluralSeparator)),M.push(d+A),m&&M.push(d+T)),x){const N=`${d}${this.options.contextSeparator||"_"}${n.context}`;M.push(N),g&&(n.ordinal&&A.indexOf(k)===0&&M.push(N+A.replace(k,this.options.pluralSeparator)),M.push(N+A),m&&M.push(N+T))}}let S;for(;S=M.pop();)this.isValidLookup(r)||(a=S,r=this.getResource(b,y,S,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:s,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!qt(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const a of n)delete i[a]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class pF{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=al.create("languageUtils")}getScriptPartFromCode(e){if(e=p0(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=p0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(qt(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(s=>{if(s===a)return s;if(!(s.indexOf("-")<0&&a.indexOf("-")<0)&&(s.indexOf("-")>0&&a.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===a||s.indexOf(a)===0&&a.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),qt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],a=s=>{s&&(this.isSupportedCode(s)?i.push(s):this.logger.warn(`rejecting language code not found in supportedLngs: ${s}`))};return qt(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):qt(e)&&a(this.formatLanguageCode(e)),r.forEach(s=>{i.indexOf(s)<0&&a(this.formatLanguageCode(s))}),i}}const mF={zero:0,one:1,two:2,few:3,many:4,other:5},gF={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Gre{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=al.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=p0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let s;try{s=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),gF;if(!e.match(/-|_/))return gF;const c=this.languageUtils.getLanguagePartFromCode(e);s=this.getRule(c,n)}return this.pluralRulesCache[a]=s,s}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,a)=>mF[i]-mF[a]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const xF=(t,e,n,r=".",i=!0)=>{let a=Lre(t,e,n);return!a&&i&&qt(n)&&(a=mk(t,n,r),a===void 0&&(a=mk(e,n,r))),a},AA=t=>t.replace(/\$/g,"$$$$");class Wre{constructor(e={}){this.logger=al.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:s,suffix:o,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:g,nestingPrefixEscaped:m,nestingSuffix:x,nestingSuffixEscaped:v,nestingOptionsSeparator:y,maxReplaces:b,alwaysFormat:M}=e.interpolation;this.escape=n!==void 0?n:Fre,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Xf(a):s||"{{",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):v||Xf(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=b||1e3,this.alwaysFormat=M!==void 0?M:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let a,s,o;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const b=xF(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),v=x.shift().trim(),y=x.join(this.formatSeparator).trim();return this.format(xF(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),y,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>AA(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?AA(this.escape(m)):AA(m)}].forEach(m=>{for(o=0;a=m.regex.exec(e);){const x=a[1].trim();if(s=u(x),s===void 0)if(typeof d=="function"){const y=d(e,a,i);s=qt(y)?y:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))s="";else if(f){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),s="";else!qt(s)&&!this.useRawValueToEscape&&(s=lF(s));const v=m.safeValue(s);if(e=e.replace(a[0],v),f?(m.regex.lastIndex+=s.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,s;const o=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let g=`{${f[1]}`;c=f[0],g=this.interpolate(g,s);const m=g.match(/'/g),x=g.match(/"/g);((m?.length??0)%2===0&&!x||x.length%2!==0)&&(g=g.replace(/'/g,'"'));try{s=JSON.parse(g),u&&(s={...u,...s})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${g}`}return s.defaultValue&&s.defaultValue.indexOf(this.prefix)>-1&&delete s.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];s={...r},s=s.replace&&!qt(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(c=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),a=n(o.call(this,i[1].trim(),s),s),a&&i[0]===e&&!qt(a))return a;qt(a)||(a=lF(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const qre=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(s=>{if(s){const[o,...c]=s.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=o.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},bF=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const s=r+JSON.stringify(a);let o=e[s];return o||(o=t(p0(r),i),e[s]=o),o(n)}},Kre=t=>(e,n,r)=>t(p0(n),r)(e);class Xre{constructor(e={}){this.logger=al.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?bF:Kre;this.formats={number:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a});return o=>s.format(o)}),currency:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a,style:"currency"});return o=>s.format(o)}),datetime:r((i,a)=>{const s=new Intl.DateTimeFormat(i,{...a});return o=>s.format(o)}),relativetime:r((i,a)=>{const s=new Intl.RelativeTimeFormat(i,{...a});return o=>s.format(o,a.range||"day")}),list:r((i,a)=>{const s=new Intl.ListFormat(i,{...a});return o=>s.format(o)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=bF(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(o=>o.indexOf(")")>-1)){const o=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,o)].join(this.formatSeparator)}return a.reduce((o,c)=>{const{formatName:u,formatOptions:d}=qre(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 Yre=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Zre extends jS{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=al.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},s={},o={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const g=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?s[g]===void 0&&(s[g]=!0):(this.state[g]=1,d=!1,s[g]===void 0&&(s[g]=!0),a[g]===void 0&&(a[g]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(o[u]=!0)}),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],s=i[1];n&&this.emit("failedLoading",a,s,n),!n&&r&&this.store.addResourceBundle(a,s,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const o={};this.queue.forEach(c=>{Ore(c.loaded,[a],s),Yre(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{o[u]||(o[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{o[u][f]===void 0&&(o[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,a=this.retryTimeout,s){if(!e.length)return s(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:s});return}this.readingCalls++;const o=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,a*2,s)},a);return}s(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(e,n);u&&typeof u.then=="function"?u.then(d=>o(null,d)).catch(o):o(null,u)}catch(u){o(u)}return}return c(e,n,o)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();qt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),qt(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(s=>{this.loadOne(s)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],a=r[1];this.read(i,a,"read",void 0,void 0,(s,o)=>{s&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,s),!s&&o&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,o),this.loaded(e,s,o)})}saveMissing(e,n,r,i,a,s={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...s,isUpdate:a},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>o(null,f)).catch(o):o(null,d)}catch(d){o(d)}else u(e,n,r,i,o,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const yF=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),qt(t[1])&&(e.defaultValue=t[1]),qt(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),vF=t=>(qt(t.ns)&&(t.ns=[t.ns]),qt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),qt(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),fv=()=>{},Qre=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Wx extends jS{constructor(e={},n){if(super(),this.options=vF(e),this.services={},this.logger=al,this.modules={external:[]},Qre(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(qt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=yF();this.options={...r,...this.options,...vF(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?al.init(i(this.modules.logger),this.options):al.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Xre;const d=new pF(this.options);this.store=new hF(this.options.resources,this.options);const f=this.services;f.logger=al,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Gre(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 Wre(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Zre(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new S1(this.services,this.options),this.translator.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=fv),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=ax(),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=fv){let r=n;const i=qt(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const a=[],s=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.push(u)})};i?s(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>s(c)),this.options.preload?.forEach?.(o=>s(o)),this.services.backendConnector.load(a,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(o)})}else r(null)}reloadResources(e,n,r){const i=ax();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=fv),this.services.backendConnector.reload(e,n,a=>{i.resolve(),r(a)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&v9.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=ax();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},a=(o,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(o,(...u)=>this.t(...u))},s=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const c=qt(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(qt(o)?[o]:o);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{a(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),r}getFixedT(e,n,r){const i=(a,s,...o)=>{let c;typeof s!="object"?c=this.options.overloadTranslationOptionHandler([a,s].concat(o)):c={...s},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(a)?d=a.map(f=>(typeof f=="function"&&(f=gk(f,{...this.options,...s})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=gk(a,{...this.options,...s})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return qt(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const s=(o,c)=>{const u=this.services.backendConnector.state[`${o}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const o=n.precheck(this,s);if(o!==void 0)return o}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(r,e)&&(!i||s(a,e)))}loadNamespaces(e,n){const r=ax();return this.options.ns?(qt(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=ax();qt(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(s=>i.indexOf(s)<0&&this.services.languageUtils.isSupportedCode(s));return a.length?(this.options.preload=i.concat(a),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const a=i.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new pF(yF());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const r=new Wx(e,n);return r.createInstance=Wx.createInstance,r}cloneInstance(e={},n=fv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new Wx(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(o=>{a[o]=this[o]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const o=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});a.store=new hF(o,i),a.services.resourceStore=a.store}return a.translator=new S1(a.services,i),a.translator.on("*",(o,...c)=>{a.emit(o,...c)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Da=Wx.createInstance();Da.createInstance;Da.dir;Da.init;Da.loadResources;Da.reloadResources;Da.use;Da.changeLanguage;Da.getFixedT;Da.t;Da.exists;Da.setDefaultNamespace;Da.hasLoadedNamespace;Da.loadNamespaces;Da.loadLanguages;const Jre=(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)},_F={},w9=(t,e,n,r)=>{Ih(n)&&_F[n]||(Ih(n)&&(_F[n]=new Date),Jre(t,e,n,r))},S9=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},xk=(t,e,n)=>{t.loadNamespaces(e,S9(t,n))},wF=(t,e,n,r)=>{if(Ih(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return xk(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,S9(t,r))},eie=(t,e,n={})=>!e.languages||!e.languages.length?(w9(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",tie=t=>typeof t=="object"&&t!==null,nie=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,rie={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},iie=t=>rie[t],aie=t=>t.replace(nie,iie);let bk={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:aie};const sie=(t={})=>{bk={...bk,...t}},oie=()=>bk;let M9;const lie=t=>{M9=t},cie=()=>M9,uie={type:"3rdParty",init(t){sie(t.options.react),lie(t)}},die=E.createContext();class hie{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 SF;function fie(){if(SF)return CA;SF=1;var t=Vm();function e(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,s=t.useDebugValue;function o(f,g){var m=g(),x=r({inst:{value:m,getSnapshot:g}}),v=x[0].inst,y=x[1];return a(function(){v.value=m,v.getSnapshot=g,c(v)&&y({inst:v})},[f,m,g]),i(function(){return c(v)&&y({inst:v}),f(function(){c(v)&&y({inst:v})})},[f]),s(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 MF;function E9(){return MF||(MF=1,TA.exports=fie()),TA.exports}var AR=E9();const pie=(t,e)=>Ih(e)?e:tie(e)&&Ih(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,mie={t:pie,ready:!1},gie=()=>()=>{},Gm=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=E.useContext(die)||{},a=n||r||cie();a&&!a.reportNamespaces&&(a.reportNamespaces=new hie),a||w9(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=E.useMemo(()=>({...oie(),...a?.options?.react,...e}),[a,e]),{useSuspense:o,keyPrefix:c}=s,u=i||a?.options?.defaultNS,d=Ih(u)?[u]:u||["translation"],f=E.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const g=E.useRef(0),m=E.useCallback(C=>{if(!a)return gie;const{bindI18n:D,bindI18nStore:F}=s,O=()=>{g.current+=1,C()};return D&&a.on(D,O),F&&a.store.on(F,O),()=>{D&&D.split(" ").forEach(q=>a.off(q,O)),F&&F.split(" ").forEach(q=>a.store.off(q,O))}},[a,s]),x=E.useRef(),v=E.useCallback(()=>{if(!a)return mie;const C=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>eie(W,a,s)),D=e.lng||a.language,F=g.current,O=x.current;if(O&&O.ready===C&&O.lng===D&&O.keyPrefix===c&&O.revision===F)return O;const R={t:a.getFixedT(D,s.nsMode==="fallback"?f:f[0],c),ready:C,lng:D,keyPrefix:c,revision:F};return x.current=R,R},[a,f,c,s,e.lng]),[y,b]=E.useState(0),{t:M,ready:S}=AR.useSyncExternalStore(m,v,v);E.useEffect(()=>{if(a&&!S&&!o){const C=()=>b(D=>D+1);e.lng?wF(a,e.lng,f,C):xk(a,f,C)}},[a,e.lng,f,S,o,y]);const A=a||{},T=E.useRef(null),k=E.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=E.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 O=[M,F,S];return O.t=M,O.i18n=F,O.ready=S,O},[M,A,S,A.resolvedLanguage,A.language,A.languages]);if(a&&o&&!S)throw new Promise(C=>{const D=()=>C();e.lng?wF(a,e.lng,f,D):xk(a,f,D)});return I},{slice:xie,forEach:bie}=[];function yie(t){return bie.call(xie.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 EF=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,_ie=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let a=`${t}=${i}`;if(r.maxAge>0){const s=r.maxAge-0;if(Number.isNaN(s))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(s)}`}if(r.domain){if(!EF.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!EF.test(r.path))throw new TypeError("option path is invalid");a+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(a+="; Partitioned"),a},AF={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=_ie(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 wie={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return AF.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&AF.create(n,t,r,i,a)}},Sie={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const a=r.substring(1).split("&");for(let s=0;s<a.length;s++){const o=a[s].indexOf("=");o>0&&a[s].substring(0,o)===e&&(n=a[s].substring(o+1))}}return n}},Mie={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const a=i.substring(1);if(e){const s=a.split("&");for(let o=0;o<s.length;o++){const c=s[o].indexOf("=");c>0&&s[o].substring(0,c)===e&&(r=s[o].substring(c+1))}}if(r)return r;if(!r&&n>-1){const s=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(s)?s[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let Yf=null;const TF=()=>{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&&TF())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&TF()&&window.localStorage.setItem(n,t)}};let Zf=null;const CF=()=>{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 Aie={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&CF())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&CF()&&window.sessionStorage.setItem(n,t)}},Tie={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let a=0;a<n.length;a++)e.push(n[a]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},Cie={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}},Nie={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}},kie={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 A9=!1;try{document.cookie,A9=!0}catch{}const T9=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];A9||T9.splice(1,1);const Pie=()=>({order:T9,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class C9{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=yie(n,this.options||{},Pie()),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(wie),this.addDetector(Sie),this.addDetector(Eie),this.addDetector(Aie),this.addDetector(Tie),this.addDetector(Cie),this.addDetector(Nie),this.addDetector(kie),this.addDetector(Mie)}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)}))}}C9.type="languageDetector";const Rie={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",telemetry:"Anonymous telemetry",telemetryDescription:"Help improve BamBuddy by sending anonymous usage data",telemetryLearnMore:"Learn more",telemetryInfoTitle:"What data is collected?",telemetryInfoIntro:"BamBuddy collects minimal anonymous data to help understand how many people use the app and which versions are in use. This helps prioritize bug fixes and new features.",telemetryInfoCollected:"What we collect:",telemetryInfoItem1:"A random installation ID (not linked to you or your hardware)",telemetryInfoItem2:"The app version you're running",telemetryInfoItem3:"A timestamp (to count daily/weekly active users)",telemetryInfoNotCollected:"What we do NOT collect:",telemetryInfoNotItem1:"IP addresses or location data",telemetryInfoNotItem2:"Printer names, serial numbers, or any printer data",telemetryInfoNotItem3:"Print history, filenames, or any personal content",telemetryInfoNotItem4:"Any information that could identify you",telemetryInfoFooter:"You can disable telemetry at any time. The installation ID is randomly generated and cannot be traced back to you.",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},Die={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",telemetry:"Anonyme Telemetrie",telemetryDescription:"Helfen Sie BamBuddy zu verbessern, indem Sie anonyme Nutzungsdaten senden",telemetryLearnMore:"Mehr erfahren",telemetryInfoTitle:"Welche Daten werden gesammelt?",telemetryInfoIntro:"BamBuddy sammelt minimale anonyme Daten, um zu verstehen, wie viele Personen die App nutzen und welche Versionen verwendet werden. Dies hilft bei der Priorisierung von Fehlerbehebungen und neuen Funktionen.",telemetryInfoCollected:"Was wir sammeln:",telemetryInfoItem1:"Eine zufällige Installations-ID (nicht mit Ihnen oder Ihrer Hardware verknüpft)",telemetryInfoItem2:"Die App-Version, die Sie verwenden",telemetryInfoItem3:"Ein Zeitstempel (um tägliche/wöchentliche aktive Nutzer zu zählen)",telemetryInfoNotCollected:"Was wir NICHT sammeln:",telemetryInfoNotItem1:"IP-Adressen oder Standortdaten",telemetryInfoNotItem2:"Druckernamen, Seriennummern oder Druckerdaten",telemetryInfoNotItem3:"Druckverlauf, Dateinamen oder persönliche Inhalte",telemetryInfoNotItem4:"Informationen, die Sie identifizieren könnten",telemetryInfoFooter:"Sie können die Telemetrie jederzeit deaktivieren. Die Installations-ID wird zufällig generiert und kann nicht zu Ihnen zurückverfolgt werden.",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},jie={en:{translation:Rie},de:{translation:Die}};Da.use(C9).use(uie).init({resources:jie,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const NF=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var kF="popstate";function Oie(t={}){function e(r,i){let{pathname:a,search:s,hash:o}=r.location;return yk("",{pathname:a,search:s,hash:o},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:m0(i)}return Iie(e,n,null,t)}function vr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Fo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Lie(){return Math.random().toString(36).substring(2,10)}function PF(t,e){return{usr:t.state,key:t.key,idx:e}}function yk(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Wm(e):e,state:n,key:e&&e.key||r||Lie()}}function m0({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function Wm(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substring(n),t=t.substring(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substring(r),t=t.substring(0,r)),t&&(e.pathname=t)}return e}function Iie(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,s=i.history,o="POP",c=null,u=d();u==null&&(u=0,s.replaceState({...s.state,idx:u},""));function d(){return(s.state||{idx:null}).idx}function f(){o="POP";let y=d(),b=y==null?null:y-u;u=y,c&&c({action:o,location:v.location,delta:b})}function g(y,b){o="PUSH";let M=yk(v.location,y,b);u=d()+1;let S=PF(M,u),A=v.createHref(M);try{s.pushState(S,"",A)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(A)}a&&c&&c({action:o,location:v.location,delta:1})}function m(y,b){o="REPLACE";let M=yk(v.location,y,b);u=d();let S=PF(M,u),A=v.createHref(M);s.replaceState(S,"",A),a&&c&&c({action:o,location:v.location,delta:0})}function x(y){return Fie(y)}let v={get action(){return o},get location(){return t(i,s)},listen(y){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(kF,f),c=y,()=>{i.removeEventListener(kF,f),c=null}},createHref(y){return e(i,y)},createURL:x,encodeLocation(y){let b=x(y);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:g,replace:m,go(y){return s.go(y)}};return v}function Fie(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),vr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:m0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function N9(t,e,n="/"){return Uie(t,e,n,!1)}function Uie(t,e,n,r){let i=typeof e=="string"?Wm(e):e,a=Tc(i.pathname||"/",n);if(a==null)return null;let s=k9(t);zie(s);let o=null;for(let c=0;o==null&&c<s.length;++c){let u=Zie(a);o=Xie(s[c],u,r)}return o}function k9(t,e=[],n=[],r="",i=!1){let a=(s,o,c=i,u)=>{let d={relativePath:u===void 0?s.path||"":u,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;vr(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=yc([r,d.relativePath]),g=n.concat(d);s.children&&s.children.length>0&&(vr(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),k9(s.children,e,g,f,c)),!(s.path==null&&!s.index)&&e.push({path:f,score:qie(f,s.index),routesMeta:g})};return t.forEach((s,o)=>{if(s.path===""||!s.path?.includes("?"))a(s,o);else for(let c of P9(s.path))a(s,o,!0,c)}),e}function P9(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let s=P9(r.join("/")),o=[];return o.push(...s.map(c=>c===""?a:[a,c].join("/"))),i&&o.push(...s),o.map(c=>t.startsWith("/")&&c===""?"/":c)}function zie(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Kie(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Bie=/^:[\w-]+$/,Hie=3,$ie=2,Vie=1,Gie=10,Wie=-2,RF=t=>t==="*";function qie(t,e){let n=t.split("/"),r=n.length;return n.some(RF)&&(r+=Wie),e&&(r+=$ie),n.filter(i=>!RF(i)).reduce((i,a)=>i+(Bie.test(a)?Hie:a===""?Vie:Gie),r)}function Kie(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 Xie(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",s=[];for(let o=0;o<r.length;++o){let c=r[o],u=o===r.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=M1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),g=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=M1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),s.push({params:i,pathname:yc([a,f.pathname]),pathnameBase:nae(yc([a,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(a=yc([a,f.pathnameBase]))}return s}function M1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Yie(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],s=a.replace(/(.)\/+$/,"$1"),o=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},g)=>{if(d==="*"){let x=o[g]||"";s=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const m=o[g];return f&&!m?u[d]=void 0:u[d]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:s,pattern:t}}function Yie(t,e=!1,n=!0){Fo(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function Zie(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Fo(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),t}}function Tc(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}var Qie=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Jie=t=>Qie.test(t);function eae(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Wm(t):t,a;if(n)if(Jie(n))a=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),Fo(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?a=DF(n.substring(1),"/"):a=DF(n,e)}else a=e;return{pathname:a,search:rae(r),hash:iae(i)}}function DF(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 tae(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function R9(t){let e=tae(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function D9(t,e,n,r=!1){let i;typeof t=="string"?i=Wm(t):(i={...t},vr(!i.pathname||!i.pathname.includes("?"),NA("?","pathname","search",i)),vr(!i.pathname||!i.pathname.includes("#"),NA("#","pathname","hash",i)),vr(!i.search||!i.search.includes("#"),NA("#","search","hash",i)));let a=t===""||i.pathname==="",s=a?"/":i.pathname,o;if(s==null)o=n;else{let f=e.length-1;if(!r&&s.startsWith("..")){let g=s.split("/");for(;g[0]==="..";)g.shift(),f-=1;i.pathname=g.join("/")}o=f>=0?e[f]:"/"}let c=eae(i,o),u=s&&s!=="/"&&s.endsWith("/"),d=(a||s===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var yc=t=>t.join("/").replace(/\/\/+/g,"/"),nae=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),rae=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,iae=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function aae(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 j9=["POST","PUT","PATCH","DELETE"];new Set(j9);var sae=["GET",...j9];new Set(sae);var qm=E.createContext(null);qm.displayName="DataRouter";var OS=E.createContext(null);OS.displayName="DataRouterState";E.createContext(!1);var O9=E.createContext({isTransitioning:!1});O9.displayName="ViewTransition";var oae=E.createContext(new Map);oae.displayName="Fetchers";var lae=E.createContext(null);lae.displayName="Await";var _l=E.createContext(null);_l.displayName="Navigation";var fb=E.createContext(null);fb.displayName="Location";var Bo=E.createContext({outlet:null,matches:[],isDataRoute:!1});Bo.displayName="Route";var TR=E.createContext(null);TR.displayName="RouteError";function cae(t,{relative:e}={}){vr(pb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=E.useContext(_l),{hash:i,pathname:a,search:s}=mb(t,{relative:e}),o=a;return n!=="/"&&(o=a==="/"?n:yc([n,a])),r.createHref({pathname:o,search:s,hash:i})}function pb(){return E.useContext(fb)!=null}function xd(){return vr(pb(),"useLocation() may be used only in the context of a <Router> component."),E.useContext(fb).location}var L9="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function I9(t){E.useContext(_l).static||E.useLayoutEffect(t)}function CR(){let{isDataRoute:t}=E.useContext(Bo);return t?Mae():uae()}function uae(){vr(pb(),"useNavigate() may be used only in the context of a <Router> component.");let t=E.useContext(qm),{basename:e,navigator:n}=E.useContext(_l),{matches:r}=E.useContext(Bo),{pathname:i}=xd(),a=JSON.stringify(R9(r)),s=E.useRef(!1);return I9(()=>{s.current=!0}),E.useCallback((c,u={})=>{if(Fo(s.current,L9),!s.current)return;if(typeof c=="number"){n.go(c);return}let d=D9(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:yc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var dae=E.createContext(null);function hae(t){let e=E.useContext(Bo).outlet;return E.useMemo(()=>e&&E.createElement(dae.Provider,{value:t},e),[e,t])}function F9(){let{matches:t}=E.useContext(Bo),e=t[t.length-1];return e?e.params:{}}function mb(t,{relative:e}={}){let{matches:n}=E.useContext(Bo),{pathname:r}=xd(),i=JSON.stringify(R9(n));return E.useMemo(()=>D9(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function fae(t,e){return U9(t,e)}function U9(t,e,n,r,i){vr(pb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=E.useContext(_l),{matches:s}=E.useContext(Bo),o=s[s.length-1],c=o?o.params:{},u=o?o.pathname:"/",d=o?o.pathnameBase:"/",f=o&&o.route;{let M=f&&f.path||"";z9(u,!f||M.endsWith("*")||M.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${M}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${M}"> to <Route path="${M==="/"?"*":`${M}/*`}">.`)}let g=xd(),m;if(e){let M=typeof e=="string"?Wm(e):e;vr(d==="/"||M.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 "${M.pathname}" was given in the \`location\` prop.`),m=M}else m=g;let x=m.pathname||"/",v=x;if(d!=="/"){let M=d.replace(/^\//,"").split("/");v="/"+x.replace(/^\//,"").split("/").slice(M.length).join("/")}let y=N9(t,{pathname:v});Fo(f||y!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Fo(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${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=bae(y&&y.map(M=>Object.assign({},M,{params:Object.assign({},c,M.params),pathname:yc([d,a.encodeLocation?a.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?d:yc([d,a.encodeLocation?a.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),s,n,r,i);return e&&b?E.createElement(fb.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},b):b}function pae(){let t=Sae(),e=aae(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},s=null;return console.error("Error handled by React Router default ErrorBoundary:",t),s=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:a},"ErrorBoundary")," or"," ",E.createElement("code",{style:a},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},e),n?E.createElement("pre",{style:i},n):null,s)}var mae=E.createElement(pae,null),gae=class extends E.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?E.createElement(Bo.Provider,{value:this.props.routeContext},E.createElement(TR.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function xae({routeContext:t,match:e,children:n}){let r=E.useContext(qm);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),E.createElement(Bo.Provider,{value:t},n)}function bae(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let a=t,s=n?.errors;if(s!=null){let d=a.findIndex(f=>f.route.id&&s?.[f.route.id]!==void 0);vr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let o=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:g,errors: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?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,g)=>{let m,x=!1,v=null,y=null;n&&(m=s&&f.route.id?s[f.route.id]:void 0,v=f.route.errorElement||mae,o&&(c<0&&g===0?(z9("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,y=null):c===g&&(x=!0,y=f.route.hydrateFallbackElement||null)));let b=e.concat(a.slice(0,g+1)),M=()=>{let S;return m?S=v:x?S=y:f.route.Component?S=E.createElement(f.route.Component,null):f.route.element?S=f.route.element:S=d,E.createElement(xae,{match:f,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:S})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?E.createElement(gae,{location:n.location,revalidation:n.revalidation,component:v,error:m,children:M(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):M()},null)}function NR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yae(t){let e=E.useContext(qm);return vr(e,NR(t)),e}function vae(t){let e=E.useContext(OS);return vr(e,NR(t)),e}function _ae(t){let e=E.useContext(Bo);return vr(e,NR(t)),e}function kR(t){let e=_ae(t),n=e.matches[e.matches.length-1];return vr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function wae(){return kR("useRouteId")}function Sae(){let t=E.useContext(TR),e=vae("useRouteError"),n=kR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Mae(){let{router:t}=yae("useNavigate"),e=kR("useNavigate"),n=E.useRef(!1);return I9(()=>{n.current=!0}),E.useCallback(async(i,a={})=>{Fo(n.current,L9),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var jF={};function z9(t,e,n){!e&&!jF[t]&&(jF[t]=!0,Fo(!1,n))}E.memo(Eae);function Eae({routes:t,future:e,state:n,unstable_onError:r}){return U9(t,void 0,n,r,e)}function Aae(t){return hae(t.context)}function fs(t){vr(!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 Tae({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){vr(!pb(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=t.replace(/^\/*/,"/"),o=E.useMemo(()=>({basename:s,navigator:i,static:a,future:{}}),[s,i,a]);typeof n=="string"&&(n=Wm(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,m=E.useMemo(()=>{let x=Tc(c,s);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:g},navigationType:r}},[s,c,u,d,f,g,r]);return Fo(m!=null,`<Router basename="${s}"> is not able to match the URL "${c}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:E.createElement(_l.Provider,{value:o},E.createElement(fb.Provider,{children:e,value:m}))}function Cae({children:t,location:e}){return fae(vk(t),e)}function vk(t,e=[]){let n=[];return E.Children.forEach(t,(r,i)=>{if(!E.isValidElement(r))return;let a=[...e,i];if(r.type===E.Fragment){n.push.apply(n,vk(r.props.children,a));return}vr(r.type===fs,`[${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>`),vr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let s={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(s.children=vk(r.props.children,a)),n.push(s)}),n}var Z_="get",Q_="application/x-www-form-urlencoded";function LS(t){return t!=null&&typeof t.tagName=="string"}function Nae(t){return LS(t)&&t.tagName.toLowerCase()==="button"}function kae(t){return LS(t)&&t.tagName.toLowerCase()==="form"}function Pae(t){return LS(t)&&t.tagName.toLowerCase()==="input"}function Rae(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Dae(t,e){return t.button===0&&(!e||e==="_self")&&!Rae(t)}var pv=null;function jae(){if(pv===null)try{new FormData(document.createElement("form"),0),pv=!1}catch{pv=!0}return pv}var Oae=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function kA(t){return t!=null&&!Oae.has(t)?(Fo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Q_}"`),null):t}function Lae(t,e){let n,r,i,a,s;if(kae(t)){let o=t.getAttribute("action");r=o?Tc(o,e):null,n=t.getAttribute("method")||Z_,i=kA(t.getAttribute("enctype"))||Q_,a=new FormData(t)}else if(Nae(t)||Pae(t)&&(t.type==="submit"||t.type==="image")){let o=t.form;if(o==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=t.getAttribute("formaction")||o.getAttribute("action");if(r=c?Tc(c,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||Z_,i=kA(t.getAttribute("formenctype"))||kA(o.getAttribute("enctype"))||Q_,a=new FormData(o,t),!jae()){let{name:u,type:d,value:f}=t;if(d==="image"){let g=u?`${u}.`:"";a.append(`${g}x`,"0"),a.append(`${g}y`,"0")}else u&&a.append(u,f)}}else{if(LS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Z_,r=null,i=Q_,s=t}return a&&i==="text/plain"&&(s=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function PR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Iae(t,e,n){let r=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r.pathname==="/"?r.pathname=`_root.${n}`:e&&Tc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Fae(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 Uae(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 zae(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let s=await Fae(a,n);return s.links?s.links():[]}return[]}));return Vae(r.flat(1).filter(Uae).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function OF(t,e,n,r,i,a){let s=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,o=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return a==="assets"?e.filter((c,u)=>s(c,u)||o(c,u)):a==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(s(c,u)||o(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function Bae(t,e,{includeHydrateFallback:n}={}){return Hae(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let a=[i.module];return i.clientActionModule&&(a=a.concat(i.clientActionModule)),i.clientLoaderModule&&(a=a.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(a=a.concat(i.hydrateFallbackModule)),i.imports&&(a=a.concat(i.imports)),a}).flat(1))}function Hae(t){return[...new Set(t)]}function $ae(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Vae(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify($ae(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function B9(){let t=E.useContext(qm);return PR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Gae(){let t=E.useContext(OS);return PR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var RR=E.createContext(void 0);RR.displayName="FrameworkContext";function H9(){let t=E.useContext(RR);return PR(t,"You must render this element inside a <HydratedRouter> element"),t}function Wae(t,e){let n=E.useContext(RR),[r,i]=E.useState(!1),[a,s]=E.useState(!1),{onFocus:o,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,g=E.useRef(null);E.useEffect(()=>{if(t==="render"&&s(!0),t==="viewport"){let v=b=>{b.forEach(M=>{s(M.isIntersecting)})},y=new IntersectionObserver(v,{threshold:.5});return g.current&&y.observe(g.current),()=>{y.disconnect()}}},[t]),E.useEffect(()=>{if(r){let v=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(v)}}},[r]);let m=()=>{i(!0)},x=()=>{i(!1),s(!1)};return n?t!=="intent"?[a,g,{}]:[a,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 qae({page:t,...e}){let{router:n}=B9(),r=E.useMemo(()=>N9(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?E.createElement(Xae,{page:t,matches:r,...e}):null}function Kae(t){let{manifest:e,routeModules:n}=H9(),[r,i]=E.useState([]);return E.useEffect(()=>{let a=!1;return zae(t,e,n).then(s=>{a||i(s)}),()=>{a=!0}},[t,e,n]),r}function Xae({page:t,matches:e,...n}){let r=xd(),{manifest:i,routeModules:a}=H9(),{basename:s}=B9(),{loaderData:o,matches:c}=Gae(),u=E.useMemo(()=>OF(t,e,c,i,r,"data"),[t,e,c,i,r]),d=E.useMemo(()=>OF(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=E.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,v=!1;if(e.forEach(b=>{let M=i.routes[b.route.id];!M||!M.hasLoader||(!u.some(S=>S.route.id===b.route.id)&&b.route.id in o&&a[b.route.id]?.shouldRevalidate||M.hasClientLoader?v=!0:x.add(b.route.id))}),x.size===0)return[];let y=Iae(t,s,"data");return v&&x.size>0&&y.searchParams.set("_routes",e.filter(b=>x.has(b.route.id)).map(b=>b.route.id).join(",")),[y.pathname+y.search]},[s,o,r,i,u,e,t,a]),g=E.useMemo(()=>Bae(d,i),[d,i]),m=Kae(d);return E.createElement(E.Fragment,null,f.map(x=>E.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.map(x=>E.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),m.map(({key:x,link:v})=>E.createElement("link",{key:x,nonce:n.nonce,...v})))}function Yae(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var $9=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{$9&&(window.__reactRouterVersion="7.9.6")}catch{}function Zae({basename:t,children:e,window:n}){let r=E.useRef();r.current==null&&(r.current=Oie({window:n,v5Compat:!0}));let i=r.current,[a,s]=E.useState({action:i.action,location:i.location}),o=E.useCallback(c=>{E.startTransition(()=>s(c))},[s]);return E.useLayoutEffect(()=>i.listen(o),[i,o]),E.createElement(Tae,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var V9=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,IS=E.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:s,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f,...g},m){let{basename:x}=E.useContext(_l),v=typeof u=="string"&&V9.test(u),y,b=!1;if(typeof u=="string"&&v&&(y=u,$9))try{let C=new URL(window.location.href),D=u.startsWith("//")?new URL(C.protocol+u):new URL(u),F=Tc(D.pathname,x);D.origin===C.origin&&F!=null?u=F+D.search+D.hash:b=!0}catch{Fo(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let M=cae(u,{relative:i}),[S,A,T]=Wae(r,g),k=ese(u,{replace:s,state:o,target:c,preventScrollReset:d,relative:i,viewTransition:f});function N(C){e&&e(C),C.defaultPrevented||k(C)}let I=E.createElement("a",{...g,...T,href:y||M,onClick:b||a?e:N,ref:Yae(m,A),target:c,"data-discover":!v&&n==="render"?"true":void 0});return S&&!v?E.createElement(E.Fragment,null,I,E.createElement(qae,{page:M})):I});IS.displayName="Link";var Rx=E.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:s,viewTransition:o,children:c,...u},d){let f=mb(s,{relative:u.relative}),g=xd(),m=E.useContext(OS),{navigator:x,basename:v}=E.useContext(_l),y=m!=null&&ase(f)&&o===!0,b=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,M=g.pathname,S=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(M=M.toLowerCase(),S=S?S.toLowerCase():null,b=b.toLowerCase()),S&&v&&(S=Tc(S,v)||S);const A=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let T=M===b||!i&&M.startsWith(b)&&M.charAt(A)==="/",k=S!=null&&(S===b||!i&&S.startsWith(b)&&S.charAt(b.length)==="/"),N={isActive:T,isPending:k,isTransitioning:y},I=T?e:void 0,C;typeof r=="function"?C=r(N):C=[r,T?"active":null,k?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let D=typeof a=="function"?a(N):a;return E.createElement(IS,{...u,"aria-current":I,className:C,ref:d,style:D,to:s,viewTransition:o},typeof c=="function"?c(N):c)});Rx.displayName="NavLink";var Qae=E.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:s=Z_,action:o,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...g},m)=>{let x=rse(),v=ise(o,{relative:u}),y=s.toLowerCase()==="get"?"get":"post",b=typeof o=="string"&&V9.test(o),M=S=>{if(c&&c(S),S.defaultPrevented)return;S.preventDefault();let A=S.nativeEvent.submitter,T=A?.getAttribute("formmethod")||s;x(A||S.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f})};return E.createElement("form",{ref:m,method:y,action:v,onSubmit:r?c:M,...g,"data-discover":!b&&t==="render"?"true":void 0})});Qae.displayName="Form";function Jae(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function G9(t){let e=E.useContext(qm);return vr(e,Jae(t)),e}function ese(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:s}={}){let o=CR(),c=xd(),u=mb(t,{relative:a});return E.useCallback(d=>{if(Dae(d,e)){d.preventDefault();let f=n!==void 0?n:m0(c)===m0(u);o(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:s})}},[c,o,u,n,r,e,t,i,a,s])}var tse=0,nse=()=>`__${String(++tse)}__`;function rse(){let{router:t}=G9("useSubmit"),{basename:e}=E.useContext(_l),n=wae();return E.useCallback(async(r,i={})=>{let{action:a,method:s,encType:o,formData:c,body:u}=Lae(r,e);if(i.navigate===!1){let d=i.fetcherKey||nse();await t.fetch(d,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||s,formEncType:i.encType||o,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||s,formEncType:i.encType||o,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function ise(t,{relative:e}={}){let{basename:n}=E.useContext(_l),r=E.useContext(Bo);vr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...mb(t||".",{relative:e})},s=xd();if(t==null){a.search=s.search;let o=new URLSearchParams(a.search),c=o.getAll("index");if(c.some(d=>d==="")){o.delete("index"),c.filter(f=>f).forEach(f=>o.append("index",f));let d=o.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:yc([n,a.pathname])),m0(a)}function ase(t,{relative:e}={}){let n=E.useContext(O9);vr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=G9("useViewTransitionState"),i=mb(t,{relative:e});if(!n.isTransitioning)return!1;let a=Tc(n.currentLocation.pathname,r)||n.currentLocation.pathname,s=Tc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return M1(i.pathname,s)!=null||M1(i.pathname,a)!=null}var hc=b9();const sse=fo(hc);var Km=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ose={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},lse=class{#e=ose;#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 lse;function cse(t){setTimeout(t,0)}var Fh=typeof window>"u"||"Deno"in globalThis;function wa(){}function use(t,e){return typeof t=="function"?t(e):t}function _k(t){return typeof t=="number"&&t>=0&&t!==1/0}function W9(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Wu(t,e){return typeof t=="function"?t(e):t}function Ws(t,e){return typeof t=="function"?t(e):t}function LF(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:s,stale:o}=t;if(s){if(r){if(e.queryHash!==DR(s,e.options))return!1}else if(!g0(e.queryKey,s))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||i&&i!==e.state.fetchStatus||a&&!a(e))}function IF(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Uh(e.options.mutationKey)!==Uh(a))return!1}else if(!g0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function DR(t,e){return(e?.queryKeyHashFn||Uh)(t)}function Uh(t){return JSON.stringify(t,(e,n)=>wk(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function g0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>g0(t[n],e[n])):!1}var dse=Object.prototype.hasOwnProperty;function q9(t,e){if(t===e)return t;const n=FF(t)&&FF(e);if(!n&&!(wk(t)&&wk(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),s=a.length,o=n?new Array(s):{};let c=0;for(let u=0;u<s;u++){const d=n?u:a[u],f=t[d],g=e[d];if(f===g){o[d]=f,(n?u<i:dse.call(t,d))&&c++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){o[d]=g;continue}const m=q9(f,g);o[d]=m,m===f&&c++}return i===s&&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 FF(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function wk(t){if(!UF(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!UF(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function UF(t){return Object.prototype.toString.call(t)==="[object Object]"}function hse(t){return new Promise(e=>{hh.setTimeout(e,t)})}function Sk(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?q9(t,e):e}function fse(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function pse(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var jR=Symbol();function K9(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===jR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function X9(t,e){return typeof t=="function"?t(...e):!!t}var mse=class extends Km{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Fh&&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"}},OR=new mse;function Mk(){let t,e;const n=new Promise((i,a)=>{t=i,e=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var gse=cse;function xse(){let t=[],e=0,n=o=>{o()},r=o=>{o()},i=gse;const a=o=>{e?t.push(o):i(()=>{n(o)})},s=()=>{const o=t;t=[],o.length&&i(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;e++;try{c=o()}finally{e--,e||s()}return c},batchCalls:o=>(...c)=>{a(()=>{o(...c)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var hi=xse(),bse=class extends Km{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Fh&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},A1=new bse;function yse(t){return Math.min(1e3*2**t,3e4)}function Y9(t){return(t??"online")==="online"?A1.isOnline():!0}var Ek=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Z9(t){let e=!1,n=0,r;const i=Mk(),a=()=>i.status!=="pending",s=v=>{if(!a()){const y=new Ek(v);g(y),t.onCancel?.(y)}},o=()=>{e=!0},c=()=>{e=!1},u=()=>OR.isFocused()&&(t.networkMode==="always"||A1.isOnline())&&t.canRun(),d=()=>Y9(t.networkMode)&&t.canRun(),f=v=>{a()||(r?.(),i.resolve(v))},g=v=>{a()||(r?.(),i.reject(v))},m=()=>new Promise(v=>{r=y=>{(a()||u())&&v(y)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())return;let v;const y=n===0?t.initialPromise:void 0;try{v=y??t.fn()}catch(b){v=Promise.reject(b)}Promise.resolve(v).then(f).catch(b=>{if(a())return;const M=t.retry??(Fh?0:3),S=t.retryDelay??yse,A=typeof S=="function"?S(n,b):S,T=M===!0||typeof M=="number"&&n<M||typeof M=="function"&&M(n,b);if(e||!T){g(b);return}n++,t.onFail?.(n,b),hse(A).then(()=>u()?void 0:m()).then(()=>{e?g(b):x()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?x():m().then(x),i)}}var Q9=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),_k(this.gcTime)&&(this.#e=hh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Fh?1/0:300*1e3))}clearGcTimeout(){this.#e&&(hh.clearTimeout(this.#e),this.#e=void 0)}},vse=class extends Q9{#e;#t;#n;#i;#r;#s;#o;constructor(t){super(),this.#o=!1,this.#s=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=BF(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#s,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=BF(this.options);e.data!==void 0&&(this.setState(zF(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=Sk(this.state.data,t,this.options);return this.#a({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#a({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(wa).catch(wa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Ws(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===jR||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:!W9(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(c=>c.options.queryFn);o&&this.setOptions(o.options)}const n=new AbortController,r=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const o=K9(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(o,u,this):o(u)},s=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(o),o})();this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#a({type:"fetch",meta:s.fetchOptions?.meta}),this.#r=Z9({initialPromise:e?.initialPromise,fn:s.fetchFn,onCancel:o=>{o instanceof Ek&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(o,c)=>{this.#a({type:"failed",failureCount:o,error:c})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const o=await this.#r.start();if(o===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#n.config.onSuccess?.(o,this),this.#n.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof Ek){if(o.silent)return this.#r.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#a({type:"error",error:o}),this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...J9(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...zF(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 J9(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Y9(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function zF(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function BF(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 _se=class extends Km{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=Mk(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#s;#o;#a;#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),HF(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ak(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ak(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ws(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&&$F(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Ws(this.options.enabled,this.#t)!==Ws(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||Ws(this.options.enabled,this.#t)!==Ws(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 Sse(this,n)&&(this.#i=n,this.#s=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#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(wa)),e}#g(){this.#v();const t=Wu(this.options.staleTime,this.#t);if(Fh||this.#i.isStale||!_k(t))return;const n=W9(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,!(Fh||Ws(this.options.enabled,this.#t)===!1||!_k(this.#l)||this.#l===0)&&(this.#u=hh.setInterval(()=>{(this.options.refetchIntervalInBackground||OR.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){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,a=this.#r,s=this.#s,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,g;if(e._optimisticResults){const I=this.hasListeners(),C=!I&&HF(t,e),D=I&&$F(t,n,e,r);(C||D)&&(d={...d,...J9(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:x,status:v}=d;g=d.data;let y=!1;if(e.placeholderData!==void 0&&g===void 0&&v==="pending"){let I;i?.isPlaceholderData&&e.placeholderData===s?.placeholderData?(I=i.data,y=!0):I=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,I!==void 0&&(v="success",g=Sk(i?.data,I,e),f=!0)}if(e.select&&g!==void 0&&!y)if(i&&g===a?.data&&e.select===this.#m)g=this.#h;else try{this.#m=e.select,g=e.select(g),g=Sk(i?.data,g,e),this.#h=g,this.#a=null}catch(I){this.#a=I}this.#a&&(m=this.#a,g=this.#h,x=Date.now(),v="error");const b=d.fetchStatus==="fetching",M=v==="pending",S=v==="error",A=M&&b,T=g!==void 0,N={status:v,fetchStatus:d.fetchStatus,isPending:M,isSuccess:v==="success",isError:S,isInitialLoading:A,isLoading:A,data:g,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:b,isRefetching:b&&!M,isLoadingError:S&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:S&&T,isStale:LR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Ws(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=Mk();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.#s=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 a=new Set(i??this.#p);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(s=>{const o=s;return this.#i[o]!==t[o]&&a.has(o)})};this.#S({listeners:n()})}#w(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){hi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function wse(t,e){return Ws(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function HF(t,e){return wse(t,e)||t.state.data!==void 0&&Ak(t,e,e.refetchOnMount)}function Ak(t,e,n){if(Ws(e.enabled,t)!==!1&&Wu(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&LR(t,e)}return!1}function $F(t,e,n,r){return(t!==e||Ws(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&LR(t,n)}function LR(t,e){return Ws(e.enabled,t)!==!1&&t.isStaleByTime(Wu(e.staleTime,t))}function Sse(t,e){return!E1(t.getCurrentResult(),e)}function VF(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],s=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=K9(e.options,e.fetchOptions),m=async(x,v,y)=>{if(d)return Promise.reject();if(v==null&&x.pages.length)return Promise.resolve(x);const M=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:v,direction:y?"backward":"forward",meta:e.options.meta};return f(k),k})(),S=await g(M),{maxPages:A}=e.options,T=y?pse:fse;return{pages:T(x.pages,S,A),pageParams:T(x.pageParams,v,A)}};if(i&&a.length){const x=i==="backward",v=x?Mse:GF,y={pages:a,pageParams:s},b=v(r,y);o=await m(y,b,x)}else{const x=t??a.length;do{const v=c===0?s[0]??r.initialPageParam:GF(r,o);if(c>0&&v==null)break;o=await m(o,v),c++}while(c<x)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function GF(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 Mse(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Ese=class extends Q9{#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||eG(),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=Z9({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,s)=>{this.#r({type:"failed",failureCount:a,error:s})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const s=await this.options.onMutate?.(t,n);s!==this.state.context&&this.#r({type:"pending",context:s,variables:t,isPaused:i})}const a=await this.#i.start();return await this.#n.config.onSuccess?.(a,t,this.state.context,this,n),await this.options.onSuccess?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,t,this.state.context,n),this.#r({type:"success",data:a}),a}catch(a){try{throw await this.#n.config.onError?.(a,t,this.state.context,this,n),await this.options.onError?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,a,t,this.state.context,n),a}finally{this.#r({type:"error",error:a})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),hi.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function eG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ase=class extends Km{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(t,e,n){const r=new Ese({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=mv(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=mv(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=mv(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=mv(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=>IF(e,n))}findAll(t={}){return this.getAll().filter(e=>IF(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(wa))))}};function mv(t){return t.options.scope?.id}var Tse=class extends Km{#e;#t=void 0;#n;#i;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),E1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Uh(n.mutationKey)!==Uh(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#s()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??eG();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#s(e){hi.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,n,r,i),this.#i.onSettled?.(e.data,null,n,r,i)):e?.type==="error"&&(this.#i.onError?.(e.error,n,r,i),this.#i.onSettled?.(void 0,e.error,n,r,i))}this.listeners.forEach(n=>{n(this.#t)})})}},Cse=class extends Km{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??DR(r,e);let a=this.get(i);return a||(a=new vse({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){hi.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>LF(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>LF(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()})})}},Nse=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new Cse,this.#t=t.mutationCache||new Ase,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=OR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=A1.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(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}),a=this.#e.get(r.queryHash)?.state.data,s=use(e,a);if(s!==void 0)return this.#e.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(t,e,n){return hi.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;hi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return hi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=hi.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(wa).catch(wa)}invalidateQueries(t,e={}){return hi.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=hi.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(wa)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(wa)}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(wa).catch(wa)}fetchInfiniteQuery(t){return t.behavior=VF(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(wa).catch(wa)}ensureInfiniteQueryData(t){return t.behavior=VF(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return A1.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(Uh(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{g0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Uh(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{g0(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=DR(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===jR&&(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()}},tG=E.createContext(void 0),En=t=>{const e=E.useContext(tG);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},kse=({client:t,children:e})=>(E.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),l.jsx(tG.Provider,{value:t,children:e})),nG=E.createContext(!1),Pse=()=>E.useContext(nG);nG.Provider;function Rse(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Dse=E.createContext(Rse()),jse=()=>E.useContext(Dse),Ose=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Lse=t=>{E.useEffect(()=>{t.clearReset()},[t])},Ise=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||X9(n,[t.error,r])),Fse=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))}},Use=(t,e)=>t.isLoading&&t.isFetching&&!e,zse=(t,e)=>t?.suspense&&e.isPending,WF=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Bse(t,e,n){const r=Pse(),i=jse(),a=En(),s=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(s),s._optimisticResults=r?"isRestoring":"optimistic",Fse(s),Ose(s,i),Lse(i);const o=!a.getQueryCache().get(s.queryHash),[c]=E.useState(()=>new e(a,s)),u=c.getOptimisticResult(s),d=!r&&t.subscribed!==!1;if(E.useSyncExternalStore(E.useCallback(f=>{const g=d?c.subscribe(hi.batchCalls(f)):wa;return c.updateResult(),g},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),E.useEffect(()=>{c.setOptions(s)},[s,c]),zse(s,u))throw WF(s,c,i);if(Ise({result:u,errorResetBoundary:i,throwOnError:s.throwOnError,query:a.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(s,u),s.experimental_prefetchInRender&&!Fh&&Use(u,r)&&(o?WF(s,c,i):a.getQueryCache().get(s.queryHash)?.promise)?.catch(wa).finally(()=>{c.updateResult()}),s.notifyOnChangeProps?u:c.trackResult(u)}function vt(t,e){return Bse(t,_se)}function wt(t,e){const n=En(),[r]=E.useState(()=>new Tse(n,t));E.useEffect(()=>{r.setOptions(t)},[r,t]);const i=E.useSyncExternalStore(E.useCallback(s=>r.subscribe(hi.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=E.useCallback((s,o)=>{r.mutate(s,o).catch(wa)},[r]);if(i.error&&X9(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Hse=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),$se=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),qF=t=>{const e=$se(t);return e.charAt(0).toUpperCase()+e.slice(1)},rG=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Vse=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Gse={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 Wse=E.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:s,...o},c)=>E.createElement("svg",{ref:c,...Gse,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:rG("lucide",i),...!a&&!Vse(o)&&{"aria-hidden":"true"},...o},[...s.map(([u,d])=>E.createElement(u,d)),...Array.isArray(a)?a:[a]]));const qe=(t,e)=>{const n=E.forwardRef(({className:r,...i},a)=>E.createElement(Wse,{ref:a,iconNode:e,className:rG(`lucide-${Hse(qF(t))}`,`lucide-${t}`,r),...i}));return n.displayName=qF(t),n};const qse=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],_h=qe("archive",qse);const Kse=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],x0=qe("arrow-down",Kse);const Xse=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Tk=qe("arrow-right",Xse);const Yse=[["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"}]],Zse=qe("arrow-up-down",Yse);const Qse=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],hm=qe("arrow-up",Qse);const Jse=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],wh=qe("bell",Jse);const eoe=[["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"}]],toe=qe("bold",eoe);const noe=[["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"}]],roe=qe("book",noe);const ioe=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],aoe=qe("bookmark",ioe);const soe=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],fm=qe("box",soe);const ooe=[["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"}]],loe=qe("cable",ooe);const coe=[["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"}]],uoe=qe("calendar-days",coe);const doe=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Zr=qe("calendar",doe);const hoe=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],b0=qe("camera",hoe);const foe=[["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"}]],poe=qe("chart-column",foe);const moe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],zh=qe("check",moe);const goe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],uf=qe("chevron-down",goe);const xoe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],df=qe("chevron-right",xoe);const boe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Bh=qe("chevron-left",boe);const yoe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],FS=qe("chevron-up",yoe);const voe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],lo=qe("circle-alert",voe);const _oe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],PA=qe("circle-arrow-up",_oe);const woe=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],fi=qe("circle-check-big",woe);const Soe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Moe=qe("circle-check",Soe);const Eoe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Aoe=qe("circle-dot",Eoe);const Toe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Coe=qe("circle-stop",Toe);const Noe=[["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"}]],gs=qe("circle-x",Noe);const koe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_r=qe("clock",koe);const Poe=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],US=qe("cloud",Poe);const Roe=[["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"}]],Doe=qe("code-xml",Roe);const joe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],iG=qe("code",joe);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"}]],Loe=qe("coffee",Ooe);const Ioe=[["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"}]],Foe=qe("cog",Ioe);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"}]],zoe=qe("compass",Uoe);const Boe=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Hh=qe("copy",Boe);const Hoe=[["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"}]],gv=qe("cpu",Hoe);const $oe=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],pm=qe("database",$oe);const Voe=[["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"}]],Ck=qe("dollar-sign",Voe);const Goe=[["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"}]],Es=qe("download",Goe);const Woe=[["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"}]],IR=qe("droplet",Woe);const qoe=[["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"}]],aG=qe("droplets",qoe);const Koe=[["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"}]],sG=qe("ellipsis-vertical",Koe);const Xoe=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],RA=qe("equal",Xoe);const Yoe=[["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"}]],As=qe("external-link",Yoe);const Zoe=[["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"}]],FR=qe("eye-off",Zoe);const Qoe=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],mm=qe("eye",Qoe);const Joe=[["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"}]],ele=qe("fan",Joe);const tle=[["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"}]],nle=qe("file-box",tle);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:"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"}]],KF=qe("file-code",rle);const ile=[["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"}]],ale=qe("file-exclamation-point",ile);const sle=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],T1=qe("file-spreadsheet",sle);const 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"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],to=qe("file-text",ole);const lle=[["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"}]],oG=qe("file",lle);const cle=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],Zp=qe("film",cle);const ule=[["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"}]],dle=qe("flame",ule);const hle=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],qu=qe("folder-kanban",hle);const fle=[["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"}]],ple=qe("folder-open",fle);const mle=[["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"}]],lG=qe("folder",mle);const gle=[["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"}]],UR=qe("funnel",gle);const xle=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],zR=qe("gauge",xle);const ble=[["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"}]],yle=qe("gift",ble);const vle=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],Qp=qe("git-compare",vle);const _le=[["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"}]],XF=qe("github",_le);const wle=[["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"}]],y0=qe("globe",wle);const Sle=[["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"}]],v0=qe("grip-vertical",Sle);const Mle=[["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"}]],BR=qe("hard-drive",Mle);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"}]],Ale=qe("heart",Ele);const Tle=[["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"}]],Nk=qe("history",Tle);const Cle=[["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"}]],Nle=qe("house",Cle);const kle=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],gb=qe("image",kle);const Ple=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],_0=qe("info",Ple);const Rle=[["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"}]],Dle=qe("italic",Rle);const jle=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Vp=qe("key",jle);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"}]],kk=qe("keyboard",Ole);const Lle=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],$h=qe("layers",Lle);const Ile=[["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"}]],cG=qe("layout-grid",Ile);const Fle=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]],Ule=qe("layout-list",Fle);const zle=[["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"}]],Ble=qe("link-2-off",zle);const Hle=[["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"}]],Pk=qe("link-2",Hle);const $le=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],zS=qe("link",$le);const Vle=[["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"}]],uG=qe("list-ordered",Vle);const Gle=[["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"}]],Wle=qe("list-todo",Gle);const qle=[["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"}]],HR=qe("list",qle);const Kle=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],At=qe("loader-circle",Kle);const Xle=[["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"}]],YF=qe("log-in",Xle);const Yle=[["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"}]],Zle=qe("log-out",Yle);const Qle=[["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"}]],Jle=qe("mail",Qle);const ece=[["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"}]],tce=qe("map",ece);const nce=[["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"}]],rce=qe("maximize-2",nce);const ice=[["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"}]],ace=qe("maximize",ice);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"}]],oce=qe("memory-stick",sce);const lce=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],cce=qe("menu",lce);const uce=[["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"}]],dce=qe("minimize-2",uce);const hce=[["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"}]],fce=qe("minimize",hce);const pce=[["path",{d:"M5 12h14",key:"1ays0h"}]],Rk=qe("minus",pce);const mce=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],C1=qe("moon",mce);const gce=[["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"}]],xce=qe("music",gce);const bce=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],w0=qe("package",bce);const yce=[["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"}]],dG=qe("palette",yce);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"}]],_ce=qe("pause",vce);const wce=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],S0=qe("pen-line",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"}]],$R=qe("pen",Sce);const Mce=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],rd=qe("pencil",Mce);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"}]],Ace=qe("phone",Ece);const Tce=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],BS=qe("play",Tce);const Cce=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],Jp=qe("plug",Cce);const Nce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pr=qe("plus",Nce);const kce=[["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"}]],VR=qe("power-off",kce);const Pce=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],bd=qe("power",Pce);const Rce=[["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"}]],Ts=qe("printer",Rce);const Dce=[["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"}]],jce=qe("qr-code",Dce);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"}]],Ta=qe("refresh-cw",Oce);const Lce=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Xm=qe("rotate-ccw",Lce);const Ice=[["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"}]],Fce=qe("ruler",Ice);const Uce=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Ro=qe("save",Uce);const zce=[["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"}]],Bce=qe("scan-search",zce);const Hce=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],id=qe("search",Hce);const $ce=[["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"}]],GR=qe("send",$ce);const Vce=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],th=qe("server",Vce);const Gce=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],HS=qe("settings-2",Gce);const Wce=[["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"}]],WR=qe("settings",Wce);const qce=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Kce=qe("shield",qce);const Xce=[["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"}]],Yce=qe("shopping-cart",Xce);const Zce=[["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"}]],Qce=qe("signal",Zce);const Jce=[["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"}]],eue=qe("skip-back",Jce);const tue=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],N1=qe("skip-forward",tue);const nue=[["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"}]],ZF=qe("sliders-vertical",nue);const rue=[["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"}]],M0=qe("sparkles",rue);const iue=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Vh=qe("square-check-big",iue);const aue=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],gm=qe("square",aue);const sue=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],xm=qe("star",sue);const oue=[["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"}]],hG=qe("sticky-note",oue);const lue=[["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"}]],QF=qe("sun",lue);const cue=[["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=qe("tag",cue);const uue=[["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"}]],fG=qe("target",uue);const due=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],pG=qe("terminal",due);const hue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],fue=qe("text-align-center",hue);const pue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],mue=qe("text-align-end",pue);const gue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],xue=qe("text-align-start",gue);const bue=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Sh=qe("thermometer",bue);const yue=[["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"}]],Uu=qe("timer",yue);const vue=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Rn=qe("trash-2",vue);const _ue=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],mG=qe("trending-down",_ue);const wue=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],gG=qe("trending-up",wue);const Sue=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ti=qe("triangle-alert",Sue);const Mue=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Eue=qe("underline",Mue);const Aue=[["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"}]],xG=qe("unlink",Aue);const Tue=[["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"}]],vs=qe("upload",Tue);const Cue=[["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"}]],Dk=qe("user",Cue);const Nue=[["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"}]],kue=qe("users",Nue);const Pue=[["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"}]],bG=qe("video",Pue);const Rue=[["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"}]],qR=qe("wifi-off",Rue);const Due=[["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"}]],yG=qe("wifi",Due);const jue=[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]],Oue=qe("wind",jue);const Lue=[["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"}]],ad=qe("wrench",Lue);const Iue=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=qe("x",Iue);const Fue=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Uue=qe("zoom-in",Fue);const zue=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],bm=qe("zap",zue);const Bue=[["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"}]],Hue=qe("zoom-out",Bue),vG=E.createContext(void 0);function $ue({children:t}){const[e,n]=E.useState(()=>{const a=localStorage.getItem("theme");return a||"dark"});E.useEffect(()=>{const a=document.documentElement;e==="dark"?a.classList.add("dark"):a.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const r=()=>{n(a=>a==="dark"?"light":"dark")},i=a=>{n(a)};return l.jsx(vG.Provider,{value:{theme:e,toggleTheme:r,setTheme:i},children:t})}function xb(){const t=E.useContext(vG);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function Nt({children:t,className:e="",onClick:n,onContextMenu:r}){return l.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function Ha({children:t,className:e=""}){return l.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Rt({children:t,className:e=""}){return l.jsx("div",{className:`p-6 ${e}`,children:t})}function Vue(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,a)=>({keys:[String(a+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,a)=>({keys:[String(a+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function JF({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 Gue({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Gm(),i=Vue(n,e,r);return E.useEffect(()=>{const a=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(kk,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),l.jsx("div",{className:"space-y-2",children:a.items.map(s=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[s.description,s.isExternal&&l.jsx(As,{className:"w-3 h-3 text-bambu-gray"})]}),l.jsx("div",{className:"flex gap-1",children:s.keys.map(o=>l.jsx(JF,{children:o},o))})]},s.description))})]},a.category))}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",l.jsx(JF,{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 s=await n.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(r){const s=r.match(/filename="?([^"]+)"?/);s&&(i=s[1])}return{blob:await n.blob(),filename:i}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=await fetch(`${er}/archives/stats/export?${e}`);if(!n.ok){const s=await n.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(r){const s=r.match(/filename="?([^"]+)"?/);s&&(i=s[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>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 a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(a=>n.append("files",a));const r=e?`${er}/archives/upload-bulk?printer_id=${e}`:`${er}/archives/upload-bulk`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getSettings:()=>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 a="bambuddy-backup.json";if(i){const o=i.match(/filename=([^;]+)/);o&&(a=o[1].trim())}return{blob:await r.blob(),filename:a}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${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")},_G=[{name:"globe",icon:y0},{name:"link",icon:zS},{name:"external-link",icon:As},{name:"book",icon:roe},{name:"file-text",icon:to},{name:"home",icon:Nle},{name:"star",icon:xm},{name:"heart",icon:Ale},{name:"bookmark",icon:aoe},{name:"shopping-cart",icon:Yce},{name:"music",icon:xce},{name:"video",icon:bG},{name:"image",icon:gb},{name:"camera",icon:b0},{name:"map",icon:tce},{name:"compass",icon:zoe},{name:"coffee",icon:Loe},{name:"gift",icon:yle},{name:"wrench",icon:ad},{name:"zap",icon:bm},{name:"cloud",icon:US},{name:"database",icon:pm},{name:"folder",icon:lG},{name:"mail",icon:Jle},{name:"phone",icon:Ace},{name:"user",icon:Dk},{name:"users",icon:kue},{name:"server",icon:th},{name:"terminal",icon:pG},{name:"code",icon:iG}];function $S(t){return _G.find(n=>n.name===t)?.icon||zS}function Wue({value:t,onChange:e}){const[n,r]=E.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:_G.map(({name:a,icon:s})=>l.jsx("button",{type:"button",onClick:()=>{e(a),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===a?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:a,children:l.jsx(s,{className:"w-5 h-5"})},a))})})]})]})}const eU=768;function wG(){const[t,e]=E.useState(()=>typeof window<"u"?window.innerWidth<eU:!1);return E.useEffect(()=>{const n=window.matchMedia(`(max-width: ${eU-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const A0=[{id:"printers",to:"/",icon:Ts,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:poe,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:US,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:ad,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:qu,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:WR,labelKey:"nav.settings"}];function que(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return A0.map(e=>e.id)}return A0.map(e=>e.id)}function Kue(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function DA(t){return t.startsWith("ext-")}function SG(){return localStorage.getItem("defaultView")||"/"}function Xue(t){localStorage.setItem("defaultView",t)}function Yue(){const t=CR(),e=xd(),{theme:n,toggleTheme:r}=xb(),{t:i}=Gm(),a=wG(),[s,o]=E.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=E.useState(!1),[d,f]=E.useState(!1),[g,m]=E.useState(que),[x,v]=E.useState(null),[y,b]=E.useState(null),M=E.useRef(!1),[S,A]=E.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(A0.map(Q=>[Q.id,Q])),D=new Map((I||[]).map(Q=>[`ext-${Q.id}`,Q])),F=(()=>{const Q=[],U=new Set;for(const $ of g)(C.has($)||D.has($))&&(Q.push($),U.add($));for(const $ of A0)U.has($.id)||(Q.push($.id),U.add($.id));for(const $ of I||[]){const X=`ext-${$.id}`;U.has(X)||(Q.push(X),U.add(X))}return Q})(),O=(Q,U)=>{v(U),Q.dataTransfer.effectAllowed="move",Q.dataTransfer.setData("text/plain",U)},q=(Q,U)=>{Q.preventDefault(),Q.dataTransfer.dropEffect="move",b(U)},R=()=>{b(null)},W=(Q,U)=>{if(Q.preventDefault(),x===null||x===U){v(null),b(null);return}const $=[...F],X=$.indexOf(x),te=$.indexOf(U);if(X===-1||te===-1){v(null),b(null);return}$.splice(X,1),$.splice(te,0,x),m($),Kue($),v(null),b(null)},K=()=>{v(null),b(null)},G=N?.update_available&&N.latest_version&&N.latest_version!==S,ee=()=>{N?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",N.latest_version),A(N.latest_version))};E.useEffect(()=>{if(!M.current&&e.pathname==="/"){const Q=SG();Q!=="/"&&(M.current=!0,t(Q,{replace:!0}))}},[e.pathname,t]),E.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(s))},[s]),E.useEffect(()=>{a&&u(!1)},[e.pathname,a]);const Z=E.useCallback(Q=>{const U=Q.target;if(!(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable)&&!Q.metaKey&&!Q.ctrlKey&&!Q.altKey){const $=parseInt(Q.key);if($>=1&&$<=F.length&&$<=9){const X=F[$-1];if(Q.preventDefault(),DA(X)){const te=X.replace("ext-","");t(`/external/${te}`)}else{const te=C.get(X);te&&t(te.to)}return}switch(Q.key){case"?":Q.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,F,C]);return E.useEffect(()=>(document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)),[Z]),l.jsxs("div",{className:"flex min-h-screen",children:[a&&l.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[l.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:l.jsx(cce,{className:"w-6 h-6 text-white"})}),l.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&c&&l.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),l.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${a?`fixed inset-y-0 left-0 z-50 w-72 transform ${c?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${s?"w-64":"w-16"}`}`,children:[l.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||s?"p-4":"p-2"}`,children:l.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||s?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),l.jsx("nav",{className:"flex-1 p-2",children:l.jsx("ul",{className:"space-y-2",children:F.map(Q=>{if(DA(Q)){const $=D.get(Q);if(!$)return null;const X=$.custom_icon?null:$S($.icon);return l.jsx("li",{draggable:!0,onDragStart:te=>O(te,Q),onDragOver:te=>q(te,Q),onDragLeave:R,onDrop:te=>W(te,Q),onDragEnd:K,className:`relative ${x===Q?"opacity-50":""} ${y===Q&&x!==Q?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:l.jsxs(Rx,{to:`/external/${$.id}`,className:({isActive:te})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${te?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?$.name:void 0,children:[s&&!a&&l.jsx(v0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),$.custom_icon?l.jsx("img",{src:`/api/v1/external-links/${$.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):X&&l.jsx(X,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&l.jsx("span",{children:$.name})]})},Q)}else{const $=C.get(Q);if(!$)return null;const{to:X,icon:te,labelKey:fe}=$;return l.jsx("li",{draggable:!0,onDragStart:pe=>O(pe,Q),onDragOver:pe=>q(pe,Q),onDragLeave:R,onDrop:pe=>W(pe,Q),onDragEnd:K,className:`relative ${x===Q?"opacity-50":""} ${y===Q&&x!==Q?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:l.jsxs(Rx,{to:X,className:({isActive:pe})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${pe?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?i(fe):void 0,children:[s&&!a&&l.jsx(v0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),l.jsx(te,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&l.jsx("span",{children:i(fe)})]})},Q)}})})}),!a&&l.jsx("button",{onClick:()=>o(!s),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(s?"nav.collapseSidebar":"nav.expandSidebar"),children:s?l.jsx(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:a||s?l.jsxs("div",{className:"flex items-center justify-between px-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",T?.version||"..."]}),N?.update_available&&l.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:N.latest_version}),children:[l.jsx(PA,{className:"w-4 h-4"}),l.jsx("span",{children:i("nav.update")})]})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(Rx,{to:"/system",className:({isActive:Q})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${Q?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:l.jsx(_0,{className:"w-5 h-5"})}),l.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:l.jsx(XF,{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(kk,{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(QF,{className:"w-5 h-5"}):l.jsx(C1,{className:"w-5 h-5"})})]})]}):l.jsxs("div",{className:"flex flex-col items-center gap-1",children:[N?.update_available&&l.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:N.latest_version}),children:l.jsx(PA,{className:"w-5 h-5"})}),l.jsx(Rx,{to:"/system",className:({isActive:Q})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${Q?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:l.jsx(_0,{className:"w-5 h-5"})}),l.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:l.jsx(XF,{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(kk,{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(QF,{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 ${a?"mt-14":s?"ml-64":"ml-16"}`,children:[G&&l.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx(PA,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{children:i("nav.updateAvailableBanner",{version:N?.latest_version,defaultValue:`Version ${N?.latest_version} is available!`})}),l.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),l.jsx("button",{onClick:ee,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsx(Aae,{})]}),d&&l.jsx(Gue,{onClose:()=>f(!1),sidebarItems:F.map(Q=>{if(DA(Q)){const U=D.get(Q);return U?{type:"external",label:U.name}:null}else{const U=C.get(Q);return U?{type:"nav",label:U.labelKey,labelKey:U.labelKey}:null}}).filter(Boolean)})]})}function Le({variant:t="primary",size:e="md",className:n="",children:r,...i}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",s={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},o={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return l.jsx("button",{className:`${a} ${s[t]} ${o[e]} ${n}`,...i,children:r})}function Qr({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:s}){E.useEffect(()=>{const u=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s]);const c={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-start gap-4",children:[l.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${c.icon}`,children:l.jsx(ti,{className:"w-6 h-6"})}),l.jsxs("div",{className:"flex-1",children:[l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),l.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),l.jsxs("div",{className:"flex gap-3 mt-6",children:[l.jsx(Le,{variant:"secondary",onClick:s,className:"flex-1",children:r}),l.jsx(Le,{onClick:a,className:`flex-1 ${c.button}`,children:n})]})]})})})}const MG=E.createContext(void 0);function ai(){const t=E.useContext(MG);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Zue={success:l.jsx(fi,{className:"w-5 h-5 text-green-400"}),error:l.jsx(gs,{className:"w-5 h-5 text-red-400"}),warning:l.jsx(lo,{className:"w-5 h-5 text-yellow-400"}),info:l.jsx(_0,{className:"w-5 h-5 text-blue-400"}),loading:l.jsx(At,{className:"w-5 h-5 text-bambu-green animate-spin"})},Que={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30",loading:"bg-bambu-green/10 border-bambu-green/30"};function Jue({children:t}){const[e,n]=E.useState([]),r=E.useCallback((s,o="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:s,type:o}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=E.useCallback((s,o,c="info")=>{n(u=>u.find(f=>f.id===s)?u.map(f=>f.id===s?{...f,message:o,type:c,persistent:!0}:f):[...u,{id:s,message:o,type:c,persistent:!0}])},[]),a=E.useCallback(s=>{n(o=>o.filter(c=>c.id!==s))},[]);return l.jsxs(MG.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:a},children:[t,l.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(s=>l.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Que[s.type]}`,children:[Zue[s.type],l.jsx("span",{className:"text-white text-sm",children:s.message}),l.jsx("button",{onClick:()=>a(s.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-4 h-4"})})]},s.id))})]})}function ede(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 tU(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 tde(t,e){if(e)return lG;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return nle;case"gcode":return to;case"mp4":case"avi":return Zp;case"png":case"jpg":case"jpeg":return gb;default:return oG}}function nde({printerId:t,printerName:e,onClose:n}){const{showToast:r}=ai(),i=En(),[a,s]=E.useState("/"),[o,c]=E.useState(null),[u,d]=E.useState(""),[f,g]=E.useState(null);E.useEffect(()=>{const N=I=>{I.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]);const{data:m,isLoading:x,refetch:v}=vt({queryKey:["printerFiles",t,a],queryFn:()=>ke.getPrinterFiles(t,a)}),{data:y}=vt({queryKey:["printerStorage",t],queryFn:()=>ke.getPrinterStorage(t),staleTime:3e4}),b=wt({mutationFn:N=>ke.deletePrinterFile(t,N),onSuccess:(N,I)=>{r(`Deleted: ${I.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:N=>{r(`Delete failed: ${N.message}`,"error")}}),M=N=>{s(N),c(null)},S=()=>{if(a==="/")return;const N=a.split("/").filter(Boolean);N.pop(),s(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(BR,{className:"w-5 h-5 text-bambu-green"}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[y&&(y.used_bytes!=null||y.free_bytes!=null)&&l.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[y.used_bytes!=null&&l.jsxs("span",{children:["Used: ",tU(y.used_bytes)]}),y.used_bytes!=null&&y.free_bytes!=null&&l.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),y.free_bytes!=null&&l.jsxs("span",{children:["Free: ",tU(y.free_bytes)]})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),l.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[k.map(N=>l.jsx("button",{onClick:()=>{M(N.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===N.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:N.label},N.path)),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"relative",children:[l.jsx(id,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:N=>d(N.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>v(),disabled:x,children:l.jsx(Ta,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[l.jsx("button",{onClick:S,disabled:a==="/",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:a})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:x?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(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=tde(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?M(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:ede(N.size)}),N.is_directory&&l.jsx(Bh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},N.path)})}):l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[l.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${m?.files?.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${m?.files?.length||0} items`:`${m?.files?.length||0} items`}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{variant:"secondary",disabled:!o,onClick:()=>o&&A(o),children:[l.jsx(Es,{className:"w-4 h-4"}),"Download"]}),l.jsxs(Le,{variant:"secondary",disabled:!o||b.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[b.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&l.jsx(Qr,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{b.mutate(f),g(null)},onCancel:()=>g(null)})]})}function rde({printerId:t,printerName:e,onClose:n}){const r=En(),[i,a]=E.useState(!0),[s,o]=E.useState(new Set),[c,u]=E.useState(""),[d,f]=E.useState("all"),g=E.useRef(null),{data:m,isLoading:x,refetch:v}=vt({queryKey:["mqtt-logs",t],queryFn:()=>ke.getMQTTLogs(t),refetchInterval:1e3}),y=wt({mutationFn:()=>ke.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),b=wt({mutationFn:()=>ke.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),M=wt({mutationFn:()=>ke.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});E.useEffect(()=>{const C=D=>{D.key==="Escape"&&n()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[n]),E.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[m?.logs,i]);const S=C=>{o(D=>{const F=new Set(D);return F.has(C)?F.delete(C):F.add(C),F})},A=C=>new Date(C).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(C,D)=>{if(C==null)return"<empty>";const F=typeof C=="string"?JSON.parse(C):C,O=JSON.stringify(F,null,D?2:0);return!D&&O.length>100?O.substring(0,100)+"...":O},k=m?.logging_enabled??!1,N=m?.logs??[],I=E.useMemo(()=>N.filter(C=>{if(d!=="all"&&C.direction!==d)return!1;if(c.trim()){const D=c.toLowerCase(),F=C.topic.toLowerCase().includes(D),q=JSON.stringify(C.payload).toLowerCase().includes(D);return F||q}return!0}),[N,c,d]);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[k?l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,children:[l.jsx(gm,{className:"w-4 h-4"}),"Stop"]}):l.jsxs(Le,{size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:[l.jsx(BS,{className:"w-4 h-4"}),"Start Logging"]}),l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>M.mutate(),disabled:M.isPending||N.length===0,children:[l.jsx(Rn,{className:"w-4 h-4"}),"Clear"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>v(),disabled:x,children:l.jsx(Ta,{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=>a(C.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),l.jsxs("span",{className:"text-sm text-bambu-gray",children:[I.length,"/",N.length]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx(id,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:C=>u(C.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),c&&l.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[l.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),l.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[l.jsx(x0,{className:"w-3 h-3"}),"In"]}),l.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[l.jsx(hm,{className:"w-3 h-3"}),"Out"]})]})]})]}),l.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:N.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[l.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!k&&l.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):I.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[l.jsx("p",{className:"mb-2",children:"No messages match your filter"}),l.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):l.jsx("div",{className:"space-y-1",children:I.map((C,D)=>{const F=s.has(D),O=C.direction==="in";return l.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>S(D),children:[l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx("span",{className:"text-bambu-gray shrink-0",children:A(C.timestamp)}),l.jsx("span",{className:`shrink-0 ${O?"text-blue-400":"text-green-400"}`,title:O?"Incoming":"Outgoing",children:O?l.jsx(x0,{className:"w-3 h-3"}):l.jsx(hm,{className:"w-3 h-3"})}),l.jsx("span",{className:"text-purple-400 shrink-0",children:C.topic})]}),F?l.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:T(C.payload,!0)}):l.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(C.payload,!1)})]},D)})})}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[l.jsx("div",{className:"text-sm text-bambu-gray",children:k?l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):l.jsx("span",{children:"Logging stopped"})}),l.jsx(Le,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const jk={"0300_4000":"Z axis homing failed; the task has been stopped.","0300_4001":"The printer timed out waiting for the nozzle to cool down before homing.","0300_4002":"Auto Bed Leveling failed; the task has been stopped.","0300_4005":"The hotend cooling fan speed is abnormal.","0300_4006":"The nozzle is clogged.","0300_4008":"The AMS failed to change filament.","0300_4009":"Homing XY axis failed.","0300_400A":"Mechanical resonance frequency identification failed.","0300_400B":"Internal communication exception","0300_400C":"The task was canceled.","0300_400D":"Resume failed after power loss.","0300_400E":"The motor self-check failed.","0300_400F":"The power supply voltage does not match the printer.","0300_4010":"Nozzle offset calibration failed.","0300_4011":"Flow Dynamics Calibration failed; please reinitiate printing or calibration.","0300_4013":"Printing cannot be initiated while AMS is drying.","0300_4014":"Homing Z axis failed: temperature control abnormality.","0300_4015":"Nozzle clumping detection calibration failed. Please go to 'Assistant' for troubleshooting.","0300_4016":"Nozzle cleaning failed. Please click the Assistant for troubleshooting.","0300_401F":"The hotend is not installed, and the toolhead cannot perform homing. Please install the hotend and then continue.","0300_4020":"The nozzle presence detection failed. Please check the Assistant for details.","0300_4021":"Nozzle offset calibration sensor signal abnormality detected. Please check the sensor and retry.","0300_4042":"The Laser Safety Window is not properly installed. The task has been stopped.","0300_4044":"The Flame Sensor is abnormal. The sensor may be short-circuited. Please troubleshoot the issue before starting a print job.","0300_404B":"Task aborted because the front door or top cover is open.","0300_404D":"The current temperature of the hotend, heatbed, or chamber is too high. Please wait for it to cool down to room temperature before restarting the task.","0300_4050":"Liveview Camera calibration timeout; please restart the printer.","0300_4052":"Blade Z-axis homing failed","0300_4057":"Z-axis step loss detected. The task has stopped. Please check if there are any obstructions beneath the heatbed.","0300_4066":"Calibration of motion precision failed.","0300_4067":"Calibration result is over the threshold.","0300_4068":"Step loss occurred during the motion accuracy enhancement process. Please try again.","0300_8000":"Printing was paused for unknown reason. You can select 'Resume' to resume the print job.","0300_8001":"Printing was paused by the user. You can select 'Resume' to continue printing.","0300_8002":"First layer defects were detected by the Micro Lidar. Please check the quality of the printed model before continuing your print.","0300_8003":"Spaghetti defects were detected by the AI Print Monitoring. Please check the quality of the printed model before continuing your print.","0300_8004":"Filament ran out. Please load new filament.","0300_8005":"Toolhead front cover fell off. Please remount the front cover and check to make sure your print is going okay.","0300_8006":"The build plate marker was not detected. Please confirm the build plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible.","0300_8007":"There was an unfinished print job when the printer lost power. If the model is still adhered to the build plate, you can try resuming the print job.","0300_8008":"Nozzle temperature malfunction","0300_8009":"Heatbed temperature malfunction","0300_800A":"A Filament pile-up was detected by AI Print Monitoring. Please clean filament from the waste chute.","0300_800B":"The cutter is stuck. Please make sure the cutter handle is out and check the filament sensor cable connection.","0300_800C":"Skipped step detected: auto-recover complete; please resume print and check if there are any layer shift problems.","0300_800D":"Detected that the extruder is not extruding normally. If the defects are acceptable, select 'Resume' to resume the print job.","0300_800E":"The print file is not available. Please check to see if the storage media has been removed.","0300_800F":"The door seems to be open, so printing was paused.","0300_8010":"The hotend cooling fan speed is abnormal.","0300_8011":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0300_8013":"Printing paused due to the pause command added to the printing file.","0300_8014":"The nozzle is covered with filament, or the build plate is installed incorrectly. Please cancel this print and clean the nozzle or adjust the build plate according to the actual status. You can als...","0300_8015":"The filament on external spool has run out; please load new filament. If the filament is loaded, please select 'Resume'.","0300_8016":"The nozzle is clogged with filament. Please cancel this print and clean the nozzle or select 'Resume' to resume the print job.","0300_8017":"Foreign objects detected on heatbed. Please check and clean the heatbed. Then, select 'Resume' to resume the print job.","0300_8018":"Chamber temperature malfunction.","0300_8019":"No build plate is placed.","0300_801A":"Filament extrusion error; please check the assistant for troubleshooting. After resolving the issue, decide whether to cancel or resume the print job based on the actual print status.","0300_801B":"Nozzle temperature problem detected. Refer to Assistant to re-connect the hotend connector. POWER OFF the printer before this operation to avoid short circuits.","0300_801C":"The extrusion resistance is abnormal. The extruder may be clogged; please refer to the assistant. After trouble shooting, you can select 'Resume' to resume the print job.","0300_801D":"The extruder servo motor position sensor is malfunctioning. Please power off the printer first and check if the connection cable is loose.","0300_801E":"The extrusion motor is overloaded, please check the Assistant for details.","0300_8021":"The nozzle may not be installed or not properly installed. Please ensure the nozzle is correctly installed before proceeding.","0300_8022":"The heatbed may be obstructed while moving downward. Please clear any objects beneath the heatbed and check for any resistance or jamming during its movement.","0300_8028":"Nozzle offset calibration sensor error. If using a single hotend or the calibration function is disabled, you may ignore this and continue printing; otherwise, it is recommended to check the sensor...","0300_8041":"Platform detection timeout: please restart the printer.","0300_8042":"Task paused because the door is open.","0300_8043":"The laser module is abnormal.","0300_8044":"Fire was detected inside the chamber.","0300_8045":"Material detection timeout: please restart the printer.","0300_8046":"Foreign object detect timeout: please restart the printer.","0300_8047":"Quick-release lever detection time out: please restart the printer.","0300_8048":"Laser Module unlock has timed out, and the task cannot proceed. Please restart the printer and try again.","0300_8049":"The current plate is invalid.","0300_804A":"Emergency stop button improperly installed. Please reinstall according to the Wiki before proceeding.","0300_804B":"Task paused. The Laser Safety Window is open.","0300_804E":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0300_804F":"The loading/unloading process is currently ongoing. Please stop the process or remove the laser/cutting module.","0300_8050":"This device does not support the 40W Laser Module. Please remove it or replace it with a 10W Laser Module.","0300_8051":"The cutting module has dropped or the cutting module cable is disconnected; please check the module.","0300_8053":"Laser module detected. Please install the right nozzle correctly to ensure proper Laser Module Mounting Calibration.","0300_8054":"Please place the paper required for Print Then Cut.","0300_8055":"The module mounted on the toolhead does not match the task. Please install the correct module.","0300_8057":"The rotary attachment is disconnected. Please ensure it is properly installed and the cable is securely plugged in.","0300_8058":"The rotary attachment is detected. Please remove it before continuing.","0300_8061":"The mode of Airflow System failed to activate; check the air door condition.","0300_8062":"The chamber temperature is too high. It may be due to high environmental temperature.","0300_8063":"The chamber temperature is too high. Please open the top cover and front door to cool down.","0300_8064":"The chamber temperature is too high. Please open the top cover and front door to cool down. (Open door detection for this print job will be set to 'Notification' level)","0300_8065":"The temperature of the MC module is too high. Please check the Wiki for possible explanations.","0300_8071":"The Toolhead Enhanced Cooling Fan module is malfunctioning.","0300_807D":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807E":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807F":"Fire Extinguisher is malfunctioning.","0300_8080":"Fire extinguisher motor reset failed.","0300_8081":"Fire extinguisher cylinder not installed. Please confirm on the extinguisher page.","0300_8082":"The Fire Extinguisher Gas Cylinder is empty.","0300_C012":"Please heat the nozzle to above 170°C.","0300_C056":"A minor fire was detected inside the chamber, and the Auto Fire Extinguishing process has been aborted.","0300_C070":"The fire extinguisher has been detected and is ready for use after the laser module is connected.","0500_4001":"Failed to connect to Bambu Cloud. Please check your network connection.","0500_4002":"Unsupported print file path or name. Please resend the print job.","0500_4003":"Printing stopped because the printer was unable to parse the file. Please resend your print job.","0500_4004":"Device is busy and cannot start new task. Please wait for current task to complete before sending new task.","0500_4005":"Print jobs are not allowed to be sent while updating firmware.","0500_4006":"There is not enough free storage space for the print job. Restoring to factory settings can free up available space.","0500_4007":"The device requires a repair upgrade, and printing is currently unavailable.","0500_4008":"Starting printing failed; please power cycle the printer and resend the print job.","0500_4009":"Print jobs are not allowed to be sent while updating logs.","0500_400A":"The file name is not supported. Please rename and restart the print job.","0500_400B":"There was a problem downloading a file. Please check your network connection and resend the print job.","0500_400C":"Please insert a MicroSD card and restart the print job.","0500_400D":"Please run a self-test and restart the print job.","0500_400E":"Printing was cancelled.","0500_400F":"AMS is initializing and cannot be upgraded at the moment. Please try again later.","0500_4010":"AMS is drying and cannot be upgraded at the moment. Please try again later.","0500_4011":"The printer is loading or unloading filament and cannot be upgraded at the moment. Please try again later.","0500_4012":"The device is printing and cannot be upgraded at the moment. Please try again later.","0500_4013":"AMS is in operation and cannot be upgraded at the moment. Please try again when it is idle.","0500_4014":"Slicing for the print job failed. Please check your settings and restart the print job.","0500_4015":"There is not enough free storage space for the print job. Please format or clear files from the MicroSD card to free up space.","0500_4016":"The MicroSD Card is write-protected. Please replace the MicroSD Card.","0500_4017":"Binding failed. Please retry or restart the printer and retry.","0500_4018":"Binding configuration information parsing failed; please try again.","0500_4019":"The printer has already been bound. Please unbind it and try again.","0500_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0500_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_402A":"Failed to connect to the router, which may be caused by wireless interference or being too far away from the router. Please try again or move the printer closer to the router and try again.","0500_402B":"Router connection failed due to incorrect password. Please check the password and try again.","0500_402C":"Failed to obtain IP address, which may be caused by wireless interference resulting in data transmission failure or the DHCP address pool of the router being full. Please move the printer closer to...","0500_402D":"System exception","0500_402E":"System does not support the file system currently used by the USB flash drive. Please replace or format the USB flash drive to FAT32.","0500_402F":"The MicroSD card sector data is damaged. Please use the SD card repair tool to repair or format it. If it still cannot be identified, please replace the MicroSD card.","0500_4030":"The device is currently upgrading. Please try again when it is idle.","0500_4031":"The accessory firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4033":"The AMS firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4034":"The Laser Module firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4035":"The BirdsEye Camera is malfunctioning. Please try restarting the device. If the issue persists after multiple restarts, check the camera connection status or contact customer support.","0500_4037":"Your sliced file is not compatible with current printer model. This file can't be printed on this printer.","0500_4038":"The nozzle diameter in sliced file is not consistent with the current nozzle setting. This file can't be printed.","0500_4039":"The current task does not allow the installation of the laser/cutting module, and the task has been halted.","0500_403A":"The current temperature is too low. In order to protect you and your printer, printing tasks, moving an axis and other operations are disabled. Please move the printer to an environment above 10 de...","0500_403B":"Laser/cutting tasks cannot be initiated on the machine at the moment. Please use the computer software to start the task.","0500_403C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_403D":"The toolhead module is not set up. Please set it up before initiating the task.","0500_403E":"The current tool head does not support initialization.","0500_403F":"Failed to download print job; please check your network connection.","0500_4040":"The printer has reached its power limit. Please connect a dedicated power adapter to this AMS to enable drying.","0500_4041":"The AMS drying cannot be started during printing.","0500_4042":"Due to power limitations, starting AMS drying will pause current operations such as nozzle heating and fan running. Do you want to proceed with drying?","0500_4043":"Due to power limitations, only one AMS is allowed to use the device's power for drying.","0500_4044":"BirdsEye Camera malfunction: please contact customer support.","0500_4045":"Hotend check in progress. This operation is temporarily unavailable. Please wait.","0500_4050":"Error detected on the print board.","0500_4052":"Error detected on the hot end.","0500_4054":"Error detected on the mat.","0500_405D":"Laser module Serial Number error: unable to calibrate or make project.","0500_4065":"The task requires a Laser Platform, but the current one is a Cutting Platform. Please replace it, measure the material thickness in the software, and then restart the task.","0500_4070":"The laser or cutter module is connected, so the device cannot initiate a 3D printing task.","0500_4075":"No Laser Platform was detected, which may affect thickness measurement accuracy. Please place the laser platform correctly and ensure the rear markers are not blocked, then restart the thickness me...","0500_4076":"Please place the Laser Platform correctly and ensure the rear markers are not blocked, then restart the thickness measurement in the software before initiating the task.","0500_4097":"The device cannot detect the Laser Module. Please reconnect the module cable or restart the printer.","0500_4098":"The device cannot detect AMS A. Please reconnect the AMS cable or restart the printer.","0500_4099":"The firmware of Cutting Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409A":"The firmware of the Air Pump does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409B":"The firmware of the Laser Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409D":"The firmware of AMS A does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0500_409E":"The device cannot detect the Cutting Module. Please reconnect the module cable or restart the printer.","0500_409F":"The device cannot detect the Air Pump. Please reconnect the module cable or restart the printer.","0500_40A0":"The Rotary Attachment module is not detected. Please reconnect the cable or restart the printer.","0500_40A1":"The Auto Fire Extinguishing System is not detected. Please reconnect the module cable or restart the printer.","0500_40A3":"AMS(or AMS lite) A communication is abnormal. Please reconnect the module cable or restart the printer.","0500_40A4":"The current firmware only supports 1 AMS Lite. Please remove all AMS units before reconnecting the supported AMS Lite device.","0500_40A5":"The current firmware only supports AMS/AMS 2 Pro/AMS HT, with a maximum of 4 units. Please remove all AMS units before reconnecting the supported one.","0500_8013":"The print file is not available. Please check to see if the storage media has been removed.","0500_8036":"Your sliced file is not consistent with the current printer model. Continue?","0500_803C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_8040":"Toolhead front cover is detached. Moving the toolhead may damage the printer. Do you want to continue?","0500_8041":"The filament in hotend is too cold. Extrusion may damage the extruder. Still feeding in/out the filament?","0500_8048":"The module on the toolhead is not calibrated. Please cancel the task to perform calibration or switch to a calibrated module.","0500_8051":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0500_8053":"Nozzle mismatch was detected during printing. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","0500_8055":"Laser module is installed, but a Cutting Platform is detected. Please place a Laser Platform and perform laser calibration.","0500_8056":"Cutting module is installed, but the laser platform is detected. Please place the cutting platform for calibration.","0500_8058":"Please place the light grip cutting mat correctly and ensure the marker is exposed.","0500_8059":"Cutting platform base is not correctly aligned. Please ensure that the four corners of the platform are aligned with the heatbed.","0500_805A":"Please place the cutting mat on cutting protection base.","0500_805B":"The cutting mat type is unknown; please replace it with the correct cutting mat.","0500_805C":"The grip cutting mat type does not match; please place a LightGrip cutting mat.","0500_805E":"Cutting module Serial Number error: unable to calibrate or make project.","0500_8060":"The current module on toolhead does not meet requirements. Please replace the module as per the on-screen instructions.","0500_8061":"No print plate detected. Please make sure it is placed correctly.","0500_8062":"The print plate marker was not detected. Please confirm the print plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible. If strong light is shining o...","0500_8063":"The platform is not detected during calibration; please make sure the Laser Platform is properly placed.","0500_8064":"Please place the Laser Platform correctly and ensure the rear markers are not blocked for laser calibration.","0500_8066":"The task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + LightGrip cutting mat).","0500_8067":"Please place a LightGrip cutting mat on the cutting protection base.","0500_8068":"Please place the strong grip cutting mat correctly and ensure the marker is exposed.","0500_8069":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please manually set the hotend types.","0500_806A":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please set hotend types on printer screen before next print.","0500_806B":"Quick-release Lever is not locked. Please press down the external toolhead module to ensure it is properly seated, then push down the level to lock it in place.","0500_806C":"Please place the cutting platform correctly and ensure the marker is exposed.","0500_806D":"Material not detected. Please confirm placement and continue.","0500_806E":"Foreign objects detected on heatbed; please check and clean up the heatbed.","0500_806F":"The grip cutting mat type does not match; please place a StrongGrip cutting mat.","0500_8071":"No cutting platform was detected. Please confirm that it has been correctly placed.","0500_8072":"Live View camera is blocked","0500_8073":"Heatbed limit block is obstructed or contaminated. Please clean and ensure the limit block is visible, otherwise platform position offset detection may be inaccurate.","0500_8074":"The Laser Platform is offset. Please ensure that the four corners of the platform are aligned with the heatbed, and the marker is not obstructed.","0500_8077":"The visual marker was not detected. Please ensure the paper is properly placed.","0500_8078":"Current material does not match the sliced file settings. Please load the correct material and ensure the QR code on the material is not damaged or dirty.","0500_8079":"Please place the Laser Test Material (350g paperboard) and position support strips underneath to prevent material warping.","0500_807A":"The foreign object detection function is not working. You can continue the task or check the assistant for troubleshooting.","0500_807B":"Please place the cutting platform (cutting protection base + LightGrip cutting mat).","0500_807C":"Please place the cutting platform (cutting protection base + StrongGrip cutting mat).","0500_807D":"This task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + StrongGrip Cutting Mat).","0500_807E":"Please place a StrongGrip cutting mat on the cutting protection base.","0500_8080":"The left and right hotends are not installed.","0500_8081":"The left and right hotends are not installed.","0500_8082":"Please remove the protective film on the Opaque Glossy Acrylic before processing","0500_8083":"Material is not allowed in Mounting Calibration. Please remove the material from the platform.","0500_8084":"The Live View Camera is dirty; please clean it and continue.","0500_8085":"Toolhead camera is obstructed","0500_8086":"Toolhead Camera is dirty, which affects the AI function; please clean the lens surface.","0500_8087":"BirdsEye camera is obstructed","0500_8088":"The Birdseye Camera is dirty","0500_8089":"Task paused due to Presence Check failed. Please check the printer to continue.","0500_808A":"The BirdsEye Camera is installed offset. Please refer to the assistant to reinstall it.","0500_808B":"The BirdsEye Camera setup failed. Please remove all objects and the mat on the heatbed to ensure the heatbed markers are visible. Meanwhile, please ensure the BirdsEye Camera is installed correctly...","0500_808C":"Detected build plate offset. Please align the build plate with the heatbed, and then continue.","0500_808D":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the cutting material is properly positioned and check whether the cutting blade tip is worn.","0500_808E":"BirdsEye Camera initialization failed. The toolhead camera did not detect the Heatbed features. Please clean the Heatbed, remove all objects and pads, and ensure the bed markings are visible. Check...","0500_808F":"Nozzle camera lens is dirty, affecting AI monitoring. Clean the lens with a non-woven cloth and a small amount of alcohol. Beware of hotend heat; wait for it to cool before handling.","0500_8090":"Please attach the 80g White Printing Paper to the center area of the platform.","0500_8091":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the 80g white printer paper(letter paper thickness) is properly positioned and check whether the cut...","0500_8092":"Toolhead Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0500_8093":"The nozzle silicone sleeve is not installed; there is a risk of temperature control failure. Please install it correctly and try again.","0500_80A0":"The visual encoder board was not detected. Please check if the board is properly placed and aligned at all four corners, and ensure the positioning markings are clear and free from wear.","0500_C010":"MicroSD Card read/write exception: please reinsert or replace the MicroSD Card.","0500_C032":"Laser/Cutting module connected to the toolhead. The drying process has been automatically stopped.","0500_C036":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0500_C07F":"Device is busy and cannot perform this operation. To proceed, please pause or stop the current task.","0501_4017":"Binding failed. Please retry or restart the printer and retry.","0501_4018":"Binding configuration information parsing failed; please try again.","0501_4019":"The printer has already been bound. Please unbind it and try again.","0501_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0501_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4031":"Device discovery binding is in progress, and the QR code cannot be displayed on the screen. You can wait for the binding to finish or abort the device discovery binding process in the APP/Studio an...","0501_4032":"QR code binding is in progress, so device discovery binding cannot be performed. You can scan the QR code on the screen for binding or exit the QR code display page on screen and try device discove...","0501_4033":"Your APP region does not match with your printer; please download the APP in the corresponding region and register your account again.","0501_4034":"The slicing progress has not been updated for a long time, and the printing task has exited. Please confirm the parameters and reinitiate printing.","0501_4035":"The device is in the process of binding and cannot respond to new binding requests.","0501_4038":"The regional settings do not match the printer; please check the printer's regional settings.","0501_4039":"Device login has expired; please try to bind again.","0501_4098":"The device cannot detect AMS B. Please reconnect the AMS cable or restart the printer.","0501_409D":"The firmware of AMS B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0501_40A3":"AMS(or AMS lite) B communication is abnormal. Please reconnect the module cable or restart the printer.","0502_4001":"Current filament will be used in this print job. Settings cannot be changed.","0502_4002":"Please go to “Settings > Calibration” to run the Motion Accuracy Enhancement Calibration before turning on Motion Accuracy Enhancement mode.","0502_4003":"The printer is currently printing and the motion accuracy enhancement feature cannot be turned on or off.","0502_4004":"Some features are not supported by the current device. Please check the Studio feature settings or update the firmware to the latest version.","0502_4005":"The AMS has not been calibrated yet, so printing cannot be initiated.","0502_4006":"Unknown module detected; please try updating the firmware to the latest version.","0502_400D":"Failed to start a new task: filament loading/unloading not completed.","0502_400E":"Failed to start a new task: The nozzle cold pull was not completed.","0502_4013":"This device is not compatible with the 40W laser module. Please replace it with a 10W laser module or remove it.","0502_4098":"The device cannot detect AMS C. Please reconnect the AMS cable or restart the printer.","0502_409D":"The firmware of AMS C does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0502_40A3":"AMS(or AMS lite) C communication is abnormal. Please reconnect the module cable or restart the printer.","0502_C00F":"The device is busy and cannot perform nozzle identification.","0502_C010":"Due to printer power limitations, printing, calibration, controls and other actions cannot be performed during AMS drying. Please stop the drying process before proceeding with any other operation.","0502_C011":"Currently in 2D production mode. Please continue the operation on the printer","0502_C012":"The task cannot be paused.","0502_C014":"The AMS Remaining Filament Estimation is enabled by default and cannot be disabled.","0502_C024":"The flow dynamic calibration records have exceeded the storage limit. Please delete some historical records in the slicer software before adding new calibration data.","0503_4098":"The device cannot detect AMS D. Please reconnect the AMS cable or restart the printer.","0503_409D":"The firmware of AMS D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0503_40A3":"AMS(or AMS lite) D communication is abnormal. Please reconnect the module cable or restart the printer.","0580_4096":"The device cannot detect AMS-HT A. Please reconnect the AMS-HT cable or restart the printer.","0580_409C":"The firmware of AMS-HT A does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0580_40A2":"AMS-HT A communication is abnormal. Please reconnect the module cable or restart the printer.","0581_4096":"The device cannot detect AMS-HT B. Please reconnect the AMS-HT cable or restart the printer.","0581_409C":"The firmware of AMS-HT B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0581_40A2":"AMS-HT B communication is abnormal. Please reconnect the module cable or restart the printer.","0582_4096":"The device cannot detect AMS-HT C. Please reconnect the AMS-HT cable or restart the printer.","0582_409C":"The firmware of AMS-HT C does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0582_40A2":"AMS-HT C communication is abnormal. Please reconnect the module cable or restart the printer.","0583_4096":"The device cannot detect AMS-HT D. Please reconnect the AMS-HT cable or restart the printer.","0583_409C":"The firmware of AMS-HT D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0583_40A2":"AMS-HT D communication is abnormal. Please reconnect the module cable or restart the printer.","0584_4096":"The device cannot detect AMS-HT F. Please reconnect the AMS-HT cable or restart the printer.","0584_409C":"The firmware of AMS-HT E does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0584_40A2":"AMS-HT E communication is abnormal. Please reconnect the module cable or restart the printer.","0585_4096":"The device cannot detect AMS-HT E. Please reconnect the AMS-HT cable or restart the printer.","0585_409C":"The firmware of AMS-HT F does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0585_40A2":"AMS-HT F communication is abnormal. Please reconnect the module cable or restart the printer.","0586_4096":"The device cannot detect AMS-HT G. Please reconnect the AMS-HT cable or restart the printer.","0586_409C":"The firmware of AMS-HT G does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0586_40A2":"AMS-HT G communication is abnormal. Please reconnect the module cable or restart the printer.","0587_4096":"The device cannot detect AMS-HT H. Please reconnect the AMS-HT cable or restart the printer.","0587_409C":"The firmware of AMS-HT H does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0587_40A2":"AMS-HT H communication is abnormal. Please reconnect the module cable or restart the printer.","05FE_8053":"The left nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FE_8069":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FE_806A":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FE_8080":"The left hotend is not installed.","05FE_8081":"The left hotend is not installed.","05FF_8053":"The right nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FF_8069":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FF_806A":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FF_8080":"The right hotend is not installed.","05FF_8081":"The right hotend is not installed.","0700_4001":"The AMS has been disabled for a print, but it still has filament loaded. Please unload the AMS filament and switch to the spool holder filament for printing.","0700_4025":"Failed to read the filament information.","0700_8001":"Failed to cut the filament. Please check the cutter.","0700_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0700_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0700_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0700_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0700_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0700_8007":"Extruding filament failed. The extruder might be clogged.","0700_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS A to the extruder is properly connected.","0700_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0700_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0700_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0700_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0700_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0700_8017":"AMS A is drying. Please stop drying process before loading/unloading material.","0700_8021":"AMS setup failed; please refer to the assistant.","0700_8023":"AMS A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0700_C069":"An error occurred during AMS A drying. Please go to Assistant for more details.","0700_C06A":"AMS A is reading RFID. Unable to start drying. Please try again later.","0700_C06B":"AMS A is changing filament. Unable to start drying. Please try again later.","0700_C06C":"AMS A is in Feed Assist Mode. Unable to start drying. Please try again later.","0700_C06D":"AMS A is assisting in filament insertion. Unable to start drying. Please try again later.","0700_C06E":"AMS A motor is performing self-test. Unable to start drying. Please try again later.","0701_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0701_4025":"Failed to read the filament information.","0701_8001":"Failed to cut the filament. Please check the cutter.","0701_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0701_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0701_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0701_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0701_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0701_8007":"Extruding filament failed. The extruder might be clogged.","0701_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS B to the extruder is properly connected.","0701_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0701_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0701_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0701_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0701_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0701_8017":"AMS B is drying. Please stop drying process before loading/unloading material.","0701_8021":"AMS setup failed; please refer to the assistant.","0701_8023":"AMS B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0701_C069":"An error occurred during AMS B drying. Please go to Assistant for more details.","0701_C06A":"AMS B is reading RFID. Unable to start drying. Please try again later.","0701_C06B":"AMS B is changing filament. Unable to start drying. Please try again later.","0701_C06C":"AMS B is in Feed Assist Mode. Unable to start drying. Please try again later.","0701_C06D":"AMS B is assisting in filament insertion. Unable to start drying. Please try again later.","0701_C06E":"AMS B motor is performing self-test. Unable to start drying. Please try again later.","0702_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0702_4025":"Failed to read the filament information.","0702_8001":"Failed to cut the filament. Please check the cutter.","0702_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0702_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0702_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0702_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0702_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0702_8007":"Extruding filament failed. The extruder might be clogged.","0702_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS C to the extruder is properly connected.","0702_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0702_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0702_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0702_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0702_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0702_8017":"AMS C is drying. Please stop drying process before loading/unloading material.","0702_8021":"AMS setup failed; please refer to the assistant.","0702_8023":"AMS C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0702_C069":"An error occurred during AMS C drying. Please go to Assistant for more details.","0702_C06A":"AMS C is reading RFID. Unable to start drying. Please try again later.","0702_C06B":"AMS C is changing filament. Unable to start drying. Please try again later.","0702_C06C":"AMS C is in Feed Assist Mode. Unable to start drying. Please try again later.","0702_C06D":"AMS C is assisting in filament insertion. Unable to start drying. Please try again later.","0702_C06E":"AMS C motor is performing self-test. Unable to start drying. Please try again later.","0703_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0703_4025":"Failed to read the filament information.","0703_8001":"Failed to cut the filament. Please check the cutter.","0703_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0703_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0703_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0703_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0703_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0703_8007":"Extruding filament failed. The extruder might be clogged.","0703_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS D to the extruder is properly connected.","0703_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0703_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0703_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0703_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0703_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0703_8017":"AMS D is drying. Please stop drying process before loading/unloading material.","0703_8021":"AMS setup failed; please refer to the assistant.","0703_8023":"AMS D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0703_C069":"An error occurred during AMS D drying. Please go to Assistant for more details.","0703_C06A":"AMS D is reading RFID. Unable to start drying. Please try again later.","0703_C06B":"AMS D is changing filament. Unable to start drying. Please try again later.","0703_C06C":"AMS D is in Feed Assist Mode. Unable to start drying. Please try again later.","0703_C06D":"AMS D is assisting in filament insertion. Unable to start drying. Please try again later.","0703_C06E":"AMS D motor is performing self-test. Unable to start drying. Please try again later.","0704_4025":"Failed to read the filament information.","0704_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0704_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0704_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0704_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0704_8007":"Extruding filament failed. The extruder might be clogged.","0704_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS E to the extruder is properly connected.","0704_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0704_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0704_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0704_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0704_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0704_8021":"AMS setup failed; please refer to the assistant.","0704_8023":"AMS E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0705_4025":"Failed to read the filament information.","0705_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0705_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0705_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0705_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0705_8007":"Extruding filament failed. The extruder might be clogged.","0705_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS F to the extruder is properly connected.","0705_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0705_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0705_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0705_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0705_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0705_8021":"AMS setup failed; please refer to the assistant.","0705_8023":"AMS F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0706_4025":"Failed to read the filament information.","0706_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0706_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0706_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0706_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0706_8007":"Extruding filament failed. The extruder might be clogged.","0706_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS G to the extruder is properly connected.","0706_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0706_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0706_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0706_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0706_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0706_8021":"AMS setup failed; please refer to the assistant.","0706_8023":"AMS G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0707_4025":"Failed to read the filament information.","0707_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0707_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0707_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0707_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0707_8007":"Extruding filament failed. The extruder might be clogged.","0707_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS H to the extruder is properly connected.","0707_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0707_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0707_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0707_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0707_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0707_8021":"AMS setup failed; please refer to the assistant.","0707_8023":"AMS H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","07FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","07FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","07FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","07FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","07FE_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FE_8010":"Check if the left external filament spool or filament is stuck.","07FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","07FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","07FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","07FE_8020":"Extruder change failed; please refer to the assistant.","07FE_8021":"AMS setup failed; please refer to the assistant.","07FE_8024":"Extruder position calibration failed; please refer to the assistant.","07FE_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FE_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FE_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FE_C011":"Please manually and slowly pull out the filament from the extruder. Then click “Continue”.","07FE_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","07FF_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","07FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","07FF_8002":"The cutter is stuck. Please make sure the cutter handle is out.","07FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","07FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","07FF_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FF_8010":"Check if the external filament spool or filament is stuck.","07FF_8011":"External filament has run out; please load a new filament.","07FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","07FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","07FF_8020":"Extruder change failed; please refer to the assistant.","07FF_8021":"AMS setup failed; please refer to the assistant.","07FF_8024":"Extruder position calibration failed; please refer to the assistant.","07FF_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FF_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FF_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FF_C011":"Hold the driven wheel bracket, slowly pull the filament from the extruder, then press 'Continue'.","07FF_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","0C00_4020":"The setup of BirdsEye Camera failed. Please clear all objects and remove the mat. Make sure the marker is not obstructed. Meanwhile, clean both the BirdsEye Camera and Toolhead Camera, and remove a...","0C00_4021":"The setup of BirdsEye Camera failed; please reboot the printer.","0C00_4022":"The setup of BirdsEye Camera failed. Please check if the laser module is working properly.","0C00_4024":"The Birdseye Camera is installed offset. Please refer to the assistant to reinstall it.","0C00_4025":"The Birdseye Camera is dirty. Please clean it and restart the process.","0C00_4026":"The Live View Camera initialization failed; please reboot the printer.","0C00_4027":"The Live View Camera calibration failed. Please refer to the assistant for details and recalibrate the camera after processing.","0C00_4029":"Material not detected. Please confirm placement and continue.","0C00_402A":"The visual marker was not detected. Please re-paste the paper in the correct position.","0C00_402C":"Device data link error. Please reboot the printer","0C00_402D":"The toolhead camera is not working properly; please reboot the device.","0C00_403D":"The vision encoder plate was not detected. Please confirm it is correctly positioned on the heatbed.","0C00_403E":"The high-precision nozzle offset calibration has failed, possibly due to a damaged pattern or the similarity of the colors of the two selected filaments. Please clear the printed pattern and replac...","0C00_4041":"Toolhead camera calibration failed. Please ensure the Calibration Marker on the heatbed or Height Calibration Marker on the homing area is clean and undamaged, then re-run the calibration process.","0C00_8001":"First layer defects were detected. If the defects are acceptable, select 'Resume' to resume the print job.","0C00_8005":"Purged filament has piled up in the waste chute, which may cause a tool head collision.","0C00_8009":"Build plate localization marker was not found.","0C00_800B":"The heatbed marker was not detected. Please clear all objects and remove the mat. Make sure the marker is not obstructed.","0C00_8015":"Objects detected on the platform; please clean them up in a timely manner.","0C00_8016":"The foreign object detection function is not working. You can continue the task or check assistant for solutions.","0C00_8017":"Foreign objects detected on the platform; please clean them up on time.","0C00_8018":"The foreign object detection function is not working. You can continue the task or view the assistant for troubleshooting.","0C00_8033":"Quick-release Lever is not locked. Please push it down to secure.","0C00_8034":"Liveview Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0C00_803F":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_8040":"AI detected air-printing defect. Please check the hotend extrusion status. Refer to assistant for solutions.","0C00_8042":"The AI print monitor has detected a spaghetti defect. Please check the print and take the necessary action.","0C00_8043":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_C003":"Possible defects were detected in the first layer.","0C00_C004":"Possible spaghetti failure was detected.","0C00_C006":"Purged filament may have piled up in the waste chute.","1000_C001":"High bed temperature may lead to filament clogging in the nozzle. You may open the chamber door.","1000_C002":"Printing CF material with stainless steel may cause nozzle damage.","1000_C003":"Enabling Timelapse in traditional mode may cause defects; please activate this feature as needed.","1001_4001":"Timelapse is not supported as Spiral Vase mode is enabled in slicing presets.","1001_4002":"Timelapse is not supported as the Print sequence is set to 'By object'.","1001_8003":"The time-lapse mode is set to Traditional in the slicing file. This may cause surface defects. Would you like to enable it?","1001_8004":"Prime Tower is not enabled and time-lapse mode is set to Smooth in slicing file. This may cause surface defects. Would you like to enable it?","1200_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1200_8001":"Cutting the filament failed. Please check to see if the cutter is stuck. Refer to the Assistant for solutions.","1200_8002":"The cutter is stuck. Please pull out the cutter handle.","1200_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1200_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1200_8005":"The filament is not inserted. Please insert the filament.","1200_8006":"Unable to feed filament into the extruder. This could be due to tangled filament or a stuck spool. If not, please check if the AMS PTFE tube is connected.","1200_8007":"Failed to extrude the filament. This might be caused by clogged extruder or stuck filament. Refer to the Assistant for solutions.","1200_8010":"Filament or spool may be stuck.","1200_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1200_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1200_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1200_8014":"The filament location in the toolhead was not found. Refer to the Assistant for solutions.","1200_8015":"Failed to pull out the filament from the toolhead. Please check if the filament is stuck, or if it is broken inside the extruder or PTFE tube.","1200_8016":"The extruder is not extruding normally. Refer to the Assistant for troubleshooting. There may be defects in this layer, but you may resume if the defects are acceptable.","1201_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1201_8001":"Failed to cut the filament. Please check the cutter.","1201_8002":"The cutter is stuck. Please pull out the cutter handle.","1201_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1201_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1201_8005":"Failed to feed the filament. Please load the filament and then select 'Retry'.","1201_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1201_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1201_8010":"Please check if the spool or filament is stuck.","1201_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1201_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1201_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1201_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1201_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or the filament is broken inside the extruder.","1201_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1202_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1202_8001":"Failed to cut the filament. Please check the cutter.","1202_8002":"The cutter is stuck. Please pull out the cutter handle.","1202_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1202_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1202_8005":"The filament is not inserted. Please insert the filament.","1202_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1202_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1202_8010":"Please check if the spool or filament is stuck.","1202_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1202_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1202_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1202_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1202_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1202_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1203_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1203_8001":"Failed to cut the filament. Please check the cutter.","1203_8002":"The cutter is stuck. Please pull out the cutter handle.","1203_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1203_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1203_8005":"The filament is not inserted. Please insert the filament.","1203_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1203_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1203_8010":"Please check if the spool or filament is stuck.","1203_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1203_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1203_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1203_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1203_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1203_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","12FF_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","12FF_8001":"Failed to cut the filament. Please check the cutter.","12FF_8002":"The cutter is stuck. Please pull out the cutter handle.","12FF_8003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube if you are about to us...","12FF_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","12FF_8005":"The filament is not inserted. Please insert the filament.","12FF_8006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","12FF_8007":"Check nozzle. Select 'Done' if filament was extruded, otherwise push filament forward slightly and select 'Retry.'","12FF_8010":"Please check if the filament or the spool is stuck.","12FF_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","12FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","12FF_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","12FF_C003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE Tube. (Connect a PTFE tube if you are about to us...","12FF_C006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","1800_4025":"Failed to read the filament information.","1800_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1800_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1800_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1800_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1800_8007":"Extruding filament failed. The extruder might be clogged.","1800_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT A to the extruder is properly connected.","1800_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1800_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1800_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1800_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1800_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1800_8017":"AMS-HT A is drying. Please stop drying process before loading/unloading material.","1800_8021":"AMS setup failed; please refer to the assistant.","1800_8023":"AMS-HT A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1800_C069":"An error occurred during AMS-HT A drying. Please go to Assistant for more details.","1800_C06A":"AMS-HT A is reading RFID. Unable to start drying. Please try again later.","1800_C06B":"AMS-HT A is changing filament. Unable to start drying. Please try again later.","1800_C06C":"AMS-HT A is in Feed Assist Mode. Unable to start drying. Please try again later.","1800_C06D":"AMS-HT A is assisting in filament insertion. Unable to start drying. Please try again later.","1800_C06E":"AMS-HT A motor is performing self-test. Unable to start drying. Please try again later.","1801_4025":"Failed to read the filament information.","1801_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1801_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1801_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1801_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1801_8007":"Extruding filament failed. The extruder might be clogged.","1801_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT B to the extruder is properly connected.","1801_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1801_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1801_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1801_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1801_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1801_8017":"AMS-HT B is drying. Please stop drying process before loading/unloading material.","1801_8021":"AMS setup failed; please refer to the assistant.","1801_8023":"AMS-HT B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1801_C069":"An error occurred during AMS-HT B drying. Please go to Assistant for more details.","1801_C06A":"AMS-HT B is reading RFID. Unable to start drying. Please try again later.","1801_C06B":"AMS-HT B is changing filament. Unable to start drying. Please try again later.","1801_C06C":"AMS-HT B is in Feed Assist Mode. Unable to start drying. Please try again later.","1801_C06D":"AMS-HT B is assisting in filament insertion. Unable to start drying. Please try again later.","1801_C06E":"AMS-HT B motor is performing self-test. Unable to start drying. Please try again later.","1802_4025":"Failed to read the filament information.","1802_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1802_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1802_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1802_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1802_8007":"Extruding filament failed. The extruder might be clogged.","1802_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT C to the extruder is properly connected.","1802_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1802_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1802_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1802_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1802_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1802_8017":"AMS-HT C is drying. Please stop drying process before loading/unloading material.","1802_8021":"AMS setup failed; please refer to the assistant.","1802_8023":"AMS-HT C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1802_C069":"An error occurred during AMS-HT C drying. Please go to Assistant for more details.","1802_C06A":"AMS-HT C is reading RFID. Unable to start drying. Please try again later.","1802_C06B":"AMS-HT C is changing filament. Unable to start drying. Please try again later.","1802_C06C":"AMS-HT C is in Feed Assist Mode. Unable to start drying. Please try again later.","1802_C06D":"AMS-HT C is assisting in filament insertion. Unable to start drying. Please try again later.","1802_C06E":"AMS-HT C motor is performing self-test. Unable to start drying. Please try again later.","1803_4025":"Failed to read the filament information.","1803_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1803_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1803_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1803_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1803_8007":"Extruding filament failed. The extruder might be clogged.","1803_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT D to the extruder is properly connected.","1803_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1803_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1803_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1803_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1803_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1803_8017":"AMS-HT D is drying. Please stop drying process before loading/unloading material.","1803_8021":"AMS setup failed; please refer to the assistant.","1803_8023":"AMS-HT D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1803_C069":"An error occurred during AMS-HT D drying. Please go to Assistant for more details.","1803_C06A":"AMS-HT D is reading RFID. Unable to start drying. Please try again later.","1803_C06B":"AMS-HT D is changing filament. Unable to start drying. Please try again later.","1803_C06C":"AMS-HT D is in Feed Assist Mode. Unable to start drying. Please try again later.","1803_C06D":"AMS-HT D is assisting in filament insertion. Unable to start drying. Please try again later.","1803_C06E":"AMS-HT D motor is performing self-test. Unable to start drying. Please try again later.","1804_4025":"Failed to read the filament information.","1804_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1804_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1804_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1804_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1804_8007":"Extruding filament failed. The extruder might be clogged.","1804_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT E to the extruder is properly connected.","1804_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1804_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1804_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1804_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1804_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1804_8021":"AMS setup failed; please refer to the assistant.","1804_8023":"AMS-HT E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1804_C069":"An error occurred during AMS-HT E drying. Please go to Assistant for more details.","1804_C06A":"AMS-HT E is reading RFID. Unable to start drying. Please try again later.","1804_C06B":"AMS-HT E is changing filament. Unable to start drying. Please try again later.","1804_C06C":"AMS-HT E is in Feed Assist Mode. Unable to start drying. Please try again later.","1804_C06D":"AMS-HT E is assisting in filament insertion. Unable to start drying. Please try again later.","1804_C06E":"AMS-HT E motor is performing self-test. Unable to start drying. Please try again later.","1805_4025":"Failed to read the filament information.","1805_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1805_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1805_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1805_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1805_8007":"Extruding filament failed. The extruder might be clogged.","1805_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT F to the extruder is properly connected.","1805_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1805_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1805_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1805_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1805_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1805_8021":"AMS setup failed; please refer to the assistant.","1805_8023":"AMS-HT F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1805_C069":"An error occurred during AMS-HT F drying. Please go to Assistant for more details.","1805_C06A":"AMS-HT F is reading RFID. Unable to start drying. Please try again later.","1805_C06B":"AMS-HT F is changing filament. Unable to start drying. Please try again later.","1805_C06C":"AMS-HT F is in Feed Assist Mode. Unable to start drying. Please try again later.","1805_C06D":"AMS-HT F is assisting in filament insertion. Unable to start drying. Please try again later.","1805_C06E":"AMS-HT F motor is performing self-test. Unable to start drying. Please try again later.","1806_4025":"Failed to read the filament information.","1806_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1806_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1806_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1806_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1806_8007":"Extruding filament failed. The extruder might be clogged.","1806_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT G to the extruder is properly connected.","1806_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1806_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1806_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1806_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1806_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1806_8021":"AMS setup failed; please refer to the assistant.","1806_8023":"AMS-HT G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1806_C069":"An error occurred during AMS-HT G drying. Please go to Assistant for more details.","1806_C06A":"AMS-HT G is reading RFID. Unable to start drying. Please try again later.","1806_C06B":"AMS-HT G is changing filament. Unable to start drying. Please try again later.","1806_C06C":"AMS-HT G is in Feed Assist Mode. Unable to start drying. Please try again later.","1806_C06D":"AMS-HT G is assisting in filament insertion. Unable to start drying. Please try again later.","1806_C06E":"AMS-HT G motor is performing self-test. Unable to start drying. Please try again later.","1807_4025":"Failed to read the filament information.","1807_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1807_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1807_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1807_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1807_8007":"Extruding filament failed. The extruder might be clogged.","1807_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT H to the extruder is properly connected.","1807_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1807_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1807_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1807_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1807_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1807_8021":"AMS setup failed; please refer to the assistant.","1807_8023":"AMS-HT H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1807_C069":"An error occurred during AMS-HT H drying. Please go to Assistant for more details.","1807_C06A":"AMS-HT H is reading RFID. Unable to start drying. Please try again later.","1807_C06B":"AMS-HT H is changing filament. Unable to start drying. Please try again later.","1807_C06C":"AMS-HT H is in Feed Assist Mode. Unable to start drying. Please try again later.","1807_C06D":"AMS-HT H is assisting in filament insertion. Unable to start drying. Please try again later.","1807_C06E":"AMS-HT H motor is performing self-test. Unable to start drying. Please try again later.","18FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","18FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","18FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","18FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","18FE_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","18FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","18FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","18FE_8020":"Extruder change failed; please refer to the assistant.","18FE_8021":"AMS setup failed; please refer to the assistant.","18FE_8024":"Extruder position calibration failed; please refer to the assistant.","18FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","18FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","18FF_8002":"The cutter of the right extruder is stuck. Please pull out the cutter handle.","18FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","18FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","18FF_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FF_8011":"The external filament connected to the right extruder has run out; please load a new filament.","18FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","18FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","18FF_8020":"Extruder change failed; please refer to the assistant.","18FF_8021":"AMS setup failed; please refer to the assistant.","18FF_8024":"Extruder position calibration failed; please refer to the assistant.","18FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'."};function ide(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:ti};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:ti};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:lo};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:_0}}}function Ok(t,e){const n=t>>16&65535||(t>>8&255)<<8|t&255,r=e&65535;return`${n.toString(16).padStart(4,"0").toUpperCase()}_${r.toString(16).padStart(4,"0").toUpperCase()}`}function ade(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=Ok(e.attr,n);return jk[r]!==void 0})}function sde(){return"https://wiki.bambulab.com/en/hms/home"}function ode({printerName:t,errors:e,onClose:n}){console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const r=e.filter(i=>{const a=parseInt(i.code.replace("0x",""),16)||0,s=Ok(i.attr,a);return jk[s]!==void 0});return E.useEffect(()=>{const i=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ti,{className:"w-5 h-5 text-orange-400"}),l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),l.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(lo,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{children:"No errors"})]}):l.jsx("div",{className:"space-y-3",children:r.map((i,a)=>{const{label:s,color:o,bgColor:c,Icon:u}=ide(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=Ok(i.attr,d),g=jk[f],m=sde(),x=f.replace("_","-");return l.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(u,{className:`w-5 h-5 ${o} flex-shrink-0 mt-0.5`}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsxs("span",{className:`font-mono text-sm ${o}`,children:["[",x,"]"]}),l.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${o}`,children:s})]}),l.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:g}),l.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[l.jsx(As,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${a}`)})})}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function lde(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 cde({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"}),lde(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 EG(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=EG(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Mn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=EG(t))&&(r&&(r+=" "),r+=e);return r}var ude=["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 KR(t){if(typeof t!="string")return!1;var e=ude;return e.includes(t)}var dde=["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"],hde=new Set(dde);function AG(t){return typeof t!="string"?!1:hde.has(t)}function TG(t){return typeof t=="string"&&t.startsWith("data-")}function Ca(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(AG(n)||TG(n))&&(e[n]=t[n]);return e}function Gh(t){if(t==null)return null;if(E.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ca(e)}return typeof t=="object"&&!Array.isArray(t)?Ca(t):null}function na(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(AG(n)||TG(n)||KR(n))&&(e[n]=t[n]);return e}function fde(t){return t==null?null:E.isValidElement(t)?na(t.props):typeof t=="object"&&!Array.isArray(t)?na(t):null}var pde=["children","width","height","viewBox","className","style","title","desc"];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 mde(t,e){if(t==null)return{};var n,r,i=gde(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function 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 XR=E.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:s,style:o,title:c,desc:u}=t,d=mde(t,pde),f=a||{width:r,height:i,x:0,y:0},g=Mn("recharts-surface",s);return E.createElement("svg",Lk({},na(d),{className:g,width:r,height:i,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),E.createElement("title",null,c),E.createElement("desc",null,u),n)}),xde=["children","className"];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 bde(t,e){if(t==null)return{};var n,r,i=yde(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function yde(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=E.forwardRef((t,e)=>{var{children:n,className:r}=t,i=bde(t,xde),a=Mn("recharts-layer",r);return E.createElement("g",Ik({className:a},na(i),{ref:e}),n)}),CG=E.createContext(null),vde=()=>E.useContext(CG);function ir(t){return function(){return t}}const NG=Math.cos,k1=Math.sin,Ho=Math.sqrt,P1=Math.PI,VS=2*P1,Fk=Math.PI,Uk=2*Fk,nh=1e-6,_de=Uk-nh;function kG(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function wde(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return kG;const n=10**e;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class Sde{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?kG:wde(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,a,s){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+s}`}arcTo(e,n,r,i,a){if(e=+e,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let s=this._x1,o=this._y1,c=r-e,u=i-n,d=s-e,f=o-n,g=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>nh)if(!(Math.abs(f*c-u*d)>nh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-s,x=i-o,v=c*c+u*u,y=m*m+x*x,b=Math.sqrt(v),M=Math.sqrt(g),S=a*Math.tan((Fk-Math.acos((v+g-y)/(2*b*M)))/2),A=S/M,T=S/b;Math.abs(A-1)>nh&&this._append`L${e+A*d},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*m>d*x)},${this._x1=e+T*c},${this._y1=n+T*u}`}}arc(e,n,r,i,a,s){if(e=+e,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),c=r*Math.sin(i),u=e+o,d=n+c,f=1^s,g=s?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>nh||Math.abs(this._y1-d)>nh)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%Uk+Uk),g>_de?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>=Fk)},${f},${this._x1=e+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function YR(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 Sde(e)}function ZR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function PG(t){this._context=t}PG.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 PG(t)}function RG(t){return t[0]}function DG(t){return t[1]}function jG(t,e){var n=ir(!0),r=null,i=GS,a=null,s=YR(o);t=typeof t=="function"?t:t===void 0?RG:ir(t),e=typeof e=="function"?e:e===void 0?DG:ir(e);function o(c){var u,d=(c=ZR(c)).length,f,g=!1,m;for(r==null&&(a=i(m=s())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===g&&((g=!g)?a.lineStart():a.lineEnd()),g&&a.point(+t(f,u,c),+e(f,u,c));if(m)return a=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&&(a=i(r)),o):i},o.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),o):r},o}function xv(t,e,n){var r=null,i=ir(!0),a=null,s=GS,o=null,c=YR(u);t=typeof t=="function"?t:t===void 0?RG:ir(+t),e=typeof e=="function"?e:ir(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?DG:ir(+n);function u(f){var g,m,x,v=(f=ZR(f)).length,y,b=!1,M,S=new Array(v),A=new Array(v);for(a==null&&(o=s(M=c())),g=0;g<=v;++g){if(!(g<v&&i(y=f[g],g,f))===b)if(b=!b)m=g,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),x=g-1;x>=m;--x)o.point(S[x],A[x]);o.lineEnd(),o.areaEnd()}b&&(S[g]=+t(y,g,f),A[g]=+e(y,g,f),o.point(r?+r(y,g,f):S[g],n?+n(y,g,f):A[g]))}if(M)return o=null,M+""||null}function d(){return jG().defined(i).curve(s).context(a)}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?(s=f,a!=null&&(o=s(a)),u):s},u.context=function(f){return arguments.length?(f==null?a=o=null:o=s(a=f),u):a},u}class OG{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 Mde(t){return new OG(t,!0)}function Ede(t){return new OG(t,!1)}const QR={draw(t,e){const n=Ho(e/P1);t.moveTo(n,0),t.arc(0,0,n,0,VS)}},Ade={draw(t,e){const n=Ho(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},LG=Ho(1/3),Tde=LG*2,Cde={draw(t,e){const n=Ho(e/Tde),r=n*LG;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Nde={draw(t,e){const n=Ho(e),r=-n/2;t.rect(r,r,n,n)}},kde=.8908130915292852,IG=k1(P1/10)/k1(7*P1/10),Pde=k1(VS/10)*IG,Rde=-NG(VS/10)*IG,Dde={draw(t,e){const n=Ho(e*kde),r=Pde*n,i=Rde*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const s=VS*a/5,o=NG(s),c=k1(s);t.lineTo(c*n,-o*n),t.lineTo(o*r-c*i,c*r+o*i)}t.closePath()}},jA=Ho(3),jde={draw(t,e){const n=-Ho(e/(jA*3));t.moveTo(0,n*2),t.lineTo(-jA*n,-n),t.lineTo(jA*n,-n),t.closePath()}},Fs=-.5,Us=Ho(3)/2,zk=1/Ho(12),Ode=(zk/2+1)*3,Lde={draw(t,e){const n=Ho(e/Ode),r=n/2,i=n*zk,a=r,s=n*zk+n,o=-a,c=s;t.moveTo(r,i),t.lineTo(a,s),t.lineTo(o,c),t.lineTo(Fs*r-Us*i,Us*r+Fs*i),t.lineTo(Fs*a-Us*s,Us*a+Fs*s),t.lineTo(Fs*o-Us*c,Us*o+Fs*c),t.lineTo(Fs*r+Us*i,Fs*i-Us*r),t.lineTo(Fs*a+Us*s,Fs*s-Us*a),t.lineTo(Fs*o+Us*c,Fs*c-Us*o),t.closePath()}};function Ide(t,e){let n=null,r=YR(i);t=typeof t=="function"?t:ir(t||QR),e=typeof e=="function"?e:ir(e===void 0?64:+e);function i(){let a;if(n||(n=a=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(t=typeof a=="function"?a:ir(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:ir(+a),i):e},i.context=function(a){return arguments.length?(n=a??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 FG(t){this._context=t}FG.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 Fde(t){return new FG(t)}function UG(t){this._context=t}UG.prototype={areaStart:R1,areaEnd:R1,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:D1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Ude(t){return new UG(t)}function zG(t){this._context=t}zG.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 zde(t){return new zG(t)}function BG(t){this._context=t}BG.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 Bde(t){return new BG(t)}function nU(t){return t<0?-1:1}function rU(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),s=(n-t._y1)/(i||r<0&&-0),o=(a*i+s*r)/(r+i);return(nU(a)+nU(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(o))||0}function iU(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function OA(t,e,n){var r=t._x0,i=t._y0,a=t._x1,s=t._y1,o=(a-r)/3;t._context.bezierCurveTo(r+o,i+o*e,a-o,s-o*n,a,s)}function j1(t){this._context=t}j1.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:OA(this,this._t0,iU(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,OA(this,iU(this,n=rU(this,t,e)),n);break;default:OA(this,this._t0,n=rU(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function HG(t){this._context=new $G(t)}(HG.prototype=Object.create(j1.prototype)).point=function(t,e){j1.prototype.point.call(this,e,t)};function $G(t){this._context=t}$G.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,a){this._context.bezierCurveTo(e,t,r,n,a,i)}};function Hde(t){return new j1(t)}function $de(t){return new HG(t)}function VG(t){this._context=t}VG.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=aU(t),i=aU(e),a=0,s=1;s<n;++a,++s)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[s],e[s]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function aU(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),s=new Array(n);for(i[0]=0,a[0]=2,s[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,s[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,s[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,s[e]-=r*s[e-1];for(i[n-1]=s[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(s[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-i[e+1];return[i,a]}function Vde(t){return new VG(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 Gde(t){return new WS(t,.5)}function Wde(t){return new WS(t,0)}function qde(t){return new WS(t,1)}function ym(t,e){if((s=t.length)>1)for(var n=1,r,i,a=t[e[0]],s,o=a.length;n<s;++n)for(i=a,a=t[e[n]],r=0;r<o;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function Bk(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Kde(t,e){return t[e]}function Xde(t){const e=[];return e.key=t,e}function Yde(){var t=ir([]),e=Bk,n=ym,r=Kde;function i(a){var s=Array.from(t.apply(this,arguments),Xde),o,c=s.length,u=-1,d;for(const f of a)for(o=0,++u;o<c;++o)(s[o][u]=[0,+r(f,s[o].key,u,a)]).data=f;for(o=0,d=ZR(e(s));o<c;++o)s[d[o]].index=o;return n(s,d),s}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:ir(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:ir(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?Bk:typeof a=="function"?a:ir(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??ym,i):n},i}function Zde(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,s;i<a;++i){for(s=n=0;n<r;++n)s+=t[n][i][1]||0;if(s)for(n=0;n<r;++n)t[n][i][1]/=s}ym(t,e)}}function Qde(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var s=0,o=0;s<i;++s)o+=t[s][n][1]||0;r[n][1]+=r[n][0]=-o/2}ym(t,e)}}function Jde(t,e){if(!(!((s=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,s;r<a;++r){for(var o=0,c=0,u=0;o<s;++o){for(var d=t[e[o]],f=d[r][1]||0,g=d[r-1][1]||0,m=(f-g)/2,x=0;x<o;++x){var v=t[e[x]],y=v[r][1]||0,b=v[r-1][1]||0;m+=y-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,ym(t,e)}}var LA={},IA={},sU;function ehe(){return sU||(sU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(IA)),IA}var FA={},oU;function GG(){return oU||(oU=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})(FA)),FA}var UA={},lU;function JR(){return lU||(lU=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})(UA)),UA}var zA={},BA={},cU;function the(){return cU||(cU=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 uU;function eD(){return uU||(uU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=the(),n=JR();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],s=i.length;if(s===0)return a;let o=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),o++);o<s;){const f=i[o];u?f==="\\"&&o+1<s?(o++,c+=i[o]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,o++}return c&&a.push(c),a}t.toPath=r})(zA)),zA}var dU;function tD(){return dU||(dU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ehe(),n=GG(),r=JR(),i=eD();function a(o,c,u){if(o==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=o[c];return d===void 0?n.isDeepKey(c)?a(o,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=o[c];return d===void 0?u:d}default:{if(Array.isArray(c))return s(o,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=o[c];return d===void 0?u:d}}}function s(o,c,u){if(c.length===0)return u;let d=o;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=a})(LA)),LA}var HA,hU;function nhe(){return hU||(hU=1,HA=tD().get),HA}var rhe=nhe();const Wh=fo(rhe);var Li=t=>t===0?0:t>0?1:-1,Za=t=>typeof t=="number"&&t!=+t,Cc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Pt=t=>(typeof t=="number"||t instanceof Number)&&!Za(t),co=t=>Pt(t)||typeof t=="string",ihe=0,T0=t=>{var e=++ihe;return"".concat(t||"").concat(e)},pa=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Pt(e)&&typeof e!="string")return r;var a;if(Cc(e)){if(n==null)return r;var s=e.indexOf("%");a=n*parseFloat(e.slice(0,s))/100}else a=+e;return Za(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},WG=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 jn(t,e,n){return Pt(t)&&Pt(e)?t+n*(e-t):e}function qG(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Wh(r,e))===n)}var dr=t=>t===null||typeof t>"u",bb=t=>dr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function ahe(t){return t!=null}function yb(){}var she=["type","size","sizeType"];function Hk(){return Hk=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Hk.apply(null,arguments)}function fU(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 pU(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fU(Object(n),!0).forEach(function(r){ohe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ohe(t,e,n){return(e=lhe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lhe(t){var e=che(t,"string");return typeof e=="symbol"?e:e+""}function che(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 uhe(t,e){if(t==null)return{};var n,r,i=dhe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function dhe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var KG={symbolCircle:QR,symbolCross:Ade,symbolDiamond:Cde,symbolSquare:Nde,symbolStar:Dde,symbolTriangle:jde,symbolWye:Lde},hhe=Math.PI/180,fhe=t=>{var e="symbol".concat(bb(t));return KG[e]||QR},phe=(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*hhe;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}},mhe=(t,e)=>{KG["symbol".concat(bb(t))]=e},nD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=uhe(t,she),a=pU(pU({},i),{},{type:e,size:n,sizeType:r}),s="circle";typeof e=="string"&&(s=e);var o=()=>{var g=fhe(s),m=Ide().type(g).size(phe(n,r,s)),x=m();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=na(a);return Pt(u)&&Pt(d)&&Pt(n)?E.createElement("path",Hk({},f,{className:Mn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:o()})):null};nD.registerSymbol=mhe;var XG=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,rD=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(E.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{KR(i)&&(r[i]=(a=>n[i](n,a)))}),r},ghe=(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 a=t[i];KR(i)&&typeof a=="function"&&(r||(r={}),r[i]=ghe(a,e,n))}),r};function mU(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 xhe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mU(Object(n),!0).forEach(function(r){bhe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bhe(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=vhe(t,"string");return typeof e=="symbol"?e:e+""}function vhe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Sr(t,e){var n=xhe({},t),r=e,i=Object.keys(e),a=i.reduce((s,o)=>(s[o]===void 0&&r[o]!==void 0&&(s[o]=r[o]),s),n);return a}function O1(){return O1=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},O1.apply(null,arguments)}function gU(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 _he(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gU(Object(n),!0).forEach(function(r){whe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function whe(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=Mhe(t,"string");return typeof e=="symbol"?e:e+""}function Mhe(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 Vs=32,Ehe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Ahe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Vs/2,a=Vs/6,s=Vs/3,o=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return E.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:Vs,y2:i,className:"recharts-legend-icon"})}if(c==="line")return E.createElement("path",{strokeWidth:4,fill:"none",stroke:o,d:"M0,".concat(i,"h").concat(s,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*s,",").concat(i,`
- H`).concat(Vs,"M").concat(2*s,",").concat(i,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(s,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return E.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Vs/8,"h").concat(Vs,"v").concat(Vs*3/4,"h").concat(-Vs,"z"),className:"recharts-legend-icon"});if(E.isValidElement(e.legendIcon)){var d=_he({},e);return delete d.legendIcon,E.cloneElement(e.legendIcon,d)}return E.createElement(nD,{fill:o,cx:i,cy:i,size:Vs,sizeType:"diameter",type:c})}function The(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:s}=t,o={x:0,y:0,width:Vs,height:Vs},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=Mn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?a:d.color,v=g?g(d.value,d,f):d.value;return E.createElement("li",O1({className:m,style:c,key:"legend-item-".concat(f)},vb(t,d,f)),E.createElement(XR,{width:n,height:n,viewBox:o,style:u,"aria-label":"".concat(v," legend icon")},E.createElement(Ahe,{data:d,iconType:s,inactiveColor:a})),E.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},v))})}var Che=t=>{var e=Sr(t,Ehe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return E.createElement("ul",{className:"recharts-default-legend",style:a},E.createElement(The,O1({},e,{payload:n})))},$A={},VA={},xU;function Nhe(){return xU||(xU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const s=n[a],o=r(s);i.has(o)||i.set(o,s)}return Array.from(i.values())}t.uniqBy=e})(VA)),VA}var GA={},bU;function YG(){return bU||(bU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(GA)),GA}var WA={},qA={},KA={},yU;function khe(){return yU||(yU=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 vU;function iD(){return vU||(vU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=khe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(qA)),qA}var XA={},_U;function Phe(){return _U||(_U=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 wU;function Rhe(){return wU||(wU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iD(),n=Phe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(WA)),WA}var YA={},ZA={},SU;function Dhe(){return SU||(SU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(ZA)),ZA}var QA={},JA={},eT={},tT={},MU;function ZG(){return MU||(MU=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={},EU;function QG(){return EU||(EU=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={},AU;function JG(){return AU||(AU=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 TU;function jhe(){return TU||(TU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ZG(),n=QG(),r=JG();function i(d,f,g){return typeof g!="function"?i(d,f,()=>{}):a(d,f,function m(x,v,y,b,M,S){const A=g(x,v,y,b,M,S);return A!==void 0?!!A:a(x,v,m,S)},new Map)}function a(d,f,g,m){if(f===d)return!0;switch(typeof f){case"object":return s(d,f,g,m);case"function":return Object.keys(f).length>0?a(d,{...f},g,m):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function s(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 v=0;v<x.length;v++){const y=x[v];if(!n.isPrimitive(d)&&!(y in d)||f[y]===void 0&&d[y]!==void 0||f[y]===null&&d[y]!==null||!g(d[y],f[y],y,d,f,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,v]of f.entries()){const y=d.get(x);if(g(y,v,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 v=0;v<f.length;v++){const y=f[v];let b=!1;for(let M=0;M<d.length;M++){if(x.has(M))continue;const S=d[M];let A=!1;if(g(S,y,v,d,f,m)&&(A=!0),A){x.add(M),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 CU;function eW(){return CU||(CU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jhe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(JA)),JA}var iT={},aT={},sT={},NU;function Ohe(){return NU||(NU=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})(sT)),sT}var oT={},kU;function tW(){return kU||(kU=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={},PU;function nW(){return PU||(PU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",s="[object Symbol]",o="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",g="[object ArrayBuffer]",m="[object Object]",x="[object Error]",v="[object DataView]",y="[object Uint8Array]",b="[object Uint8ClampedArray]",M="[object Uint16Array]",S="[object Uint32Array]",A="[object BigUint64Array]",T="[object Int8Array]",k="[object Int16Array]",N="[object Int32Array]",I="[object BigInt64Array]",C="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=g,t.arrayTag=d,t.bigInt64ArrayTag=I,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=v,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=s,t.uint16ArrayTag=M,t.uint32ArrayTag=S,t.uint8ArrayTag=y,t.uint8ClampedArrayTag=b})(lT)),lT}var cT={},RU;function Lhe(){return RU||(RU=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 DU;function rW(){return DU||(DU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ohe(),n=tW(),r=nW(),i=QG(),a=Lhe();function s(d,f){return o(d,void 0,d,new Map,f)}function o(d,f,g,m=new Map,x=void 0){const v=x?.(d,f,g,m);if(v!==void 0)return v;if(i.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const y=new Array(d.length);m.set(d,y);for(let b=0;b<d.length;b++)y[b]=o(d[b],b,g,m,x);return Object.hasOwn(d,"index")&&(y.index=d.index),Object.hasOwn(d,"input")&&(y.input=d.input),y}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const y=new RegExp(d.source,d.flags);return y.lastIndex=d.lastIndex,y}if(d instanceof Map){const y=new Map;m.set(d,y);for(const[b,M]of d)y.set(b,o(M,b,g,m,x));return y}if(d instanceof Set){const y=new Set;m.set(d,y);for(const b of d)y.add(o(b,void 0,g,m,x));return y}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const y=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,y);for(let b=0;b<d.length;b++)y[b]=o(d[b],b,g,m,x);return y}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const y=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return m.set(d,y),c(y,d,g,m,x),y}if(typeof File<"u"&&d instanceof File){const y=new File([d],d.name,{type:d.type});return m.set(d,y),c(y,d,g,m,x),y}if(typeof Blob<"u"&&d instanceof Blob){const y=new Blob([d],{type:d.type});return m.set(d,y),c(y,d,g,m,x),y}if(d instanceof Error){const y=new d.constructor;return m.set(d,y),y.message=d.message,y.name=d.name,y.stack=d.stack,y.cause=d.cause,c(y,d,g,m,x),y}if(d instanceof Boolean){const y=new Boolean(d.valueOf());return m.set(d,y),c(y,d,g,m,x),y}if(d instanceof Number){const y=new Number(d.valueOf());return m.set(d,y),c(y,d,g,m,x),y}if(d instanceof String){const y=new String(d.valueOf());return m.set(d,y),c(y,d,g,m,x),y}if(typeof d=="object"&&u(d)){const y=Object.create(Object.getPrototypeOf(d));return m.set(d,y),c(y,d,g,m,x),y}return d}function c(d,f,g=d,m,x){const v=[...Object.keys(f),...e.getSymbols(f)];for(let y=0;y<v.length;y++){const b=v[y],M=Object.getOwnPropertyDescriptor(d,b);(M==null||M.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=s,t.cloneDeepWithImpl=o,t.copyProperties=c})(aT)),aT}var jU;function Ihe(){return jU||(jU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rW();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(iT)),iT}var OU;function Fhe(){return OU||(OU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eW(),n=Ihe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(QA)),QA}var uT={},dT={},hT={},LU;function Uhe(){return LU||(LU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rW(),n=nW();function r(i,a){return e.cloneDeepWith(i,(s,o,c,u)=>{const d=a?.(s,o,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(hT)),hT}var IU;function zhe(){return IU||(IU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uhe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(dT)),dT}var fT={},pT={},FU;function iW(){return FU||(FU=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={},UU;function Bhe(){return UU||(UU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tW();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(mT)),mT}var zU;function Hhe(){return zU||(zU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GG(),n=iW(),r=Bhe(),i=eD();function a(s,o){let c;if(Array.isArray(o)?c=o:typeof o=="string"&&e.isDeepKey(o)&&s?.[o]==null?c=i.toPath(o):c=[o],c.length===0)return!1;let u=s;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=a})(fT)),fT}var BU;function $he(){return BU||(BU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eW(),n=JR(),r=zhe(),i=tD(),a=Hhe();function s(o,c){switch(typeof o){case"object":{Object.is(o?.valueOf(),-0)&&(o="-0");break}case"number":{o=n.toKey(o);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,o);return d===void 0?a.has(u,o):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=s})(uT)),uT}var HU;function Vhe(){return HU||(HU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YG(),n=Dhe(),r=Fhe(),i=$he();function a(s){if(s==null)return e.identity;switch(typeof s){case"function":return s;case"object":return Array.isArray(s)&&s.length===2?i.matchesProperty(s[0],s[1]):r.matches(s);case"string":case"symbol":case"number":return n.property(s)}}t.iteratee=a})(YA)),YA}var $U;function Ghe(){return $U||($U=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Nhe(),n=YG(),r=Rhe(),i=Vhe();function a(s,o=n.identity){return r.isArrayLikeObject(s)?e.uniqBy(Array.from(s),i.iteratee(o)):[]}t.uniqBy=a})($A)),$A}var gT,VU;function Whe(){return VU||(VU=1,gT=Ghe().uniqBy),gT}var qhe=Whe();const GU=fo(qhe);function aW(t,e,n){return e===!0?GU(t,n):typeof e=="function"?GU(t,e):t}var xT={exports:{}},bT={};var WU;function Khe(){if(WU)return bT;WU=1;var t=Vm(),e=E9();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,s=t.useEffect,o=t.useMemo,c=t.useDebugValue;return bT.useSyncExternalStoreWithSelector=function(u,d,f,g,m){var x=a(null);if(x.current===null){var v={hasValue:!1,value:null};x.current=v}else v=x.current;x=o(function(){function b(k){if(!M){if(M=!0,S=k,k=g(k),m!==void 0&&v.hasValue){var N=v.value;if(m(N,k))return A=N}return A=k}if(N=A,r(S,k))return N;var I=g(k);return m!==void 0&&m(N,I)?(S=k,N):(S=k,A=I)}var M=!1,S,A,T=f===void 0?null:f;return[function(){return b(d())},T===null?void 0:function(){return b(T())}]},[d,f,g,m]);var y=i(u,x[0],x[1]);return s(function(){v.hasValue=!0,v.value=y},[y]),c(y),y},bT}var qU;function Xhe(){return qU||(qU=1,xT.exports=Khe()),xT.exports}var sW=Xhe(),aD=E.createContext(null),Yhe=t=>t,rr=()=>{var t=E.useContext(aD);return t?t.store.dispatch:Yhe},J_=()=>{},Zhe=()=>J_,Qhe=(t,e)=>t===e;function Ct(t){var e=E.useContext(aD);return sW.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Zhe,e?e.store.getState:J_,e?e.store.getState:J_,e?t:J_,Qhe)}function Jhe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function efe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function tfe(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 KU=t=>Array.isArray(t)?t:[t];function nfe(t){const e=Array.isArray(t[0])?t[0]:t;return tfe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function rfe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var ife=class{constructor(t){this.value=t}deref(){return this.value}},afe=typeof WeakRef<"u"?WeakRef:ife,sfe=0,XU=1;function bv(){return{s:sfe,v:void 0,o:null,p:null}}function oW(t,e={}){let n=bv();const{resultEqualityCheck:r}=e;let i,a=0;function s(){let o=n;const{length:c}=arguments;for(let f=0,g=c;f<g;f++){const m=arguments[f];if(typeof m=="function"||typeof m=="object"&&m!==null){let x=o.o;x===null&&(o.o=x=new WeakMap);const v=x.get(m);v===void 0?(o=bv(),x.set(m,o)):o=v}else{let x=o.p;x===null&&(o.p=x=new Map);const v=x.get(m);v===void 0?(o=bv(),x.set(m,o)):o=v}}const u=o;let d;if(o.s===XU)d=o.v;else if(d=t.apply(null,arguments),a++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,a!==0&&a--),i=typeof d=="object"&&d!==null||typeof d=="function"?new afe(d):d}return u.s=XU,u.v=d,d}return s.clearCache=()=>{n=bv(),s.resetResultsCount()},s.resultsCount=()=>a,s.resetResultsCount=()=>{a=0},s}function ofe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,s=0,o,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),Jhe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:g=[],argsMemoize:m=oW,argsMemoizeOptions:x=[]}=d,v=KU(g),y=KU(x),b=nfe(i),M=f(function(){return a++,u.apply(null,arguments)},...v),S=m(function(){s++;const T=rfe(b,arguments);return o=M.apply(null,T),o},...y);return Object.assign(S,{resultFunc:u,memoizedResultFunc:M,dependencies:b,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>o,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var Ge=ofe(oW),lfe=Object.assign((t,e=Ge)=>{efe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(a=>t[a]);return e(r,(...a)=>a.reduce((s,o,c)=>(s[n[c]]=o,s),{}))},{withTypes:()=>lfe}),yT={},vT={},_T={},YU;function cfe(){return YU||(YU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const s=e(r),o=e(i);if(s===o&&s===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?o-s:s-o}return 0};t.compareValues=n})(_T)),_T}var wT={},ST={},ZU;function lW(){return ZU||(ZU=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 QU;function ufe(){return QU||(QU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lW(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,s){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||e.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||s!=null&&Object.hasOwn(s,a)}t.isKey=i})(wT)),wT}var JU;function dfe(){return JU||(JU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cfe(),n=ufe(),r=eD();function i(a,s,o,c){if(a==null)return[];o=c?void 0:o,Array.isArray(a)||(a=Object.values(a)),Array.isArray(s)||(s=s==null?[null]:[s]),s.length===0&&(s=[null]),Array.isArray(o)||(o=o==null?[]:[o]),o=o.map(m=>String(m));const u=(m,x)=>{let v=m;for(let y=0;y<x.length&&v!=null;++y)v=v[x[y]];return v},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=s.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 a.map(m=>({original:m,criteria:f.map(x=>d(x,m))})).slice().sort((m,x)=>{for(let v=0;v<f.length;v++){const y=e.compareValues(m.criteria[v],x.criteria[v],o[v]);if(y!==0)return y}return 0}).map(m=>m.original)}t.orderBy=i})(vT)),vT}var MT={},ez;function hfe(){return ez||(ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),s=(o,c)=>{for(let u=0;u<o.length;u++){const d=o[u];Array.isArray(d)&&c<a?s(d,c+1):i.push(d)}};return s(n,0),i}t.flatten=e})(MT)),MT}var ET={},tz;function cW(){return tz||(tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iW(),n=iD(),r=ZG(),i=JG();function a(s,o,c){return r.isObject(c)&&(typeof o=="number"&&n.isArrayLike(c)&&e.isIndex(o)&&o<c.length||typeof o=="string"&&o in c)?i.eq(c[o],s):!1}t.isIterateeCall=a})(ET)),ET}var nz;function ffe(){return nz||(nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dfe(),n=hfe(),r=cW();function i(a,...s){const o=s.length;return o>1&&r.isIterateeCall(a,s[0],s[1])?s=[]:o>2&&r.isIterateeCall(s[0],s[1],s[2])&&(s=[s[0]]),e.orderBy(a,n.flatten(s),["asc"])}t.sortBy=i})(yT)),yT}var AT,rz;function pfe(){return rz||(rz=1,AT=ffe().sortBy),AT}var mfe=pfe();const qS=fo(mfe);var uW=t=>t.legend.settings,gfe=t=>t.legend.size,xfe=t=>t.legend.payload,bfe=Ge([xfe,uW],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?qS(r,n):r});function yfe(){return Ct(bfe)}var yv=1;function dW(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=E.useState({height:0,left:0,top:0,width:0}),r=E.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),s={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(s.height-e.height)>yv||Math.abs(s.left-e.left)>yv||Math.abs(s.top-e.top)>yv||Math.abs(s.width-e.width)>yv)&&n({height:s.height,left:s.left,top:s.top,width:s.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function Xi(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var vfe=typeof Symbol=="function"&&Symbol.observable||"@@observable",iz=vfe,TT=()=>Math.random().toString(36).substring(7).split("").join("."),_fe={INIT:`@@redux/INIT${TT()}`,REPLACE:`@@redux/REPLACE${TT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${TT()}`},L1=_fe;function sD(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 hW(t,e,n){if(typeof t!="function")throw new Error(Xi(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Xi(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Xi(1));return n(hW)(t,e)}let r=t,i=e,a=new Map,s=a,o=0,c=!1;function u(){s===a&&(s=new Map,a.forEach((y,b)=>{s.set(b,y)}))}function d(){if(c)throw new Error(Xi(3));return i}function f(y){if(typeof y!="function")throw new Error(Xi(4));if(c)throw new Error(Xi(5));let b=!0;u();const M=o++;return s.set(M,y),function(){if(b){if(c)throw new Error(Xi(6));b=!1,u(),s.delete(M),a=null}}}function g(y){if(!sD(y))throw new Error(Xi(7));if(typeof y.type>"u")throw new Error(Xi(8));if(typeof y.type!="string")throw new Error(Xi(17));if(c)throw new Error(Xi(9));try{c=!0,i=r(i,y)}finally{c=!1}return(a=s).forEach(M=>{M()}),y}function m(y){if(typeof y!="function")throw new Error(Xi(10));r=y,g({type:L1.REPLACE})}function x(){const y=f;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(Xi(11));function M(){const A=b;A.next&&A.next(d())}return M(),{unsubscribe:y(M)}},[iz](){return this}}}return g({type:L1.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:m,[iz]:x}}function wfe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:L1.INIT})>"u")throw new Error(Xi(12));if(typeof n(void 0,{type:L1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Xi(13))})}function fW(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const s=e[a];typeof t[s]=="function"&&(n[s]=t[s])}const r=Object.keys(n);let i;try{wfe(n)}catch(a){i=a}return function(s={},o){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],g=n[f],m=s[f],x=g(m,o);if(typeof x>"u")throw o&&o.type,new Error(Xi(14));u[f]=x,c=c||x!==m}return c=c||r.length!==Object.keys(s).length,c?u:s}}function I1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Sfe(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(Xi(15))};const s={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},o=t.map(c=>c(s));return a=I1(...o)(i.dispatch),{...i,dispatch:a}}}function pW(t){return sD(t)&&"type"in t&&typeof t.type=="string"}var mW=Symbol.for("immer-nothing"),az=Symbol.for("immer-draftable"),Na=Symbol.for("immer-state");function To(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ys=Object,vm=ys.getPrototypeOf,F1="constructor",KS="prototype",$k="configurable",U1="enumerable",e1="writable",C0="value",Nc=t=>!!t&&!!t[Na];function Uo(t){return t?gW(t)||XS(t)||!!t[az]||!!t[F1]?.[az]||YS(t)||ZS(t):!1}var Mfe=ys[KS][F1].toString(),sz=new WeakMap;function gW(t){if(!t||!oD(t))return!1;const e=vm(t);if(e===null||e===ys[KS])return!0;const n=ys.hasOwnProperty.call(e,F1)&&e[F1];if(n===Object)return!0;if(!Fp(n))return!1;let r=sz.get(n);return r===void 0&&(r=Function.toString.call(n),sz.set(n,r)),r===Mfe}function _b(t,e,n=!0){wb(t)===0?(n?Reflect.ownKeys(t):ys.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function wb(t){const e=t[Na];return e?e.type_:XS(t)?1:YS(t)?2:ZS(t)?3:0}var oz=(t,e,n=wb(t))=>n===2?t.has(e):ys[KS].hasOwnProperty.call(t,e),Vk=(t,e,n=wb(t))=>n===2?t.get(e):t[e],z1=(t,e,n,r=wb(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Efe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var XS=Array.isArray,YS=t=>t instanceof Map,ZS=t=>t instanceof Set,oD=t=>typeof t=="object",Fp=t=>typeof t=="function",CT=t=>typeof t=="boolean",lc=t=>t.copy_||t.base_,lD=t=>t.modified_?t.copy_:t.base_;function Gk(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=gW(t);if(e===!0||e==="class_only"&&!n){const r=ys.getOwnPropertyDescriptors(t);delete r[Na];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o[e1]===!1&&(o[e1]=!0,o[$k]=!0),(o.get||o.set)&&(r[s]={[$k]:!0,[e1]:!0,[U1]:o[U1],[C0]:t[s]})}return ys.create(vm(t),r)}else{const r=vm(t);if(r!==null&&n)return{...t};const i=ys.create(r);return ys.assign(i,t)}}function cD(t,e=!1){return QS(t)||Nc(t)||!Uo(t)||(wb(t)>1&&ys.defineProperties(t,{set:vv,add:vv,clear:vv,delete:vv}),ys.freeze(t),e&&_b(t,(n,r)=>{cD(r,!0)},!1)),t}function Afe(){To(2)}var vv={[C0]:Afe};function QS(t){return t===null||!oD(t)?!0:ys.isFrozen(t)}var B1="MapSet",Wk="Patches",xW={};function _m(t){const e=xW[t];return e||To(0,t),e}var Tfe=t=>!!xW[t],N0,bW=()=>N0,Cfe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Tfe(B1)?_m(B1):void 0});function lz(t,e){e&&(t.patchPlugin_=_m(Wk),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function qk(t){Kk(t),t.drafts_.forEach(Nfe),t.drafts_=null}function Kk(t){t===N0&&(N0=t.parent_)}var cz=t=>N0=Cfe(N0,t);function Nfe(t){const e=t[Na];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function uz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Na].modified_&&(qk(e),To(4)),Uo(t)&&(t=dz(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Na].base_,t,e)}else t=dz(e,n);return kfe(e,t,!0),qk(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==mW?t:void 0}function dz(t,e){if(QS(e))return e;const n=e[Na];if(!n)return uD(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);_W(n,t)}return n.copy_}function kfe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&cD(e,n)}function yW(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var JS=(t,e)=>t.scope_===e,Pfe=[];function vW(t,e,n,r){const i=lc(t),a=t.type_;if(r!==void 0&&Vk(i,r,a)===e){z1(i,r,n,a);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;_b(i,(c,u)=>{if(Nc(u)){const d=o.get(u)||[];d.push(c),o.set(u,d)}})}const s=t.draftLocations_.get(e)??Pfe;for(const o of s)z1(i,o,n,a)}function Rfe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!JS(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=lD(a);vW(t,a.draft_??a,s,n),_W(a,i)})}function _W(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)}yW(t)}}function Dfe(t,e,n){const{scope_:r}=t;if(Nc(n)){const i=n[Na];JS(i,r)&&i.callbacks_.push(function(){t1(t);const s=lD(i);vW(t,n,s,e)})}else Uo(n)&&t.callbacks_.push(function(){const a=lc(t);Vk(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&uD(Vk(t.copy_,e,t.type_),r.handledSet_,r)})}function uD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Nc(t)||e.has(t)||!Uo(t)||QS(t)||(e.add(t),_b(t,(r,i)=>{if(Nc(i)){const a=i[Na];if(JS(a,n)){const s=lD(a);z1(t,r,s,t.type_),yW(a)}}else Uo(i)&&uD(i,e,n)})),t}function jfe(t,e){const n=XS(t),r={type_:n?1:0,scope_:e?e.scope_:bW(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=dD;n&&(i=[r],a=k0);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,[o,r]}var dD={get(t,e){if(e===Na)return t;const n=lc(t);if(!oz(n,e,t.type_))return Ofe(t,n,e);const r=n[e];if(t.finalized_||!Uo(r))return r;if(r===NT(t.base_,e)){t1(t);const i=t.type_===1?+e:e,a=Yk(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in lc(t)},ownKeys(t){return Reflect.ownKeys(lc(t))},set(t,e,n){const r=wW(lc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=NT(lc(t),e),a=i?.[Na];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Efe(n,i)&&(n!==void 0||oz(t.base_,e,t.type_)))return!0;t1(t),Xk(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),Dfe(t,e,n)),!0},deleteProperty(t,e){return t1(t),NT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),Xk(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=lc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[e1]:!0,[$k]:t.type_!==1||e!=="length",[U1]:r[U1],[C0]:n[e]}},defineProperty(){To(11)},getPrototypeOf(t){return vm(t.base_)},setPrototypeOf(){To(12)}},k0={};_b(dD,(t,e)=>{k0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});k0.deleteProperty=function(t,e){return k0.set.call(this,t,e,void 0)};k0.set=function(t,e,n){return dD.set.call(this,t[0],e,n,t[0])};function NT(t,e){const n=t[Na];return(n?lc(n):t)[e]}function Ofe(t,e,n){const r=wW(e,n);return r?C0 in r?r[C0]:r.get?.call(t.draft_):void 0}function wW(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 Xk(t){t.modified_||(t.modified_=!0,t.parent_&&Xk(t.parent_))}function t1(t){t.copy_||(t.assigned_=new Map,t.copy_=Gk(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Lfe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Fp(n)&&!Fp(r)){const s=r;r=n;const o=this;return function(u=s,...d){return o.produce(u,f=>r.call(this,f,...d))}}Fp(r)||To(6),i!==void 0&&!Fp(i)&&To(7);let a;if(Uo(n)){const s=cz(this),o=Yk(s,n,void 0);let c=!0;try{a=r(o),c=!1}finally{c?qk(s):Kk(s)}return lz(s,i),uz(a,s)}else if(!n||!oD(n)){if(a=r(n),a===void 0&&(a=n),a===mW&&(a=void 0),this.autoFreeze_&&cD(a,!0),i){const s=[],o=[];_m(Wk).generateReplacementPatches_(n,a,{patches_:s,inversePatches_:o}),i(s,o)}return a}else To(1,n)},this.produceWithPatches=(n,r)=>{if(Fp(n))return(o,...c)=>this.produceWithPatches(o,u=>n(u,...c));let i,a;return[this.produce(n,r,(o,c)=>{i=o,a=c}),i,a]},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)||To(8),Nc(e)&&(e=Lo(e));const n=cz(this),r=Yk(n,e,void 0);return r[Na].isManual_=!0,Kk(n),r}finishDraft(e,n){const r=e&&e[Na];(!r||!r.isManual_)&&To(9);const{scope_:i}=r;return lz(i,n),uz(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}r>-1&&(n=n.slice(r+1));const i=_m(Wk).applyPatches_;return Nc(e)?i(e,n):this.produce(e,a=>i(a,n))}};function Yk(t,e,n,r){const[i,a]=YS(e)?_m(B1).proxyMap_(e,n):ZS(e)?_m(B1).proxySet_(e,n):jfe(e,n);return(n?.scope_??bW()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Rfe(n,a,r):a.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=c;a.modified_&&u&&u.generatePatches_(a,[],c)}),i}function Lo(t){return Nc(t)||To(10,t),SW(t)}function SW(t){if(!Uo(t)||QS(t))return t;const e=t[Na];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=Gk(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=Gk(t,!0);return _b(n,(i,a)=>{z1(n,i,SW(a))},r),e&&(e.finalized_=!1),n}var Ife=new Lfe,MW=Ife.produce;function EW(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Ffe=EW(),Ufe=EW,zfe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?I1:I1.apply(null,arguments)};function uo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(_s(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=>pW(r)&&r.type===t,n}var AW=class Dx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Dx.prototype)}static get[Symbol.species](){return Dx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Dx(...e[0].concat(this)):new Dx(...e.concat(this))}};function hz(t){return Uo(t)?MW(t,()=>{}):t}function _v(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Bfe(t){return typeof t=="boolean"}var Hfe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let s=new AW;return n&&(Bfe(n)?s.push(Ffe):s.push(Ufe(n.extraArgument))),s},TW="RTK_autoBatch",fr=()=>t=>({payload:t,meta:{[TW]:!0}}),fz=t=>e=>{setTimeout(e,t)},CW=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,s=!1;const o=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:fz(10):t.type==="callback"?t.queueNotification:fz(t.timeout),u=()=>{s=!1,a&&(a=!1,o.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),g=r.subscribe(f);return o.add(d),()=>{g(),o.delete(d)}},dispatch(d){try{return i=!d?.meta?.[TW],a=!i,a&&(s||(s=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},$fe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new AW(t);return r&&i.push(CW(typeof r=="object"?r:void 0)),i};function Vfe(t){const e=Hfe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:s=void 0}=t||{};let o;if(typeof n=="function")o=n;else if(sD(n))o=fW(n);else throw new Error(_s(1));let c;typeof r=="function"?c=r(e):c=e();let u=I1;i&&(u=zfe({trace:!1,...typeof i=="object"&&i}));const d=Sfe(...c),f=$fe(d);let g=typeof s=="function"?s(f):f();const m=u(...g);return hW(o,a,m)}function NW(t){const e={},n=[];let r;const i={addCase(a,s){const o=typeof a=="string"?a:a.type;if(!o)throw new Error(_s(28));if(o in e)throw new Error(_s(29));return e[o]=s,i},addAsyncThunk(a,s){return s.pending&&(e[a.pending.type]=s.pending),s.rejected&&(e[a.rejected.type]=s.rejected),s.fulfilled&&(e[a.fulfilled.type]=s.fulfilled),s.settled&&n.push({matcher:a.settled,reducer:s.settled}),i},addMatcher(a,s){return n.push({matcher:a,reducer:s}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function Gfe(t){return typeof t=="function"}function Wfe(t,e){let[n,r,i]=NW(e),a;if(Gfe(t))a=()=>hz(t());else{const o=hz(t);a=()=>o}function s(o=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Nc(d)){const m=f(d,c);return m===void 0?d:m}else{if(Uo(d))return MW(d,g=>f(g,c));{const g=f(d,c);if(g===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return d},o)}return s.getInitialState=a,s}var qfe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Kfe=(t=21)=>{let e="",n=t;for(;n--;)e+=qfe[Math.random()*64|0];return e},Xfe=Symbol.for("rtk-slice-createasyncthunk");function Yfe(t,e){return`${t}/${e}`}function Zfe({creators:t}={}){const e=t?.asyncThunk?.[Xfe];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(_s(11));const s=(typeof r.reducers=="function"?r.reducers(Jfe()):r.reducers)||{},o=Object.keys(s),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(S,A){const T=typeof S=="string"?S:S.type;if(!T)throw new Error(_s(12));if(T in c.sliceCaseReducersByType)throw new Error(_s(13));return c.sliceCaseReducersByType[T]=A,u},addMatcher(S,A){return c.sliceMatchers.push({matcher:S,reducer:A}),u},exposeAction(S,A){return c.actionCreators[S]=A,u},exposeCaseReducer(S,A){return c.sliceCaseReducersByName[S]=A,u}};o.forEach(S=>{const A=s[S],T={reducerName:S,type:Yfe(i,S),createNotation:typeof r.reducers=="function"};tpe(A)?rpe(T,A,u,e):epe(T,A,u)});function d(){const[S={},A=[],T=void 0]=typeof r.extraReducers=="function"?NW(r.extraReducers):[r.extraReducers],k={...S,...c.sliceCaseReducersByType};return Wfe(r.initialState,N=>{for(let I in k)N.addCase(I,k[I]);for(let I of c.sliceMatchers)N.addMatcher(I.matcher,I.reducer);for(let I of A)N.addMatcher(I.matcher,I.reducer);T&&N.addDefaultCase(T)})}const f=S=>S,g=new Map,m=new WeakMap;let x;function v(S,A){return x||(x=d()),x(S,A)}function y(){return x||(x=d()),x.getInitialState()}function b(S,A=!1){function T(N){let I=N[S];return typeof I>"u"&&A&&(I=_v(m,T,y)),I}function k(N=f){const I=_v(g,A,()=>new WeakMap);return _v(I,N,()=>{const C={};for(const[D,F]of Object.entries(r.selectors??{}))C[D]=Qfe(F,N,()=>_v(m,N,y),A);return C})}return{reducerPath:S,getSelectors:k,get selectors(){return k(T)},selectSlice:T}}const M={name:i,reducer:v,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:y,...b(a),injectInto(S,{reducerPath:A,...T}={}){const k=A??a;return S.inject({reducerPath:k,reducer:v},T),{...M,...b(k,!0)}}};return M}}function Qfe(t,e,n,r){function i(a,...s){let o=e(a);return typeof o>"u"&&r&&(o=n()),t(o,...s)}return i.unwrapped=t,i}var Qa=Zfe();function Jfe(){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 epe({type:t,reducerName:e,createNotation:n},r,i){let a,s;if("reducer"in r){if(n&&!npe(r))throw new Error(_s(17));a=r.reducer,s=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,s?uo(t,s):uo(t))}function tpe(t){return t._reducerDefinitionType==="asyncThunk"}function npe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function rpe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(_s(18));const{payloadCreator:a,fulfilled:s,pending:o,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),s&&r.addCase(f.fulfilled,s),o&&r.addCase(f.pending,o),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:s||wv,pending:o||wv,rejected:c||wv,settled:u||wv})}function wv(){}var ipe="task",kW="listener",PW="completed",hD="cancelled",ape=`task-${hD}`,spe=`task-${PW}`,Zk=`${kW}-${hD}`,ope=`${kW}-${PW}`,eM=class{constructor(t){this.code=t,this.message=`${ipe} ${hD} (reason: ${t})`}name="TaskAbortError";message},fD=(t,e)=>{if(typeof t!="function")throw new TypeError(_s(32))},H1=()=>{},RW=(t,e=H1)=>(t.catch(e),t),DW=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Mh=(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))},Eh=t=>{if(t.aborted){const{reason:e}=t;throw new eM(e)}};function jW(t,e){let n=H1;return new Promise((r,i)=>{const a=()=>i(new eM(t.reason));if(t.aborted){a();return}n=DW(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=H1})}var lpe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof eM?"cancelled":"rejected",error:n}}finally{e?.()}},$1=t=>e=>RW(jW(t,e).then(n=>(Eh(t),n))),OW=t=>{const e=$1(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:em}=Object,pz={},tM="listenerMiddleware",cpe=(t,e)=>{const n=r=>DW(t,()=>Mh(r,t.reason));return(r,i)=>{fD(r);const a=new AbortController;n(a);const s=lpe(async()=>{Eh(t),Eh(a.signal);const o=await r({pause:$1(a.signal),delay:OW(a.signal),signal:a.signal});return Eh(a.signal),o},()=>Mh(a,spe));return i?.autoJoin&&e.push(s.catch(H1)),{result:$1(t)(s),cancel(){Mh(a,ape)}}}},upe=(t,e)=>{const n=async(r,i)=>{Eh(e);let a=()=>{};const o=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,g)=>{g.unsubscribe(),c([f,g.getState(),g.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&o.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await jW(e,Promise.race(o));return Eh(e),c}finally{a()}};return(r,i)=>RW(n(r,i))},LW=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=uo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(_s(21));return fD(a),{predicate:i,type:e,effect:a}},IW=em(t=>{const{type:e,predicate:n,effect:r}=LW(t);return{id:Kfe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(_s(22))}}},{withTypes:()=>IW}),mz=(t,e)=>{const{type:n,effect:r,predicate:i}=LW(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},Qk=t=>{t.pending.forEach(e=>{Mh(e,Zk)})},dpe=(t,e)=>()=>{for(const n of e.keys())Qk(n);t.clear()},gz=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},FW=em(uo(`${tM}/add`),{withTypes:()=>FW}),hpe=uo(`${tM}/removeAll`),UW=em(uo(`${tM}/remove`),{withTypes:()=>UW}),fpe=(...t)=>{console.error(`${tM}/error`,...t)},Sb=(t={})=>{const e=new Map,n=new Map,r=m=>{const x=n.get(m)??0;n.set(m,x+1)},i=m=>{const x=n.get(m)??1;x===1?n.delete(m):n.set(m,x-1)},{extra:a,onError:s=fpe}=t;fD(s);const o=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),x=>{m.unsubscribe(),x?.cancelActive&&Qk(m)}),c=m=>{const x=mz(e,m)??IW(m);return o(x)};em(c,{withTypes:()=>c});const u=m=>{const x=mz(e,m);return x&&(x.unsubscribe(),m.cancelActive&&Qk(x)),!!x};em(u,{withTypes:()=>u});const d=async(m,x,v,y)=>{const b=new AbortController,M=upe(c,b.signal),S=[];try{m.pending.add(b),r(m),await Promise.resolve(m.effect(x,em({},v,{getOriginalState:y,condition:(A,T)=>M(A,T).then(Boolean),take:M,delay:OW(b.signal),pause:$1(b.signal),extra:a,signal:b.signal,fork:cpe(b.signal,S),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((A,T,k)=>{A!==b&&(Mh(A,Zk),k.delete(A))})},cancel:()=>{Mh(b,Zk),m.pending.delete(b)},throwIfCancelled:()=>{Eh(b.signal)}})))}catch(A){A instanceof eM||gz(s,A,{raisedBy:"effect"})}finally{await Promise.all(S),Mh(b,ope),i(m),m.pending.delete(b)}},f=dpe(e,n);return{middleware:m=>x=>v=>{if(!pW(v))return x(v);if(FW.match(v))return c(v.payload);if(hpe.match(v)){f();return}if(UW.match(v))return u(v.payload);let y=m.getState();const b=()=>{if(y===pz)throw new Error(_s(23));return y};let M;try{if(M=x(v),e.size>0){const S=m.getState(),A=Array.from(e.values());for(const T of A){let k=!1;try{k=T.predicate(v,S,y)}catch(N){k=!1,gz(s,N,{raisedBy:"predicate"})}k&&d(T,v,m,b)}}}finally{y=pz}return M},startListening:c,stopListening:u,clearListeners:f}};function _s(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 ppe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},zW=Qa({name:"chartLayout",initialState:ppe,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,a;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(a=e.payload.left)!==null&&a!==void 0?a:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:mpe,setLayout:gpe,setChartSize:xpe,setScale:bpe}=zW.actions,ype=zW.reducer;function BW(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function xz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Gp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xz(Object(n),!0).forEach(function(r){vpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vpe(t,e,n){return(e=_pe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _pe(t){var e=wpe(t,"string");return typeof e=="symbol"?e:e+""}function wpe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Bn(t,e,n){return dr(t)||dr(e)?n:co(e)?Wh(t,e,n):typeof e=="function"?e(t):n}var Spe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:s,layout:o}=e;if((o==="vertical"||o==="horizontal"&&s==="middle")&&a!=="center"&&Pt(t[a]))return Gp(Gp({},t),{},{[a]:t[a]+(r||0)});if((o==="horizontal"||o==="vertical"&&a==="center")&&s!=="middle"&&Pt(t[s]))return Gp(Gp({},t),{},{[s]:t[s]+(i||0)})}return t},wl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",HW=(t,e,n,r)=>{if(r)return t.map(o=>o.coordinate);var i,a,s=t.map(o=>(o.coordinate===e&&(i=!0),o.coordinate===n&&(a=!0),o.coordinate));return i||s.push(e),a||s.push(n),s},$W=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:s,realScaleType:o,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:g,axisType:m}=t;if(!s)return null;var x=o==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,v=i==="category"&&s.bandwidth?s.bandwidth()/x:0;if(v=m==="angleAxis"&&a&&a.length>=2?Li(a[0]-a[1])*2*v:v,f||g){var y=(f||g||[]).map((b,M)=>{var S=r?r.indexOf(b):b;return{coordinate:s(S)+v,value:b,offset:v,index:M}});return y.filter(b=>!Za(b.coordinate))}return c&&u?u.map((b,M)=>({coordinate:s(b)+v,value:b,index:M,offset:v})):s.ticks&&d!=null?s.ticks(d).map((b,M)=>({coordinate:s(b)+v,value:b,offset:v,index:M})):s.domain().map((b,M)=>({coordinate:s(b)+v,value:r?r[b]:b,index:M,offset:v}))},bz=1e-4,Mpe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-bz,a=Math.max(r[0],r[1])+bz,s=t(e[0]),o=t(e[n-1]);(s<i||s>a||o<i||o>a)&&t.domain([e[0],e[n-1]])}},Epe=(t,e)=>{if(!e||e.length!==2||!Pt(e[0])||!Pt(e[1]))return t;var n=Math.min(e[0],e[1]),r=Math.max(e[0],e[1]),i=[t[0],t[1]];return(!Pt(t[0])||t[0]<n)&&(i[0]=n),(!Pt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},Ape=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,s=0;s<e;++s){var o=Za(t[s][n][1])?t[s][n][0]:t[s][n][1];o>=0?(t[s][n][0]=i,t[s][n][1]=i+o,i=t[s][n][1]):(t[s][n][0]=a,t[s][n][1]=a+o,a=t[s][n][1])}},Tpe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0;a<e;++a){var s=Za(t[a][n][1])?t[a][n][0]:t[a][n][1];s>=0?(t[a][n][0]=i,t[a][n][1]=i+s,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},Cpe={sign:Ape,expand:Zde,none:ym,silhouette:Qde,wiggle:Jde,positive:Tpe},Npe=(t,e,n)=>{var r=Cpe[n],i=Yde().keys(e).value((a,s)=>Number(Bn(a,s,0))).order(Bk).offset(r);return i(t)};function VW(t){return t==null?void 0:String(t)}function V1(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:s}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!dr(i[e.dataKey])){var o=qG(n,"value",i[e.dataKey]);if(o)return o.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=Bn(i,dr(s)?e.dataKey:s);return dr(c)?null:e.scale(c)}var yz=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:s}=t;if(e.type==="category")return n[s]?n[s].coordinate+r:null;var o=Bn(a,e.dataKey,e.scale.domain()[s]);return dr(o)?null:e.scale(o)-i/2+r},kpe=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]},Ppe=t=>{var e=t.flat(2).filter(Pt);return[Math.min(...e),Math.max(...e)]},Rpe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Dpe=(t,e,n)=>{if(t!=null)return Rpe(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:s}=a,o=s.reduce((c,u)=>{var d=BW(u,e,n),f=Ppe(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]))},vz=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,_z=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,sd=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var r=t.scale.bandwidth();if(!n||r>0)return r}if(t&&e&&e.length>=2){for(var i=qS(e,d=>d.coordinate),a=1/0,s=1,o=i.length;s<o;s++){var c=i[s],u=i[s-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function wz(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Gp(Gp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function yd(t,e){if(t)return String(t);if(typeof e=="string")return e}var jpe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Ope=(t,e)=>e==="centric"?t.angle:t.radius,Ic=t=>t.layout.width,Fc=t=>t.layout.height,Lpe=t=>t.layout.scale,GW=t=>t.layout.margin,nM=Ge(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),rM=Ge(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),WW="data-recharts-item-index",qW="data-recharts-item-data-key",Mb=60;function Sz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Sz(Object(n),!0).forEach(function(r){Ipe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Sz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ipe(t,e,n){return(e=Fpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Fpe(t){var e=Upe(t,"string");return typeof e=="symbol"?e:e+""}function Upe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var zpe=t=>t.brush.height;function Bpe(t){var e=rM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Mb;return n+i}return n},0)}function Hpe(t){var e=rM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Mb;return n+i}return n},0)}function $pe(t){var e=nM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Vpe(t){var e=nM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var bi=Ge([Ic,Fc,GW,zpe,Bpe,Hpe,$pe,Vpe,uW,gfe],(t,e,n,r,i,a,s,o,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+s,bottom:(n.bottom||0)+o},g=Sv(Sv({},f),d),m=g.bottom;g.bottom+=r,g=Spe(g,c,u);var x=t-g.left-g.right,v=e-g.top-g.bottom;return Sv(Sv({brushBottom:m},g),{},{width:Math.max(x,0),height:Math.max(v,0)})}),Gpe=Ge(bi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),pD=Ge(Ic,Fc,(t,e)=>({x:0,y:0,width:t,height:e})),Wpe=E.createContext(null),yi=()=>E.useContext(Wpe)!=null,iM=t=>t.brush,aM=Ge([iM,bi,GW],(t,e,n)=>({height:t.height,x:Pt(t.x)?t.x:e.left,y:Pt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Pt(t.width)?t.width:e.width})),kT={},PT={},RT={},Mz;function qpe(){return Mz||(Mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let s,o=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{o!==null&&(n.apply(s,o),s=void 0,o=null)},f=()=>{u&&d(),v()};let g=null;const m=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,f()},r)},x=()=>{g!==null&&(clearTimeout(g),g=null)},v=()=>{x(),s=void 0,o=null},y=()=>{d()},b=function(...M){if(i?.aborted)return;s=this,o=M;const S=g==null;m(),c&&S&&d()};return b.schedule=m,b.cancel=v,b.flush=y,i?.addEventListener("abort",v,{once:!0}),b}t.debounce=e})(RT)),RT}var Ez;function Kpe(){return Ez||(Ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qpe();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:s=!1,trailing:o=!0,maxWait:c}=a,u=Array(2);s&&(u[0]="leading"),o&&(u[1]="trailing");let d,f=null;const g=e.debounce(function(...v){d=r.apply(this,v),f=null},i,{edges:u}),m=function(...v){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,v),f=Date.now(),g.cancel(),g.schedule(),d):(g.apply(this,v),d)},x=()=>(g.flush(),d);return m.cancel=g.cancel,m.flush=x,m}t.debounce=n})(PT)),PT}var Az;function Xpe(){return Az||(Az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kpe();function n(r,i=0,a={}){const{leading:s=!0,trailing:o=!0}=a;return e.debounce(r,i,{leading:s,maxWait:i,trailing:o})}t.throttle=n})(kT)),kT}var DT,Tz;function Ype(){return Tz||(Tz=1,DT=Xpe().throttle),DT}var Zpe=Ype();const Qpe=fo(Zpe);var G1=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=0;console.warn(n.replace(/%s/g,()=>i[s++]))}},KW=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:s}=n,o=Cc(r)?t:Number(r),c=Cc(i)?e:Number(i);return a&&a>0&&(o?c=o/a:c&&(o=c*a),s&&c!=null&&c>s&&(c=s)),{calculatedWidth:o,calculatedHeight:c}},Jpe={width:0,height:0,overflow:"visible"},eme={width:0,overflowX:"visible"},tme={height:0,overflowY:"visible"},nme={},rme=t=>{var{width:e,height:n}=t,r=Cc(e),i=Cc(n);return r&&i?Jpe:r?eme:i?tme:nme};function ime(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i="100%",a="100%"):i===void 0?i=r&&r>0?void 0:"100%":a===void 0&&(a=r&&r>0?void 0:"100%"),{width:i,height:a}}function Hn(t){return Number.isFinite(t)}function hl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function Jk(){return Jk=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},Jk.apply(null,arguments)}function Cz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Nz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Cz(Object(n),!0).forEach(function(r){ame(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Cz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ame(t,e,n){return(e=sme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sme(t){var e=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 XW=E.createContext({width:-1,height:-1});function lme(t){return hl(t.width)&&hl(t.height)}function YW(t){var{children:e,width:n,height:r}=t,i=E.useMemo(()=>({width:n,height:r}),[n,r]);return lme(i)?E.createElement(XW.Provider,{value:i},e):null}var mD=()=>E.useContext(XW),cme=E.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:s=0,minHeight:o,maxHeight:c,children:u,debounce:d=0,id:f,className:g,onResize:m,style:x={}}=t,v=E.useRef(null),y=E.useRef();y.current=m,E.useImperativeHandle(e,()=>v.current);var[b,M]=E.useState({containerWidth:r.width,containerHeight:r.height}),S=E.useCallback((I,C)=>{M(D=>{var F=Math.round(I),O=Math.round(C);return D.containerWidth===F&&D.containerHeight===O?D:{containerWidth:F,containerHeight:O}})},[]);E.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return yb;var I=O=>{var q,{width:R,height:W}=O[0].contentRect;S(R,W),(q=y.current)===null||q===void 0||q.call(y,R,W)};d>0&&(I=Qpe(I,d,{trailing:!0,leading:!1}));var C=new ResizeObserver(I),{width:D,height:F}=v.current.getBoundingClientRect();return S(D,F),C.observe(v.current),()=>{C.disconnect()}},[S,d]);var{containerWidth:A,containerHeight:T}=b;G1(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:N}=KW(A,T,{width:i,height:a,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,a,s,o,n),E.createElement("div",{id:f?"".concat(f):void 0,className:Mn("recharts-responsive-container",g),style:Nz(Nz({},x),{},{width:i,height:a,minWidth:s,minHeight:o,maxHeight:c}),ref:v},E.createElement("div",{style:rme({width:i,height:a})},E.createElement(YW,{width:k,height:N},u)))}),n1=E.forwardRef((t,e)=>{var n=mD();if(hl(n.width)&&hl(n.height))return t.children;var{width:r,height:i}=ime({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:s}=KW(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Pt(a)&&Pt(s)?E.createElement(YW,{width:a,height:s},t.children):E.createElement(cme,Jk({},t,{width:r,height:i,ref:e}))});function ZW(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=yi(),n=Ct(Gpe),r=Ct(aM),i=(t=Ct(iM))===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}},ume={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},QW=()=>{var t;return(t=Ct(bi))!==null&&t!==void 0?t:ume},gD=()=>Ct(Ic),xD=()=>Ct(Fc),dme=()=>Ct(t=>t.layout.margin),xn=t=>t.layout.layoutType,hf=()=>Ct(xn),hme=()=>{var t=hf();if(t==="horizontal"||t==="vertical")return t},fme=()=>{var t=hf();return t!==void 0},sM=t=>{var e=rr(),n=yi(),{width:r,height:i}=t,a=mD(),s=r,o=i;return a&&(s=a.width>0?a.width:r,o=a.height>0?a.height:i),E.useEffect(()=>{!n&&hl(s)&&hl(o)&&e(xpe({width:s,height:o}))},[e,n,s,o]),null},JW=Symbol.for("immer-nothing"),kz=Symbol.for("immer-draftable"),Cs=Symbol.for("immer-state");function Co(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var P0=Object.getPrototypeOf;function wm(t){return!!t&&!!t[Cs]}function qh(t){return t?eq(t)||Array.isArray(t)||!!t[kz]||!!t.constructor?.[kz]||Ab(t)||lM(t):!1}var pme=Object.prototype.constructor.toString(),Pz=new WeakMap;function eq(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=Pz.get(n);return r===void 0&&(r=Function.toString.call(n),Pz.set(n,r)),r===pme}function W1(t,e,n=!0){oM(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 oM(t){const e=t[Cs];return e?e.type_:Array.isArray(t)?1:Ab(t)?2:lM(t)?3:0}function e3(t,e){return oM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function tq(t,e,n){const r=oM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function mme(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Ab(t){return t instanceof Map}function lM(t){return t instanceof Set}function rh(t){return t.copy_||t.base_}function t3(t,e){if(Ab(t))return new Map(t);if(lM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=eq(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Cs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[s]})}return Object.create(P0(t),r)}else{const r=P0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function bD(t,e=!1){return cM(t)||wm(t)||!qh(t)||(oM(t)>1&&Object.defineProperties(t,{set:Mv,add:Mv,clear:Mv,delete:Mv}),Object.freeze(t),e&&Object.values(t).forEach(n=>bD(n,!0))),t}function gme(){Co(2)}var Mv={value:gme};function cM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var xme={};function Kh(t){const e=xme[t];return e||Co(0,t),e}var R0;function nq(){return R0}function bme(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Rz(t,e){e&&(Kh("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function n3(t){r3(t),t.drafts_.forEach(yme),t.drafts_=null}function r3(t){t===R0&&(R0=t.parent_)}function Dz(t){return R0=bme(R0,t)}function yme(t){const e=t[Cs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function jz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Cs].modified_&&(n3(e),Co(4)),qh(t)&&(t=q1(e,t),e.parent_||K1(e,t)),e.patches_&&Kh("Patches").generateReplacementPatches_(n[Cs].base_,t,e.patches_,e.inversePatches_)):t=q1(e,n,[]),n3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==JW?t:void 0}function q1(t,e,n){if(cM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Cs];if(!i)return W1(e,(a,s)=>Oz(t,i,e,a,s,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 a=i.copy_;let s=a,o=!1;i.type_===3&&(s=new Set(a),a.clear(),o=!0),W1(s,(c,u)=>Oz(t,i,a,c,u,n,o),r),K1(t,a,!1),n&&t.patches_&&Kh("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function Oz(t,e,n,r,i,a,s){if(i==null||typeof i!="object"&&!s)return;const o=cM(i);if(!(o&&!s)){if(wm(i)){const c=a&&e&&e.type_!==3&&!e3(e.assigned_,r)?a.concat(r):void 0,u=q1(t,i,c);if(tq(n,r,u),wm(u))t.canAutoFreeze_=!1;else return}else s&&n.add(i);if(qh(i)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&o)return;q1(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Ab(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&K1(t,i)}}}function K1(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&bD(e,n)}function vme(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:nq(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=yD;n&&(i=[r],a=D0);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,o}var yD={get(t,e){if(e===Cs)return t;const n=rh(t);if(!e3(n,e))return _me(t,n,e);const r=n[e];return t.finalized_||!qh(r)?r:r===jT(t.base_,e)?(OT(t),t.copy_[e]=a3(r,t)):r},has(t,e){return e in rh(t)},ownKeys(t){return Reflect.ownKeys(rh(t))},set(t,e,n){const r=rq(rh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=jT(rh(t),e),a=i?.[Cs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(mme(n,i)&&(n!==void 0||e3(t.base_,e)))return!0;OT(t),i3(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 jT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,OT(t),i3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=rh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Co(11)},getPrototypeOf(t){return P0(t.base_)},setPrototypeOf(){Co(12)}},D0={};W1(yD,(t,e)=>{D0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});D0.deleteProperty=function(t,e){return D0.set.call(this,t,e,void 0)};D0.set=function(t,e,n){return yD.set.call(this,t[0],e,n,t[0])};function jT(t,e){const n=t[Cs];return(n?rh(n):t)[e]}function _me(t,e,n){const r=rq(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function rq(t,e){if(!(e in t))return;let n=P0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=P0(n)}}function i3(t){t.modified_||(t.modified_=!0,t.parent_&&i3(t.parent_))}function OT(t){t.copy_||(t.copy_=t3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var wme=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const s=this;return function(c=a,...u){return s.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Co(6),r!==void 0&&typeof r!="function"&&Co(7);let i;if(qh(e)){const a=Dz(this),s=a3(e,void 0);let o=!0;try{i=n(s),o=!1}finally{o?n3(a):r3(a)}return Rz(a,r),jz(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===JW&&(i=void 0),this.autoFreeze_&&bD(i,!0),r){const a=[],s=[];Kh("Patches").generateReplacementPatches_(e,i,a,s),r(a,s)}return i}else Co(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(s,...o)=>this.produceWithPatches(s,c=>e(c,...o));let r,i;return[this.produce(e,n,(s,o)=>{r=s,i=o}),r,i]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){qh(t)||Co(8),wm(t)&&(t=Sme(t));const e=Dz(this),n=a3(t,void 0);return n[Cs].isManual_=!0,r3(e),n}finishDraft(t,e){const n=t&&t[Cs];(!n||!n.isManual_)&&Co(9);const{scope_:r}=n;return Rz(r,e),jz(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const i=e[n];if(i.path.length===0&&i.op==="replace"){t=i.value;break}}n>-1&&(e=e.slice(n+1));const r=Kh("Patches").applyPatches_;return wm(t)?r(t,e):this.produce(t,i=>r(i,e))}};function a3(t,e){const n=Ab(t)?Kh("MapSet").proxyMap_(t,e):lM(t)?Kh("MapSet").proxySet_(t,e):vme(t,e);return(e?e.scope_:nq()).drafts_.push(n),n}function Sme(t){return wm(t)||Co(10,t),iq(t)}function iq(t){if(!qh(t)||cM(t))return t;const e=t[Cs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=t3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=t3(t,!0);return W1(n,(i,a)=>{tq(n,i,iq(a))},r),e&&(e.finalized_=!1),n}var Mme=new wme;Mme.produce;var Eme={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},aq=Qa({name:"legend",initialState:Eme,reducers:{setLegendSize(t,e){t.size.width=e.payload.width,t.size.height=e.payload.height},setLegendSettings(t,e){t.settings.align=e.payload.align,t.settings.layout=e.payload.layout,t.settings.verticalAlign=e.payload.verticalAlign,t.settings.itemSorter=e.payload.itemSorter},addLegendPayload:{reducer(t,e){t.payload.push(e.payload)},prepare:fr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:fr()},removeLegendPayload:{reducer(t,e){var n=Lo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:fr()}}}),{setLegendSize:Lz,setLegendSettings:Ame,addLegendPayload:sq,replaceLegendPayload:oq,removeLegendPayload:lq}=aq.actions,Tme=aq.reducer,Cme=["contextPayload"];function s3(){return s3=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},s3.apply(null,arguments)}function Iz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Iz(Object(n),!0).forEach(function(r){Nme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Iz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Nme(t,e,n){return(e=kme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kme(t){var e=Pme(t,"string");return typeof e=="symbol"?e:e+""}function Pme(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Rme(t,e){if(t==null)return{};var n,r,i=Dme(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Dme(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 jme(t){return t.value}function Ome(t){var{contextPayload:e}=t,n=Rme(t,Cme),r=aW(e,t.payloadUniqBy,jme),i=Sm(Sm({},n),{},{payload:r});return E.isValidElement(t.content)?E.cloneElement(t.content,i):typeof t.content=="function"?E.createElement(t.content,i):E.createElement(Che,i)}function Lme(t,e,n,r,i,a){var{layout:s,align:o,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&s==="vertical"?u={left:((r||0)-a.width)/2}:u=o==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(c==="middle"?d={top:((i||0)-a.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Sm(Sm({},u),d)}function Ime(t){var e=rr();return E.useEffect(()=>{e(Ame(t))},[e,t]),null}function Fme(t){var e=rr();return E.useEffect(()=>(e(Lz(t)),()=>{e(Lz({width:0,height:0}))}),[e,t]),null}function Ume(t,e,n,r){return t==="vertical"&&Pt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var zme={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function vD(t){var e=Sr(t,zme),n=yfe(),r=vde(),i=dme(),{width:a,height:s,wrapperStyle:o,portal:c}=e,[u,d]=dW([n]),f=gD(),g=xD();if(f==null||g==null)return null;var m=f-(i?.left||0)-(i?.right||0),x=Ume(e.layout,s,a,m),v=c?o:Sm(Sm({position:"absolute",width:x?.width||a||"auto",height:x?.height||s||"auto"},Lme(o,e,i,f,g,u)),o),y=c??r;if(y==null||n==null)return null;var b=E.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:d},E.createElement(Ime,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&E.createElement(Fme,{width:u.width,height:u.height}),E.createElement(Ome,s3({},e,x,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return hc.createPortal(b,y)}vD.displayName="Legend";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 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 LT(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){Bme(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 Bme(t,e,n){return(e=Hme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Hme(t){var e=$me(t,"string");return typeof e=="symbol"?e:e+""}function $me(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Vme(t){return Array.isArray(t)&&co(t[0])&&co(t[1])?t.join(" ~ "):t}var Gme=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:s,itemSorter:o,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:g=!1}=t,m=()=>{if(a&&a.length){var T={padding:0,margin:0},k=(o?qS(a,o):a).map((N,I)=>{if(N.type==="none")return null;var C=N.formatter||s||Vme,{value:D,name:F}=N,O=D,q=F;if(C){var R=C(D,F,N,I,a);if(Array.isArray(R))[O,q]=R;else if(R!=null)O=R;else return null}var W=LT({display:"block",paddingTop:4,paddingBottom:4,color:N.color||"#000"},r);return E.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(I),style:W},co(q)?E.createElement("span",{className:"recharts-tooltip-item-name"},q):null,co(q)?E.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,E.createElement("span",{className:"recharts-tooltip-item-value"},O),E.createElement("span",{className:"recharts-tooltip-item-unit"},N.unit||""))});return E.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),v=LT({margin:0},i),y=!dr(d),b=y?d:"",M=Mn("recharts-default-tooltip",c),S=Mn("recharts-tooltip-label",u);y&&f&&a!==void 0&&a!==null&&(b=f(d,a));var A=g?{role:"status","aria-live":"assertive"}:{};return E.createElement("div",o3({className:M,style:x},A),E.createElement("p",{className:S,style:v},E.isValidElement(b)?b:"".concat(b)),m())},ox="recharts-tooltip-wrapper",Wme={visibility:"hidden"};function qme(t){var{coordinate:e,translateX:n,translateY:r}=t;return Mn(ox,{["".concat(ox,"-right")]:Pt(n)&&e&&Pt(e.x)&&n>=e.x,["".concat(ox,"-left")]:Pt(n)&&e&&Pt(e.x)&&n<e.x,["".concat(ox,"-bottom")]:Pt(r)&&e&&Pt(e.y)&&r>=e.y,["".concat(ox,"-top")]:Pt(r)&&e&&Pt(e.y)&&r<e.y})}function Uz(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:s,tooltipDimension:o,viewBox:c,viewBoxDimension:u}=t;if(a&&Pt(a[r]))return a[r];var d=n[r]-o-(i>0?i:0),f=n[r]+i;if(e[r])return s[r]?d:f;var g=c[r];if(g==null)return 0;if(s[r]){var m=d,x=g;return m<x?Math.max(f,g):Math.max(d,g)}if(u==null)return 0;var v=f+o,y=g+u;return v>y?Math.max(d,g):Math.max(f,g)}function Kme(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 Xme(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:s,useTranslate3d:o,viewBox:c}=t,u,d,f;return s.height>0&&s.width>0&&n?(d=Uz({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.width,viewBox:c,viewBoxDimension:c.width}),f=Uz({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.height,viewBox:c,viewBoxDimension:c.height}),u=Kme({translateX:d,translateY:f,useTranslate3d:o})):u=Wme,{cssProperties:u,cssClasses:qme({translateX:d,translateY:f,coordinate:n})}}function zz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ev(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zz(Object(n),!0).forEach(function(r){l3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function l3(t,e,n){return(e=Yme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Yme(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)}class Qme extends E.PureComponent{constructor(){super(...arguments),l3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),l3(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:a,coordinate:s,hasPayload:o,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:g,viewBox:m,wrapperStyle:x,lastBoundingBox:v,innerRef:y,hasPortalFromProps:b}=this.props,{cssClasses:M,cssProperties:S}=Xme({allowEscapeViewBox:n,coordinate:s,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:v.height,width:v.width},useTranslate3d:g,viewBox:m}),A=b?{}:Ev(Ev({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},S),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&o?"visible":"hidden",position:"absolute",top:0,left:0}),T=Ev(Ev({},A),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},x);return E.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:M,style:T,ref:y},a)}}var cq=()=>{var t;return(t=Ct(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function c3(){return c3=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},c3.apply(null,arguments)}function Bz(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 Hz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Bz(Object(n),!0).forEach(function(r){Jme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Bz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jme(t,e,n){return(e=ege(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ege(t){var e=tge(t,"string");return typeof e=="symbol"?e:e+""}function tge(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 $z={curveBasisClosed:Ude,curveBasisOpen:zde,curveBasis:Fde,curveBumpX:Mde,curveBumpY:Ede,curveLinearClosed:Bde,curveLinear:GS,curveMonotoneX:Hde,curveMonotoneY:$de,curveNatural:Vde,curveStep:Gde,curveStepAfter:qde,curveStepBefore:Wde},X1=t=>Hn(t.x)&&Hn(t.y),Vz=t=>t.base!=null&&X1(t.base)&&X1(t),lx=t=>t.x,cx=t=>t.y,nge=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(bb(t));return(n==="curveMonotone"||n==="curveBump")&&e?$z["".concat(n).concat(e==="vertical"?"Y":"X")]:$z[n]||GS},rge=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,s=nge(e,i),o=a?n.filter(X1):n,c;if(Array.isArray(r)){var u=n.map((m,x)=>Hz(Hz({},m),{},{base:r[x]}));i==="vertical"?c=xv().y(cx).x1(lx).x0(m=>m.base.x):c=xv().x(lx).y1(cx).y0(m=>m.base.y);var d=c.defined(Vz).curve(s),f=a?u.filter(Vz):u;return d(f)}i==="vertical"&&Pt(r)?c=xv().y(cx).x1(lx).x0(r):Pt(r)?c=xv().x(lx).y1(cx).y0(r):c=jG().x(lx).y(cx);var g=c.defined(X1).curve(s);return g(o)},tm=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?rge(t):r;return E.createElement("path",c3({},Ca(t),rD(t),{className:Mn("recharts-curve",e),d:a===null?void 0:a,ref:i}))},ige=["x","y","top","left","width","height","className"];function u3(){return u3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},u3.apply(null,arguments)}function Gz(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 age(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Gz(Object(n),!0).forEach(function(r){sge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Gz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sge(t,e,n){return(e=oge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oge(t){var e=lge(t,"string");return typeof e=="symbol"?e:e+""}function lge(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 cge(t,e){if(t==null)return{};var n,r,i=uge(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function uge(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 dge=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),hge=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:s=0,className:o}=t,c=cge(t,ige),u=age({x:e,y:n,top:r,left:i,width:a,height:s},c);return!Pt(e)||!Pt(n)||!Pt(a)||!Pt(s)||!Pt(r)||!Pt(i)?null:E.createElement("path",u3({},na(u),{className:Mn("recharts-cross",o),d:dge(e,n,a,s,r,i)}))};function fge(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 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 qz(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){pge(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 pge(t,e,n){return(e=mge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mge(t){var e=gge(t,"string");return typeof e=="symbol"?e:e+""}function gge(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 xge=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),uq=(t,e,n)=>t.map(r=>"".concat(xge(r)," ").concat(e,"ms ").concat(n)).join(","),bge=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),j0=(t,e)=>Object.keys(e).reduce((n,r)=>qz(qz({},n),{},{[r]:t(r,e[r])}),{});function Kz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ui(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Kz(Object(n),!0).forEach(function(r){yge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Kz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function yge(t,e,n){return(e=vge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vge(t){var e=_ge(t,"string");return typeof e=="symbol"?e:e+""}function _ge(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,d3=t=>{var{from:e,to:n}=t;return e!==n},dq=(t,e,n)=>{var r=j0((i,a)=>{if(d3(a)){var[s,o]=t(a.from,a.to,a.velocity);return ui(ui({},a),{},{from:s,velocity:o})}return a},e);return n<1?j0((i,a)=>d3(a)?ui(ui({},a),{},{velocity:Y1(a.velocity,r[i].velocity,n),from:Y1(a.from,r[i].from,n)}):a,e):dq(t,r,n-1)};function wge(t,e,n,r,i,a){var s,o=r.reduce((g,m)=>ui(ui({},g),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),c=()=>j0((g,m)=>m.from,o),u=()=>!Object.values(o).filter(d3).length,d=null,f=g=>{s||(s=g);var m=g-s,x=m/n.dt;o=dq(n,o,x),i(ui(ui(ui({},t),e),c())),s=g,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var g;(g=d)===null||g===void 0||g()})}function Sge(t,e,n,r,i,a,s){var o=null,c=i.reduce((f,g)=>ui(ui({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,m=j0((v,y)=>Y1(...y,n(g)),c);if(a(ui(ui(ui({},t),e),m)),g<1)o=s.setTimeout(d);else{var x=j0((v,y)=>Y1(...y,n(1)),c);a(ui(ui(ui({},t),e),x))}};return()=>(o=s.setTimeout(d),()=>{var f;(f=o)===null||f===void 0||f()})}const Mge=(t,e,n,r,i,a)=>{var s=bge(t,e);return n==null?()=>(i(ui(ui({},t),e)),()=>{}):n.isStepper===!0?wge(t,e,n,s,i,a):Sge(t,e,n,r,s,i,a)};var Z1=1e-4,hq=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],fq=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),Xz=(t,e)=>n=>{var r=hq(t,e);return fq(r,n)},Ege=(t,e)=>n=>{var r=hq(t,e),i=[...r.map((a,s)=>a*s).slice(1),0];return fq(i,n)},Age=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var s=a[1].split(")")[0].split(",").map(o=>parseFloat(o));return[s[0],s[1],s[2],s[3]]}}}return n.length===4?n:[0,0,1,1]},Tge=(t,e,n,r)=>{var i=Xz(t,n),a=Xz(e,r),s=Ege(t,n),o=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,g=0;g<8;++g){var m=i(f)-d,x=s(f);if(Math.abs(m-d)<Z1||x<Z1)return a(f);f=o(f-m/x)}return a(f)};return c.isStepper=!1,c},Yz=function(){return Tge(...Age(...arguments))},Cge=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(s,o,c)=>{var u=-(s-o)*n,d=c*r,f=c+(u-d)*i/1e3,g=c*i/1e3+s;return Math.abs(g-o)<Z1&&Math.abs(f)<Z1?[o,0]:[g,f]};return a.isStepper=!0,a.dt=i,a},Nge=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return Yz(t);case"spring":return Cge();default:if(t.split("(")[0]==="cubic-bezier")return Yz(t)}return typeof t=="function"?t:null};function kge(t){var e,n=()=>null,r=!1,i=null,a=s=>{if(!r){if(Array.isArray(s)){if(!s.length)return;var o=s,[c,...u]=o;if(typeof c=="number"){i=t.setTimeout(a.bind(null,u),c);return}a(c),i=t.setTimeout(a.bind(null,u));return}typeof s=="string"&&(e=s,n(e)),typeof s=="object"&&(e=s,n(e)),typeof s=="function"&&s()}};return{stop:()=>{r=!0},start:s=>{r=!1,i&&(i(),i=null),a(s)},subscribe:s=>(n=s,()=>{n=()=>null}),getTimeoutController:()=>t}}class Pge{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=s=>{s-r>=n?e(s):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function Rge(){return kge(new Pge)}var Dge=E.createContext(Rge);function jge(t,e){var n=E.useContext(Dge);return E.useMemo(()=>e??n(t),[t,e,n])}var Oge=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Ym={devToolsEnabled:!1,isSsr:Oge()},Lge={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},Zz={t:0},IT={t:1};function Zm(t){var e=Sr(t,Lge),{isActive:n,canBegin:r,duration:i,easing:a,begin:s,onAnimationEnd:o,onAnimationStart:c,children:u}=e,d=n==="auto"?!Ym.isSsr:n,f=jge(e.animationId,e.animationManager),[g,m]=E.useState(d?Zz:IT),x=E.useRef(null);return E.useEffect(()=>{d||m(IT)},[d]),E.useEffect(()=>{if(!d||!r)return yb;var v=Mge(Zz,IT,Nge(a),i,m,f.getTimeoutController()),y=()=>{x.current=v()};return f.start([c,s,y,i,o]),()=>{f.stop(),x.current&&x.current(),o()}},[d,r,i,a,s,c,o,f]),u(g.t)}function Qm(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=E.useRef(T0(e)),r=E.useRef(t);return r.current!==t&&(n.current=T0(e),r.current=t),n.current}var Ige=["radius"],Fge=["radius"];function Qz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Jz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Qz(Object(n),!0).forEach(function(r){Uge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Qz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Uge(t,e,n){return(e=zge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zge(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)}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 eB(t,e){if(t==null)return{};var n,r,i=Hge(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Hge(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 tB=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),s=r>=0?1:-1,o=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,g=4;f<g;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+s*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+o*d[0],",").concat(e)),u+="L ".concat(t+n-o*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
- `).concat(t+n,",").concat(e+s*d[1])),u+="L ".concat(t+n,",").concat(e+r-s*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
- `).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-s*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var m=Math.min(a,i);u="M ".concat(t,",").concat(e+s*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+s*m,`
- L `).concat(t+n,",").concat(e+r-s*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-s*m," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},nB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},pq=t=>{var e=Sr(t,nB),n=E.useRef(null),[r,i]=E.useState(-1);E.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var G=n.current.getTotalLength();G&&i(G)}catch{}},[]);var{x:a,y:s,width:o,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:g,animationBegin:m,isAnimationActive:x,isUpdateAnimationActive:v}=e,y=E.useRef(o),b=E.useRef(c),M=E.useRef(a),S=E.useRef(s),A=E.useMemo(()=>({x:a,y:s,width:o,height:c,radius:u}),[a,s,o,c,u]),T=Qm(A,"rectangle-");if(a!==+a||s!==+s||o!==+o||c!==+c||o===0||c===0)return null;var k=Mn("recharts-rectangle",d);if(!v){var N=na(e),{radius:I}=N,C=eB(N,Ige);return E.createElement("path",Q1({},C,{radius:typeof u=="number"?u:void 0,className:k,d:tB(a,s,o,c,u)}))}var D=y.current,F=b.current,O=M.current,q=S.current,R="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),K=uq(["strokeDasharray"],g,typeof f=="string"?f:nB.animationEasing);return E.createElement(Zm,{animationId:T,key:T,canBegin:r>0,duration:g,easing:f,isActive:v,begin:m},G=>{var ee=jn(D,o,G),Z=jn(F,c,G),Q=jn(O,a,G),U=jn(q,s,G);n.current&&(y.current=ee,b.current=Z,M.current=Q,S.current=U);var $;x?G>0?$={transition:K,strokeDasharray:W}:$={strokeDasharray:R}:$={strokeDasharray:W};var X=na(e),{radius:te}=X,fe=eB(X,Fge);return E.createElement("path",Q1({},fe,{radius:typeof u=="number"?u:void 0,className:k,d:tB(Q,U,ee,Z,u),ref:n,style:Jz(Jz({},$),e.style)}))})};function rB(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 iB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rB(Object(n),!0).forEach(function(r){$ge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $ge(t,e,n){return(e=Vge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vge(t){var e=Gge(t,"string");return typeof e=="symbol"?e:e+""}function Gge(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,Wge=t=>t*180/Math.PI,Jr=(t,e,n,r)=>({x:t+Math.cos(-J1*r)*n,y:e+Math.sin(-J1*r)*n}),mq=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},qge=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},Kge=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,s=qge({x:n,y:r},{x:i,y:a});if(s<=0)return{radius:s,angle:0};var o=(n-i)/s,c=Math.acos(o);return r>a&&(c=2*Math.PI-c),{radius:s,angle:Wge(c),angleInRadian:c}},Xge=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:e-a*360,endAngle:n-a*360}},Yge=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),s=Math.min(i,a);return t+s*360},Zge=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=Kge({x:n,y:r},e),{innerRadius:s,outerRadius:o}=e;if(i<s||i>o||i===0)return null;var{startAngle:c,endAngle:u}=Xge(e),d=a,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?iB(iB({},e),{},{radius:i,angle:Yge(d,e)}):null};function gq(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,s=Jr(e,n,r,i),o=Jr(e,n,r,a);return{points:[s,o],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function h3(){return h3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},h3.apply(null,arguments)}var Qge=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Av=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:s,cornerRadius:o,cornerIsExternal:c}=t,u=o*(s?1:-1)+r,d=Math.asin(o/u)/J1,f=c?i:i+a*d,g=Jr(e,n,u,f),m=Jr(e,n,r,f),x=c?i-a*d:i,v=Jr(e,n,u*Math.cos(d*J1),x);return{center:g,circleTangency:m,lineTangency:v,theta:d}},xq=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:s}=t,o=Qge(a,s),c=a+o,u=Jr(e,n,i,a),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(+(a>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var g=Jr(e,n,r,a),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(+(a<=c),`,
- `).concat(g.x,",").concat(g.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},Jge=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:s,cornerIsExternal:o,startAngle:c,endAngle:u}=t,d=Li(u-c),{circleTangency:f,lineTangency:g,theta:m}=Av({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:o}),{circleTangency:x,lineTangency:v,theta:y}=Av({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:o}),b=o?Math.abs(c-u):Math.abs(c-u)-m-y;if(b<0)return s?"M ".concat(g.x,",").concat(g.y,`
- a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
- a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
- `):xq({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var M="M ".concat(g.x,",").concat(g.y,`
- A`).concat(a,",").concat(a,",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(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(v.x,",").concat(v.y,`
- `);if(r>0){var{circleTangency:S,lineTangency:A,theta:T}=Av({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),{circleTangency:k,lineTangency:N,theta:I}=Av({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),C=o?Math.abs(c-u):Math.abs(c-u)-T-I;if(C<0&&a===0)return"".concat(M,"L").concat(e,",").concat(n,"Z");M+="L".concat(N.x,",").concat(N.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(k.x,",").concat(k.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(C>180),",").concat(+(d>0),",").concat(S.x,",").concat(S.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else M+="L".concat(e,",").concat(n,"Z");return M},exe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},bq=t=>{var e=Sr(t,exe),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var g=Mn("recharts-sector",f),m=a-i,x=pa(s,m,0,!0),v;return x>0&&Math.abs(u-d)<360?v=Jge({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,m/2),forceCornerRadius:o,cornerIsExternal:c,startAngle:u,endAngle:d}):v=xq({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),E.createElement("path",h3({},na(e),{className:g,d:v}))};function txe(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(XG(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:s,angle:o}=e,c=Jr(r,i,a,o),u=Jr(r,i,s,o);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return gq(e)}}var FT={},UT={},zT={},aB;function nxe(){return aB||(aB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lW();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(zT)),zT}var sB;function rxe(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nxe();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})(UT)),UT}var oB;function ixe(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cW(),n=rxe();function r(i,a,s){s&&typeof s!="number"&&e.isIterateeCall(i,a,s)&&(a=s=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),s=s===void 0?i<a?1:-1:n.toFinite(s);const o=Math.max(Math.ceil((a-i)/(s||1)),0),c=new Array(o);for(let u=0;u<o;u++)c[u]=i,i+=s;return c}t.range=r})(FT)),FT}var BT,lB;function axe(){return lB||(lB=1,BT=ixe().range),BT}var sxe=axe();const yq=fo(sxe);function Ku(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function oxe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function _D(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===oxe?t:lxe,n=t,r=t);function i(o,c,u=0,d=o.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(o[f],c)<0?u=f+1:d=f}while(u<d)}return u}function a(o,c,u=0,d=o.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(o[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function s(o,c,u=0,d=o.length){const f=i(o,c,u,d-1);return f>u&&r(o[f-1],c)>-r(o[f],c)?f-1:f}return{left:i,center:s,right:a}}function lxe(){return 0}function vq(t){return t===null?NaN:+t}function*cxe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const uxe=_D(Ku),Tb=uxe.right;_D(vq).center;class cB extends Map{constructor(e,n=fxe){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(uB(this,e))}has(e){return super.has(uB(this,e))}set(e,n){return super.set(dxe(this,e),n)}delete(e){return super.delete(hxe(this,e))}}function uB({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function dxe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function hxe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function fxe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function pxe(t=Ku){if(t===Ku)return _q;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 _q(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const mxe=Math.sqrt(50),gxe=Math.sqrt(10),xxe=Math.sqrt(2);function ew(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),s=a>=mxe?10:a>=gxe?5:a>=xxe?2:1;let o,c,u;return i<0?(u=Math.pow(10,-i)/s,o=Math.round(t*u),c=Math.round(e*u),o/u<t&&++o,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*s,o=Math.round(t/u),c=Math.round(e/u),o*u<t&&++o,c*u>e&&--c),c<o&&.5<=n&&n<2?ew(t,e,n*2):[o,c,u]}function f3(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,s]=r?ew(e,t,n):ew(t,e,n);if(!(a>=i))return[];const o=a-i+1,c=new Array(o);if(r)if(s<0)for(let u=0;u<o;++u)c[u]=(a-u)/-s;else for(let u=0;u<o;++u)c[u]=(a-u)*s;else if(s<0)for(let u=0;u<o;++u)c[u]=(i+u)/-s;else for(let u=0;u<o;++u)c[u]=(i+u)*s;return c}function p3(t,e,n){return e=+e,t=+t,n=+n,ew(t,e,n)[2]}function m3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?p3(e,t,n):p3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function dB(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function hB(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function wq(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?_q:pxe(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));wq(t,e,m,x,i)}const a=t[e];let s=n,o=r;for(ux(t,n,e),i(t[r],a)>0&&ux(t,n,r);s<o;){for(ux(t,s,o),++s,--o;i(t[s],a)<0;)++s;for(;i(t[o],a)>0;)--o}i(t[n],a)===0?ux(t,n,o):(++o,ux(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function ux(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function bxe(t,e,n){if(t=Float64Array.from(cxe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return hB(t);if(e>=1)return dB(t);var r,i=(r-1)*e,a=Math.floor(i),s=dB(wq(t,a).subarray(0,a+1)),o=hB(t.subarray(a+1));return s+(o-s)*(i-a)}}function yxe(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,a=Math.floor(i),s=+n(t[a],a,t),o=+n(t[a+1],a+1,t);return s+(o-s)*(i-a)}}function vxe(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(i);++r<i;)a[r]=t+r*n;return a}function po(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Uc(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 g3=Symbol("implicit");function wD(){var t=new cB,e=[],n=[],r=g3;function i(a){let s=t.get(a);if(s===void 0){if(r!==g3)return r;t.set(a,s=e.push(a)-1)}return n[s%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new cB;for(const s of a)t.has(s)||t.set(s,e.push(s)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return wD(e,n).unknown(r)},po.apply(i,arguments),i}function SD(){var t=wD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,s,o=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var g=e().length,m=i<r,x=m?i:r,v=m?r:i;a=(v-x)/Math.max(1,g-c+u*2),o&&(a=Math.floor(a)),x+=(v-x-a*(g-c))*d,s=a*(1-c),o&&(x=Math.round(x),s=Math.round(s));var y=vxe(g).map(function(b){return x+a*b});return n(m?y.reverse():y)}return t.domain=function(g){return arguments.length?(e(g),f()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,o=!0,f()},t.bandwidth=function(){return s},t.step=function(){return a},t.round=function(g){return arguments.length?(o=!!g,f()):o},t.padding=function(g){return arguments.length?(c=Math.min(1,u=+g),f()):c},t.paddingInner=function(g){return arguments.length?(c=Math.min(1,g),f()):c},t.paddingOuter=function(g){return arguments.length?(u=+g,f()):u},t.align=function(g){return arguments.length?(d=Math.max(0,Math.min(1,g)),f()):d},t.copy=function(){return SD(e(),[r,i]).round(o).paddingInner(c).paddingOuter(u).align(d)},po.apply(f(),arguments)}function Sq(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return Sq(e())},t}function _xe(){return Sq(SD.apply(null,arguments).paddingInner(1))}function MD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Mq(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Cb(){}var O0=.7,tw=1/O0,nm="\\s*([+-]?\\d+)\\s*",L0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",cl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",wxe=/^#([0-9a-f]{3,8})$/,Sxe=new RegExp(`^rgb\\(${nm},${nm},${nm}\\)$`),Mxe=new RegExp(`^rgb\\(${cl},${cl},${cl}\\)$`),Exe=new RegExp(`^rgba\\(${nm},${nm},${nm},${L0}\\)$`),Axe=new RegExp(`^rgba\\(${cl},${cl},${cl},${L0}\\)$`),Txe=new RegExp(`^hsl\\(${L0},${cl},${cl}\\)$`),Cxe=new RegExp(`^hsla\\(${L0},${cl},${cl},${L0}\\)$`),fB={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};MD(Cb,I0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:pB,formatHex:pB,formatHex8:Nxe,formatHsl:kxe,formatRgb:mB,toString:mB});function pB(){return this.rgb().formatHex()}function Nxe(){return this.rgb().formatHex8()}function kxe(){return Eq(this).formatHsl()}function mB(){return this.rgb().formatRgb()}function I0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=wxe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?gB(e):n===3?new Wa(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Tv(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Tv(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=Sxe.exec(t))?new Wa(e[1],e[2],e[3],1):(e=Mxe.exec(t))?new Wa(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Exe.exec(t))?Tv(e[1],e[2],e[3],e[4]):(e=Axe.exec(t))?Tv(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Txe.exec(t))?yB(e[1],e[2]/100,e[3]/100,1):(e=Cxe.exec(t))?yB(e[1],e[2]/100,e[3]/100,e[4]):fB.hasOwnProperty(t)?gB(fB[t]):t==="transparent"?new Wa(NaN,NaN,NaN,0):null}function gB(t){return new Wa(t>>16&255,t>>8&255,t&255,1)}function Tv(t,e,n,r){return r<=0&&(t=e=n=NaN),new Wa(t,e,n,r)}function Pxe(t){return t instanceof Cb||(t=I0(t)),t?(t=t.rgb(),new Wa(t.r,t.g,t.b,t.opacity)):new Wa}function x3(t,e,n,r){return arguments.length===1?Pxe(t):new Wa(t,e,n,r??1)}function Wa(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}MD(Wa,x3,Mq(Cb,{brighter(t){return t=t==null?tw:Math.pow(tw,t),new Wa(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?O0:Math.pow(O0,t),new Wa(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Wa(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:xB,formatHex:xB,formatHex8:Rxe,formatRgb:bB,toString:bB}));function xB(){return`#${fh(this.r)}${fh(this.g)}${fh(this.b)}`}function Rxe(){return`#${fh(this.r)}${fh(this.g)}${fh(this.b)}${fh((isNaN(this.opacity)?1:this.opacity)*255)}`}function bB(){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 yB(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new No(t,e,n,r)}function Eq(t){if(t instanceof No)return new No(t.h,t.s,t.l,t.opacity);if(t instanceof Cb||(t=I0(t)),!t)return new No;if(t instanceof No)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),s=NaN,o=a-i,c=(a+i)/2;return o?(e===a?s=(n-r)/o+(n<r)*6:n===a?s=(r-e)/o+2:s=(e-n)/o+4,o/=c<.5?a+i:2-a-i,s*=60):o=c>0&&c<1?0:s,new No(s,o,c,t.opacity)}function Dxe(t,e,n,r){return arguments.length===1?Eq(t):new No(t,e,n,r??1)}function No(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}MD(No,Dxe,Mq(Cb,{brighter(t){return t=t==null?tw:Math.pow(tw,t),new No(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?O0:Math.pow(O0,t),new No(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Wa(HT(t>=240?t-240:t+120,i,r),HT(t,i,r),HT(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new No(vB(this.h),Cv(this.s),Cv(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("}${vB(this.h)}, ${Cv(this.s)*100}%, ${Cv(this.l)*100}%${t===1?")":`, ${t})`}`}}));function vB(t){return t=(t||0)%360,t<0?t+360:t}function Cv(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 ED=t=>()=>t;function jxe(t,e){return function(n){return t+n*e}}function Oxe(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function Lxe(t){return(t=+t)==1?Aq:function(e,n){return n-e?Oxe(e,n,t):ED(isNaN(e)?n:e)}}function Aq(t,e){var n=e-t;return n?jxe(t,n):ED(isNaN(t)?e:t)}const _B=(function t(e){var n=Lxe(e);function r(i,a){var s=n((i=x3(i)).r,(a=x3(a)).r),o=n(i.g,a.g),c=n(i.b,a.b),u=Aq(i.opacity,a.opacity);return function(d){return i.r=s(d),i.g=o(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function Ixe(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=t[i]*(1-a)+e[i]*a;return r}}function Fxe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Uxe(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),s;for(s=0;s<r;++s)i[s]=Jm(t[s],e[s]);for(;s<n;++s)a[s]=e[s];return function(o){for(s=0;s<r;++s)a[s]=i[s](o);return a}}function zxe(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 Bxe(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=Jm(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var b3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$T=new RegExp(b3.source,"g");function Hxe(t){return function(){return t}}function $xe(t){return function(e){return t(e)+""}}function Vxe(t,e){var n=b3.lastIndex=$T.lastIndex=0,r,i,a,s=-1,o=[],c=[];for(t=t+"",e=e+"";(r=b3.exec(t))&&(i=$T.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),o[s]?o[s]+=a:o[++s]=a),(r=r[0])===(i=i[0])?o[s]?o[s]+=i:o[++s]=i:(o[++s]=null,c.push({i:s,x:rw(r,i)})),n=$T.lastIndex;return n<e.length&&(a=e.slice(n),o[s]?o[s]+=a:o[++s]=a),o.length<2?c[0]?$xe(c[0].x):Hxe(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)o[(f=c[d]).i]=f.x(u);return o.join("")})}function Jm(t,e){var n=typeof e,r;return e==null||n==="boolean"?ED(e):(n==="number"?rw:n==="string"?(r=I0(e))?(e=r,_B):Vxe:e instanceof I0?_B:e instanceof Date?zxe:Fxe(e)?Ixe:Array.isArray(e)?Uxe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Bxe:rw)(t,e)}function AD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Gxe(t,e){e===void 0&&(e=t,t=Jm);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(s){var o=Math.max(0,Math.min(r-1,Math.floor(s*=r)));return a[o](s-o)}}function Wxe(t){return function(){return t}}function iw(t){return+t}var wB=[0,1];function Ma(t){return t}function y3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Wxe(isNaN(e)?NaN:.5)}function qxe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Kxe(t,e,n){var r=t[0],i=t[1],a=e[0],s=e[1];return i<r?(r=y3(i,r),a=n(s,a)):(r=y3(r,i),a=n(a,s)),function(o){return a(r(o))}}function Xxe(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)i[s]=y3(t[s],t[s+1]),a[s]=n(e[s],e[s+1]);return function(o){var c=Tb(t,o,1,r)-1;return a[c](i[c](o))}}function Nb(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function uM(){var t=wB,e=wB,n=Jm,r,i,a,s=Ma,o,c,u;function d(){var g=Math.min(t.length,e.length);return s!==Ma&&(s=qxe(t[0],t[g-1])),o=g>2?Xxe:Kxe,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?a:(c||(c=o(t.map(r),e,n)))(r(s(g)))}return f.invert=function(g){return s(i((u||(u=o(e,t.map(r),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=AD,d()},f.clamp=function(g){return arguments.length?(s=g?!0:Ma,d()):s!==Ma},f.interpolate=function(g){return arguments.length?(n=g,d()):n},f.unknown=function(g){return arguments.length?(a=g,f):a},function(g,m){return r=g,i=m,d()}}function TD(){return uM()(Ma,Ma)}function Yxe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function aw(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 Mm(t){return t=aw(Math.abs(t)),t?t[1]:NaN}function Zxe(t,e){return function(n,r){for(var i=n.length,a=[],s=0,o=t[0],c=0;i>0&&o>0&&(c+o+1>r&&(o=Math.max(1,r-c)),a.push(n.substring(i-=o,i+o)),!((c+=o+1)>r));)o=t[s=(s+1)%t.length];return a.reverse().join(e)}}function Qxe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Jxe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function F0(t){if(!(e=Jxe.exec(t)))throw new Error("invalid format: "+t);var e;return new CD({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]})}F0.prototype=CD.prototype;function CD(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+""}CD.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 e0e(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 Tq;function t0e(t,e){var n=aw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(Tq=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,s=r.length;return a===s?r:a>s?r+new Array(a-s+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+aw(t,Math.max(0,e+a-1))[0]}function SB(t,e){var n=aw(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 MB={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Yxe,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)=>SB(t*100,e),r:SB,s:t0e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function EB(t){return t}var AB=Array.prototype.map,TB=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function n0e(t){var e=t.grouping===void 0||t.thousands===void 0?EB:Zxe(AB.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?EB:Qxe(AB.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=F0(f);var g=f.fill,m=f.align,x=f.sign,v=f.symbol,y=f.zero,b=f.width,M=f.comma,S=f.precision,A=f.trim,T=f.type;T==="n"?(M=!0,T="g"):MB[T]||(S===void 0&&(S=12),A=!0,T="g"),(y||g==="0"&&m==="=")&&(y=!0,g="0",m="=");var k=v==="$"?n:v==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",N=v==="$"?r:/[%p]/.test(T)?s:"",I=MB[T],C=/[defgprs%]/.test(T);S=S===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,S)):Math.max(0,Math.min(20,S));function D(F){var O=k,q=N,R,W,K;if(T==="c")q=I(F)+q,F="";else{F=+F;var G=F<0||1/F<0;if(F=isNaN(F)?c:I(Math.abs(F),S),A&&(F=e0e(F)),G&&+F==0&&x!=="+"&&(G=!1),O=(G?x==="("?x:o:x==="-"||x==="("?"":x)+O,q=(T==="s"?TB[8+Tq/3]:"")+q+(G&&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}}}M&&!y&&(F=e(F,1/0));var ee=O.length+F.length+q.length,Z=ee<b?new Array(b-ee+1).join(g):"";switch(M&&y&&(F=e(Z+F,Z.length?b-q.length:1/0),Z=""),m){case"<":F=O+F+q+Z;break;case"=":F=O+Z+F+q;break;case"^":F=Z.slice(0,ee=Z.length>>1)+O+F+q+Z.slice(ee);break;default:F=Z+O+F+q;break}return a(F)}return D.toString=function(){return f+""},D}function d(f,g){var m=u((f=F0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Mm(g)/3)))*3,v=Math.pow(10,-x),y=TB[8+x/3];return function(b){return m(v*b)+y}}return{format:u,formatPrefix:d}}var Nv,ND,Cq;r0e({thousands:",",grouping:[3],currency:["$",""]});function r0e(t){return Nv=n0e(t),ND=Nv.format,Cq=Nv.formatPrefix,Nv}function i0e(t){return Math.max(0,-Mm(Math.abs(t)))}function a0e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Mm(e)/3)))*3-Mm(Math.abs(t)))}function s0e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Mm(e)-Mm(t))+1}function Nq(t,e,n,r){var i=m3(t,e,n),a;switch(r=F0(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=a0e(i,s))&&(r.precision=a),Cq(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=s0e(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=i0e(i))&&(r.precision=a-(r.type==="%")*2);break}}return ND(r)}function vd(t){var e=t.domain;return t.ticks=function(n){var r=e();return f3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return Nq(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,s=r[i],o=r[a],c,u,d=10;for(o<s&&(u=s,s=o,o=u,u=i,i=a,a=u);d-- >0;){if(u=p3(s,o,n),u===c)return r[i]=s,r[a]=o,e(r);if(u>0)s=Math.floor(s/u)*u,o=Math.ceil(o/u)*u;else if(u<0)s=Math.ceil(s*u)/u,o=Math.floor(o*u)/u;else break;c=u}return t},t}function kq(){var t=TD();return t.copy=function(){return Nb(t,kq())},po.apply(t,arguments),vd(t)}function Pq(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 Pq(t).unknown(e)},t=arguments.length?Array.from(t,iw):[0,1],vd(n)}function Rq(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],s;return a<i&&(s=n,n=r,r=s,s=i,i=a,a=s),t[n]=e.floor(i),t[r]=e.ceil(a),t}function CB(t){return Math.log(t)}function NB(t){return Math.exp(t)}function o0e(t){return-Math.log(-t)}function l0e(t){return-Math.exp(-t)}function c0e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function u0e(t){return t===10?c0e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function d0e(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 kB(t){return(e,n)=>-t(-e,n)}function kD(t){const e=t(CB,NB),n=e.domain;let r=10,i,a;function s(){return i=d0e(r),a=u0e(r),n()[0]<0?(i=kB(i),a=kB(a),t(o0e,l0e)):t(CB,NB),e}return e.base=function(o){return arguments.length?(r=+o,s()):r},e.domain=function(o){return arguments.length?(n(o),s()):n()},e.ticks=o=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let g=i(u),m=i(d),x,v;const y=o==null?10:+o;let b=[];if(!(r%1)&&m-g<y){if(g=Math.floor(g),m=Math.ceil(m),u>0){for(;g<=m;++g)for(x=1;x<r;++x)if(v=g<0?x/a(-g):x*a(g),!(v<u)){if(v>d)break;b.push(v)}}else for(;g<=m;++g)for(x=r-1;x>=1;--x)if(v=g>0?x/a(-g):x*a(g),!(v<u)){if(v>d)break;b.push(v)}b.length*2<y&&(b=f3(u,d,y))}else b=f3(g,m,Math.min(m-g,y)).map(a);return f?b.reverse():b},e.tickFormat=(o,c)=>{if(o==null&&(o=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=F0(c)).precision==null&&(c.trim=!0),c=ND(c)),o===1/0)return c;const u=Math.max(1,r*o/e.ticks().length);return d=>{let f=d/a(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(Rq(n(),{floor:o=>a(Math.floor(i(o))),ceil:o=>a(Math.ceil(i(o)))})),e}function Dq(){const t=kD(uM()).domain([1,10]);return t.copy=()=>Nb(t,Dq()).base(t.base()),po.apply(t,arguments),t}function PB(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function RB(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function PD(t){var e=1,n=t(PB(e),RB(e));return n.constant=function(r){return arguments.length?t(PB(e=+r),RB(e)):e},vd(n)}function jq(){var t=PD(uM());return t.copy=function(){return Nb(t,jq()).constant(t.constant())},po.apply(t,arguments)}function DB(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function h0e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function f0e(t){return t<0?-t*t:t*t}function RD(t){var e=t(Ma,Ma),n=1;function r(){return n===1?t(Ma,Ma):n===.5?t(h0e,f0e):t(DB(n),DB(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},vd(e)}function DD(){var t=RD(uM());return t.copy=function(){return Nb(t,DD()).exponent(t.exponent())},po.apply(t,arguments),t}function p0e(){return DD.apply(null,arguments).exponent(.5)}function jB(t){return Math.sign(t)*t*t}function m0e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function Oq(){var t=TD(),e=[0,1],n=!1,r;function i(a){var s=m0e(t(a));return isNaN(s)?r:n?Math.round(s):s}return i.invert=function(a){return t.invert(jB(a))},i.domain=function(a){return arguments.length?(t.domain(a),i):t.domain()},i.range=function(a){return arguments.length?(t.range((e=Array.from(a,iw)).map(jB)),i):e.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(t.clamp(a),i):t.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return Oq(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},po.apply(i,arguments),vd(i)}function Lq(){var t=[],e=[],n=[],r;function i(){var s=0,o=Math.max(1,e.length);for(n=new Array(o-1);++s<o;)n[s-1]=yxe(t,s/o);return a}function a(s){return s==null||isNaN(s=+s)?r:e[Tb(n,s)]}return a.invertExtent=function(s){var o=e.indexOf(s);return o<0?[NaN,NaN]:[o>0?n[o-1]:t[0],o<n.length?n[o]:t[t.length-1]]},a.domain=function(s){if(!arguments.length)return t.slice();t=[];for(let o of s)o!=null&&!isNaN(o=+o)&&t.push(o);return t.sort(Ku),i()},a.range=function(s){return arguments.length?(e=Array.from(s),i()):e.slice()},a.unknown=function(s){return arguments.length?(r=s,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return Lq().domain(t).range(e).unknown(r)},po.apply(a,arguments)}function Iq(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function s(c){return c!=null&&c<=c?i[Tb(r,c,0,n)]:a}function o(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return s}return s.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,o()):[t,e]},s.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,o()):i.slice()},s.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},s.unknown=function(c){return arguments.length&&(a=c),s},s.thresholds=function(){return r.slice()},s.copy=function(){return Iq().domain([t,e]).range(i).unknown(a)},po.apply(vd(s),arguments)}function Fq(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Tb(t,a,0,r)]:n}return i.domain=function(a){return arguments.length?(t=Array.from(a),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(a){return arguments.length?(e=Array.from(a),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(a){var s=e.indexOf(a);return[t[s-1],t[s]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return Fq().domain(t).range(e).unknown(n)},po.apply(i,arguments)}const VT=new Date,GT=new Date;function vi(t,e,n,r){function i(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(t(a=new Date(+a)),a),i.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),i.round=a=>{const s=i(a),o=i.ceil(a);return a-s<o-a?s:o},i.offset=(a,s)=>(e(a=new Date(+a),s==null?1:Math.floor(s)),a),i.range=(a,s,o)=>{const c=[];if(a=i.ceil(a),o=o==null?1:Math.floor(o),!(a<s)||!(o>0))return c;let u;do c.push(u=new Date(+a)),e(a,o),t(a);while(u<a&&a<s);return c},i.filter=a=>vi(s=>{if(s>=s)for(;t(s),!a(s);)s.setTime(s-1)},(s,o)=>{if(s>=s)if(o<0)for(;++o<=0;)for(;e(s,-1),!a(s););else for(;--o>=0;)for(;e(s,1),!a(s););}),n&&(i.count=(a,s)=>(VT.setTime(+a),GT.setTime(+s),t(VT),t(GT),Math.floor(n(VT,GT))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?s=>r(s)%a===0:s=>i.count(0,s)%a===0):i)),i}const sw=vi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);sw.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):sw);sw.range;const fc=1e3,no=fc*60,pc=no*60,kc=pc*24,jD=kc*7,OB=kc*30,WT=kc*365,ph=vi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*fc)},(t,e)=>(e-t)/fc,t=>t.getUTCSeconds());ph.range;const OD=vi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*fc)},(t,e)=>{t.setTime(+t+e*no)},(t,e)=>(e-t)/no,t=>t.getMinutes());OD.range;const LD=vi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*no)},(t,e)=>(e-t)/no,t=>t.getUTCMinutes());LD.range;const ID=vi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*fc-t.getMinutes()*no)},(t,e)=>{t.setTime(+t+e*pc)},(t,e)=>(e-t)/pc,t=>t.getHours());ID.range;const FD=vi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*pc)},(t,e)=>(e-t)/pc,t=>t.getUTCHours());FD.range;const kb=vi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*no)/kc,t=>t.getDate()-1);kb.range;const dM=vi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/kc,t=>t.getUTCDate()-1);dM.range;const Uq=vi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/kc,t=>Math.floor(t/kc));Uq.range;function ff(t){return 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())*no)/jD)}const hM=ff(0),ow=ff(1),g0e=ff(2),x0e=ff(3),Em=ff(4),b0e=ff(5),y0e=ff(6);hM.range;ow.range;g0e.range;x0e.range;Em.range;b0e.range;y0e.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)/jD)}const fM=pf(0),lw=pf(1),v0e=pf(2),_0e=pf(3),Am=pf(4),w0e=pf(5),S0e=pf(6);fM.range;lw.range;v0e.range;_0e.range;Am.range;w0e.range;S0e.range;const UD=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());UD.range;const zD=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());zD.range;const Pc=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());Pc.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)});Pc.range;const Rc=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());Rc.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)});Rc.range;function zq(t,e,n,r,i,a){const s=[[ph,1,fc],[ph,5,5*fc],[ph,15,15*fc],[ph,30,30*fc],[a,1,no],[a,5,5*no],[a,15,15*no],[a,30,30*no],[i,1,pc],[i,3,3*pc],[i,6,6*pc],[i,12,12*pc],[r,1,kc],[r,2,2*kc],[n,1,jD],[e,1,OB],[e,3,3*OB],[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=_D(([,,y])=>y).right(s,g);if(m===s.length)return t.every(m3(u/WT,d/WT,f));if(m===0)return sw.every(Math.max(m3(u,d,f),1));const[x,v]=s[g/s[m-1][2]<s[m][2]/g?m-1:m];return x.every(v)}return[o,c]}const[M0e,E0e]=zq(Rc,zD,fM,Uq,FD,LD),[A0e,T0e]=zq(Pc,UD,hM,kb,ID,OD);function qT(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function KT(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function dx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function C0e(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,s=t.shortDays,o=t.months,c=t.shortMonths,u=hx(i),d=fx(i),f=hx(a),g=fx(a),m=hx(s),x=fx(s),v=hx(o),y=fx(o),b=hx(c),M=fx(c),S={a:G,A:ee,b:Z,B:Q,c:null,d:BB,e:BB,f:Z0e,g:obe,G:cbe,H:K0e,I:X0e,j:Y0e,L:Bq,m:Q0e,M:J0e,p:U,q:$,Q:VB,s:GB,S:ebe,u:tbe,U:nbe,V:rbe,w:ibe,W:abe,x:null,X:null,y:sbe,Y:lbe,Z:ube,"%":$B},A={a:X,A:te,b:fe,B:pe,c:null,d:HB,e:HB,f:pbe,g:Mbe,G:Abe,H:dbe,I:hbe,j:fbe,L:$q,m:mbe,M:gbe,p:xe,q:Ne,Q:VB,s:GB,S:xbe,u:bbe,U:ybe,V:vbe,w:_be,W:wbe,x:null,X:null,y:Sbe,Y:Ebe,Z:Tbe,"%":$B},T={a:D,A:F,b:O,B:q,c:R,d:UB,e:UB,f:V0e,g:FB,G:IB,H:zB,I:zB,j:z0e,L:$0e,m:U0e,M:B0e,p:C,q:F0e,Q:W0e,s:q0e,S:H0e,u:D0e,U:j0e,V:O0e,w:R0e,W:L0e,x:W,X:K,y:FB,Y:IB,Z:I0e,"%":G0e};S.x=k(n,S),S.X=k(r,S),S.c=k(e,S),A.x=k(n,A),A.X=k(r,A),A.c=k(e,A);function k(ie,be){return function(je){var he=[],ht=-1,H=0,B=ie.length,re,V,J;for(je instanceof Date||(je=new Date(+je));++ht<B;)ie.charCodeAt(ht)===37&&(he.push(ie.slice(H,ht)),(V=LB[re=ie.charAt(++ht)])!=null?re=ie.charAt(++ht):V=re==="e"?" ":"0",(J=be[re])&&(re=J(je,V)),he.push(re),H=ht+1);return he.push(ie.slice(H,ht)),he.join("")}}function N(ie,be){return function(je){var he=dx(1900,void 0,1),ht=I(he,ie,je+="",0),H,B;if(ht!=je.length)return null;if("Q"in he)return new Date(he.Q);if("s"in he)return new Date(he.s*1e3+("L"in he?he.L:0));if(be&&!("Z"in he)&&(he.Z=0),"p"in he&&(he.H=he.H%12+he.p*12),he.m===void 0&&(he.m="q"in he?he.q:0),"V"in he){if(he.V<1||he.V>53)return null;"w"in he||(he.w=1),"Z"in he?(H=KT(dx(he.y,0,1)),B=H.getUTCDay(),H=B>4||B===0?lw.ceil(H):lw(H),H=dM.offset(H,(he.V-1)*7),he.y=H.getUTCFullYear(),he.m=H.getUTCMonth(),he.d=H.getUTCDate()+(he.w+6)%7):(H=qT(dx(he.y,0,1)),B=H.getDay(),H=B>4||B===0?ow.ceil(H):ow(H),H=kb.offset(H,(he.V-1)*7),he.y=H.getFullYear(),he.m=H.getMonth(),he.d=H.getDate()+(he.w+6)%7)}else("W"in he||"U"in he)&&("w"in he||(he.w="u"in he?he.u%7:"W"in he?1:0),B="Z"in he?KT(dx(he.y,0,1)).getUTCDay():qT(dx(he.y,0,1)).getDay(),he.m=0,he.d="W"in he?(he.w+6)%7+he.W*7-(B+5)%7:he.w+he.U*7-(B+6)%7);return"Z"in he?(he.H+=he.Z/100|0,he.M+=he.Z%100,KT(he)):qT(he)}}function I(ie,be,je,he){for(var ht=0,H=be.length,B=je.length,re,V;ht<H;){if(he>=B)return-1;if(re=be.charCodeAt(ht++),re===37){if(re=be.charAt(ht++),V=T[re in LB?be.charAt(ht++):re],!V||(he=V(ie,je,he))<0)return-1}else if(re!=je.charCodeAt(he++))return-1}return he}function C(ie,be,je){var he=u.exec(be.slice(je));return he?(ie.p=d.get(he[0].toLowerCase()),je+he[0].length):-1}function D(ie,be,je){var he=m.exec(be.slice(je));return he?(ie.w=x.get(he[0].toLowerCase()),je+he[0].length):-1}function F(ie,be,je){var he=f.exec(be.slice(je));return he?(ie.w=g.get(he[0].toLowerCase()),je+he[0].length):-1}function O(ie,be,je){var he=b.exec(be.slice(je));return he?(ie.m=M.get(he[0].toLowerCase()),je+he[0].length):-1}function q(ie,be,je){var he=v.exec(be.slice(je));return he?(ie.m=y.get(he[0].toLowerCase()),je+he[0].length):-1}function R(ie,be,je){return I(ie,e,be,je)}function W(ie,be,je){return I(ie,n,be,je)}function K(ie,be,je){return I(ie,r,be,je)}function G(ie){return s[ie.getDay()]}function ee(ie){return a[ie.getDay()]}function Z(ie){return c[ie.getMonth()]}function Q(ie){return o[ie.getMonth()]}function U(ie){return i[+(ie.getHours()>=12)]}function $(ie){return 1+~~(ie.getMonth()/3)}function X(ie){return s[ie.getUTCDay()]}function te(ie){return a[ie.getUTCDay()]}function fe(ie){return c[ie.getUTCMonth()]}function pe(ie){return o[ie.getUTCMonth()]}function xe(ie){return i[+(ie.getUTCHours()>=12)]}function Ne(ie){return 1+~~(ie.getUTCMonth()/3)}return{format:function(ie){var be=k(ie+="",S);return be.toString=function(){return ie},be},parse:function(ie){var be=N(ie+="",!1);return be.toString=function(){return ie},be},utcFormat:function(ie){var be=k(ie+="",A);return be.toString=function(){return ie},be},utcParse:function(ie){var be=N(ie+="",!0);return be.toString=function(){return ie},be}}}var LB={"-":"",_:" ",0:"0"},Ui=/^\s*\d+/,N0e=/^%/,k0e=/[\\^$*+?|[\]().{}]/g;function Nn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function P0e(t){return t.replace(k0e,"\\$&")}function hx(t){return new RegExp("^(?:"+t.map(P0e).join("|")+")","i")}function fx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function R0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function D0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function j0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function O0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function L0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function IB(t,e,n){var r=Ui.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function FB(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 I0e(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 F0e(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 U0e(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 UB(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function z0e(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 zB(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function B0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function H0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function $0e(t,e,n){var r=Ui.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function V0e(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 G0e(t,e,n){var r=N0e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function W0e(t,e,n){var r=Ui.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function q0e(t,e,n){var r=Ui.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function BB(t,e){return Nn(t.getDate(),e,2)}function K0e(t,e){return Nn(t.getHours(),e,2)}function X0e(t,e){return Nn(t.getHours()%12||12,e,2)}function Y0e(t,e){return Nn(1+kb.count(Pc(t),t),e,3)}function Bq(t,e){return Nn(t.getMilliseconds(),e,3)}function Z0e(t,e){return Bq(t,e)+"000"}function Q0e(t,e){return Nn(t.getMonth()+1,e,2)}function J0e(t,e){return Nn(t.getMinutes(),e,2)}function ebe(t,e){return Nn(t.getSeconds(),e,2)}function tbe(t){var e=t.getDay();return e===0?7:e}function nbe(t,e){return Nn(hM.count(Pc(t)-1,t),e,2)}function Hq(t){var e=t.getDay();return e>=4||e===0?Em(t):Em.ceil(t)}function rbe(t,e){return t=Hq(t),Nn(Em.count(Pc(t),t)+(Pc(t).getDay()===4),e,2)}function ibe(t){return t.getDay()}function abe(t,e){return Nn(ow.count(Pc(t)-1,t),e,2)}function sbe(t,e){return Nn(t.getFullYear()%100,e,2)}function obe(t,e){return t=Hq(t),Nn(t.getFullYear()%100,e,2)}function lbe(t,e){return Nn(t.getFullYear()%1e4,e,4)}function cbe(t,e){var n=t.getDay();return t=n>=4||n===0?Em(t):Em.ceil(t),Nn(t.getFullYear()%1e4,e,4)}function ube(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Nn(e/60|0,"0",2)+Nn(e%60,"0",2)}function HB(t,e){return Nn(t.getUTCDate(),e,2)}function dbe(t,e){return Nn(t.getUTCHours(),e,2)}function hbe(t,e){return Nn(t.getUTCHours()%12||12,e,2)}function fbe(t,e){return Nn(1+dM.count(Rc(t),t),e,3)}function $q(t,e){return Nn(t.getUTCMilliseconds(),e,3)}function pbe(t,e){return $q(t,e)+"000"}function mbe(t,e){return Nn(t.getUTCMonth()+1,e,2)}function gbe(t,e){return Nn(t.getUTCMinutes(),e,2)}function xbe(t,e){return Nn(t.getUTCSeconds(),e,2)}function bbe(t){var e=t.getUTCDay();return e===0?7:e}function ybe(t,e){return Nn(fM.count(Rc(t)-1,t),e,2)}function Vq(t){var e=t.getUTCDay();return e>=4||e===0?Am(t):Am.ceil(t)}function vbe(t,e){return t=Vq(t),Nn(Am.count(Rc(t),t)+(Rc(t).getUTCDay()===4),e,2)}function _be(t){return t.getUTCDay()}function wbe(t,e){return Nn(lw.count(Rc(t)-1,t),e,2)}function Sbe(t,e){return Nn(t.getUTCFullYear()%100,e,2)}function Mbe(t,e){return t=Vq(t),Nn(t.getUTCFullYear()%100,e,2)}function Ebe(t,e){return Nn(t.getUTCFullYear()%1e4,e,4)}function Abe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Am(t):Am.ceil(t),Nn(t.getUTCFullYear()%1e4,e,4)}function Tbe(){return"+0000"}function $B(){return"%"}function VB(t){return+t}function GB(t){return Math.floor(+t/1e3)}var Qf,Gq,Wq;Cbe({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 Cbe(t){return Qf=C0e(t),Gq=Qf.format,Qf.parse,Wq=Qf.utcFormat,Qf.utcParse,Qf}function Nbe(t){return new Date(t)}function kbe(t){return t instanceof Date?+t:+new Date(+t)}function BD(t,e,n,r,i,a,s,o,c,u){var d=TD(),f=d.invert,g=d.domain,m=u(".%L"),x=u(":%S"),v=u("%I:%M"),y=u("%I %p"),b=u("%a %d"),M=u("%b %d"),S=u("%B"),A=u("%Y");function T(k){return(c(k)<k?m:o(k)<k?x:s(k)<k?v:a(k)<k?y:r(k)<k?i(k)<k?b:M:n(k)<k?S:A)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?g(Array.from(k,kbe)):g().map(Nbe)},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(Rq(N,k)):d},d.copy=function(){return Nb(d,BD(t,e,n,r,i,a,s,o,c,u))},d}function Pbe(){return po.apply(BD(A0e,T0e,Pc,UD,hM,kb,ID,OD,ph,Gq).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Rbe(){return po.apply(BD(M0e,E0e,Rc,zD,fM,dM,FD,LD,ph,Wq).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function pM(){var t=0,e=1,n,r,i,a,s=Ma,o=!1,c;function u(f){return f==null||isNaN(f=+f)?c:s(i===0?.5:(f=(a(f)-n)*i,o?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(o=!!f,u):o},u.interpolator=function(f){return arguments.length?(s=f,u):s};function d(f){return function(g){var m,x;return arguments.length?([m,x]=g,s=f(m,x),u):[s(0),s(1)]}}return u.range=d(Jm),u.rangeRound=d(AD),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return a=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function _d(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function qq(){var t=vd(pM()(Ma));return t.copy=function(){return _d(t,qq())},Uc.apply(t,arguments)}function Kq(){var t=kD(pM()).domain([1,10]);return t.copy=function(){return _d(t,Kq()).base(t.base())},Uc.apply(t,arguments)}function Xq(){var t=PD(pM());return t.copy=function(){return _d(t,Xq()).constant(t.constant())},Uc.apply(t,arguments)}function HD(){var t=RD(pM());return t.copy=function(){return _d(t,HD()).exponent(t.exponent())},Uc.apply(t,arguments)}function Dbe(){return HD.apply(null,arguments).exponent(.5)}function Yq(){var t=[],e=Ma;function n(r){if(r!=null&&!isNaN(r=+r))return e((Tb(t,r,1)-1)/(t.length-1))}return n.domain=function(r){if(!arguments.length)return t.slice();t=[];for(let i of r)i!=null&&!isNaN(i=+i)&&t.push(i);return t.sort(Ku),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,a)=>bxe(t,a/r))},n.copy=function(){return Yq(e).domain(t)},Uc.apply(n,arguments)}function mM(){var t=0,e=.5,n=1,r=1,i,a,s,o,c,u=Ma,d,f=!1,g;function m(v){return isNaN(v=+v)?g:(v=.5+((v=+d(v))-a)*(r*v<r*a?o:c),u(f?Math.max(0,Math.min(1,v)):v))}m.domain=function(v){return arguments.length?([t,e,n]=v,i=d(t=+t),a=d(e=+e),s=d(n=+n),o=i===a?0:.5/(a-i),c=a===s?0:.5/(s-a),r=a<i?-1:1,m):[t,e,n]},m.clamp=function(v){return arguments.length?(f=!!v,m):f},m.interpolator=function(v){return arguments.length?(u=v,m):u};function x(v){return function(y){var b,M,S;return arguments.length?([b,M,S]=y,u=Gxe(v,[b,M,S]),m):[u(0),u(.5),u(1)]}}return m.range=x(Jm),m.rangeRound=x(AD),m.unknown=function(v){return arguments.length?(g=v,m):g},function(v){return d=v,i=v(t),a=v(e),s=v(n),o=i===a?0:.5/(a-i),c=a===s?0:.5/(s-a),r=a<i?-1:1,m}}function Zq(){var t=vd(mM()(Ma));return t.copy=function(){return _d(t,Zq())},Uc.apply(t,arguments)}function Qq(){var t=kD(mM()).domain([.1,1,10]);return t.copy=function(){return _d(t,Qq()).base(t.base())},Uc.apply(t,arguments)}function Jq(){var t=PD(mM());return t.copy=function(){return _d(t,Jq()).constant(t.constant())},Uc.apply(t,arguments)}function $D(){var t=RD(mM());return t.copy=function(){return _d(t,$D()).exponent(t.exponent())},Uc.apply(t,arguments)}function jbe(){return $D.apply(null,arguments).exponent(.5)}const jx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:SD,scaleDiverging:Zq,scaleDivergingLog:Qq,scaleDivergingPow:$D,scaleDivergingSqrt:jbe,scaleDivergingSymlog:Jq,scaleIdentity:Pq,scaleImplicit:g3,scaleLinear:kq,scaleLog:Dq,scaleOrdinal:wD,scalePoint:_xe,scalePow:DD,scaleQuantile:Lq,scaleQuantize:Iq,scaleRadial:Oq,scaleSequential:qq,scaleSequentialLog:Kq,scaleSequentialPow:HD,scaleSequentialQuantile:Yq,scaleSequentialSqrt:Dbe,scaleSequentialSymlog:Xq,scaleSqrt:p0e,scaleSymlog:jq,scaleThreshold:Fq,scaleTime:Pbe,scaleUtc:Rbe,tickFormat:Nq},Symbol.toStringTag,{value:"Module"}));var wd=t=>t.chartData,VD=Ge([wd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Pb=(t,e,n,r)=>r?VD(t):wd(t);function od(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(Hn(e)&&Hn(n))return!0}return!1}function WB(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function eK(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(Hn(n))i=n;else if(typeof n=="function")return;if(Hn(r))a=r;else if(typeof r=="function")return;var s=[i,a];if(od(s))return s}}function Obe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(od(r))return WB(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,s,o;if(i==="auto")e!=null&&(s=Math.min(...e));else if(Pt(i))s=i;else if(typeof i=="function")try{e!=null&&(s=i(e?.[0]))}catch{}else if(typeof i=="string"&&vz.test(i)){var c=vz.exec(i);if(c==null||e==null)s=void 0;else{var u=+c[1];s=e[0]-u}}else s=e?.[0];if(a==="auto")e!=null&&(o=Math.max(...e));else if(Pt(a))o=a;else if(typeof a=="function")try{e!=null&&(o=a(e?.[1]))}catch{}else if(typeof a=="string"&&_z.test(a)){var d=_z.exec(a);if(d==null||e==null)o=void 0;else{var f=+d[1];o=e[1]+f}}else o=e?.[1];var g=[s,o];if(od(g))return e==null?g:WB(g,e,n)}}}var eg=1e9,Lbe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},WD,gr=!0,ho="[DecimalError] ",Th=ho+"Invalid argument: ",GD=ho+"Exponent out of range: ",tg=Math.floor,ih=Math.pow,Ibe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,xs,Di=1e7,ur=7,tK=9007199254740991,cw=tg(tK/ur),Dt={};Dt.absoluteValue=Dt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Dt.comparedTo=Dt.cmp=function(t){var e,n,r,i,a=this;if(t=new a.constructor(t),a.s!==t.s)return a.s||-t.s;if(a.e!==t.e)return a.e>t.e^a.s<0?1:-1;for(r=a.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(a.d[e]!==t.d[e])return a.d[e]>t.d[e]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};Dt.decimalPlaces=Dt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*ur;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Dt.dividedBy=Dt.div=function(t){return vc(this,new this.constructor(t))};Dt.dividedToIntegerBy=Dt.idiv=function(t){var e=this,n=e.constructor;return nr(vc(e,new n(t),0,1),n.precision)};Dt.equals=Dt.eq=function(t){return!this.cmp(t)};Dt.exponent=function(){return ni(this)};Dt.greaterThan=Dt.gt=function(t){return this.cmp(t)>0};Dt.greaterThanOrEqualTo=Dt.gte=function(t){return this.cmp(t)>=0};Dt.isInteger=Dt.isint=function(){return this.e>this.d.length-2};Dt.isNegative=Dt.isneg=function(){return this.s<0};Dt.isPositive=Dt.ispos=function(){return this.s>0};Dt.isZero=function(){return this.s===0};Dt.lessThan=Dt.lt=function(t){return this.cmp(t)<0};Dt.lessThanOrEqualTo=Dt.lte=function(t){return this.cmp(t)<1};Dt.logarithm=Dt.log=function(t){var e,n=this,r=n.constructor,i=r.precision,a=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(xs))throw Error(ho+"NaN");if(n.s<1)throw Error(ho+(n.s?"NaN":"-Infinity"));return n.eq(xs)?new r(0):(gr=!1,e=vc(U0(n,a),U0(t,a),a),gr=!0,nr(e,i))};Dt.minus=Dt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?iK(e,t):nK(e,(t.s=-t.s,t))};Dt.modulo=Dt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(ho+"NaN");return n.s?(gr=!1,e=vc(n,t,0,1).times(t),gr=!0,n.minus(e)):nr(new r(n),i)};Dt.naturalExponential=Dt.exp=function(){return rK(this)};Dt.naturalLogarithm=Dt.ln=function(){return U0(this)};Dt.negated=Dt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Dt.plus=Dt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?nK(e,t):iK(e,(t.s=-t.s,t))};Dt.precision=Dt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Th+t);if(e=ni(i)+1,r=i.d.length-1,n=r*ur+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};Dt.squareRoot=Dt.sqrt=function(){var t,e,n,r,i,a,s,o=this,c=o.constructor;if(o.s<1){if(!o.s)return new c(0);throw Error(ho+"NaN")}for(t=ni(o),gr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=sl(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=tg((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=s=n+3;;)if(a=r,r=a.plus(vc(o,a,s+2)).times(.5),sl(a.d).slice(0,s)===(e=sl(r.d)).slice(0,s)){if(e=e.slice(s-3,s+1),i==s&&e=="4999"){if(nr(a,n+1,0),a.times(a).eq(o)){r=a;break}}else if(e!="9999")break;s+=4}return gr=!0,nr(r,n)};Dt.times=Dt.mul=function(t){var e,n,r,i,a,s,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&&(a=g,g=m,m=a,s=c,c=u,u=s),a=[],s=c+u,r=s;r--;)a.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)o=a[i]+m[r]*g[i-r-1]+e,a[i--]=o%Di|0,e=o/Di|0;a[i]=(a[i]+e)%Di|0}for(;!a[--s];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,gr?nr(t,f.precision):t};Dt.toDecimalPlaces=Dt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(fl(t,0,eg),e===void 0?e=r.rounding:fl(e,0,8),nr(n,t+ni(n)+1,e))};Dt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Xh(r,!0):(fl(t,0,eg),e===void 0?e=i.rounding:fl(e,0,8),r=nr(new i(r),t+1,e),n=Xh(r,!0,t+1)),n};Dt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Xh(i):(fl(t,0,eg),e===void 0?e=a.rounding:fl(e,0,8),r=nr(new a(i),t+ni(i)+1,e),n=Xh(r.abs(),!1,t+ni(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Dt.toInteger=Dt.toint=function(){var t=this,e=t.constructor;return nr(new e(t),ni(t)+1,e.rounding)};Dt.toNumber=function(){return+this};Dt.toPower=Dt.pow=function(t){var e,n,r,i,a,s,o=this,c=o.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(xs);if(o=new c(o),!o.s){if(t.s<1)throw Error(ho+"Infinity");return o}if(o.eq(xs))return o;if(r=c.precision,t.eq(xs))return nr(o,r);if(e=t.e,n=t.d.length-1,s=e>=n,a=o.s,s){if((n=d<0?-d:d)<=tK){for(i=new c(xs),e=Math.ceil(r/ur+4),gr=!1;n%2&&(i=i.times(o),KB(i.d,e)),n=tg(n/2),n!==0;)o=o.times(o),KB(o.d,e);return gr=!0,t.s<0?new c(xs).div(i):nr(i,r)}}else if(a<0)throw Error(ho+"NaN");return a=a<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=rK(i),i.s=a,i};Dt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=ni(i),r=Xh(i,n<=a.toExpNeg||n>=a.toExpPos)):(fl(t,1,eg),e===void 0?e=a.rounding:fl(e,0,8),i=nr(new a(i),t,e),n=ni(i),r=Xh(i,t<=n||n<=a.toExpNeg,t)),r};Dt.toSignificantDigits=Dt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(fl(t,1,eg),e===void 0?e=r.rounding:fl(e,0,8)),nr(new r(n),t,e)};Dt.toString=Dt.valueOf=Dt.val=Dt.toJSON=Dt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=ni(t),n=t.constructor;return Xh(t,e<=n.toExpNeg||e>=n.toExpPos)};function nK(t,e){var n,r,i,a,s,o,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),gr?nr(e,f):e;if(c=t.d,u=e.d,s=t.e,i=e.e,c=c.slice(),a=s-i,a){for(a<0?(r=c,a=-a,o=u.length):(r=u,i=s,o=c.length),s=Math.ceil(f/ur),o=s>o?s+1:o+1,a>o&&(a=o,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(o=c.length,a=u.length,o-a<0&&(a=o,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/Di|0,c[a]%=Di;for(n&&(c.unshift(n),++i),o=c.length;c[--o]==0;)c.pop();return e.d=c,e.e=i,gr?nr(e,f):e}function fl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Th+t)}function sl(t){var e,n,r,i=t.length-1,a="",s=t[0];if(i>0){for(a+=s,e=1;e<i;e++)r=t[e]+"",n=ur-r.length,n&&(a+=Tu(n)),a+=r;s=t[e],r=s+"",n=ur-r.length,n&&(a+=Tu(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return a+s}var vc=(function(){function t(r,i){var a,s=0,o=r.length;for(r=r.slice();o--;)a=r[o]*i+s,r[o]=a%Di|0,s=a/Di|0;return s&&r.unshift(s),r}function e(r,i,a,s){var o,c;if(a!=s)c=a>s?1:-1;else for(o=c=0;o<a;o++)if(r[o]!=i[o]){c=r[o]>i[o]?1:-1;break}return c}function n(r,i,a){for(var s=0;a--;)r[a]-=s,s=r[a]<i[a]?1:0,r[a]=s*Di+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,s){var o,c,u,d,f,g,m,x,v,y,b,M,S,A,T,k,N,I,C=r.constructor,D=r.s==i.s?1:-1,F=r.d,O=i.d;if(!r.s)return new C(r);if(!i.s)throw Error(ho+"Division by zero");for(c=r.e-i.e,N=O.length,T=F.length,m=new C(D),x=m.d=[],u=0;O[u]==(F[u]||0);)++u;if(O[u]>(F[u]||0)&&--c,a==null?M=a=C.precision:s?M=a+(ni(r)-ni(i))+1:M=a,M<0)return new C(0);if(M=M/ur+2|0,u=0,N==1)for(d=0,O=O[0],M++;(u<T||d)&&M--;u++)S=d*Di+(F[u]||0),x[u]=S/O|0,d=S%O|0;else{for(d=Di/(O[0]+1)|0,d>1&&(O=t(O,d),F=t(F,d),N=O.length,T=F.length),A=N,v=F.slice(0,N),y=v.length;y<N;)v[y++]=0;I=O.slice(),I.unshift(0),k=O[0],O[1]>=Di/2&&++k;do d=0,o=e(O,v,N,y),o<0?(b=v[0],N!=y&&(b=b*Di+(v[1]||0)),d=b/k|0,d>1?(d>=Di&&(d=Di-1),f=t(O,d),g=f.length,y=v.length,o=e(f,v,g,y),o==1&&(d--,n(f,N<g?I:O,g))):(d==0&&(o=d=1),f=O.slice()),g=f.length,g<y&&f.unshift(0),n(v,f,y),o==-1&&(y=v.length,o=e(O,v,N,y),o<1&&(d++,n(v,N<y?I:O,y))),y=v.length):o===0&&(d++,v=[0]),x[u++]=d,o&&v[0]?v[y++]=F[A]||0:(v=[F[A]],y=1);while((A++<T||v[0]!==void 0)&&M--)}return x[0]||x.shift(),m.e=c,nr(m,s?a+ni(m)+1:a)}})();function rK(t,e){var n,r,i,a,s,o,c=0,u=0,d=t.constructor,f=d.precision;if(ni(t)>16)throw Error(GD+ni(t));if(!t.s)return new d(xs);for(gr=!1,o=f,s=new d(.03125);t.abs().gte(.1);)t=t.times(s),u+=5;for(r=Math.log(ih(2,u))/Math.LN10*2+5|0,o+=r,n=i=a=new d(xs),d.precision=o;;){if(i=nr(i.times(t),o),n=n.times(++c),s=a.plus(vc(i,n,o)),sl(s.d).slice(0,o)===sl(a.d).slice(0,o)){for(;u--;)a=nr(a.times(a),o);return d.precision=f,e==null?(gr=!0,nr(a,f)):a}a=s}}function ni(t){for(var e=t.e*ur,n=t.d[0];n>=10;n/=10)e++;return e}function XT(t,e,n){if(e>t.LN10.sd())throw gr=!0,n&&(t.precision=n),Error(ho+"LN10 precision limit exceeded");return nr(new t(t.LN10),e)}function Tu(t){for(var e="";t--;)e+="0";return e}function U0(t,e){var n,r,i,a,s,o,c,u,d,f=1,g=10,m=t,x=m.d,v=m.constructor,y=v.precision;if(m.s<1)throw Error(ho+(m.s?"NaN":"-Infinity"));if(m.eq(xs))return new v(0);if(e==null?(gr=!1,u=y):u=e,m.eq(10))return e==null&&(gr=!0),XT(v,u);if(u+=g,v.precision=u,n=sl(x),r=n.charAt(0),a=ni(m),Math.abs(a)<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++;a=ni(m),r>1?(m=new v("0."+n),a++):m=new v(r+"."+n.slice(1))}else return c=XT(v,u+2,y).times(a+""),m=U0(new v(r+"."+n.slice(1)),u-g).plus(c),v.precision=y,e==null?(gr=!0,nr(m,y)):m;for(o=s=m=vc(m.minus(xs),m.plus(xs),u),d=nr(m.times(m),u),i=3;;){if(s=nr(s.times(d),u),c=o.plus(vc(s,new v(i),u)),sl(c.d).slice(0,u)===sl(o.d).slice(0,u))return o=o.times(2),a!==0&&(o=o.plus(XT(v,u+2,y).times(a+""))),o=vc(o,new v(f),u),v.precision=y,e==null?(gr=!0,nr(o,y)):o;o=c,i+=2}}function qB(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;)++r;for(i=e.length;e.charCodeAt(i-1)===48;)--i;if(e=e.slice(r,i),e){if(i-=r,n=n-r-1,t.e=tg(n/ur),t.d=[],r=(n+1)%ur,n<0&&(r+=ur),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=ur;r<i;)t.d.push(+e.slice(r,r+=ur));e=e.slice(r),r=ur-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),gr&&(t.e>cw||t.e<-cw))throw Error(GD+n)}else t.s=0,t.e=0,t.d=[0];return t}function nr(t,e,n){var r,i,a,s,o,c,u,d,f=t.d;for(s=1,a=f[0];a>=10;a/=10)s++;if(r=e-s,r<0)r+=ur,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/ur),a=f.length,d>=a)return t;for(u=a=f[d],s=1;a>=10;a/=10)s++;r%=ur,i=r-ur+s}if(n!==void 0&&(a=ih(10,s-i-1),o=u/a%10|0,c=e<0||f[d+1]!==void 0||u%a,c=n<4?(o||c)&&(n==0||n==(t.s<0?3:2)):o>5||o==5&&(n==4||c||n==6&&(r>0?i>0?u/ih(10,s-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=ni(t),f.length=1,e=e-a-1,f[0]=ih(10,(ur-e%ur)%ur),t.e=tg(-e/ur)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,a=1,d--):(f.length=d+1,a=ih(10,ur-r),f[d]=i>0?(u/ih(10,s-i)%ih(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Di&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Di)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(gr&&(t.e>cw||t.e<-cw))throw Error(GD+ni(t));return t}function iK(t,e){var n,r,i,a,s,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(),s=u-r,s){for(d=s<0,d?(n=c,s=-s,o=f.length):(n=f,r=u,o=c.length),i=Math.max(Math.ceil(m/ur),o)+2,s>i&&(s=i,n.length=1),n.reverse(),i=s;i--;)n.push(0);n.reverse()}else{for(i=c.length,o=f.length,d=i<o,d&&(o=i),i=0;i<o;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}s=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),o=c.length,i=f.length-o;i>0;--i)c[o++]=0;for(i=f.length;i>s;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=Di-1;--c[a],c[i]+=Di}c[i]-=f[i]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,gr?nr(e,m):e):new g(0)}function Xh(t,e,n){var r,i=ni(t),a=sl(t.d),s=a.length;return e?(n&&(r=n-s)>0?a=a.charAt(0)+"."+a.slice(1)+Tu(r):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Tu(-i-1)+a,n&&(r=n-s)>0&&(a+=Tu(r))):i>=s?(a+=Tu(i+1-s),n&&(r=n-i-1)>0&&(a=a+"."+Tu(r))):((r=i+1)<s&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(a+="."),a+=Tu(r))),t.s<0?"-"+a:a}function KB(t,e){if(t.length>e)return t.length=e,!0}function aK(t){var e,n,r;function i(a){var s=this;if(!(s instanceof i))return new i(a);if(s.constructor=i,a instanceof i){s.s=a.s,s.e=a.e,s.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Th+a);if(a>0)s.s=1;else if(a<0)a=-a,s.s=-1;else{s.s=0,s.e=0,s.d=[0];return}if(a===~~a&&a<1e7){s.e=0,s.d=[a];return}return qB(s,a.toString())}else if(typeof a!="string")throw Error(Th+a);if(a.charCodeAt(0)===45?(a=a.slice(1),s.s=-1):s.s=1,Ibe.test(a))qB(s,a);else throw Error(Th+a)}if(i.prototype=Dt,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=aK,i.config=i.set=Fbe,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 Fbe(t){if(!t||typeof t!="object")throw Error(ho+"Object expected");var e,n,r,i=["precision",1,eg,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e<i.length;e+=3)if((r=t[n=i[e]])!==void 0)if(tg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Th+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Th+n+": "+r);return this}var WD=aK(Lbe);xs=new WD(1);const zn=WD;var Ube=t=>t,sK={},oK=t=>t===sK,XB=t=>function e(){return arguments.length===0||arguments.length===1&&oK(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},lK=(t,e)=>t===1?e:XB(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(s=>s!==sK).length;return a>=t?e(...r):lK(t-a,XB(function(){for(var s=arguments.length,o=new Array(s),c=0;c<s;c++)o[c]=arguments[c];var u=r.map(d=>oK(d)?o.shift():d);return e(...u,...o)}))}),zbe=t=>lK(t.length,t),v3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Bbe=zbe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Hbe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Ube;var i=n.reverse(),a=i[0],s=i.slice(1);return function(){return s.reduce((o,c)=>c(o),a(...arguments))}},_3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function cK(t){var e;return t===0?e=1:e=Math.floor(new zn(t).abs().log(10).toNumber())+1,e}function uK(t,e,n){for(var r=new zn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var dK=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},hK=(t,e,n)=>{if(t.lte(0))return new zn(0);var r=cK(t.toNumber()),i=new zn(10).pow(r),a=t.div(i),s=r!==1?.05:.1,o=new zn(Math.ceil(a.div(s).toNumber())).add(n).mul(s),c=o.mul(i);return e?new zn(c.toNumber()):new zn(Math.ceil(c.toNumber()))},$be=(t,e,n)=>{var r=new zn(1),i=new zn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new zn(10).pow(cK(t)-1),i=new zn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new zn(Math.floor(t)))}else t===0?i=new zn(Math.floor((e-1)/2)):n||(i=new zn(Math.floor(t)));var s=Math.floor((e-1)/2),o=Hbe(Bbe(c=>i.add(new zn(c-s).mul(r)).toNumber()),v3);return o(0,e)},fK=function(e,n,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new zn(0),tickMin:new zn(0),tickMax:new zn(0)};var s=hK(new zn(n).sub(e).div(r-1),i,a),o;e<=0&&n>=0?o=new zn(0):(o=new zn(e).add(n).div(2),o=o.sub(new zn(o).mod(s)));var c=Math.ceil(o.sub(e).div(s).toNumber()),u=Math.ceil(new zn(n).sub(o).div(s).toNumber()),d=c+u+1;return d>r?fK(e,n,r,i,a+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:s,tickMin:o.sub(new zn(c).mul(s)),tickMax:o.add(new zn(u).mul(s))})},Vbe=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=Math.max(i,2),[o,c]=dK([n,r]);if(o===-1/0||c===1/0){var u=c===1/0?[o,...v3(0,i-1).map(()=>1/0)]:[...v3(0,i-1).map(()=>-1/0),c];return n>r?_3(u):u}if(o===c)return $be(o,i,a);var{step:d,tickMin:f,tickMax:g}=fK(o,c,s,a,0),m=uK(f,g.add(new zn(.1).mul(d)),d);return n>r?_3(m):m},Gbe=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,o]=dK([r,i]);if(s===-1/0||o===1/0)return[r,i];if(s===o)return[s];var c=Math.max(n,2),u=hK(new zn(o).sub(s).div(c-1),a,0),d=[...uK(new zn(s),new zn(o),u),o];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?_3(d):d},pK=t=>t.rootProps.maxBarSize,Wbe=t=>t.rootProps.barGap,mK=t=>t.rootProps.barCategoryGap,qbe=t=>t.rootProps.barSize,Rb=t=>t.rootProps.stackOffset,gK=t=>t.rootProps.reverseStackOrder,qD=t=>t.options.chartName,KD=t=>t.rootProps.syncId,xK=t=>t.rootProps.syncMethod,XD=t=>t.options.eventEmitter,Kbe=t=>t.rootProps.baseValue,Rr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},cc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},ps={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},gM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Xbe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:cc.angleAxisId,includeHidden:!1,name:void 0,reversed:cc.reversed,scale:cc.scale,tick:cc.tick,tickCount:void 0,ticks:void 0,type:cc.type,unit:void 0},Ybe={allowDataOverflow:ps.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ps.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ps.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ps.scale,tick:ps.tick,tickCount:ps.tickCount,ticks:void 0,type:ps.type,unit:void 0},Zbe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:cc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:cc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:cc.scale,tick:cc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},Qbe={allowDataOverflow:ps.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ps.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ps.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ps.scale,tick:ps.tick,tickCount:ps.tickCount,ticks:void 0,type:"category",unit:void 0},YD=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?Zbe:Xbe,ZD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Qbe:Ybe,xM=t=>t.polarOptions,QD=Ge([Ic,Fc,bi],mq),bK=Ge([xM,QD],(t,e)=>{if(t!=null)return pa(t.innerRadius,e,0)}),yK=Ge([xM,QD],(t,e)=>{if(t!=null)return pa(t.outerRadius,e,e*.8)}),Jbe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},vK=Ge([xM],Jbe);Ge([YD,vK],gM);var _K=Ge([QD,bK,yK],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ge([ZD,_K],gM);var wK=Ge([xn,xM,bK,yK,Ic,Fc],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:s,cy:o,startAngle:c,endAngle:u}=e;return{cx:pa(s,i,i/2),cy:pa(o,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),xr=(t,e)=>e,Db=(t,e,n)=>n;function bM(t){return t?.id}function SK(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,s=new Map;return t.forEach(o=>{var c,u=(c=o.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=bM(o);u.forEach((f,g)=>{var m=a==null||i?g:String(Bn(f,a,null)),x=Bn(f,o.dataKey,0),v;s.has(m)?v=s.get(m):v={},Object.assign(v,{[d]:x}),s.set(m,v)})}}),Array.from(s.values())}function yM(t){return t.stackId!=null&&t.dataKey!=null}var vM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function _M(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function eye(t,e){if(t.length===e.length){for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return!1}var _i=t=>{var e=xn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},ng=t=>t.tooltip.settings.axisId;function YB(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?YB(Object(n),!0).forEach(function(r){tye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tye(t,e,n){return(e=nye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nye(t){var e=rye(t,"string");return typeof e=="symbol"?e:e+""}function rye(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 w3=[0,"auto"],Pi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:void 0,height:30,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"bottom",padding:{left:0,right:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"category",unit:void 0},MK=(t,e)=>t.cartesianAxis.xAxis[e],Sl=(t,e)=>{var n=MK(t,e);return n??Pi},Ri={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:w3,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:Mb},EK=(t,e)=>t.cartesianAxis.yAxis[e],Ml=(t,e)=>{var n=EK(t,e);return n??Ri},iye={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:""},JD=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??iye},Mr=(t,e,n)=>{switch(e){case"xAxis":return Sl(t,n);case"yAxis":return Ml(t,n);case"zAxis":return JD(t,n);case"angleAxis":return YD(t,n);case"radiusAxis":return ZD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},aye=(t,e,n)=>{switch(e){case"xAxis":return Sl(t,n);case"yAxis":return Ml(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},jb=(t,e,n)=>{switch(e){case"xAxis":return Sl(t,n);case"yAxis":return Ml(t,n);case"angleAxis":return YD(t,n);case"radiusAxis":return ZD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},AK=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function ej(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,sye=Ge([xr,Db],ej),tj=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Lb=Ge([Ob,Mr,sye],tj,{memoizeOptions:{resultEqualityCheck:_M}}),TK=Ge([Lb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(yM)),CK=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),oye=Ge([Lb],CK),nj=t=>t.map(e=>e.data).filter(Boolean).flat(1),lye=Ge([Lb],nj,{memoizeOptions:{resultEqualityCheck:_M}}),rj=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},ij=Ge([lye,Pb],rj),aj=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Bn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Bn(i,r)}))):t.map(r=>({value:r})),wM=Ge([ij,Mr,Lb],aj);function NK(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function r1(t){if(co(t)||t instanceof Date){var e=Number(t);if(Hn(e))return e}}function ZB(t){if(Array.isArray(t)){var e=[r1(t[0]),r1(t[1])];return od(e)?e:void 0}var n=r1(t);if(n!=null)return[n,n]}function Dc(t){return t.map(r1).filter(ahe)}function cye(t,e,n){return!n||typeof e!="number"||Za(e)?[]:n.length?Dc(n.flatMap(r=>{var i=Bn(t,r.dataKey),a,s;if(Array.isArray(i)?[a,s]=i:a=s=i,!(!Hn(a)||!Hn(s)))return[e-a,e+s]})):[]}var wi=t=>{var e=_i(t),n=ng(t);return jb(t,e,n)},Ib=Ge([wi],t=>t?.dataKey),uye=Ge([TK,Pb,wi],SK),kK=(t,e,n,r)=>{var i={},a=e.reduce((s,o)=>(o.stackId==null||(s[o.stackId]==null&&(s[o.stackId]=[]),s[o.stackId].push(o)),s),i);return Object.fromEntries(Object.entries(a).map(s=>{var[o,c]=s,u=r?[...c].reverse():c,d=u.map(bM);return[o,{stackedData:Npe(t,d,n),graphicalItems:u}]}))},z0=Ge([uye,TK,Rb,gK],kK),PK=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var s=Dpe(t,i,a);if(!(s!=null&&s[0]===0&&s[1]===0))return s}},dye=Ge([Mr],t=>t.allowDataOverflow),sj=t=>{var e;if(t==null||!("domain"in t))return w3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Dc(t.ticks);return[Math.min(...n),Math.max(...n)]}if(t.type==="category")return t.ticks.map(String)}return(e=t?.domain)!==null&&e!==void 0?e:w3},oj=Ge([Mr],sj),lj=Ge([oj,dye],eK),hye=Ge([z0,wd,xr,lj],PK,{memoizeOptions:{resultEqualityCheck:vM}}),SM=t=>t.errorBars,fye=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>NK(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 a=i.flat(),s=Math.min(...a),o=Math.max(...a);return[s,o]}},cj=(t,e,n,r,i)=>{var a,s;if(n.length>0&&t.forEach(o=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(b=>NK(i,b)),g=Bn(o,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),m=cye(o,g,f);if(m.length>=2){var x=Math.min(...m),v=Math.max(...m);(a==null||x<a)&&(a=x),(s==null||v>s)&&(s=v)}var y=ZB(g);y!=null&&(a=a==null?y[0]:Math.min(a,y[0]),s=s==null?y[1]:Math.max(s,y[1]))})}),e?.dataKey!=null&&t.forEach(o=>{var c=ZB(Bn(o,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),s=s==null?c[1]:Math.max(s,c[1]))}),Hn(a)&&Hn(s))return[a,s]},pye=Ge([ij,Mr,oye,SM,xr],cj,{memoizeOptions:{resultEqualityCheck:vM}});function mye(t){var{value:e}=t;if(co(e)||e instanceof Date)return e}var gye=(t,e,n)=>{var r=t.map(mye).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&WG(r))?yq(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},RK=t=>t.referenceElements.dots,rg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),xye=Ge([RK,xr,Db],rg),DK=t=>t.referenceElements.areas,bye=Ge([DK,xr,Db],rg),jK=t=>t.referenceElements.lines,yye=Ge([jK,xr,Db],rg),OK=(t,e)=>{var n=Dc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},vye=Ge(xye,xr,OK),LK=(t,e)=>{var n=Dc(t.flatMap(r=>[e==="xAxis"?r.x1:r.y1,e==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},_ye=Ge([bye,xr],LK);function wye(t){var e;if(t.x!=null)return Dc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Dc(n)}function Sye(t){var e;if(t.y!=null)return Dc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Dc(n)}var IK=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?wye(r):Sye(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Mye=Ge([yye,xr],IK),Eye=Ge(vye,Mye,_ye,(t,e,n)=>dw(t,n,e)),uj=(t,e,n,r,i,a,s,o)=>{if(n!=null)return n;var c=s==="vertical"&&o==="xAxis"||s==="horizontal"&&o==="yAxis",u=c?dw(r,a,i):dw(a,i);return Obe(e,u,t.allowDataOverflow)},Aye=Ge([Mr,oj,lj,hye,pye,Eye,xn,xr],uj,{memoizeOptions:{resultEqualityCheck:vM}}),Tye=[0,1],dj=(t,e,n,r,i,a,s)=>{if(!((t==null||n==null||n.length===0)&&s===void 0)){var{dataKey:o,type:c}=t,u=wl(e,a);if(u&&o==null){var d;return yq(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?gye(r,t,u):i==="expand"?Tye:s}},hj=Ge([Mr,xn,ij,wM,Rb,xr,Aye],dj),FK=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:s}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":s==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":s==="category"?"band":"linear";if(typeof a=="string"){var o="scale".concat(bb(a));return o in jx?o:"point"}}},ig=Ge([Mr,xn,AK,qD,xr],FK);function Cye(t){if(t!=null){if(t in jx)return jx[t]();var e="scale".concat(bb(t));if(e in jx)return jx[e]()}}function fj(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=Cye(e);if(i!=null){var a=i.domain(n).range(r);return Mpe(a),a}}}var pj=(t,e,n)=>{var r=sj(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&od(t))return Vbe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&od(t))return Gbe(t,e.tickCount,e.allowDecimals)}},mj=Ge([hj,jb,ig],pj),gj=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&od(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],s=e[1],o=n[n.length-1];return[Math.min(i,a),Math.max(s,o)]}return e},Nye=Ge([Mr,hj,mj,xr],gj),kye=Ge(wM,Mr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Dc(t.map(o=>o.value))).sort((o,c)=>o-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var a=0;a<r.length-1;a++){var s=r[a+1]-r[a];n=Math.min(n,s)}return n/i}}),UK=Ge(kye,xn,mK,bi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!Hn(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var s=pa(n,t*a),o=t*a/2;return o-s-(o-s)/a*s}return 0}),Pye=(t,e)=>{var n=Sl(t,e);return n==null||typeof n.padding!="string"?0:UK(t,"xAxis",e,n.padding)},Rye=(t,e)=>{var n=Ml(t,e);return n==null||typeof n.padding!="string"?0:UK(t,"yAxis",e,n.padding)},Dye=Ge(Sl,Pye,(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}}),jye=Ge(Ml,Rye,(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}}),Oye=Ge([bi,Dye,aM,iM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),Lye=Ge([bi,xn,jye,aM,iM,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:s}=i;return a?[r.height-s.bottom,s.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),Fb=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Oye(t,n,r);case"yAxis":return Lye(t,n,r);case"zAxis":return(i=JD(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return vK(t);case"radiusAxis":return _K(t,n);default:return}},zK=Ge([Mr,Fb],gM),ld=Ge([Mr,ig,Nye,zK],fj);Ge([Lb,SM,xr],fye);function BK(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var MM=(t,e)=>e,EM=(t,e,n)=>n,Iye=Ge(nM,MM,EM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BK)),Fye=Ge(rM,MM,EM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BK)),HK=(t,e)=>({width:t.width,height:e.height}),Uye=(t,e)=>{var n=typeof e.width=="number"?e.width:Mb;return{width:n,height:t.height}},$K=Ge(bi,Sl,HK),zye=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},Bye=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},Hye=Ge(Fc,bi,Iye,MM,EM,(t,e,n,r,i)=>{var a={},s;return n.forEach(o=>{var c=HK(e,o);s==null&&(s=zye(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[o.id]=s-Number(u)*c.height,s+=(u?-1:1)*c.height}),a}),$ye=Ge(Ic,bi,Fye,MM,EM,(t,e,n,r,i)=>{var a={},s;return n.forEach(o=>{var c=Uye(e,o);s==null&&(s=Bye(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[o.id]=s-Number(u)*c.width,s+=(u?-1:1)*c.width}),a}),Vye=(t,e)=>{var n=Sl(t,e);if(n!=null)return Hye(t,n.orientation,n.mirror)},Gye=Ge([bi,Sl,Vye,(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}}}),Wye=(t,e)=>{var n=Ml(t,e);if(n!=null)return $ye(t,n.orientation,n.mirror)},qye=Ge([bi,Ml,Wye,(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}}}),VK=Ge(bi,Ml,(t,e)=>{var n=typeof e.width=="number"?e.width:Mb;return{width:n,height:t.height}}),QB=(t,e,n)=>{switch(e){case"xAxis":return $K(t,n).width;case"yAxis":return VK(t,n).height;default:return}},GK=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:s}=n,o=wl(t,r),c=e.map(u=>u.value);if(s&&o&&a==="category"&&i&&WG(c))return c}},xj=Ge([xn,wM,Mr,xr],GK),WK=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,s=wl(t,r);if(s&&(i==="number"||a!=="auto"))return e.map(o=>o.value)}},bj=Ge([xn,wM,jb,xr],WK),JB=Ge([xn,aye,ig,ld,xj,bj,Fb,mj,xr],(t,e,n,r,i,a,s,o,c)=>{if(e!=null){var u=wl(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:u,niceTicks:o,range:s,realScaleType:n,scale:r}}}),Kye=(t,e,n,r,i,a,s,o,c)=>{if(!(e==null||r==null)){var u=wl(t,c),{type:d,ticks:f,tickCount:g}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/m:0;x=c==="angleAxis"&&a!=null&&a.length>=2?Li(a[0]-a[1])*2*x:x;var v=f||i;if(v){var y=v.map((b,M)=>{var S=s?s.indexOf(b):b;return{index:M,coordinate:r(S)+x,value:b,offset:x}});return y.filter(b=>Hn(b.coordinate))}return u&&o?o.map((b,M)=>({coordinate:r(b)+x,value:b,index:M,offset:x})).filter(b=>Hn(b.coordinate)):r.ticks?r.ticks(g).map(b=>({coordinate:r(b)+x,value:b,offset:x})):r.domain().map((b,M)=>({coordinate:r(b)+x,value:s?s[b]:b,index:M,offset:x}))}},qK=Ge([xn,jb,ig,ld,mj,Fb,xj,bj,xr],Kye),Xye=(t,e,n,r,i,a,s)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=wl(t,s),{tickCount:c}=e,u=0;return u=s==="angleAxis"&&r?.length>=2?Li(r[0]-r[1])*2*u:u,o&&a?a.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},pl=Ge([xn,jb,ld,Fb,xj,bj,xr],Xye),ml=Ge(Mr,ld,(t,e)=>{if(!(t==null||e==null))return uw(uw({},t),{},{scale:e})}),Yye=Ge([Mr,ig,hj,zK],fj);Ge((t,e,n)=>JD(t,n),Yye,(t,e)=>{if(!(t==null||e==null))return uw(uw({},t),{},{scale:e})});var Zye=Ge([xn,nM,rM],(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}}),KK=t=>t.options.defaultTooltipEventType,XK=t=>t.options.validateTooltipEventTypes;function YK(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function yj(t,e){var n=KK(t),r=XK(t);return YK(e,n,r)}function Qye(t){return Ct(e=>yj(e,t))}var ZK=(t,e)=>{var n,r=Number(e);if(!(Za(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},Jye=t=>t.tooltip.settings,Ou={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},eve={itemInteraction:{click:Ou,hover:Ou},axisInteraction:{click:Ou,hover:Ou},keyboardInteraction:Ou,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}},QK=Qa({name:"tooltip",initialState:eve,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:fr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:fr()},removeTooltipEntrySettings:{reducer(t,e){var n=Lo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:fr()},setTooltipSettingsState(t,e){t.settings=e.payload},setActiveMouseOverItemIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.itemInteraction.hover.active=!0,t.itemInteraction.hover.index=e.payload.activeIndex,t.itemInteraction.hover.dataKey=e.payload.activeDataKey,t.itemInteraction.hover.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.hover.coordinate=e.payload.activeCoordinate},mouseLeaveChart(t){t.itemInteraction.hover.active=!1,t.axisInteraction.hover.active=!1},mouseLeaveItem(t){t.itemInteraction.hover.active=!1},setActiveClickItemIndex(t,e){t.syncInteraction.active=!1,t.itemInteraction.click.active=!0,t.keyboardInteraction.active=!1,t.itemInteraction.click.index=e.payload.activeIndex,t.itemInteraction.click.dataKey=e.payload.activeDataKey,t.itemInteraction.click.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.click.coordinate=e.payload.activeCoordinate},setMouseOverAxisIndex(t,e){t.syncInteraction.active=!1,t.axisInteraction.hover.active=!0,t.keyboardInteraction.active=!1,t.axisInteraction.hover.index=e.payload.activeIndex,t.axisInteraction.hover.dataKey=e.payload.activeDataKey,t.axisInteraction.hover.coordinate=e.payload.activeCoordinate},setMouseClickAxisIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.axisInteraction.click.active=!0,t.axisInteraction.click.index=e.payload.activeIndex,t.axisInteraction.click.dataKey=e.payload.activeDataKey,t.axisInteraction.click.coordinate=e.payload.activeCoordinate},setSyncInteraction(t,e){t.syncInteraction=e.payload},setKeyboardInteraction(t,e){t.keyboardInteraction.active=e.payload.active,t.keyboardInteraction.index=e.payload.activeIndex,t.keyboardInteraction.coordinate=e.payload.activeCoordinate,t.keyboardInteraction.dataKey=e.payload.activeDataKey}}}),{addTooltipEntrySettings:tve,replaceTooltipEntrySettings:nve,removeTooltipEntrySettings:rve,setTooltipSettingsState:ive,setActiveMouseOverItemIndex:JK,mouseLeaveItem:ave,mouseLeaveChart:eX,setActiveClickItemIndex:sve,setMouseOverAxisIndex:tX,setMouseClickAxisIndex:ove,setSyncInteraction:S3,setKeyboardInteraction:M3}=QK.actions,lve=QK.reducer;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 kv(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){cve(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 cve(t,e,n){return(e=uve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uve(t){var e=dve(t,"string");return typeof e=="symbol"?e:e+""}function dve(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 hve(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function fve(t){return t.index!=null}var nX=(t,e,n,r)=>{if(e==null)return Ou;var i=hve(t,e,n);if(i==null)return Ou;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var a=t.settings.active===!0;if(fve(i)){if(a)return kv(kv({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return kv(kv({},Ou),{},{coordinate:i.coordinate})};function pve(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 mve(t,e){var n=pve(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),s=Math.max(r,i);return n>=a&&n<=s}function gve(t,e,n){if(n==null||e==null)return!0;var r=Bn(t,e);return r==null||!od(n)?!0:mve(r,n)}var vj=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!Hn(a))return i;var s=0,o=1/0;e.length>0&&(o=e.length-1);var c=Math.max(s,Math.min(a,o)),u=e[c];return u==null||gve(u,n,r)?String(c):null},rX=(t,e,n,r,i,a,s,o)=>{if(!(a==null||o==null)){var c=s[0],u=c==null?void 0:o(c.positions,a);if(u!=null)return u;var d=i?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},iX=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var s;return((s=a.settings)===null||s===void 0?void 0:s.dataKey)===i})},Ub=t=>t.options.tooltipPayloadSearcher,ag=t=>t.tooltip;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 n8(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){xve(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 xve(t,e,n){return(e=bve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bve(t){var e=yve(t,"string");return typeof e=="symbol"?e:e+""}function yve(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 vve(t,e){return t??e}var aX=(t,e,n,r,i,a,s)=>{if(!(e==null||a==null)){var{chartData:o,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((g,m)=>{var x,{dataDefinedOnItem:v,settings:y}=m,b=vve(v,o),M=Array.isArray(b)?BW(b,u,d):b,S=(x=y?.dataKey)!==null&&x!==void 0?x:r,A=y?.nameKey,T;if(r&&Array.isArray(M)&&!Array.isArray(M[0])&&s==="axis"?T=qG(M,r,i):T=a(M,e,c,A),Array.isArray(T))T.forEach(N=>{var I=n8(n8({},y),{},{name:N.name,unit:N.unit,color:void 0,fill:void 0});g.push(wz({tooltipEntrySettings:I,dataKey:N.dataKey,payload:N.payload,value:Bn(N.payload,N.dataKey),name:N.name}))});else{var k;g.push(wz({tooltipEntrySettings:y,dataKey:S,payload:T,value:Bn(T,S),name:(k=Bn(T,A))!==null&&k!==void 0?k:y?.name}))}return g},f)}},_j=Ge([wi,xn,AK,qD,_i],FK),_ve=Ge([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),wve=Ge([_i,ng],ej),zb=Ge([_ve,wi,wve],tj,{memoizeOptions:{resultEqualityCheck:_M}}),Sve=Ge([zb],t=>t.filter(yM)),Mve=Ge([zb],nj,{memoizeOptions:{resultEqualityCheck:_M}}),sg=Ge([Mve,wd],rj),Eve=Ge([Sve,wd,wi],SK),wj=Ge([sg,wi,zb],aj),sX=Ge([wi],sj),Ave=Ge([wi],t=>t.allowDataOverflow),oX=Ge([sX,Ave],eK),Tve=Ge([zb],t=>t.filter(yM)),Cve=Ge([Eve,Tve,Rb,gK],kK),Nve=Ge([Cve,wd,_i,oX],PK),kve=Ge([zb],CK),Pve=Ge([sg,wi,kve,SM,_i],cj,{memoizeOptions:{resultEqualityCheck:vM}}),Rve=Ge([RK,_i,ng],rg),Dve=Ge([Rve,_i],OK),jve=Ge([DK,_i,ng],rg),Ove=Ge([jve,_i],LK),Lve=Ge([jK,_i,ng],rg),Ive=Ge([Lve,_i],IK),Fve=Ge([Dve,Ive,Ove],dw),Uve=Ge([wi,sX,oX,Nve,Pve,Fve,xn,_i],uj),Bb=Ge([wi,xn,sg,wj,Rb,_i,Uve],dj),zve=Ge([Bb,wi,_j],pj),Bve=Ge([wi,Bb,zve,_i],gj),lX=t=>{var e=_i(t),n=ng(t),r=!1;return Fb(t,e,n,r)},cX=Ge([wi,lX],gM),uX=Ge([wi,_j,Bve,cX],fj),Hve=Ge([xn,wj,wi,_i],GK),$ve=Ge([xn,wj,wi,_i],WK),Vve=(t,e,n,r,i,a,s,o)=>{if(e){var{type:c}=e,u=wl(t,o);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=o==="angleAxis"&&i!=null&&i?.length>=2?Li(i[0]-i[1])*2*f:f,u&&s?s.map((g,m)=>({coordinate:r(g)+f,value:g,index:m,offset:f})):r.domain().map((g,m)=>({coordinate:r(g)+f,value:a?a[g]:g,index:m,offset:f}))}}},zc=Ge([xn,wi,_j,uX,lX,Hve,$ve,_i],Vve),Sj=Ge([KK,XK,Jye],(t,e,n)=>YK(n.shared,t,e)),dX=t=>t.tooltip.settings.trigger,Mj=t=>t.tooltip.settings.defaultIndex,Hb=Ge([ag,Sj,dX,Mj],nX),cd=Ge([Hb,sg,Ib,Bb],vj),hX=Ge([zc,cd],ZK),Ej=Ge([Hb],t=>{if(t)return t.dataKey}),Gve=Ge([Hb],t=>{if(t)return t.graphicalItemId}),fX=Ge([ag,Sj,dX,Mj],iX),Wve=Ge([Ic,Fc,xn,bi,zc,Mj,fX,Ub],rX),qve=Ge([Hb,Wve],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),Kve=Ge([Hb],t=>t.active),Xve=Ge([fX,cd,wd,Ib,hX,Ub,Sj],aX),Yve=Ge([Xve],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function r8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function i8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r8(Object(n),!0).forEach(function(r){Zve(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zve(t,e,n){return(e=Qve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qve(t){var e=Jve(t,"string");return typeof e=="symbol"?e:e+""}function Jve(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var e_e=()=>Ct(wi),t_e=()=>{var t=e_e(),e=Ct(zc),n=Ct(uX);return sd(!t||!n?void 0:i8(i8({},t),{},{scale:n}),e)};function a8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Jf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?a8(Object(n),!0).forEach(function(r){n_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function n_e(t,e,n){return(e=r_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r_e(t){var e=i_e(t,"string");return typeof e=="symbol"?e:e+""}function i_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 a_e=(t,e,n,r)=>{var i=e.find(a=>a&&a.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},s_e=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:s}=r;return Jf(Jf(Jf({},r),Jr(r.cx,r.cy,s,a)),{},{angle:a,radius:s})}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 o_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 pX=(t,e,n,r,i)=>{var a,s=-1,o=(a=e?.length)!==null&&a!==void 0?a:0;if(o<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<o;c++){var u=c>0?n[c-1].coordinate:n[o-1].coordinate,d=n[c].coordinate,f=c>=o-1?n[0].coordinate:n[c+1].coordinate,g=void 0;if(Li(d-u)!==Li(f-d)){var m=[];if(Li(f-d)===Li(i[1]-i[0])){g=f;var x=d+i[1]-i[0];m[0]=Math.min(x,(x+u)/2),m[1]=Math.max(x,(x+u)/2)}else{g=u;var v=f+i[1]-i[0];m[0]=Math.min(d,(v+d)/2),m[1]=Math.max(d,(v+d)/2)}var y=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>y[0]&&t<=y[1]||t>=m[0]&&t<=m[1]){({index:s}=n[c]);break}}else{var b=Math.min(u,f),M=Math.max(u,f);if(t>(b+d)/2&&t<=(M+d)/2){({index:s}=n[c]);break}}}else if(e){for(var S=0;S<o;S++)if(S===0&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S>0&&S<o-1&&t>(e[S].coordinate+e[S-1].coordinate)/2&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S===o-1&&t>(e[S].coordinate+e[S-1].coordinate)/2){({index:s}=e[S]);break}}return s},mX=()=>Ct(qD),Aj=(t,e)=>e,gX=(t,e,n)=>n,Tj=(t,e,n,r)=>r,l_e=Ge(zc,t=>qS(t,e=>e.coordinate)),Cj=Ge([ag,Aj,gX,Tj],nX),Nj=Ge([Cj,sg,Ib,Bb],vj),c_e=(t,e,n)=>{if(e!=null){var r=ag(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},xX=Ge([ag,Aj,gX,Tj],iX),hw=Ge([Ic,Fc,xn,bi,zc,Tj,xX,Ub],rX),u_e=Ge([Cj,hw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),bX=Ge([zc,Nj],ZK),d_e=Ge([xX,Nj,wd,Ib,bX,Ub,Aj],aX),h_e=Ge([Cj,Nj],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),f_e=(t,e,n,r,i,a,s)=>{if(!(!t||!n||!r||!i)&&o_e(t,s)){var o=jpe(t,e),c=pX(o,a,i,n,r),u=a_e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},p_e=(t,e,n,r,i,a,s)=>{if(!(!t||!r||!i||!a||!n)){var o=Zge(t,n);if(o){var c=Ope(o,e),u=pX(c,s,a,r,i),d=s_e(e,a,u,o);return{activeIndex:String(u),activeCoordinate:d}}}},m_e=(t,e,n,r,i,a,s,o)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?f_e(t,e,r,i,a,s,o):p_e(t,e,n,r,i,a,s)},g_e=Ge(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),x_e=Ge(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Rr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:eye}});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 o8(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){b_e(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 b_e(t,e,n){return(e=y_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function y_e(t){var e=v_e(t,"string");return typeof e=="symbol"?e:e+""}function v_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var __e={},w_e={zIndexMap:Object.values(Rr).reduce((t,e)=>o8(o8({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),__e)},S_e=new Set(Object.values(Rr));function M_e(t){return S_e.has(t)}var yX=Qa({name:"zIndex",initialState:w_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&&!M_e(n)&&delete t.zIndexMap[n])},prepare:fr()},registerZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n,elementId:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElementId=r:t.zIndexMap[n].elementId=r:t.zIndexMap[n]={consumers:0,elementId:i?void 0:r,panoramaElementId:i?r:void 0}},prepare:fr()},unregisterZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElementId=void 0:t.zIndexMap[n].elementId=void 0)},prepare:fr()}}}),{registerZIndexPortal:E_e,unregisterZIndexPortal:A_e,registerZIndexPortalId:T_e,unregisterZIndexPortalId:C_e}=yX.actions,N_e=yX.reducer;function ma(t){var{zIndex:e,children:n}=t,r=fme(),i=r&&e!==void 0&&e!==0,a=yi(),s=rr();E.useLayoutEffect(()=>i?(s(E_e({zIndex:e})),()=>{s(A_e({zIndex:e}))}):yb,[s,e,i]);var o=Ct(u=>g_e(u,e,a));if(!i)return n;if(!o)return null;var c=document.getElementById(o);return c?hc.createPortal(n,c):null}function E3(){return E3=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},E3.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 Pv(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){k_e(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 k_e(t,e,n){return(e=P_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function P_e(t){var e=R_e(t,"string");return typeof e=="symbol"?e:e+""}function R_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function D_e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return E.isValidElement(e)?E.cloneElement(e,r):E.createElement(n,r)}function j_e(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:s,layout:o,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,g=r,m=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,v,y;if(d==="ScatterChart")x=f,v=hge,y=Rr.cursorLine;else if(d==="BarChart")x=fge(o,f,a,s),v=pq,y=Rr.cursorRectangle;else if(o==="radial"&&XG(f)){var{cx:b,cy:M,radius:S,startAngle:A,endAngle:T}=gq(f);x={cx:b,cy:M,startAngle:A,endAngle:T,innerRadius:S,outerRadius:S},v=bq,y=Rr.cursorLine}else x={points:txe(o,f,a)},v=tm,y=Rr.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,N=Pv(Pv(Pv(Pv({stroke:"#ccc",pointerEvents:"none"},a),x),Gh(c)),{},{payload:g,payloadIndex:m,className:Mn("recharts-tooltip-cursor",k)});return E.createElement(ma,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:y},E.createElement(D_e,{cursor:c,cursorComp:v,cursorProps:N}))}function O_e(t){var e=t_e(),n=QW(),r=hf(),i=mX();return e==null||n==null||r==null||i==null?null:E.createElement(j_e,E3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var vX=E.createContext(null),L_e=()=>E.useContext(vX),YT={exports:{}},c8;function I_e(){return c8||(c8=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var 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 s(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},o.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,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 v=n?n+u:u;if(!this._events[v])return!1;var y=this._events[v],b=arguments.length,M,S;if(y.fn){switch(y.once&&this.removeListener(u,y.fn,void 0,!0),b){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,f),!0;case 4:return y.fn.call(y.context,d,f,g),!0;case 5:return y.fn.call(y.context,d,f,g,m),!0;case 6:return y.fn.call(y.context,d,f,g,m,x),!0}for(S=1,M=new Array(b-1);S<b;S++)M[S-1]=arguments[S];y.fn.apply(y.context,M)}else{var A=y.length,T;for(S=0;S<A;S++)switch(y[S].once&&this.removeListener(u,y[S].fn,void 0,!0),b){case 1:y[S].fn.call(y[S].context);break;case 2:y[S].fn.call(y[S].context,d);break;case 3:y[S].fn.call(y[S].context,d,f);break;case 4:y[S].fn.call(y[S].context,d,f,g);break;default:if(!M)for(T=1,M=new Array(b-1);T<b;T++)M[T-1]=arguments[T];y[S].fn.apply(y[S].context,M)}}return!0},o.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},o.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},o.prototype.removeListener=function(u,d,f,g){var m=n?n+u:u;if(!this._events[m])return this;if(!d)return s(this,m),this;var x=this._events[m];if(x.fn)x.fn===d&&(!g||x.once)&&(!f||x.context===f)&&s(this,m);else{for(var v=0,y=[],b=x.length;v<b;v++)(x[v].fn!==d||g&&!x[v].once||f&&x[v].context!==f)&&y.push(x[v]);y.length?this._events[m]=y.length===1?y[0]:y:s(this,m)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&s(this,d)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o})(YT)),YT.exports}var F_e=I_e();const U_e=fo(F_e);var B0=new U_e,A3="recharts.syncEvent.tooltip",u8="recharts.syncEvent.brush";function AM(t,e){if(e){var n=Number.parseInt(e,10);if(!Za(n))return t?.[n]}}var z_e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},_X=Qa({name:"options",initialState:z_e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),B_e=_X.reducer,{createEventEmitter:H_e}=_X.actions;function $_e(t){return t.tooltip.syncInteraction}var V_e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},wX=Qa({name:"chartData",initialState:V_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:d8,setDataStartEndIndexes:G_e,setComputedData:BGe}=wX.actions,W_e=wX.reducer,q_e=["x","y"];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 ep(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){K_e(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 K_e(t,e,n){return(e=X_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X_e(t){var e=Y_e(t,"string");return typeof e=="symbol"?e:e+""}function Y_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Z_e(t,e){if(t==null)return{};var n,r,i=Q_e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Q_e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function J_e(){var t=Ct(KD),e=Ct(XD),n=rr(),r=Ct(xK),i=Ct(zc),a=hf(),s=Eb(),o=Ct(c=>c.rootProps.className);E.useEffect(()=>{if(t==null)return yb;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var g;if(s&&d!==null&&d!==void 0&&(g=d.payload)!==null&&g!==void 0&&g.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x,y:v}=m,y=Z_e(m,q_e),{x:b,y:M,width:S,height:A}=d.payload.sourceViewBox,T=ep(ep({},y),{},{x:s.x+(S?(x-b)/S:0)*s.width,y:s.y+(A?(v-M)/A:0)*s.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||s==null){n(S3({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,O=Math.min(D,s.x+s.width),q=Math.min(F,s.y+s.height),R={x:a==="horizontal"?k.coordinate:O,y:a==="horizontal"?q:k.coordinate},W=S3({active:d.payload.active,coordinate:R,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(W)}}};return B0.on(A3,c),()=>{B0.off(A3,c)}},[o,n,e,t,r,i,a,s])}function e1e(){var t=Ct(KD),e=Ct(XD),n=rr();E.useEffect(()=>{if(t==null)return yb;var r=(i,a,s)=>{e!==s&&t===i&&n(G_e(a))};return B0.on(u8,r),()=>{B0.off(u8,r)}},[n,e,t])}function t1e(){var t=rr();E.useEffect(()=>{t(H_e())},[t]),J_e(),e1e()}function n1e(t,e,n,r,i,a){var s=Ct(m=>c_e(m,t,e)),o=Ct(XD),c=Ct(KD),u=Ct(xK),d=Ct($_e),f=d?.active,g=Eb();E.useEffect(()=>{if(!f&&c!=null&&o!=null){var m=S3({active:a,coordinate:n,dataKey:s,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});B0.emit(A3,c,m,o)}},[f,n,s,i,r,o,c,u,a,g])}function f8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function p8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?f8(Object(n),!0).forEach(function(r){r1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r1e(t,e,n){return(e=i1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i1e(t){var e=a1e(t,"string");return typeof e=="symbol"?e:e+""}function a1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function s1e(t){return t.dataKey}function o1e(t,e){return E.isValidElement(t)?E.cloneElement(t,e):typeof t=="function"?E.createElement(t,e):E.createElement(Gme,e)}var m8=[],l1e={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function i1(t){var e,n,r=Sr(t,l1e),{active:i,allowEscapeViewBox:a,animationDuration:s,animationEasing:o,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:g,position:m,reverseDirection:x,useTranslate3d:v,wrapperStyle:y,cursor:b,shared:M,trigger:S,defaultIndex:A,portal:T,axisId:k}=r,N=rr(),I=typeof A=="number"?String(A):A;E.useEffect(()=>{N(ive({shared:M,trigger:S,axisId:k,active:i,defaultIndex:I}))},[N,M,S,k,i,I]);var C=Eb(),D=cq(),F=Qye(M),{activeIndex:O,isActive:q}=(e=Ct(xe=>h_e(xe,F,S,I)))!==null&&e!==void 0?e:{},R=Ct(xe=>d_e(xe,F,S,I)),W=Ct(xe=>bX(xe,F,S,I)),K=Ct(xe=>u_e(xe,F,S,I)),G=R,ee=L_e(),Z=(n=i??q)!==null&&n!==void 0?n:!1,[Q,U]=dW([G,Z]),$=F==="axis"?W:void 0;n1e(F,S,K,$,O,Z);var X=T??ee;if(X==null||C==null||F==null)return null;var te=G??m8;Z||(te=m8),u&&te.length&&(te=aW(te.filter(xe=>xe.value!=null&&(xe.hide!==!0||r.includeHidden)),g,s1e));var fe=te.length>0,pe=E.createElement(Qme,{allowEscapeViewBox:a,animationDuration:s,animationEasing:o,isAnimationActive:d,active:Z,coordinate:K,hasPayload:fe,offset:f,position:m,reverseDirection:x,useTranslate3d:v,viewBox:C,wrapperStyle:y,lastBoundingBox:Q,innerRef:U,hasPortalFromProps:!!T},o1e(c,p8(p8({},r),{},{payload:te,label:$,active:Z,activeIndex:O,coordinate:K,accessibilityLayer:D})));return E.createElement(E.Fragment,null,hc.createPortal(pe,X),Z&&E.createElement(O_e,{cursor:b,tooltipEventType:F,coordinate:K,payload:te,index:O}))}var $b=t=>null;$b.displayName="Cell";function c1e(t,e,n){return(e=u1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u1e(t){var e=d1e(t,"string");return typeof e=="symbol"?e:e+""}function d1e(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 h1e{constructor(e){c1e(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 g8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function f1e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?g8(Object(n),!0).forEach(function(r){p1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function p1e(t,e,n){return(e=m1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function m1e(t){var e=g1e(t,"string");return typeof e=="symbol"?e:e+""}function g1e(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 x1e={cacheSize:2e3,enableCache:!0},SX=f1e({},x1e),x8=new h1e(SX.cacheSize),b1e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},b8="recharts_measurement_span";function y1e(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",s=e.letterSpacing||"",o=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(s,"|").concat(o)}var y8=(t,e)=>{try{var n=document.getElementById(b8);n||(n=document.createElement("span"),n.setAttribute("id",b8),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,b1e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},qx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Ym.isSsr)return{width:0,height:0};if(!SX.enableCache)return y8(e,n);var r=y1e(e,n),i=x8.get(r);if(i)return i;var a=y8(e,n);return x8.set(r,a),a},v8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,_8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,v1e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,_1e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,MX={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},w1e=Object.keys(MX),Wp="NaN";function S1e(t,e){return t*MX[e]}class $a{static parse(e){var n,[,r,i]=(n=_1e.exec(e))!==null&&n!==void 0?n:[];return new $a(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Za(e)&&(this.unit=""),n!==""&&!v1e.test(n)&&(this.num=NaN,this.unit=""),w1e.includes(n)&&(this.num=S1e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new $a(NaN,""):new $a(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new $a(NaN,""):new $a(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new $a(NaN,""):new $a(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new $a(NaN,""):new $a(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Za(this.num)}}function EX(t){if(t.includes(Wp))return Wp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=v8.exec(e))!==null&&n!==void 0?n:[],s=$a.parse(r??""),o=$a.parse(a??""),c=i==="*"?s.multiply(o):s.divide(o);if(c.isNaN())return Wp;e=e.replace(v8,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=_8.exec(e))!==null&&u!==void 0?u:[],m=$a.parse(d??""),x=$a.parse(g??""),v=f==="+"?m.add(x):m.subtract(x);if(v.isNaN())return Wp;e=e.replace(_8,v.toString())}return e}var w8=/\(([^()]*)\)/;function M1e(t){for(var e=t,n;(n=w8.exec(e))!=null;){var[,r]=n;e=e.replace(w8,EX(r))}return e}function E1e(t){var e=t.replace(/\s+/g,"");return e=M1e(e),e=EX(e),e}function A1e(t){try{return E1e(t)}catch{return Wp}}function ZT(t){var e=A1e(t.slice(5,-1));return e===Wp?"":e}var T1e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],C1e=["dx","dy","angle","className","breakAll"];function T3(){return T3=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},T3.apply(null,arguments)}function S8(t,e){if(t==null)return{};var n,r,i=N1e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function N1e(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 AX=/[ \f\n\r\t\v\u2028\u2029]+/,TX=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];dr(e)||(n?i=e.toString().split(""):i=e.toString().split(AX));var a=i.map(o=>({word:o,width:qx(o,r).width})),s=n?0:qx(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:s}}catch{return null}};function k1e(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var CX=(t,e,n,r)=>t.reduce((i,a)=>{var{word:s,width:o}=a,c=i[i.length-1];if(c&&o!=null&&(e==null||r||c.width+o+n<Number(e)))c.words.push(s),c.width+=o+n;else{var u={words:[s],width:o};i.push(u)}return i},[]),NX=t=>t.reduce((e,n)=>e.width>n.width?e:n),P1e="…",M8=(t,e,n,r,i,a,s,o)=>{var c=t.slice(0,e),u=TX({breakAll:n,style:r,children:c+P1e});if(!u)return[!1,[]];var d=CX(u.wordsWithComputedWidth,a,s,o),f=d.length>i||NX(d).width>Number(a);return[f,d]},R1e=(t,e,n,r,i)=>{var{maxLines:a,children:s,style:o,breakAll:c}=t,u=Pt(a),d=String(s),f=CX(e,r,n,i);if(!u||i)return f;var g=f.length>a||NX(f).width>Number(r);if(!g)return f;for(var m=0,x=d.length-1,v=0,y;m<=x&&v<=d.length-1;){var b=Math.floor((m+x)/2),M=b-1,[S,A]=M8(d,M,c,o,a,r,n,i),[T]=M8(d,b,c,o,a,r,n,i);if(!S&&!T&&(m=b+1),S&&T&&(x=b-1),!S&&T){y=A;break}v++}return y||f},E8=t=>{var e=dr(t)?[]:t.toString().split(AX);return[{words:e,width:void 0}]},D1e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:s}=t;if((e||n)&&!Ym.isSsr){var o,c,u=TX({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;o=d,c=f}else return E8(r);return R1e({breakAll:a,children:r,maxLines:s,style:i},o,c,e,!!n)}return E8(r)},kX="#808080",j1e={angle:0,breakAll:!1,capHeight:"0.71em",fill:kX,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},TM=E.forwardRef((t,e)=>{var n=Sr(t,j1e),{x:r,y:i,lineHeight:a,capHeight:s,fill:o,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=S8(n,T1e),g=E.useMemo(()=>D1e({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:v,className:y,breakAll:b}=f,M=S8(f,C1e);if(!co(r)||!co(i)||g.length===0)return null;var S=Number(r)+(Pt(m)?m:0),A=Number(i)+(Pt(x)?x:0);if(!Hn(S)||!Hn(A))return null;var T;switch(d){case"start":T=ZT("calc(".concat(s,")"));break;case"middle":T=ZT("calc(".concat((g.length-1)/2," * -").concat(a," + (").concat(s," / 2))"));break;default:T=ZT("calc(".concat(g.length-1," * -").concat(a,")"));break}var k=[];if(c){var N=g[0].width,{width:I}=f;k.push("scale(".concat(Pt(I)&&Pt(N)?I/N:1,")"))}return v&&k.push("rotate(".concat(v,", ").concat(S,", ").concat(A,")")),k.length&&(M.transform=k.join(" ")),E.createElement("text",T3({},na(M),{ref:e,x:S,y:A,className:Mn("recharts-text",y),textAnchor:u,fill:o.includes("url")?kX:o}),g.map((C,D)=>{var F=C.words.join(b?"":" ");return E.createElement("tspan",{x:S,dy:D===0?T:a,key:"".concat(F,"-").concat(D)},F)}))});TM.displayName="Text";var O1e=["labelRef"];function L1e(t,e){if(t==null)return{};var n,r,i=I1e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function I1e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function A8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ur(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A8(Object(n),!0).forEach(function(r){F1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function F1e(t,e,n){return(e=U1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U1e(t){var e=z1e(t,"string");return typeof e=="symbol"?e:e+""}function z1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function uc(){return uc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},uc.apply(null,arguments)}var PX=E.createContext(null),RX=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s,children:o}=t,c=E.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s}),[e,n,r,i,a,s]);return E.createElement(PX.Provider,{value:c},o)},DX=()=>{var t=E.useContext(PX),e=Eb();return t||ZW(e)},B1e=E.createContext(null),H1e=()=>{var t=E.useContext(B1e),e=Ct(wK);return t||e},$1e=t=>{var{value:e,formatter:n}=t,r=dr(t.children)?e:t.children;return typeof n=="function"?n(r):r},kj=t=>t!=null&&typeof t=="function",V1e=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),360);return n*r},G1e=(t,e,n,r,i)=>{var{offset:a,className:s}=t,{cx:o,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:g,clockWise:m}=i,x=(u+d)/2,v=V1e(f,g),y=v>=0?1:-1,b,M;switch(e){case"insideStart":b=f+y*a,M=m;break;case"insideEnd":b=g-y*a,M=!m;break;case"end":b=g+y*a,M=m;break;default:throw new Error("Unsupported position ".concat(e))}M=v<=0?M:!M;var S=Jr(o,c,x,b),A=Jr(o,c,x,b+(M?1:-1)*359),T="M".concat(S.x,",").concat(S.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(M?0:1,`,
- `).concat(A.x,",").concat(A.y),k=dr(t.id)?T0("recharts-radial-line-"):t.id;return E.createElement("text",uc({},r,{dominantBaseline:"central",className:Mn("recharts-radial-bar-label",s)}),E.createElement("defs",null,E.createElement("path",{id:k,d:T})),E.createElement("textPath",{xlinkHref:"#".concat(k)},n))},W1e=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:s,startAngle:o,endAngle:c}=t,u=(o+c)/2;if(n==="outside"){var{x:d,y:f}=Jr(r,i,s+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(a+s)/2,{x:m,y:x}=Jr(r,i,g,u);return{x:m,y:x,textAnchor:"middle",verticalAnchor:"middle"}},C3=t=>"cx"in t&&Pt(t.cx),q1e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!C3(n)&&(a=n);var{x:s,y:o,upperWidth:c,lowerWidth:u,height:d}=e,f=s,g=s+(c-u)/2,m=(f+g)/2,x=(c+u)/2,v=f+c/2,y=d>=0?1:-1,b=y*r,M=y>0?"end":"start",S=y>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:M};return Ur(Ur({},I),a?{height:Math.max(o-a.y,0),width:c}:{})}if(i==="bottom"){var C={x:g+u/2,y:o+d+b,textAnchor:"middle",verticalAnchor:S};return Ur(Ur({},C),a?{height:Math.max(a.y+a.height-(o+d),0),width:u}:{})}if(i==="left"){var D={x:m-T,y:o+d/2,textAnchor:k,verticalAnchor:"middle"};return Ur(Ur({},D),a?{width:Math.max(D.x-a.x,0),height:d}:{})}if(i==="right"){var F={x:m+x+T,y:o+d/2,textAnchor:N,verticalAnchor:"middle"};return Ur(Ur({},F),a?{width:Math.max(a.x+a.width-F.x,0),height:d}:{})}var O=a?{width:x,height:d}:{};return i==="insideLeft"?Ur({x:m+T,y:o+d/2,textAnchor:N,verticalAnchor:"middle"},O):i==="insideRight"?Ur({x:m+x-T,y:o+d/2,textAnchor:k,verticalAnchor:"middle"},O):i==="insideTop"?Ur({x:f+c/2,y:o+b,textAnchor:"middle",verticalAnchor:S},O):i==="insideBottom"?Ur({x:g+u/2,y:o+d-b,textAnchor:"middle",verticalAnchor:M},O):i==="insideTopLeft"?Ur({x:f+T,y:o+b,textAnchor:N,verticalAnchor:S},O):i==="insideTopRight"?Ur({x:f+c-T,y:o+b,textAnchor:k,verticalAnchor:S},O):i==="insideBottomLeft"?Ur({x:g+T,y:o+d-b,textAnchor:N,verticalAnchor:M},O):i==="insideBottomRight"?Ur({x:g+u-T,y:o+d-b,textAnchor:k,verticalAnchor:M},O):i&&typeof i=="object"&&(Pt(i.x)||Cc(i.x))&&(Pt(i.y)||Cc(i.y))?Ur({x:s+pa(i.x,x),y:o+pa(i.y,d),textAnchor:"end",verticalAnchor:"end"},O):Ur({x:v,y:o+d/2,textAnchor:"middle",verticalAnchor:"middle"},O)},K1e={angle:0,offset:5,zIndex:Rr.label,position:"middle",textBreakAll:!1};function Cu(t){var e=Sr(t,K1e),{viewBox:n,position:r,value:i,children:a,content:s,className:o="",textBreakAll:c,labelRef:u}=e,d=H1e(),f=DX(),g=r==="center"?f:d??f,m,x,v;if(n==null?m=g:C3(n)?m=n:m=ZW(n),!m||dr(i)&&dr(a)&&!E.isValidElement(s)&&typeof s!="function")return null;var y=Ur(Ur({},e),{},{viewBox:m});if(E.isValidElement(s)){var{labelRef:b}=y,M=L1e(y,O1e);return E.cloneElement(s,M)}if(typeof s=="function"){if(x=E.createElement(s,y),E.isValidElement(x))return x}else x=$1e(e);var S=na(e);if(C3(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return G1e(e,r,x,S,m);v=W1e(m,e.offset,e.position)}else v=q1e(e,m);return E.createElement(ma,{zIndex:e.zIndex},E.createElement(TM,uc({ref:u,className:Mn("recharts-label",o)},S,v,{textAnchor:k1e(S.textAnchor)?S.textAnchor:v.textAnchor,breakAll:c}),x))}Cu.displayName="Label";var X1e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?E.createElement(Cu,uc({key:"label-implicit"},r)):co(t)?E.createElement(Cu,uc({key:"label-implicit",value:t},r)):E.isValidElement(t)?t.type===Cu?E.cloneElement(t,Ur({key:"label-implicit"},r)):E.createElement(Cu,uc({key:"label-implicit",content:t},r)):kj(t)?E.createElement(Cu,uc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?E.createElement(Cu,uc({},t,{key:"label-implicit"},r)):null};function jX(t){var{label:e,labelRef:n}=t,r=DX();return X1e(e,r,n)||null}var QT={},JT={},T8;function Y1e(){return T8||(T8=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={},C8;function Z1e(){return C8||(C8=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 N8;function Q1e(){return N8||(N8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Y1e(),n=Z1e(),r=iD();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(QT)),QT}var tC,k8;function J1e(){return k8||(k8=1,tC=Q1e().last),tC}var ewe=J1e();const twe=fo(ewe);var nwe=["valueAccessor"],rwe=["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 P8(t,e){if(t==null)return{};var n,r,i=iwe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function iwe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var awe=t=>Array.isArray(t.value)?twe(t.value):t.value,OX=E.createContext(void 0),Pj=OX.Provider,LX=E.createContext(void 0),swe=LX.Provider;function owe(){return E.useContext(OX)}function lwe(){return E.useContext(LX)}function a1(t){var{valueAccessor:e=awe}=t,n=P8(t,nwe),{dataKey:r,clockWise:i,id:a,textBreakAll:s,zIndex:o}=n,c=P8(n,rwe),u=owe(),d=lwe(),f=u||d;return!f||!f.length?null:E.createElement(ma,{zIndex:o??Rr.label},E.createElement(wr,{className:"recharts-label-list"},f.map((g,m)=>{var x,v=dr(r)?e(g,m):Bn(g&&g.payload,r),y=dr(a)?{}:{id:"".concat(a,"-").concat(m)};return E.createElement(Cu,fw({key:"label-".concat(m)},na(g),c,y,{fill:(x=n.fill)!==null&&x!==void 0?x:g.fill,parentViewBox:g.parentViewBox,value:v,textBreakAll:s,viewBox:g.viewBox,index:m,zIndex:0}))})))}a1.displayName="LabelList";function CM(t){var{label:e}=t;return e?e===!0?E.createElement(a1,{key:"labelList-implicit"}):E.isValidElement(e)||kj(e)?E.createElement(a1,{key:"labelList-implicit",content:e}):typeof e=="object"?E.createElement(a1,fw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function N3(){return N3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},N3.apply(null,arguments)}var IX=t=>{var{cx:e,cy:n,r,className:i}=t,a=Mn("recharts-dot",i);return Pt(e)&&Pt(n)&&Pt(r)?E.createElement("circle",N3({},Ca(t),rD(t),{className:a,cx:e,cy:n,r})):null},FX=t=>t.graphicalItems.polarItems,cwe=Ge([xr,Db],ej),NM=Ge([FX,Mr,cwe],tj),uwe=Ge([NM],nj),kM=Ge([uwe,VD],rj),dwe=Ge([kM,Mr,NM],aj);Ge([kM,Mr,NM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,s=Bn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:s,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Bn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var R8=()=>{},hwe=Ge([kM,Mr,NM,SM,xr],cj),fwe=Ge([Mr,oj,lj,R8,hwe,R8,xn,xr],uj),UX=Ge([Mr,xn,kM,dwe,Rb,xr,fwe],dj),pwe=Ge([UX,Mr,ig],pj);Ge([Mr,UX,pwe,xr],gj);var mwe={radiusAxis:{},angleAxis:{}},zX=Qa({name:"polarAxis",initialState:mwe,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:HGe,removeRadiusAxis:$Ge,addAngleAxis:VGe,removeAngleAxis:GGe}=zX.actions,gwe=zX.reducer;function D8(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 j8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D8(Object(n),!0).forEach(function(r){xwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xwe(t,e,n){return(e=bwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bwe(t){var e=ywe(t,"string");return typeof e=="symbol"?e:e+""}function ywe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var vwe=(t,e)=>e,Rj=Ge([FX,vwe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),_we=[],Dj=(t,e,n)=>n?.length===0?_we:n,BX=Ge([VD,Rj,Dj],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(a=>j8(j8({},e.presentationProps),a.props))),i!=null)return i}}),wwe=Ge([BX,Rj,Dj],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,s=Bn(r,e.nameKey,e.name),o;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:yd(s,e.dataKey),color:o,payload:r,type:e.legendType}})}),Swe=Ge([BX,Rj,Dj,bi],(t,e,n,r)=>{if(!(e==null||t==null))return MSe({offset:r,pieSettings:e,displayedData:t,cells:n})}),nC={exports:{}},Wn={};var O8;function Mwe(){if(O8)return Wn;O8=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function x(v){if(typeof v=="object"&&v!==null){var y=v.$$typeof;switch(y){case t:switch(v=v.type,v){case n:case i:case r:case c:case u:case g:return v;default:switch(v=v&&v.$$typeof,v){case s:case o:case f:case d:return v;case a:return v;default:return y}}case e:return y}}}return Wn.ContextConsumer=a,Wn.ContextProvider=s,Wn.Element=t,Wn.ForwardRef=o,Wn.Fragment=n,Wn.Lazy=f,Wn.Memo=d,Wn.Portal=e,Wn.Profiler=i,Wn.StrictMode=r,Wn.Suspense=c,Wn.SuspenseList=u,Wn.isContextConsumer=function(v){return x(v)===a},Wn.isContextProvider=function(v){return x(v)===s},Wn.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},Wn.isForwardRef=function(v){return x(v)===o},Wn.isFragment=function(v){return x(v)===n},Wn.isLazy=function(v){return x(v)===f},Wn.isMemo=function(v){return x(v)===d},Wn.isPortal=function(v){return x(v)===e},Wn.isProfiler=function(v){return x(v)===i},Wn.isStrictMode=function(v){return x(v)===r},Wn.isSuspense=function(v){return x(v)===c},Wn.isSuspenseList=function(v){return x(v)===u},Wn.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===c||v===u||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===d||v.$$typeof===s||v.$$typeof===a||v.$$typeof===o||v.$$typeof===m||v.getModuleId!==void 0)},Wn.typeOf=x,Wn}var L8;function Ewe(){return L8||(L8=1,nC.exports=Mwe()),nC.exports}var Awe=Ewe(),I8=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",F8=null,rC=null,HX=t=>{if(t===F8&&Array.isArray(rC))return rC;var e=[];return E.Children.forEach(t,n=>{dr(n)||(Awe.isFragment(n)?e=e.concat(HX(n.props.children)):e.push(n))}),rC=e,F8=t,e};function jj(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>I8(i)):r=[I8(e)],HX(t).forEach(i=>{var a=Wh(i,"type.displayName")||Wh(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var Oj=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,iC={},U8;function Twe(){return U8||(U8=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 aC,z8;function Cwe(){return z8||(z8=1,aC=Twe().isPlainObject),aC}var Nwe=Cwe();const kwe=fo(Nwe);function B8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function H8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B8(Object(n),!0).forEach(function(r){Pwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pwe(t,e,n){return(e=Rwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rwe(t){var e=Dwe(t,"string");return typeof e=="symbol"?e:e+""}function Dwe(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 $8=(t,e,n,r,i)=>{var a=n-r,s;return s="M ".concat(t,",").concat(e),s+="L ".concat(t+n,",").concat(e),s+="L ".concat(t+n-a/2,",").concat(e+i),s+="L ".concat(t+n-a/2-r,",").concat(e+i),s+="L ".concat(t,",").concat(e," Z"),s},jwe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Owe=t=>{var e=Sr(t,jwe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:s,className:o}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,g=E.useRef(null),[m,x]=E.useState(-1),v=E.useRef(i),y=E.useRef(a),b=E.useRef(s),M=E.useRef(n),S=E.useRef(r),A=Qm(t,"trapezoid-");if(E.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var R=g.current.getTotalLength();R&&x(R)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||s!==+s||i===0&&a===0||s===0)return null;var T=Mn("recharts-trapezoid",o);if(!f)return E.createElement("g",null,E.createElement("path",pw({},na(e),{className:T,d:$8(n,r,i,a,s)})));var k=v.current,N=y.current,I=b.current,C=M.current,D=S.current,F="0px ".concat(m===-1?1:m,"px"),O="".concat(m,"px 0px"),q=uq(["strokeDasharray"],u,c);return E.createElement(Zm,{animationId:A,key:A,canBegin:m>0,duration:u,easing:c,isActive:f,begin:d},R=>{var W=jn(k,i,R),K=jn(N,a,R),G=jn(I,s,R),ee=jn(C,n,R),Z=jn(D,r,R);g.current&&(v.current=W,y.current=K,b.current=G,M.current=ee,S.current=Z);var Q=R>0?{transition:q,strokeDasharray:O}:{strokeDasharray:F};return E.createElement("path",pw({},na(e),{className:T,d:$8(ee,Z,W,K,G),ref:g,style:H8(H8({},Q),e.style)}))})},Lwe=["option","shapeType","propTransformer","activeClassName"];function Iwe(t,e){if(t==null)return{};var n,r,i=Fwe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Fwe(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 V8(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?V8(Object(n),!0).forEach(function(r){Uwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Uwe(t,e,n){return(e=zwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zwe(t){var e=Bwe(t,"string");return typeof e=="symbol"?e:e+""}function Bwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Hwe(t,e){return mw(mw({},e),t)}function $we(t,e){return t==="symbols"}function G8(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return E.createElement(pq,n);case"trapezoid":return E.createElement(Owe,n);case"sector":return E.createElement(bq,n);case"symbols":if($we(e))return E.createElement(nD,n);break;case"curve":return E.createElement(tm,n);default:return null}}function Vwe(t){return E.isValidElement(t)?t.props:t}function Lj(t){var{option:e,shapeType:n,propTransformer:r=Hwe,activeClassName:i="recharts-active-shape"}=t,a=Iwe(t,Lwe),s;if(E.isValidElement(e))s=E.cloneElement(e,mw(mw({},a),Vwe(e)));else if(typeof e=="function")s=e(a,a.index);else if(kwe(e)&&typeof e!="boolean"){var o=r(e,a);s=E.createElement(G8,{shapeType:n,elementProps:o})}else{var c=a;s=E.createElement(G8,{shapeType:n,elementProps:c})}return a.isActive?E.createElement(wr,{className:i},s):s}var Ij=(t,e,n)=>{var r=rr();return(i,a)=>s=>{t?.(i,a,s),r(JK({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},Fj=t=>{var e=rr();return(n,r)=>i=>{t?.(n,r,i),e(ave())}},Uj=(t,e,n)=>{var r=rr();return(i,a)=>s=>{t?.(i,a,s),r(sve({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function PM(t){var{tooltipEntrySettings:e}=t,n=rr(),r=yi(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(tve(e)):i.current!==e&&n(nve({prev:i.current,next:e})),i.current=e)},[e,n,r]),E.useLayoutEffect(()=>()=>{i.current&&(n(rve(i.current)),i.current=null)},[n]),null}function zj(t){var{legendPayload:e}=t,n=rr(),r=yi(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(sq(e)):i.current!==e&&n(oq({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(lq(i.current)),i.current=null)},[n]),null}function Gwe(t){var{legendPayload:e}=t,n=rr(),r=Ct(xn),i=E.useRef(null);return E.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(sq(e)):i.current!==e&&n(oq({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(lq(i.current)),i.current=null)},[n]),null}var sC,Wwe=()=>{var[t]=E.useState(()=>T0("uid-"));return t},qwe=(sC=Are.useId)!==null&&sC!==void 0?sC:Wwe;function $X(t,e){var n=qwe();return e||(t?"".concat(t,"-").concat(n):n)}var Kwe=E.createContext(void 0),RM=t=>{var{id:e,type:n,children:r}=t,i=$X("recharts-".concat(n),e);return E.createElement(Kwe.Provider,{value:i},r(i))},Xwe={cartesianItems:[],polarItems:[]},VX=Qa({name:"graphicalItems",initialState:Xwe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:fr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:fr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Lo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:fr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:fr()},removePolarGraphicalItem:{reducer(t,e){var n=Lo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:fr()}}}),{addCartesianGraphicalItem:Ywe,replaceCartesianGraphicalItem:Zwe,removeCartesianGraphicalItem:Qwe,addPolarGraphicalItem:Jwe,removePolarGraphicalItem:eSe}=VX.actions,tSe=VX.reducer,nSe=t=>{var e=rr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(Ywe(t)):n.current!==t&&e(Zwe({prev:n.current,next:t})),n.current=t},[e,t]),E.useLayoutEffect(()=>()=>{n.current&&(e(Qwe(n.current)),n.current=null)},[e]),null},Bj=E.memo(nSe);function rSe(t){var e=rr();return E.useLayoutEffect(()=>(e(Jwe(t)),()=>{e(eSe(t))}),[e,t]),null}var iSe=["key"],aSe=["onMouseEnter","onClick","onMouseLeave"],sSe=["id"],oSe=["id"];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 kr(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){lSe(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 lSe(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=uSe(t,"string");return typeof e=="symbol"?e:e+""}function uSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}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 DM(t,e){if(t==null)return{};var n,r,i=dSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function dSe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function hSe(t){var e=E.useMemo(()=>jj(t.children,$b),[t.children]),n=Ct(r=>wwe(r,t.id,e));return n==null?null:E.createElement(Gwe,{legendPayload:n})}var fSe=E.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:s,name:o,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:s,dataKey:e,nameKey:n,name:yd(o,e),hide:c,type:u,color:s,unit:""}};return E.createElement(PM,{tooltipEntrySettings:d})}),pSe=(t,e)=>t>e?"start":t<e?"end":"middle",mSe=(t,e,n)=>pa(typeof e=="function"?e(t):e,n,n*.8),gSe=(t,e,n)=>{var{top:r,left:i,width:a,height:s}=e,o=mq(a,s),c=i+pa(t.cx,a,a/2),u=r+pa(t.cy,s,s/2),d=pa(t.innerRadius,o,0),f=mSe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(a*a+s*s)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:g}},xSe=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function bSe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var ySe=(t,e)=>{if(E.isValidElement(t))return E.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Mn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=DM(e,iSe);return E.createElement(tm,ud({},i,{type:"linear",className:n}))},vSe=(t,e,n)=>{if(E.isValidElement(t))return E.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),E.isValidElement(r)))return r;var i=Mn("recharts-pie-label-text",bSe(t));return E.createElement(TM,ud({},e,{alignmentBaseline:"middle",className:i}),r)};function _Se(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:s}=n;if(!r||!i||!e)return null;var o=Ca(n),c=Gh(i),u=Gh(a),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,v=Jr(g.cx,g.cy,g.outerRadius+d,x),y=kr(kr(kr(kr({},o),g),{},{stroke:"none"},c),{},{index:m,textAnchor:pSe(v.x,g.cx)},v),b=kr(kr(kr(kr({},o),g),{},{fill:"none",stroke:g.fill},u),{},{index:m,points:[Jr(g.cx,g.cy,g.outerRadius,x),v],key:"line"});return E.createElement(ma,{zIndex:Rr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},E.createElement(wr,null,a&&ySe(a,b),vSe(i,y,Bn(g,s))))});return E.createElement(wr,{className:"recharts-pie-labels"},f)}function wSe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?E.createElement(CM,{label:i}):E.createElement(_Se,{sectors:e,props:n,showLabels:r})}function SSe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:s}=t,o=Ct(cd),c=Ct(Ej),u=Ct(Gve),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,m=DM(i,aSe),x=Ij(d,i.dataKey,s),v=Fj(g),y=Uj(f,i.dataKey,s);return e==null||e.length===0?null:E.createElement(E.Fragment,null,e.map((b,M)=>{if(b?.startAngle===0&&b?.endAngle===0&&e.length!==1)return null;var S=u==null||u===s,A=String(M)===o&&(c==null||i.dataKey===c)&&S,T=o?r:null,k=n&&A?n:T,N=kr(kr({},b),{},{stroke:b.stroke,tabIndex:-1,[WW]:M,[qW]:i.dataKey});return E.createElement(wr,ud({key:"sector-".concat(b?.startAngle,"-").concat(b?.endAngle,"-").concat(b.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},vb(m,b,M),{onMouseEnter:x(b,M),onMouseLeave:v(b,M),onClick:y(b,M)}),E.createElement(Lj,ud({option:a??k,index:M,shapeType:"sector",isActive:A},N)))}))}function MSe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:s,startAngle:o,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,g=Math.abs(n.minAngle),m=xSe(o,c),x=Math.abs(m),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,y=r.filter(k=>Bn(k,u,0)!==0).length,b=(x>=360?y:y-1)*v,M=x-y*g-b,S=r.reduce((k,N)=>{var I=Bn(N,u,0);return k+(Pt(I)?I:0)},0),A;if(S>0){var T;A=r.map((k,N)=>{var I=Bn(k,u,0),C=Bn(k,d,N),D=gSe(n,a,k),F=(Pt(I)?I:0)/S,O,q=kr(kr({},k),i&&i[N]&&i[N].props);N?O=T.endAngle+Li(m)*v*(I!==0?1:0):O=o;var R=O+Li(m)*((I!==0?g:0)+F*M),W=(O+R)/2,K=(D.innerRadius+D.outerRadius)/2,G=[{name:C,value:I,payload:q,dataKey:u,type:f}],ee=Jr(D.cx,D.cy,K,W);return T=kr(kr(kr(kr({},n.presentationProps),{},{percent:F,cornerRadius:typeof s=="string"?parseFloat(s):s,name:C,tooltipPayload:G,midAngle:W,middleRadius:K,tooltipPosition:ee},q),D),{},{value:I,dataKey:u,startAngle:O,endAngle:R,payload:q,paddingAngle:Li(m)*v}),T})}return A}function ESe(t){var{showLabels:e,sectors:n,children:r}=t,i=E.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return E.createElement(swe,{value:e?i:void 0},r)}function ASe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:g}=e,m=Qm(e,"recharts-pie-"),x=n.current,[v,y]=E.useState(!1),b=E.useCallback(()=>{typeof g=="function"&&g(),y(!1)},[g]),M=E.useCallback(()=>{typeof f=="function"&&f(),y(!0)},[f]);return E.createElement(ESe,{showLabels:!v,sectors:i},E.createElement(Zm,{animationId:m,begin:s,duration:o,isActive:a,easing:c,onAnimationStart:M,onAnimationEnd:b,key:m},S=>{var A=[],T=i&&i[0],k=T?.startAngle;return i?.forEach((N,I)=>{var C=x&&x[I],D=I>0?Wh(N,"paddingAngle",0):0;if(C){var F=jn(C.endAngle-C.startAngle,N.endAngle-N.startAngle,S),O=kr(kr({},N),{},{startAngle:k+D,endAngle:k+F+D});A.push(O),k=O.endAngle}else{var{endAngle:q,startAngle:R}=N,W=jn(0,q-R,S),K=kr(kr({},N),{},{startAngle:k+D,endAngle:k+W+D});A.push(K),k=K.endAngle}}),n.current=A,E.createElement(wr,null,E.createElement(SSe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),E.createElement(wSe,{showLabels:!v,sectors:i,props:e}),e.children)}var TSe={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 CSe(t){var{id:e}=t,n=DM(t,sSe),{hide:r,className:i,rootTabIndex:a}=t,s=E.useMemo(()=>jj(t.children,$b),[t.children]),o=Ct(d=>Swe(d,e,s)),c=E.useRef(null),u=Mn("recharts-pie",i);return r||o==null?(c.current=null,E.createElement(wr,{tabIndex:a,className:u})):E.createElement(ma,{zIndex:t.zIndex},E.createElement(fSe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:o,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),E.createElement(wr,{tabIndex:a,className:u},E.createElement(ASe,{props:kr(kr({},n),{},{sectors:o}),previousSectorsRef:c,id:e})))}function GX(t){var e=Sr(t,TSe),{id:n}=e,r=DM(e,oSe),i=Ca(r);return E.createElement(RM,{id:n,type:"pie"},a=>E.createElement(E.Fragment,null,E.createElement(rSe,{type:"pie",id:a,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),E.createElement(hSe,ud({},r,{id:a})),E.createElement(CSe,ud({},r,{id:a}))))}GX.displayName="Pie";var NSe=["points"];function q8(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?q8(Object(n),!0).forEach(function(r){kSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kSe(t,e,n){return(e=PSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PSe(t){var e=RSe(t,"string");return typeof e=="symbol"?e:e+""}function RSe(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 DSe(t,e){if(t==null)return{};var n,r,i=jSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function jSe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function OSe(t){var{option:e,dotProps:n,className:r}=t;if(E.isValidElement(e))return E.cloneElement(e,n);if(typeof e=="function")return e(n);var i=Mn(r,typeof e!="boolean"?e.className:""),a=n??{},{points:s}=a,o=DSe(a,NSe);return E.createElement(IX,gw({},o,{className:i}))}function LSe(t,e){return t==null?!1:e?!0:t.length===1}function WX(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:s,needClip:o,clipPathId:c,zIndex:u=Rr.scatter}=t;if(!LSe(e,n))return null;var d=Oj(n),f=fde(n),g=e.map((x,v)=>{var y,b,M=oC(oC(oC({r:3},s),f),{},{index:v,cx:(y=x.x)!==null&&y!==void 0?y:void 0,cy:(b=x.y)!==null&&b!==void 0?b:void 0,dataKey:a,value:x.value,payload:x.payload,points:e});return E.createElement(OSe,{key:"dot-".concat(v),option:n,dotProps:M,className:i})}),m={};return o&&c!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),E.createElement(ma,{zIndex:u},E.createElement(wr,gw({className:r},m),g))}function K8(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 X8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K8(Object(n),!0).forEach(function(r){ISe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ISe(t,e,n){return(e=FSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function FSe(t){var e=USe(t,"string");return typeof e=="symbol"?e:e+""}function USe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var zSe={xAxis:{},yAxis:{},zAxis:{}},qX=Qa({name:"cartesianAxis",initialState:zSe,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 a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var s=[...a,r].slice(-3);t.yAxis[n]=X8(X8({},t.yAxis[n]),{},{width:r,widthHistory:s})}}}}),{addXAxis:BSe,replaceXAxis:HSe,removeXAxis:$Se,addYAxis:VSe,replaceYAxis:GSe,removeYAxis:WSe,addZAxis:WGe,replaceZAxis:qGe,removeZAxis:KGe,updateYAxisWidth:qSe}=qX.actions,KSe=qX.reducer,XSe=Ge([bi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),YSe=Ge([XSe,Ic,Fc],(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)}}),jM=()=>Ct(YSe),ZSe=()=>Ct(Yve);function Y8(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?Y8(Object(n),!0).forEach(function(r){QSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QSe(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=eMe(t,"string");return typeof e=="symbol"?e:e+""}function eMe(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 tMe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:s}=t;if(i===!1||e.x==null||e.y==null)return null;var o={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=lC(lC(lC({},o),Gh(i)),rD(i)),u;return E.isValidElement(i)?u=E.cloneElement(i,c):typeof i=="function"?u=i(c):u=E.createElement(IX,c),E.createElement(wr,{className:"recharts-active-dot",clipPath:s},u)};function k3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:s=Rr.activeDot}=t,o=Ct(cd),c=ZSe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return dr(u)?null:E.createElement(ma,{zIndex:s},E.createElement(tMe,{point:u,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var nMe="Invariant failed";function rMe(t,e){throw new Error(nMe)}var iMe=["x","y"];function P3(){return P3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},P3.apply(null,arguments)}function Z8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function px(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z8(Object(n),!0).forEach(function(r){aMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aMe(t,e,n){return(e=sMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sMe(t){var e=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)}function lMe(t,e){if(t==null)return{};var n,r,i=cMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function cMe(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 uMe(t,e){var{x:n,y:r}=t,i=lMe(t,iMe),a="".concat(n),s=parseInt(a,10),o="".concat(r),c=parseInt(o,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),g=parseInt(f,10);return px(px(px(px(px({},e),i),s?{x:s}:{}),c?{y:c}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function xw(t){return E.createElement(Lj,P3({shapeType:"rectangle",propTransformer:uMe,activeClassName:"recharts-active-bar"},t))}var dMe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Pt(e))return e;var a=Pt(r)||dr(r);return a?e(r,i):(a||rMe(),n)}},hMe={},KX=Qa({name:"errorBars",initialState:hMe,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(a=>a.dataKey===r.dataKey&&a.direction===r.direction?i:a))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:XGe,replaceErrorBar:YGe,removeErrorBar:ZGe}=KX.actions,fMe=KX.reducer,pMe=["children"];function mMe(t,e){if(t==null)return{};var n,r,i=gMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function gMe(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 xMe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},bMe=E.createContext(xMe);function XX(t){var{children:e}=t,n=mMe(t,pMe);return E.createElement(bMe.Provider,{value:n},e)}function OM(t,e){var n,r,i=Ct(u=>Sl(u,t)),a=Ct(u=>Ml(u,e)),s=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Pi.allowDataOverflow,o=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Ri.allowDataOverflow,c=s||o;return{needClip:c,needClipX:s,needClipY:o}}function Hj(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=jM(),{needClipX:a,needClipY:s,needClip:o}=OM(e,n);if(!o||!i)return null;var{x:c,y:u,width:d,height:f}=i;return E.createElement("clipPath",{id:"clipPath-".concat(r)},E.createElement("rect",{x:a?c:c-d/2,y:s?u:u-f/2,width:a?d:d*2,height:s?f:f*2}))}function yMe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&Hn(t.zIndex)?t.zIndex:e}var cC={exports:{}},uC={};var Q8;function vMe(){if(Q8)return uC;Q8=1;var t=Vm();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,a=t.useEffect,s=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=s(function(){function y(T){if(!b){if(b=!0,M=T,T=f(T),g!==void 0&&x.hasValue){var k=x.value;if(g(k,T))return S=k}return S=T}if(k=S,n(M,T))return k;var N=f(T);return g!==void 0&&g(k,N)?(M=T,k):(M=T,S=N)}var b=!1,M,S,A=d===void 0?null:d;return[function(){return y(u())},A===null?void 0:function(){return y(A())}]},[u,d,f,g]);var v=r(c,m[0],m[1]);return a(function(){x.hasValue=!0,x.value=v},[v]),o(v),v},uC}var J8;function _Me(){return J8||(J8=1,cC.exports=vMe()),cC.exports}_Me();function wMe(t){t()}function SMe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){wMe(()=>{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 e6={notify(){},get:()=>[]};function MMe(t,e){let n,r=e6,i=0,a=!1;function s(v){d();const y=r.subscribe(v);let b=!1;return()=>{b||(b=!0,y(),f())}}function o(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=SMe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=e6)}function g(){a||(a=!0,d())}function m(){a&&(a=!1,f())}const x={addNestedSub:s,notifyNestedSubs:o,handleChangeWrapper:c,isSubscribed:u,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return x}var EMe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",AMe=EMe(),TMe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",CMe=TMe(),NMe=()=>AMe||CMe?E.useLayoutEffect:E.useEffect,kMe=NMe();function t6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function PMe(t,e){if(t6(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])||!t6(t[n[i]],e[n[i]]))return!1;return!0}var RMe=Symbol.for("react-redux-context"),DMe=typeof globalThis<"u"?globalThis:{};function jMe(){if(!E.createContext)return{};const t=DMe[RMe]??=new Map;let e=t.get(E.createContext);return e||(e=E.createContext(null),t.set(E.createContext,e)),e}var OMe=jMe();function LMe(t){const{children:e,context:n,serverState:r,store:i}=t,a=E.useMemo(()=>{const c=MMe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),s=E.useMemo(()=>i.getState(),[i]);kMe(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),s!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,s]);const o=n||OMe;return E.createElement(o.Provider,{value:a},e)}var IMe=LMe,FMe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function UMe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Vb(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(FMe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!PMe(t[r],e[r]))return!1}else if(!UMe(t[r],e[r]))return!1;return!0}var zMe=["onMouseEnter","onMouseLeave","onClick"],BMe=["value","background","tooltipPosition"],HMe=["id"],$Me=["onMouseEnter","onClick","onMouseLeave"];function jc(){return jc=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},jc.apply(null,arguments)}function n6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n6(Object(n),!0).forEach(function(r){VMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VMe(t,e,n){return(e=GMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GMe(t){var e=WMe(t,"string");return typeof e=="symbol"?e:e+""}function WMe(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=qMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function qMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var KMe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:yd(n,e),payload:t}]},XMe=E.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:s,unit:o,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:yd(a,e),hide:s,type:c,color:i,unit:o}};return E.createElement(PM,{tooltipEntrySettings:u})});function YMe(t){var e=Ct(cd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:s,onMouseLeave:o,onClick:c}=a,u=bw(a,zMe),d=Ij(s,r),f=Fj(o),g=Uj(c,r);if(!i||n==null)return null;var m=Gh(i);return E.createElement(ma,{zIndex:yMe(i,Rr.barBackground)},n.map((x,v)=>{var{value:y,background:b,tooltipPosition:M}=x,S=bw(x,BMe);if(!b)return null;var A=d(x,v),T=f(x,v),k=g(x,v),N=Sa(Sa(Sa(Sa(Sa({option:i,isActive:String(v)===e},S),{},{fill:"#eee"},b),m),vb(u,x,v)),{},{onMouseEnter:A,onMouseLeave:T,onClick:k,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return E.createElement(xw,jc({key:"background-bar-".concat(v)},N))}))}function ZMe(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var s={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return Sa(Sa({},s),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:s,fill:a.fill})});return E.createElement(Pj,{value:e?i:void 0},n)}function QMe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:s}=t,o=Ct(cd),c=Ct(Ej),u=n&&String(a)===o&&(c==null||s===c),d=u?n:e;return u?E.createElement(ma,{zIndex:Rr.activeBar},E.createElement(xw,jc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))):E.createElement(xw,jc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))}function JMe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return E.createElement(xw,jc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function eEe(t){var e,{data:n,props:r}=t,i=(e=Ca(r))!==null&&e!==void 0?e:{},{id:a}=i,s=bw(i,HMe),{shape:o,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,m=bw(r,$Me),x=Ij(d,c),v=Fj(g),y=Uj(f,c);return n?E.createElement(E.Fragment,null,n.map((b,M)=>E.createElement(wr,jc({key:"rectangle-".concat(b?.x,"-").concat(b?.y,"-").concat(b?.value,"-").concat(M),className:"recharts-bar-rectangle"},vb(m,b,M),{onMouseEnter:x(b,M),onMouseLeave:v(b,M),onClick:y(b,M)}),u?E.createElement(QMe,{shape:o,activeBar:u,baseProps:s,entry:b,index:M,dataKey:c}):E.createElement(JMe,{shape:o,baseProps:s,entry:b,index:M,dataKey:c})))):null}function tEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,g=Qm(e,"recharts-bar-"),[m,x]=E.useState(!1),v=!m,y=E.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),b=E.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return E.createElement(ZMe,{showLabels:v,rects:r},E.createElement(Zm,{animationId:g,begin:s,duration:o,isActive:a,easing:c,onAnimationEnd:y,onAnimationStart:b,key:g},M=>{var S=M===1?r:r?.map((A,T)=>{var k=f&&f[T];if(k)return Sa(Sa({},A),{},{x:jn(k.x,A.x,M),y:jn(k.y,A.y,M),width:jn(k.width,A.width,M),height:jn(k.height,A.height,M)});if(i==="horizontal"){var N=jn(0,A.height,M),I=jn(A.stackedBarStart,A.y,M);return Sa(Sa({},A),{},{y:I,height:N})}var C=jn(0,A.width,M),D=jn(A.stackedBarStart,A.x,M);return Sa(Sa({},A),{},{width:C,x:D})});return M>0&&(n.current=S??null),S==null?null:E.createElement(wr,null,E.createElement(eEe,{props:e,data:S}))}),E.createElement(CM,{label:e.label}),e.children)}function nEe(t){var e=E.useRef(null);return E.createElement(tEe,{previousRectanglesRef:e,props:t})}var YX=0,rEe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Bn(t,e)}};class iEe extends E.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:s,needClip:o,background:c,id:u}=this.props;if(e||n==null)return null;var d=Mn("recharts-bar",i),f=u;return E.createElement(wr,{className:d,id:u},o&&E.createElement("defs",null,E.createElement(Hj,{clipPathId:f,xAxisId:a,yAxisId:s})),E.createElement(wr,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(f,")"):void 0},E.createElement(YMe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),E.createElement(nEe,this.props)))}}var aEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:YX,xAxisId:0,yAxisId:0,zIndex:Rr.bar};function sEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=OM(e,n),g=hf(),m=yi(),x=jj(t.children,$b),v=Ct(M=>jEe(M,e,n,m,t.id,x));if(g!=="vertical"&&g!=="horizontal")return null;var y,b=v?.[0];return b==null||b.height==null||b.width==null?y=0:y=g==="vertical"?b.height/2:b.width/2,E.createElement(XX,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:rEe,errorBarOffset:y},E.createElement(iEe,jc({},t,{layout:g,needClip:f,data:v,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function oEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:s,yAxis:o,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:g,cells:m,parentViewBox:x,dataStartIndex:v}=t,y=e==="horizontal"?o:s,b=d?y.scale.domain():null,M=kpe({numericAxis:y}),S=y.scale(M);return f.map((A,T)=>{var k,N,I,C,D,F;d?k=Epe(d[T+v],b):(k=Bn(A,n),Array.isArray(k)||(k=[M,k]));var O=dMe(r,YX)(k[1],T);if(e==="horizontal"){var q,[R,W]=[o.scale(k[0]),o.scale(k[1])];N=yz({axis:s,ticks:c,bandSize:a,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=Za(K)?0:K,F={x:N,y:g.top,width:C,height:g.height},Math.abs(O)>0&&Math.abs(D)<Math.abs(O)){var G=Li(D||O)*(Math.abs(O)-Math.abs(D));I-=G,D+=G}}else{var[ee,Z]=[s.scale(k[0]),s.scale(k[1])];if(N=ee,I=yz({axis:o,ticks:u,bandSize:a,offset:i.offset,entry:A,index:T}),C=Z-ee,D=i.size,F={x:g.left,y:I,width:g.width,height:D},Math.abs(O)>0&&Math.abs(C)<Math.abs(O)){var Q=Li(C||O)*(Math.abs(O)-Math.abs(C));C+=Q}}if(N==null||I==null||C==null||D==null)return null;var U=Sa(Sa({},A),{},{stackedBarStart:S,x:N,y:I,width:C,height:D,value:d?k:k[1],payload:A,background:F,tooltipPosition:{x:N+C/2,y:I+D/2},parentViewBox:x},m&&m[T]&&m[T].props);return U}).filter(Boolean)}function lEe(t){var e=Sr(t,aEe),n=yi();return E.createElement(RM,{id:e.id,type:"bar"},r=>E.createElement(E.Fragment,null,E.createElement(zj,{legendPayload:KMe(e)}),E.createElement(XMe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(Bj,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:VW(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),E.createElement(ma,{zIndex:e.zIndex},E.createElement(sEe,jc({},e,{id:r})))))}var ZX=E.memo(lEe,Vb);ZX.displayName="Bar";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 Rv(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){cEe(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 cEe(t,e,n){return(e=uEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uEe(t){var e=dEe(t,"string");return typeof e=="symbol"?e:e+""}function dEe(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 hEe=(t,e)=>e,fEe=(t,e,n)=>n,pEe=(t,e,n,r)=>r,mEe=(t,e,n,r,i)=>i,Gb=Ge([Ob,mEe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),gEe=Ge([Gb],t=>t?.maxBarSize),xEe=(t,e,n,r,i,a)=>a,i6=(t,e,n)=>{var r=n??t;if(!dr(r))return pa(r,e,0)},bEe=Ge([xn,Ob,hEe,fEe,pEe],(t,e,n,r,i)=>e.filter(a=>t==="horizontal"?a.xAxisId===n:a.yAxisId===r).filter(a=>a.isPanorama===i).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),yEe=(t,e,n,r)=>{var i=xn(t);return i==="horizontal"?z0(t,"yAxis",n,r):z0(t,"xAxis",e,r)},vEe=(t,e,n)=>{var r=xn(t);return r==="horizontal"?QB(t,"xAxis",e):QB(t,"yAxis",n)},_Ee=(t,e,n)=>{var r={},i=t.filter(yM),a=t.filter(u=>u.stackId==null),s=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),o=Object.entries(s).map(u=>{var[d,f]=u,g=f.map(x=>x.dataKey),m=i6(e,n,f[0].barSize);return{stackId:d,dataKeys:g,barSize:m}}),c=a.map(u=>{var d=[u.dataKey].filter(g=>g!=null),f=i6(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...o,...c]},wEe=Ge([bEe,qbe,vEe],_Ee),SEe=(t,e,n,r,i)=>{var a,s,o=Gb(t,e,n,r,i);if(o!=null){var c=xn(t),u=pK(t),{maxBarSize:d}=o,f=dr(d)?u:d,g,m;return c==="horizontal"?(g=ml(t,"xAxis",e,r),m=pl(t,"xAxis",e,r)):(g=ml(t,"yAxis",n,r),m=pl(t,"yAxis",n,r)),(a=(s=sd(g,m,!0))!==null&&s!==void 0?s:f)!==null&&a!==void 0?a:0}},QX=(t,e,n,r)=>{var i=xn(t),a,s;return i==="horizontal"?(a=ml(t,"xAxis",e,r),s=pl(t,"xAxis",e,r)):(a=ml(t,"yAxis",n,r),s=pl(t,"yAxis",n,r)),sd(a,s)};function MEe(t,e,n,r,i){var a=r.length;if(!(a<1)){var s=pa(t,n,0,!0),o,c=[];if(Hn(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((b,M)=>b+(M.barSize||0),0);f+=(a-1)*s,f>=n&&(f-=(a-1)*s,s=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var g=(n-f)/2>>0,m={offset:g-s,size:0};o=r.reduce((b,M)=>{var S,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:m.offset+m.size+s,size:u?d:(S=M.barSize)!==null&&S!==void 0?S:0}},T=[...b,A];return m=T[T.length-1].position,T},c)}else{var x=pa(e,n,0,!0);n-2*x-(a-1)*s<=0&&(s=0);var v=(n-2*x-(a-1)*s)/a;v>1&&(v>>=0);var y=Hn(i)?Math.min(v,i):v;o=r.reduce((b,M,S)=>[...b,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:x+(v+s)*S+(v-y)/2,size:y}}],c)}return o}}var EEe=(t,e,n,r,i,a,s)=>{var o=dr(s)?e:s,c=MEe(n,r,i!==a?i:a,t,o);return i!==a&&c!=null&&(c=c.map(u=>Rv(Rv({},u),{},{position:Rv(Rv({},u.position),{},{offset:u.position.offset-i/2})}))),c},AEe=Ge([wEe,pK,Wbe,mK,SEe,QX,gEe],EEe),TEe=(t,e,n,r)=>ml(t,"xAxis",e,r),CEe=(t,e,n,r)=>ml(t,"yAxis",n,r),NEe=(t,e,n,r)=>pl(t,"xAxis",e,r),kEe=(t,e,n,r)=>pl(t,"yAxis",n,r),PEe=Ge([AEe,Gb],(t,e)=>{if(!(t==null||e==null)){var n=t.find(r=>r.stackId===e.stackId&&e.dataKey!=null&&r.dataKeys.includes(e.dataKey));if(n!=null)return n.position}}),REe=(t,e)=>{var n=bM(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:a}=i;if(a)return a.find(s=>s.key===n)}}}},DEe=Ge([yEe,Gb],REe),jEe=Ge([bi,pD,TEe,CEe,NEe,kEe,PEe,xn,Pb,QX,DEe,Gb,xEe],(t,e,n,r,i,a,s,o,c,u,d,f,g)=>{var{chartData:m,dataStartIndex:x,dataEndIndex:v}=c;if(!(f==null||s==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:y}=f,b;if(y!=null&&y.length>0?b=y:b=m?.slice(x,v+1),b!=null)return oEe({layout:o,barSettings:f,pos:s,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:b,offset:t,cells:g,dataStartIndex:x})}}),JX=t=>{var{chartData:e}=t,n=rr(),r=yi();return E.useEffect(()=>r?()=>{}:(n(d8(e)),()=>{n(d8(void 0))}),[e,n,r]),null},a6={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},eY=Qa({name:"brush",initialState:a6,reducers:{setBrushSettings(t,e){return e.payload==null?a6:e.payload}}}),{setBrushSettings:QGe}=eY.actions,OEe=eY.reducer;function s6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Dv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?s6(Object(n),!0).forEach(function(r){tY(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tY(t,e,n){return(e=LEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LEe(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)}var FEe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},UEe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return FEe({x:e,y:n},{x:r,y:i})};class LM{static create(e){return new LM(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var s=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+s}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}tY(LM,"EPS",1e-4);var zEe=t=>{var e=Object.keys(t).reduce((n,r)=>Dv(Dv({},n),{},{[r]:LM.create(t[r])}),{});return Dv(Dv({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(a=>{var[s,o]=a;return[s,e[s].apply(o,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function BEe(t){return(t%180+180)%180}var HEe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=BEe(i),s=a*Math.PI/180,o=Math.atan(r/n),c=s>o&&s<Math.PI-o?r/Math.sin(s):n/Math.cos(s);return Math.abs(c)},$Ee={dots:[],areas:[],lines:[]},nY=Qa({name:"referenceElements",initialState:$Ee,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Lo(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=Lo(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=Lo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:JGe,removeDot:eWe,addArea:tWe,removeArea:nWe,addLine:VEe,removeLine:GEe}=nY.actions,WEe=nY.reducer,rY=E.createContext(void 0),qEe=t=>{var{children:e}=t,[n]=E.useState("".concat(T0("recharts"),"-clip")),r=jM();if(r==null)return null;var{x:i,y:a,width:s,height:o}=r;return E.createElement(rY.Provider,{value:n},E.createElement("defs",null,E.createElement("clipPath",{id:n},E.createElement("rect",{x:i,y:a,height:o,width:s}))),e)},KEe=()=>E.useContext(rY);function o6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function l6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o6(Object(n),!0).forEach(function(r){XEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XEe(t,e,n){return(e=YEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YEe(t){var e=ZEe(t,"string");return typeof e=="symbol"?e:e+""}function ZEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function yw(){return yw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},yw.apply(null,arguments)}var QEe=(t,e)=>{var n;if(E.isValidElement(t))n=E.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!Hn(e.x1)||!Hn(e.y1)||!Hn(e.x2)||!Hn(e.y2))return null;n=E.createElement("line",yw({},e,{className:"recharts-reference-line-line"}))}return n},JEe=(t,e,n,r,i,a)=>{var{x:s,width:o}=a,c=i.y.apply(t,{position:n});if(Za(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:s+o,y:c},{x:s,y:c}];return r==="left"?u.reverse():u},e2e=(t,e,n,r,i,a)=>{var{y:s,height:o}=a,c=i.x.apply(t,{position:n});if(Za(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:s+o},{x:c,y:s}];return r==="top"?u.reverse():u},t2e=(t,e,n,r)=>{var i=t.map(a=>r.apply(a,{position:n}));return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},n2e=(t,e,n,r,i,a)=>{var{x:s,y:o,segment:c,ifOverflow:u}=a,d=co(s),f=co(o);return f?JEe(o,u,n,i,t,e):d?e2e(s,u,n,r,t,e):c!=null&&c.length===2?t2e(c,u,n,t):null};function r2e(t){var e=rr();return E.useEffect(()=>(e(VEe(t)),()=>{e(GEe(t))})),null}function i2e(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,s=yi(),o=KEe(),c=Ct(k=>Sl(k,e)),u=Ct(k=>Ml(k,n)),d=Ct(k=>ld(k,"xAxis",e,s)),f=Ct(k=>ld(k,"yAxis",n,s)),g=Eb();if(!o||!g||c==null||u==null||d==null||f==null)return null;var m=zEe({x:d,y:f}),x=n2e(m,g,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:v,y},{x:b,y:M}]=x,S=a==="hidden"?"url(#".concat(o,")"):void 0,A=l6(l6({clipPath:S},na(t)),{},{x1:v,y1:y,x2:b,y2:M}),T=UEe({x1:v,y1:y,x2:b,y2:M});return E.createElement(ma,{zIndex:t.zIndex},E.createElement(wr,{className:Mn("recharts-reference-line",i)},QEe(r,A),E.createElement(RX,yw({},T,{lowerWidth:T.width,upperWidth:T.width}),E.createElement(jX,{label:t.label}),t.children)))}var a2e={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,a2e);return E.createElement(E.Fragment,null,E.createElement(r2e,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),E.createElement(i2e,e))}Ox.displayName="ReferenceLine";function iY(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;r<t.length;r+=e)n.push(t[r]);return n}function s2e(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return HEe(r,n)}function o2e(t,e,n){var r=n==="width",{x:i,y:a,width:s,height:o}=t;return e===1?{start:r?i:a,end:r?i+s:a+o}:{start:r?i+s:a+o,end:r?i:a}}function vw(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var a=n();return t*(e-t*a/2-r)>=0&&t*(e+t*a/2-i)<=0}function l2e(t,e){return iY(t,e+1)}function c2e(t,e,n,r,i){for(var a=(r||[]).slice(),{start:s,end:o}=e,c=0,u=1,d=s,f=function(){var x=r?.[c];if(x===void 0)return{v:iY(r,u)};var v=c,y,b=()=>(y===void 0&&(y=n(x,v)),y),M=x.coordinate,S=c===0||vw(t,M,b,d,o);S||(c=0,d=s,u+=1),S&&(d=M+t*(b()/2+i),c+=u)},g;u<=a.length;)if(g=f(),g)return g.v;return[]}function c6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ua(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c6(Object(n),!0).forEach(function(r){u2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function u2e(t,e,n){return(e=d2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d2e(t){var e=h2e(t,"string");return typeof e=="symbol"?e:e+""}function h2e(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 f2e(t,e,n,r,i){for(var a=(r||[]).slice(),s=a.length,{start:o}=e,{end:c}=e,u=function(g){var m=a[g],x,v=()=>(x===void 0&&(x=n(m,g)),x);if(g===s-1){var y=t*(m.coordinate+t*v()/2-c);a[g]=m=ua(ua({},m),{},{tickCoord:y>0?m.coordinate-y*t:m.coordinate})}else a[g]=m=ua(ua({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var b=vw(t,m.tickCoord,v,o,c);b&&(c=m.tickCoord-t*(v()/2+i),a[g]=ua(ua({},m),{},{isShow:!0}))}},d=s-1;d>=0;d--)u(d);return a}function p2e(t,e,n,r,i,a){var s=(r||[]).slice(),o=s.length,{start:c,end:u}=e;if(a){var d=r[o-1],f=n(d,o-1),g=t*(d.coordinate+t*f/2-u);if(s[o-1]=d=ua(ua({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var m=vw(t,d.tickCoord,()=>f,c,u);m&&(u=d.tickCoord-t*(f/2+i),s[o-1]=ua(ua({},d),{},{isShow:!0}))}}for(var x=a?o-1:o,v=function(M){var S=s[M],A,T=()=>(A===void 0&&(A=n(S,M)),A);if(M===0){var k=t*(S.coordinate-t*T()/2-c);s[M]=S=ua(ua({},S),{},{tickCoord:k<0?S.coordinate-k*t:S.coordinate})}else s[M]=S=ua(ua({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var N=vw(t,S.tickCoord,T,c,u);N&&(c=S.tickCoord+t*(T()/2+i),s[M]=ua(ua({},S),{},{isShow:!0}))}},y=0;y<x;y++)v(y);return s}function $j(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:s,orientation:o,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Pt(c)||Ym.isSsr){var g;return(g=l2e(i,Pt(c)?c:0))!==null&&g!==void 0?g:[]}var m=[],x=o==="top"||o==="bottom"?"width":"height",v=d&&x==="width"?qx(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},y=(S,A)=>{var T=typeof u=="function"?u(S.value,A):S.value;return x==="width"?s2e(qx(T,{fontSize:e,letterSpacing:n}),v,f):qx(T,{fontSize:e,letterSpacing:n})[x]},b=i.length>=2?Li(i[1].coordinate-i[0].coordinate):1,M=o2e(a,b,x);return c==="equidistantPreserveStart"?c2e(b,M,y,i,s):(c==="preserveStart"||c==="preserveStartEnd"?m=p2e(b,M,y,i,s,c==="preserveStartEnd"):m=f2e(b,M,y,i,s),m.filter(S=>S.isShow))}var m2e=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,s=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>s&&(s=f.width)}});var o=n?n.getBoundingClientRect().width:0,c=i+a,u=s+c+o+(n?r:0);return Math.round(u)}return 0},g2e=["axisLine","width","height","className","hide","ticks","axisType"];function x2e(t,e){if(t==null)return{};var n,r,i=b2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function b2e(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 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 Xr(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){y2e(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 y2e(t,e,n){return(e=v2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function v2e(t){var e=_2e(t,"string");return typeof e=="symbol"?e:e+""}function _2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var _c={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:Rr.axis};function w2e(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:s,axisLine:o,otherSvgProps:c}=t;if(!o)return null;var u=Xr(Xr(Xr({},c),Ca(o)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!s||a==="bottom"&&s);u=Xr(Xr({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!s||a==="right"&&s);u=Xr(Xr({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return E.createElement("line",Yh({},u,{className:Mn("recharts-cartesian-axis-line",Wh(o,"className"))}))}function S2e(t,e,n,r,i,a,s,o,c){var u,d,f,g,m,x,v=o?-1:1,y=t.tickSize||s,b=Pt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,g=n+ +!o*i,f=g-v*y,x=f-v*c,m=b;break;case"left":f=g=t.coordinate,d=e+ +!o*r,u=d-v*y,m=u-v*c,x=b;break;case"right":f=g=t.coordinate,d=e+ +o*r,u=d+v*y,m=u+v*c,x=b;break;default:u=d=t.coordinate,g=n+ +o*i,f=g+v*y,x=f+v*c,m=b;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:m,y:x}}}function M2e(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function E2e(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function A2e(t){var{option:e,tickProps:n,value:r}=t,i,a=Mn(n.className,"recharts-cartesian-axis-tick-value");if(E.isValidElement(e))i=E.cloneElement(e,Xr(Xr({},n),{},{className:a}));else if(typeof e=="function")i=e(Xr(Xr({},n),{},{className:a}));else{var s="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(s=Mn(s,e?.className)),i=E.createElement(TM,Yh({},n,{className:s}),r)}return i}var T2e=E.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:s,unit:o,padding:c,tickTextProps:u,orientation:d,mirror:f,x:g,y:m,width:x,height:v,tickSize:y,tickMargin:b,fontSize:M,letterSpacing:S,getTicksConfig:A,events:T,axisType:k}=t,N=$j(Xr(Xr({},A),{},{ticks:n}),M,S),I=M2e(d,f),C=E2e(d,f),D=Ca(A),F=Gh(r),O={};typeof i=="object"&&(O=i);var q=Xr(Xr({},D),{},{fill:"none"},O),R=N.map(G=>Xr({entry:G},S2e(G,g,m,x,v,d,y,f,b))),W=R.map(G=>{var{entry:ee,line:Z}=G;return E.createElement(wr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(ee.value,"-").concat(ee.coordinate,"-").concat(ee.tickCoord)},i&&E.createElement("line",Yh({},q,Z,{className:Mn("recharts-cartesian-axis-tick-line",Wh(i,"className"))})))}),K=R.map((G,ee)=>{var{entry:Z,tick:Q}=G,U=Xr(Xr(Xr(Xr({textAnchor:I,verticalAnchor:C},D),{},{stroke:"none",fill:a},F),Q),{},{index:ee,payload:Z,visibleTicksCount:N.length,tickFormatter:s,padding:c},u);return E.createElement(wr,Yh({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},vb(T,Z,ee)),r&&E.createElement(A2e,{option:r,tickProps:U,value:"".concat(typeof s=="function"?s(Z.value,ee):Z.value).concat(o||"")}))});return E.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},K.length>0&&E.createElement(ma,{zIndex:Rr.label},E.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},K)),W.length>0&&E.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},W))}),C2e=E.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:s,ticks:o,axisType:c}=t,u=x2e(t,g2e),[d,f]=E.useState(""),[g,m]=E.useState(""),x=E.useRef(null);E.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var y;return m2e({ticks:x.current,label:(y=t.labelRef)===null||y===void 0?void 0:y.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var v=E.useCallback(y=>{if(y){var b=y.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=b;var M=b[0];if(M){var S=window.getComputedStyle(M),A=S.fontSize,T=S.letterSpacing;(A!==d||T!==g)&&(f(A),m(T))}}},[d,g]);return s||r!=null&&r<=0||i!=null&&i<=0?null:E.createElement(ma,{zIndex:t.zIndex},E.createElement(wr,{className:Mn("recharts-cartesian-axis",a)},E.createElement(w2e,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ca(t)}),E.createElement(T2e,{ref:v,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),E.createElement(RX,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},E.createElement(jX,{label:t.label,labelRef:t.labelRef}),t.children)))}),Vj=E.forwardRef((t,e)=>{var n=Sr(t,_c);return E.createElement(C2e,Yh({},n,{ref:e}))});Vj.displayName="CartesianAxis";var N2e=["x1","y1","x2","y2","key"],k2e=["offset"],P2e=["xAxisId","yAxisId"],R2e=["xAxisId","yAxisId"];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 ha(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){D2e(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 D2e(t,e,n){return(e=j2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j2e(t){var e=O2e(t,"string");return typeof e=="symbol"?e:e+""}function O2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function mh(){return mh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},mh.apply(null,arguments)}function _w(t,e){if(t==null)return{};var n,r,i=L2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function L2e(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 I2e=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:s,ry:o}=t;return E.createElement("rect",{x:r,y:i,ry:o,width:a,height:s,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function aY(t){var{option:e,lineItemProps:n}=t,r;if(E.isValidElement(e))r=E.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:s,x2:o,y2:c,key:u}=n,d=_w(n,N2e),f=(i=Ca(d))!==null&&i!==void 0?i:{},{offset:g}=f,m=_w(f,k2e);r=E.createElement("line",mh({},m,{x1:a,y1:s,x2:o,y2:c,fill:"none",key:u}))}return r}function F2e(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,o=_w(t,P2e),c=i.map((u,d)=>{var f=ha(ha({},o),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return E.createElement(aY,{key:"line-".concat(d),option:r,lineItemProps:f})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function U2e(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,o=_w(t,R2e),c=i.map((u,d)=>{var f=ha(ha({},o),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return E.createElement(aY,{option:r,lineItemProps:f,key:"line-".concat(d)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function z2e(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:s,horizontalPoints:o,horizontal:c=!0}=t;if(!c||!e||!e.length||o==null)return null;var u=o.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var m=!u[g+1],x=m?i+s-f:u[g+1]-f;if(x<=0)return null;var v=g%e.length;return E.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:x,width:a,stroke:"none",fill:e[v],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function B2e(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:s,height:o,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var m=!u[g+1],x=m?i+s-f:u[g+1]-f;if(x<=0)return null;var v=g%n.length;return E.createElement("rect",{key:"react-".concat(g),x:f,y:a,width:x,height:o,stroke:"none",fill:n[v],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var H2e=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return HW($j(ha(ha(ha({},_c),n),{},{ticks:$W(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},$2e=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return HW($j(ha(ha(ha({},_c),n),{},{ticks:$W(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},V2e={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=gD(),n=xD(),r=QW(),i=ha(ha({},Sr(t,V2e)),{},{x:Pt(t.x)?t.x:r.left,y:Pt(t.y)?t.y:r.top,width:Pt(t.width)?t.width:r.width,height:Pt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:s,x:o,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:m}=i,x=yi(),v=Ct(C=>JB(C,"xAxis",a,x)),y=Ct(C=>JB(C,"yAxis",s,x));if(!hl(u)||!hl(d)||!Pt(o)||!Pt(c))return null;var b=i.verticalCoordinatesGenerator||H2e,M=i.horizontalCoordinatesGenerator||$2e,{horizontalPoints:S,verticalPoints:A}=i;if((!S||!S.length)&&typeof M=="function"){var T=g&&g.length,k=M({yAxis:y?ha(ha({},y),{},{ticks:T?g:y.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);G1(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(S=k)}if((!A||!A.length)&&typeof b=="function"){var N=m&&m.length,I=b({xAxis:v?ha(ha({},v),{},{ticks:N?m:v.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 E.createElement(ma,{zIndex:i.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(I2e,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),E.createElement(z2e,mh({},i,{horizontalPoints:S})),E.createElement(B2e,mh({},i,{verticalPoints:A})),E.createElement(F2e,mh({},i,{offset:r,horizontalPoints:S,xAxis:v,yAxis:y})),E.createElement(U2e,mh({},i,{offset:r,verticalPoints:A,xAxis:v,yAxis:y}))))}ww.displayName="CartesianGrid";var sY=(t,e,n,r)=>ml(t,"xAxis",e,r),oY=(t,e,n,r)=>pl(t,"xAxis",e,r),lY=(t,e,n,r)=>ml(t,"yAxis",n,r),cY=(t,e,n,r)=>pl(t,"yAxis",n,r),G2e=Ge([xn,sY,lY,oY,cY],(t,e,n,r,i)=>wl(t,"xAxis")?sd(e,r,!1):sd(n,i,!1)),W2e=(t,e,n,r,i)=>i;function q2e(t){return t.type==="line"}var K2e=Ge([Ob,W2e],(t,e)=>t.filter(q2e).find(n=>n.id===e)),X2e=Ge([xn,sY,lY,oY,cY,K2e,G2e,Pb],(t,e,n,r,i,a,s,o)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=o;if(!(a==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:g}=a,m;if(g!=null&&g.length>0?m=g:m=c?.slice(u,d+1),m!=null)return mAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:s,displayedData:m})}});function uY(t){var e=Gh(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,s=Number(i),o=Number(a);return(Number.isNaN(s)||s<0)&&(s=n),(Number.isNaN(o)||o<0)&&(o=r),{r:s,strokeWidth:o}}return{r:n,strokeWidth:r}}var Y2e=["id"],Z2e=["type","layout","connectNulls","needClip","shape"],Q2e=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function H0(){return H0=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},H0.apply(null,arguments)}function 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 tl(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){J2e(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 J2e(t,e,n){return(e=eAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eAe(t){var e=tAe(t,"string");return typeof e=="symbol"?e:e+""}function tAe(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 Gj(t,e){if(t==null)return{};var n,r,i=nAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function nAe(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 rAe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:yd(n,e),payload:t}]},iAe=E.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:o,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:yd(s,e),hide:o,type:u,color:r,unit:c}};return E.createElement(PM,{tooltipEntrySettings:d})}),dY=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function aAe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var sAe=(t,e,n)=>{var r=n.reduce((f,g)=>f+g);if(!r)return dY(e,t);for(var i=Math.floor(t/r),a=t%r,s=e-t,o=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){o=[...n.slice(0,c),a-u];break}var d=o.length%2===0?[0,s]:[s];return[...aAe(n,i),...o,...d].map(f=>"".concat(f,"px")).join(", ")};function oAe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:s}=r,{id:o}=r,c=Gj(r,Y2e),u=Ca(c);return E.createElement(WX,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:s,clipPathId:e})}function lAe(t){var{showLabels:e,children:n,points:r}=t,i=E.useMemo(()=>r?.map(a=>{var s,o,c={x:(s=a.x)!==null&&s!==void 0?s:0,y:(o=a.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return tl(tl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return E.createElement(Pj,{value:e?i:void 0},n)}function f6(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:s,layout:o,connectNulls:c,needClip:u,shape:d}=a,f=Gj(a,Z2e),g=tl(tl({},na(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:s,layout:o,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return E.createElement(E.Fragment,null,r?.length>1&&E.createElement(Lj,H0({shapeType:"curve",option:d},g,{pathRef:n})),E.createElement(oAe,{points:r,clipPathId:e,props:a}))}function cAe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function uAe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:s,strokeDasharray:o,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:g,width:m,height:x,onAnimationEnd:v,onAnimationStart:y}=n,b=i.current,M=Qm(s,"recharts-line-"),S=E.useRef(M),[A,T]=E.useState(!1),k=!A,N=E.useCallback(()=>{typeof v=="function"&&v(),T(!1)},[v]),I=E.useCallback(()=>{typeof y=="function"&&y(),T(!0)},[y]),C=cAe(r.current),D=E.useRef(0);S.current!==M&&(D.current=a.current,S.current=M);var F=D.current;return E.createElement(lAe,{points:s,showLabels:k},n.children,E.createElement(Zm,{animationId:M,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:N,onAnimationStart:I,key:M},O=>{var q=jn(F,C+F,O),R=Math.min(q,C),W;if(c)if(o){var K="".concat(o).split(/[,\s]+/gim).map(Z=>parseFloat(Z));W=sAe(R,C,K)}else W=dY(C,R);else W=o==null?void 0:String(o);if(O>0&&C>0&&(i.current=s,a.current=Math.max(a.current,R)),b){var G=b.length/s.length,ee=O===1?s:s.map((Z,Q)=>{var U=Math.floor(Q*G);if(b[U]){var $=b[U];return tl(tl({},Z),{},{x:jn($.x,Z.x,O),y:jn($.y,Z.y,O)})}return g?tl(tl({},Z),{},{x:jn(m*2,Z.x,O),y:jn(x/2,Z.y,O)}):tl(tl({},Z),{},{x:Z.x,y:Z.y})});return i.current=ee,E.createElement(f6,{props:n,points:ee,clipPathId:e,pathRef:r,strokeDasharray:W})}return E.createElement(f6,{props:n,points:s,clipPathId:e,pathRef:r,strokeDasharray:W})}),E.createElement(CM,{label:n.label}))}function dAe(t){var{clipPathId:e,props:n}=t,r=E.useRef(null),i=E.useRef(0),a=E.useRef(null);return E.createElement(uAe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var hAe=(t,e)=>{var n,r;return{x:(n=t.x)!==null&&n!==void 0?n:void 0,y:(r=t.y)!==null&&r!==void 0?r:void 0,value:t.value,errorVal:Bn(t.payload,e)}};class fAe extends E.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:s,top:o,left:c,width:u,height:d,id:f,needClip:g,zIndex:m}=this.props;if(e)return null;var x=Mn("recharts-line",i),v=f,{r:y,strokeWidth:b}=uY(n),M=Oj(n),S=y*2+b,A=g?"url(#clipPath-".concat(M?"":"dots-").concat(v,")"):void 0;return E.createElement(ma,{zIndex:m},E.createElement(wr,{className:x},g&&E.createElement("defs",null,E.createElement(Hj,{clipPathId:v,xAxisId:a,yAxisId:s}),!M&&E.createElement("clipPath",{id:"clipPath-dots-".concat(v)},E.createElement("rect",{x:c-S/2,y:o-S/2,width:u+S,height:d+S}))),E.createElement(XX,{xAxisId:a,yAxisId:s,data:r,dataPointFormatter:hAe,errorBarOffset:0},E.createElement(dAe,{props:this.props,clipPathId:v}))),E.createElement(k3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var hY={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 pAe(t){var e=Sr(t,hY),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:o,dot:c,hide:u,isAnimationActive:d,label:f,legendType:g,xAxisId:m,yAxisId:x,id:v}=e,y=Gj(e,Q2e),{needClip:b}=OM(m,x),M=jM(),S=hf(),A=yi(),T=Ct(D=>X2e(D,m,x,A,v));if(S!=="horizontal"&&S!=="vertical"||T==null||M==null)return null;var{height:k,width:N,x:I,y:C}=M;return E.createElement(fAe,H0({},y,{id:v,connectNulls:o,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:s,isAnimationActive:d,hide:u,label:f,legendType:g,xAxisId:m,yAxisId:x,points:T,layout:S,height:k,width:N,left:I,top:C,needClip:b}))}function mAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:s,bandSize:o,displayedData:c}=t;return c.map((u,d)=>{var f=Bn(u,s);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),v=V1({axis:r,ticks:a,bandSize:o,entry:u,index:d});return x==null||v==null?null:{x,y:v,value:f,payload:u}}).filter(Boolean)}function gAe(t){var e=Sr(t,hY),n=yi();return E.createElement(RM,{id:e.id,type:"line"},r=>E.createElement(E.Fragment,null,E.createElement(zj,{legendPayload:rAe(e)}),E.createElement(iAe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(Bj,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),E.createElement(pAe,H0({},e,{id:r}))))}var fY=E.memo(gAe,Vb);fY.displayName="Line";var pY=(t,e,n,r)=>ml(t,"xAxis",e,r),mY=(t,e,n,r)=>pl(t,"xAxis",e,r),gY=(t,e,n,r)=>ml(t,"yAxis",n,r),xY=(t,e,n,r)=>pl(t,"yAxis",n,r),xAe=Ge([xn,pY,gY,mY,xY],(t,e,n,r,i)=>wl(t,"xAxis")?sd(e,r,!1):sd(n,i,!1)),bAe=(t,e,n,r,i)=>i,bY=Ge([Ob,bAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),yAe=(t,e,n,r,i)=>{var a,s=bY(t,e,n,r,i);if(s!=null){var o=xn(t),c=wl(o,"xAxis"),u;if(c?u=z0(t,"yAxis",n,r):u=z0(t,"xAxis",e,r),u!=null){var{stackId:d}=s,f=bM(s);if(!(d==null||f==null)){var g=(a=u[d])===null||a===void 0?void 0:a.stackedData;return g?.find(m=>m.key===f)}}}},vAe=Ge([xn,pY,gY,mY,xY,yAe,Pb,xAe,bY,Kbe],(t,e,n,r,i,a,s,o,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:g}=s;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null)){var{data:m}=c,x;if(m&&m.length>0?x=m:x=d?.slice(f,g+1),x!=null)return UAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:o})}}),_Ae=["id"],wAe=["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 yY(t,e){if(t==null)return{};var n,r,i=SAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function SAe(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 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 qp(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){MAe(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 MAe(t,e,n){return(e=EAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EAe(t){var e=AAe(t,"string");return typeof e=="symbol"?e:e+""}function AAe(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 TAe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:s}=t;return[{inactive:s,dataKey:e,type:a,color:Sw(r,i),value:yd(n,e),payload:t}]},CAe=E.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:o,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:yd(s,e),hide:o,type:u,color:Sw(r,a),unit:c}};return E.createElement(PM,{tooltipEntrySettings:d})});function NAe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:s}=r,o=Ca(r);return E.createElement(WX,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:s,baseProps:o,needClip:i,clipPathId:e})}function kAe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var s,o,c={x:(s=a.x)!==null&&s!==void 0?s:0,y:(o=a.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return qp(qp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return E.createElement(Pj,{value:e?i:void 0},n)}function m6(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:s,type:o,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,g=yY(a,_Ae),m=Ca(g),x=na(g);return E.createElement(E.Fragment,null,e?.length>1&&E.createElement(wr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},E.createElement(tm,Ch({},x,{id:f,points:e,connectNulls:u,type:o,baseLine:n,layout:s,stroke:"none",className:"recharts-area-area"})),c!=="none"&&E.createElement(tm,Ch({},m,{className:"recharts-area-curve",layout:s,type:o,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&E.createElement(tm,Ch({},m,{className:"recharts-area-curve",layout:s,type:o,connectNulls:u,fill:"none",points:n}))),E.createElement(NAe,{points:e,props:g,clipPathId:i}))}function PAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,s=r[r.length-1].y;if(!Hn(a)||!Hn(s))return null;var o=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.x||0));return Pt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Pt(c)?E.createElement("rect",{x:0,y:a<s?a:a-o,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(o)}):null}function RAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,s=r[r.length-1].x;if(!Hn(a)||!Hn(s))return null;var o=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.y||0));return Pt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Pt(c)?E.createElement("rect",{x:a<s?a:a-o,y:0,width:o,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function DAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?E.createElement(PAe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):E.createElement(RAe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function jAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:s,baseLine:o,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:g,onAnimationEnd:m}=r,x=E.useMemo(()=>({points:s,baseLine:o}),[s,o]),v=Qm(x,"recharts-area-"),y=hme(),[b,M]=E.useState(!1),S=!b,A=E.useCallback(()=>{typeof m=="function"&&m(),M(!1)},[m]),T=E.useCallback(()=>{typeof g=="function"&&g(),M(!0)},[g]);if(y==null)return null;var k=i.current,N=a.current;return E.createElement(kAe,{showLabels:S,points:s},r.children,E.createElement(Zm,{animationId:v,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:T,key:v},I=>{if(k){var C=k.length/s.length,D=I===1?s:s.map((O,q)=>{var R=Math.floor(q*C);if(k[R]){var W=k[R];return qp(qp({},O),{},{x:jn(W.x,O.x,I),y:jn(W.y,O.y,I)})}return O}),F;return Pt(o)?F=jn(N,o,I):dr(o)||Za(o)?F=jn(N,0,I):F=o.map((O,q)=>{var R=Math.floor(q*C);if(Array.isArray(N)&&N[R]){var W=N[R];return qp(qp({},O),{},{x:jn(W.x,O.x,I),y:jn(W.y,O.y,I)})}return O}),I>0&&(i.current=D,a.current=F),E.createElement(m6,{points:D,baseLine:F,needClip:e,clipPathId:n,props:r})}return I>0&&(i.current=s,a.current=o),E.createElement(wr,null,c&&E.createElement("defs",null,E.createElement("clipPath",{id:"animationClipPath-".concat(n)},E.createElement(DAe,{alpha:I,points:s,baseLine:o,layout:y,strokeWidth:r.strokeWidth}))),E.createElement(wr,{clipPath:"url(#animationClipPath-".concat(n,")")},E.createElement(m6,{points:s,baseLine:o,needClip:e,clipPathId:n,props:r})))}),E.createElement(CM,{label:r.label}))}function OAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=E.useRef(null),a=E.useRef();return E.createElement(jAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class LAe extends E.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:s,needClip:o,xAxisId:c,yAxisId:u,width:d,height:f,id:g,baseLine:m,zIndex:x}=this.props;if(e)return null;var v=Mn("recharts-area",i),y=g,{r:b,strokeWidth:M}=uY(n),S=Oj(n),A=b*2+M,T=o?"url(#clipPath-".concat(S?"":"dots-").concat(y,")"):void 0;return E.createElement(ma,{zIndex:x},E.createElement(wr,{className:v},o&&E.createElement("defs",null,E.createElement(Hj,{clipPathId:y,xAxisId:c,yAxisId:u}),!S&&E.createElement("clipPath",{id:"clipPath-dots-".concat(y)},E.createElement("rect",{x:s-A/2,y:a-A/2,width:d+A,height:f+A}))),E.createElement(OAe,{needClip:o,clipPathId:y,props:this.props})),E.createElement(k3,{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)&&E.createElement(k3,{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 IAe(t){var e,n=Sr(t,vY),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:o,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:m,stroke:x,xAxisId:v,yAxisId:y}=n,b=yY(n,wAe),M=hf(),S=mX(),{needClip:A}=OM(v,y),T=yi(),{points:k,isRange:N,baseLine:I}=(e=Ct(R=>vAe(R,v,y,T,t.id)))!==null&&e!==void 0?e:{},C=jM();if(M!=="horizontal"&&M!=="vertical"||C==null||S!=="AreaChart"&&S!=="ComposedChart")return null;var{height:D,width:F,x:O,y:q}=C;return!k||!k.length?null:E.createElement(LAe,Ch({},b,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,baseLine:I,connectNulls:o,dot:c,fill:u,fillOpacity:d,height:D,hide:f,layout:M,isAnimationActive:g==="auto"?!Ym.isSsr:g,isRange:N,legendType:m,needClip:A,points:k,stroke:x,width:F,left:O,top:q,xAxisId:v,yAxisId:y}))}var FAe=(t,e,n,r,i)=>{var a=n??e;if(Pt(a))return a;var s=t==="horizontal"?i:r,o=s.scale.domain();if(s.type==="number"){var c=Math.max(o[0],o[1]),u=Math.min(o[0],o[1]);return a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(o[0],o[1]),0)}return a==="dataMin"?o[0]:a==="dataMax"?o[1]:o[0]};function UAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:s,xAxis:o,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:g,bandSize:m}=t,x=i&&i.length,v=FAe(a,s,n,o,c),y=a==="horizontal",b=!1,M=u.map((A,T)=>{var k;x?k=i[d+T]:(k=Bn(A,r),Array.isArray(k)?b=!0:k=[v,k]);var N=k[1]==null||x&&!e&&Bn(A,r)==null;return y?{x:V1({axis:o,ticks:f,bandSize:m,entry:A,index:T}),y:N?null:c.scale(k[1]),value:k,payload:A}:{x:N?null:o.scale(k[1]),y:V1({axis:c,ticks:g,bandSize:m,entry:A,index:T}),value:k,payload:A}}),S;return x||b?S=M.map(A=>{var T=Array.isArray(A.value)?A.value[0]:null;return y?{x:A.x,y:T!=null&&A.y!=null?c.scale(T):null,payload:A.payload}:{x:T!=null?o.scale(T):null,y:A.y,payload:A.payload}}):S=y?c.scale(v):o.scale(v),{points:M,baseLine:S,isRange:b}}function zAe(t){var e=Sr(t,vY),n=yi();return E.createElement(RM,{id:e.id,type:"area"},r=>E.createElement(E.Fragment,null,E.createElement(zj,{legendPayload:TAe(e)}),E.createElement(CAe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(Bj,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:VW(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),E.createElement(IAe,Ch({},e,{id:r}))))}var _Y=E.memo(zAe,Vb);_Y.displayName="Area";var BAe=["domain","range"],HAe=["domain","range"];function g6(t,e){if(t==null)return{};var n,r,i=$Ae(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function $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 x6(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 wY(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=g6(t,BAe),{domain:a,range:s}=e,o=g6(e,HAe);return!x6(n,a)||!x6(r,s)?!1:Vb(i,o)}var VAe=["dangerouslySetInnerHTML","ticks"],GAe=["id"];function R3(){return R3=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},R3.apply(null,arguments)}function b6(t,e){if(t==null)return{};var n,r,i=WAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function WAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function qAe(t){var e=rr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(BSe(t)):n.current!==t&&e(HSe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e($Se(n.current)),n.current=null)},[e]),null}var KAe=t=>{var{xAxisId:e,className:n}=t,r=Ct(pD),i=yi(),a="xAxis",s=Ct(y=>ld(y,a,e,i)),o=Ct(y=>qK(y,a,e,i)),c=Ct(y=>$K(y,e)),u=Ct(y=>Gye(y,e)),d=Ct(y=>MK(y,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,m=b6(t,VAe),{id:x}=d,v=b6(d,GAe);return E.createElement(Vj,R3({},m,v,{scale:s,x:u.x,y:u.y,width:c.width,height:c.height,className:Mn("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a}))},XAe={allowDataOverflow:Pi.allowDataOverflow,allowDecimals:Pi.allowDecimals,allowDuplicatedCategory:Pi.allowDuplicatedCategory,angle:Pi.angle,axisLine:_c.axisLine,height:Pi.height,hide:!1,includeHidden:Pi.includeHidden,interval:Pi.interval,minTickGap:Pi.minTickGap,mirror:Pi.mirror,orientation:Pi.orientation,padding:Pi.padding,reversed:Pi.reversed,scale:Pi.scale,tick:Pi.tick,tickCount:Pi.tickCount,tickLine:_c.tickLine,tickSize:_c.tickSize,type:Pi.type,xAxisId:0},YAe=t=>{var e=Sr(t,XAe);return E.createElement(E.Fragment,null,E.createElement(qAe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),E.createElement(KAe,e))},Mw=E.memo(YAe,wY);Mw.displayName="XAxis";var ZAe=["dangerouslySetInnerHTML","ticks"],QAe=["id"];function D3(){return D3=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},D3.apply(null,arguments)}function y6(t,e){if(t==null)return{};var n,r,i=JAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function JAe(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 eTe(t){var e=rr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(VSe(t)):n.current!==t&&e(GSe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(WSe(n.current)),n.current=null)},[e]),null}var tTe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=E.useRef(null),s=E.useRef(null),o=Ct(pD),c=yi(),u=rr(),d="yAxis",f=Ct(T=>ld(T,d,e,c)),g=Ct(T=>VK(T,e)),m=Ct(T=>qye(T,e)),x=Ct(T=>qK(T,d,e,c)),v=Ct(T=>EK(T,e));if(E.useLayoutEffect(()=>{if(!(r!=="auto"||!g||kj(i)||E.isValidElement(i)||v==null)){var T=a.current;if(T){var k=T.getCalculatedWidth();Math.round(g.width)!==Math.round(k)&&u(qSe({id:e,width:k}))}}},[x,g,u,i,e,r,v]),g==null||m==null||v==null)return null;var{dangerouslySetInnerHTML:y,ticks:b}=t,M=y6(t,ZAe),{id:S}=v,A=y6(v,QAe);return E.createElement(Vj,D3({},M,A,{ref:a,labelRef:s,scale:f,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:Mn("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:x,axisType:d}))},nTe={allowDataOverflow:Ri.allowDataOverflow,allowDecimals:Ri.allowDecimals,allowDuplicatedCategory:Ri.allowDuplicatedCategory,angle:Ri.angle,axisLine:_c.axisLine,hide:!1,includeHidden:Ri.includeHidden,interval:Ri.interval,minTickGap:Ri.minTickGap,mirror:Ri.mirror,orientation:Ri.orientation,padding:Ri.padding,reversed:Ri.reversed,scale:Ri.scale,tick:Ri.tick,tickCount:Ri.tickCount,tickLine:_c.tickLine,tickSize:_c.tickSize,type:Ri.type,width:Ri.width,yAxisId:0},rTe=t=>{var e=Sr(t,nTe);return E.createElement(E.Fragment,null,E.createElement(eTe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),E.createElement(tTe,e))},Ew=E.memo(rTe,wY);Ew.displayName="YAxis";var iTe=(t,e)=>e,Wj=Ge([iTe,xn,wK,_i,cX,zc,l_e,bi],m_e),qj=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)}},SY=uo("mouseClick"),MY=Sb();MY.startListening({actionCreator:SY,effect:(t,e)=>{var n=t.payload,r=Wj(e.getState(),qj(n));r?.activeIndex!=null&&e.dispatch(ove({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var j3=uo("mouseMove"),EY=Sb(),jv=null;EY.startListening({actionCreator:j3,effect:(t,e)=>{var n=t.payload;jv!==null&&cancelAnimationFrame(jv);var r=qj(n);jv=requestAnimationFrame(()=>{var i=e.getState(),a=yj(i,i.tooltip.settings.shared);if(a==="axis"){var s=Wj(i,r);s?.activeIndex!=null?e.dispatch(tX({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):e.dispatch(eX())}jv=null})}});var v6={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},AY=Qa({name:"rootProps",initialState:v6,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:v6.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}}}),aTe=AY.reducer,{updateOptions:sTe}=AY.actions,TY=Qa({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:oTe}=TY.actions,lTe=TY.reducer,CY=uo("keyDown"),NY=uo("focus"),Kj=Sb();Kj.startListening({actionCreator:CY,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,a=t.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var s=vj(i,sg(n),Ib(n),Bb(n)),o=s==null?-1:Number(s);if(!(!Number.isFinite(o)||o<0)){var c=zc(n);if(a==="Enter"){var u=hw(n,"axis","hover",String(i.index));e.dispatch(M3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=Zye(n),f=d==="left-to-right"?1:-1,g=a==="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(M3({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});Kj.startListening({actionCreator:NY,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var a="0",s=hw(n,"axis","hover",String(a));e.dispatch(M3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:s}))}}}});var $s=uo("externalEvent"),kY=Sb(),dC=new Map;kY.startListening({actionCreator:$s,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=dC.get(i);a!==void 0&&cancelAnimationFrame(a);var s=requestAnimationFrame(()=>{try{var o=e.getState(),c={activeCoordinate:qve(o),activeDataKey:Ej(o),activeIndex:cd(o),activeLabel:hX(o),activeTooltipIndex:cd(o),isTooltipActive:Kve(o)};n(c,r)}finally{dC.delete(i)}});dC.set(i,s)}}});var cTe=Ge([ag],t=>t.tooltipItemPayloads),uTe=Ge([cTe,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:a}=i;if(a!=null){var s=e(a,n);return s}}}),PY=uo("touchMove"),RY=Sb();RY.startListening({actionCreator:PY,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=yj(r,r.tooltip.settings.shared);if(i==="axis"){var a=Wj(r,qj({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(tX({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var s,o=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(o.clientX,o.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(WW),d=(s=c.getAttribute(qW))!==null&&s!==void 0?s:void 0,f=uTe(e.getState(),u,d);e.dispatch(JK({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var dTe=fW({brush:OEe,cartesianAxis:KSe,chartData:W_e,errorBars:fMe,graphicalItems:tSe,layout:ype,legend:Tme,options:B_e,polarAxis:gwe,polarOptions:lTe,referenceElements:WEe,rootProps:aTe,tooltip:lve,zIndex:N_e}),hTe=function(e){return Vfe({reducer:dTe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([MY.middleware,EY.middleware,Kj.middleware,kY.middleware,RY.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(CW({type:"raf"}))},devTools:Ym.devToolsEnabled})};function DY(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=yi(),a=E.useRef(null);if(i)return n;a.current==null&&(a.current=hTe(e));var s=aD;return E.createElement(IMe,{context:s,store:a.current},n)}function fTe(t){var{layout:e,margin:n}=t,r=rr(),i=yi();return E.useEffect(()=>{i||(r(gpe(e)),r(mpe(n)))},[r,i,e,n]),null}var jY=E.memo(fTe,Vb);function OY(t){var e=rr();return E.useEffect(()=>{e(sTe(t))},[e,t]),null}function _6(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=$X("".concat(r).concat(e)),a=rr();return E.useLayoutEffect(()=>(a(T_e({zIndex:e,elementId:i,isPanorama:n})),()=>{a(C_e({zIndex:e,isPanorama:n}))}),[a,e,i,n]),E.createElement("g",{tabIndex:-1,id:i})}function w6(t){var{children:e,isPanorama:n}=t,r=Ct(x_e);if(!r||r.length===0)return e;var i=r.filter(s=>s<0),a=r.filter(s=>s>0);return E.createElement(E.Fragment,null,i.map(s=>E.createElement(_6,{key:s,zIndex:s,isPanorama:n})),e,a.map(s=>E.createElement(_6,{key:s,zIndex:s,isPanorama:n})))}var pTe=["children"];function mTe(t,e){if(t==null)return{};var n,r,i=gTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function gTe(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 xTe={width:"100%",height:"100%",display:"block"},bTe=E.forwardRef((t,e)=>{var n=gD(),r=xD(),i=cq();if(!hl(n)||!hl(r))return null;var{children:a,otherAttributes:s,title:o,desc:c}=t,u,d;return s!=null&&(typeof s.tabIndex=="number"?u=s.tabIndex:u=i?0:void 0,typeof s.role=="string"?d=s.role:d=i?"application":void 0),E.createElement(XR,Aw({},s,{title:o,desc:c,role:d,tabIndex:u,width:n,height:r,style:xTe,ref:e}),a)}),yTe=t=>{var{children:e}=t,n=Ct(aM);if(!n)return null;var{width:r,height:i,y:a,x:s}=n;return E.createElement(XR,{width:r,height:i,x:s,y:a},e)},S6=E.forwardRef((t,e)=>{var{children:n}=t,r=mTe(t,pTe),i=yi();return i?E.createElement(yTe,null,E.createElement(w6,{isPanorama:!0},n)):E.createElement(bTe,Aw({ref:e},r),E.createElement(w6,{isPanorama:!1},n))});function vTe(){var t=rr(),[e,n]=E.useState(null),r=Ct(Lpe);return E.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;Hn(a)&&a!==r&&t(bpe(a))}},[e,t,r]),n}function M6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _Te(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M6(Object(n),!0).forEach(function(r){wTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wTe(t,e,n){return(e=STe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function STe(t){var e=MTe(t,"string");return typeof e=="symbol"?e:e+""}function MTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Zh(){return Zh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Zh.apply(null,arguments)}var ETe=()=>(t1e(),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 ATe=E.forwardRef((t,e)=>{var n,r,i=E.useRef(null),[a,s]=E.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=E.useCallback((u,d)=>{s(f=>{var g=Math.round(u),m=Math.round(d);return f.containerWidth===g&&f.containerHeight===m?f:{containerWidth:g,containerHeight:m}})},[]),c=E.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();o(d,f);var g=x=>{var{width:v,height:y}=x[0].contentRect;o(v,y)},m=new ResizeObserver(g);m.observe(u),i.current=m}},[e,o]);return E.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[o]),E.createElement(E.Fragment,null,E.createElement(sM,{width:a.containerWidth,height:a.containerHeight}),E.createElement("div",Zh({ref:c},t)))}),TTe=E.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=E.useState({containerWidth:Tw(n),containerHeight:Tw(r)}),s=E.useCallback((c,u)=>{a(d=>{var f=Math.round(c),g=Math.round(u);return d.containerWidth===f&&d.containerHeight===g?d:{containerWidth:f,containerHeight:g}})},[]),o=E.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();s(u,d)}},[e,s]);return E.createElement(E.Fragment,null,E.createElement(sM,{width:i.containerWidth,height:i.containerHeight}),E.createElement("div",Zh({ref:o},t)))}),CTe=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return E.createElement(E.Fragment,null,E.createElement(sM,{width:n,height:r}),E.createElement("div",Zh({ref:e},t)))}),NTe=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return Cc(n)||Cc(r)?E.createElement(TTe,Zh({},t,{ref:e})):E.createElement(CTe,Zh({},t,{ref:e}))});function kTe(t){return t===!0?ATe:NTe}var PTe=E.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:s,onDoubleClick:o,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:g,onTouchEnd:m,onTouchMove:x,onTouchStart:v,style:y,width:b,responsive:M,dispatchTouchEvents:S=!0}=t,A=E.useRef(null),T=rr(),[k,N]=E.useState(null),[I,C]=E.useState(null),D=vTe(),F=mD(),O=F?.width>0?F.width:b,q=F?.height>0?F.height:i,R=E.useCallback(ie=>{D(ie),typeof e=="function"&&e(ie),N(ie),C(ie),ie!=null&&(A.current=ie)},[D,e,N,C]),W=E.useCallback(ie=>{T(SY(ie)),T($s({handler:a,reactEvent:ie}))},[T,a]),K=E.useCallback(ie=>{T(j3(ie)),T($s({handler:u,reactEvent:ie}))},[T,u]),G=E.useCallback(ie=>{T(eX()),T($s({handler:d,reactEvent:ie}))},[T,d]),ee=E.useCallback(ie=>{T(j3(ie)),T($s({handler:f,reactEvent:ie}))},[T,f]),Z=E.useCallback(()=>{T(NY())},[T]),Q=E.useCallback(ie=>{T(CY(ie.key))},[T]),U=E.useCallback(ie=>{T($s({handler:s,reactEvent:ie}))},[T,s]),$=E.useCallback(ie=>{T($s({handler:o,reactEvent:ie}))},[T,o]),X=E.useCallback(ie=>{T($s({handler:c,reactEvent:ie}))},[T,c]),te=E.useCallback(ie=>{T($s({handler:g,reactEvent:ie}))},[T,g]),fe=E.useCallback(ie=>{T($s({handler:v,reactEvent:ie}))},[T,v]),pe=E.useCallback(ie=>{S&&T(PY(ie)),T($s({handler:x,reactEvent:ie}))},[T,S,x]),xe=E.useCallback(ie=>{T($s({handler:m,reactEvent:ie}))},[T,m]),Ne=kTe(M);return E.createElement(vX.Provider,{value:k},E.createElement(CG.Provider,{value:I},E.createElement(Ne,{width:O??y?.width,height:q??y?.height,className:Mn("recharts-wrapper",r),style:_Te({position:"relative",cursor:"default",width:O,height:q},y),onClick:W,onContextMenu:U,onDoubleClick:$,onFocus:Z,onKeyDown:Q,onMouseDown:X,onMouseEnter:K,onMouseLeave:G,onMouseMove:ee,onMouseUp:te,onTouchEnd:xe,onTouchMove:pe,onTouchStart:fe,ref:R},E.createElement(ETe,null),n)))}),RTe=["width","height","responsive","children","className","style","compact","title","desc"];function DTe(t,e){if(t==null)return{};var n,r,i=jTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function jTe(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 LY=E.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:s,style:o,compact:c,title:u,desc:d}=t,f=DTe(t,RTe),g=Ca(f);return c?E.createElement(E.Fragment,null,E.createElement(sM,{width:n,height:r}),E.createElement(S6,{otherAttributes:g,title:u,desc:d},a)):E.createElement(PTe,{className:s,style:o,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},E.createElement(S6,{otherAttributes:g,title:u,desc:d,ref:e},E.createElement(qEe,null,a)))});function O3(){return O3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},O3.apply(null,arguments)}var OTe={top:5,right:5,bottom:5,left:5},LTe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:OTe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},Xj=E.forwardRef(function(e,n){var r,i=Sr(e.categoricalChartProps,LTe),{chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:c,eventEmitter:void 0};return E.createElement(DY,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},E.createElement(JX,{chartData:u.data}),E.createElement(jY,{layout:i.layout,margin:i.margin}),E.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}),E.createElement(LY,O3({},i,{ref:n})))}),ITe=["axis"],FTe=E.forwardRef((t,e)=>E.createElement(Xj,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:ITe,tooltipPayloadSearcher:AM,categoricalChartProps:t,ref:e})),UTe=["axis","item"],zTe=E.forwardRef((t,e)=>E.createElement(Xj,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:UTe,tooltipPayloadSearcher:AM,categoricalChartProps:t,ref:e}));function BTe(t){var e=rr();return E.useEffect(()=>{e(oTe(t))},[e,t]),null}var HTe=["layout"];function L3(){return L3=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},L3.apply(null,arguments)}function $Te(t,e){if(t==null)return{};var n,r,i=VTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function VTe(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 GTe={top:5,right:5,bottom:5,left:5},IY={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:GTe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},WTe=E.forwardRef(function(e,n){var r,i=Sr(e.categoricalChartProps,IY),{layout:a}=i,s=$Te(i,HTe),{chartName:o,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:o,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return E.createElement(DY,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:o},E.createElement(JX,{chartData:i.data}),E.createElement(jY,{layout:a,margin:i.margin}),E.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}),E.createElement(BTe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),E.createElement(LY,L3({},s,{ref: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 A6(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){qTe(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 qTe(t,e,n){return(e=KTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KTe(t){var e=XTe(t,"string");return typeof e=="symbol"?e:e+""}function XTe(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 YTe=["item"],ZTe=A6(A6({},IY),{},{layout:"centric",startAngle:0,endAngle:360}),QTe=E.forwardRef((t,e)=>{var n=Sr(t,ZTe);return E.createElement(WTe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:YTe,tooltipPayloadSearcher:AM,categoricalChartProps:n,ref:e})}),JTe=["axis"],eCe=E.forwardRef((t,e)=>E.createElement(Xj,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:JTe,tooltipPayloadSearcher:AM,categoricalChartProps:t,ref:e}));const T6=[{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 tCe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:s="humidity",thresholds:o}){const{t:c}=Gm(),{theme:u}=xb(),[d,f]=E.useState("24h"),[g,m]=E.useState(s),x=u==="dark";E.useEffect(()=>{if(!t)return;const $=X=>{X.key==="Escape"&&e()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[t,e]);const v=T6.find($=>$.value===d)?.hours||24,{data:y,isLoading:b,error:M}=vt({queryKey:["ams-history",n,i,v],queryFn:()=>ke.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const S=y?.data.map($=>({time:new Date($.recorded_at).getTime(),humidity:$.humidity,temperature:$.temperature,timeLabel:new Date($.recorded_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}})}))||[],A=o?.humidityGood||40,T=o?.humidityFair||60,k=o?.tempGood||30,N=o?.tempFair||35,I=S[S.length-1],C=I?.humidity,D=I?.temperature,F=$=>{const X=$.filter(ie=>ie!=null);if(X.length<4)return"stable";const te=X.slice(0,Math.floor(X.length/4)),fe=X.slice(-Math.floor(X.length/4)),pe=te.reduce((ie,be)=>ie+be,0)/te.length,Ne=fe.reduce((ie,be)=>ie+be,0)/fe.length-pe;return Math.abs(Ne)<2?"stable":Ne>0?"up":"down"},O=F(S.map($=>$.humidity)),q=F(S.map($=>$.temperature)),R=({trend:$})=>$==="up"?l.jsx(gG,{className:"w-4 h-4 text-red-400"}):$==="down"?l.jsx(mG,{className:"w-4 h-4 text-green-400"}):l.jsx(Rk,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),W=$=>$==null?"#9ca3af":$<=A?"#22a352":$<=T?"#d4a017":"#c62828",K=$=>$==null?"#9ca3af":$<=k?"#22a352":$<=N?"#d4a017":"#c62828",G=x?"#2d2d2d":"#ffffff",ee=x?"#1d1d1d":"#f3f4f6",Z=x?"#3d3d3d":"#e5e7eb",Q=x?"#ffffff":"#111827",U=x?"#9ca3af":"#4b5563";return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:l.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:G},onClick:$=>$.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:Z},children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold",style:{color:Q},children:[a," ",c("common.history","History")]}),l.jsx("p",{className:"text-sm",style:{color:U},children:r})]}),l.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:U},children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ee},children:[l.jsxs("button",{onClick:()=>m("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="humidity"?"bg-blue-600 text-white":""}`,style:g!=="humidity"?{color:U}:void 0,children:[l.jsx(aG,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),l.jsxs("button",{onClick:()=>m("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="temperature"?"bg-orange-600 text-white":""}`,style:g!=="temperature"?{color:U}:void 0,children:[l.jsx(Sh,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),l.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ee},children:T6.map($=>l.jsx("button",{onClick:()=>f($.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===$.value?"bg-bambu-green text-white":""}`,style:d!==$.value?{color:U}:void 0,children:$.label},$.value))})]}),l.jsx("div",{className:"grid grid-cols-4 gap-4",children:g==="humidity"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.current","Current")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-2xl font-bold",style:{color:W(C)},children:C!=null?`${C}%`:"—"}),l.jsx(R,{trend:O})]})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.average","Average")}),l.jsx("p",{className:"text-2xl font-bold",style:{color:Q},children:y?.avg_humidity!=null?`${y.avg_humidity}%`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.min","Min")}),l.jsx("p",{className:"text-2xl font-bold text-green-500",children:y?.min_humidity!=null?`${y.min_humidity}%`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.max","Max")}),l.jsx("p",{className:"text-2xl font-bold text-red-500",children:y?.max_humidity!=null?`${y.max_humidity}%`:"—"})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.current","Current")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-2xl font-bold",style:{color:K(D)},children:D!=null?`${D}°C`:"—"}),l.jsx(R,{trend:q})]})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.average","Average")}),l.jsx("p",{className:"text-2xl font-bold",style:{color:Q},children:y?.avg_temperature!=null?`${y.avg_temperature}°C`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.min","Min")}),l.jsx("p",{className:"text-2xl font-bold text-blue-500",children:y?.min_temperature!=null?`${y.min_temperature}°C`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.max","Max")}),l.jsx("p",{className:"text-2xl font-bold text-red-500",children:y?.max_temperature!=null?`${y.max_temperature}°C`:"—"})]})]})}),l.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:b?l.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:c("common.loading","Loading...")}):M?l.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):S.length===0?l.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:c("common.noData","No data available for this time range")}):l.jsx(n1,{width:"100%",height:300,children:l.jsxs(FTe,{data:S,children:[l.jsx(ww,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),l.jsx(Mw,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:$=>{const X=new Date($);return v>24?X.toLocaleDateString([],{day:"numeric",month:"short"}):X.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),l.jsx(Ew,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:g==="humidity"?[0,100]:["auto","auto"],tickFormatter:$=>g==="humidity"?`${$}%`:`${$}°C`}),l.jsx(i1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:$=>new Date($).toLocaleString(),formatter:$=>[g==="humidity"?`${$}%`:`${$}°C`,g==="humidity"?"Humidity":"Temperature"]}),l.jsx(vD,{}),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(fY,{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 nCe({side:t}){const{theme:e}=xb(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return l.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function rCe({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 iCe({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 C6({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 aCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),l.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function sCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),l.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function oCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("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 lCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("rect",{x:"4.5",y:"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 cCe({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 uCe({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r}){const i=typeof t=="string"?parseInt(t,10):t,a=typeof e=="number"?e:40,s=typeof n=="number"?n:60;let o,c;isNaN(i)?(o="#C3C2C1",c="Unknown"):i<=a?(o="#22a352",c="Good"):i<=s?(o="#d4a017",c="Fair"):(o="#c62828",c="Bad");let u;return isNaN(i)||i<=a?u=C6:i<=s?u=aCe:u=sCe,l.jsxs("button",{type:"button",onClick:r,className:`flex items-center justify-end gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${i}% - ${c}${r?" (click for history)":""}`,children:[l.jsx(u,{className:"w-3 h-4"}),l.jsxs("span",{className:"text-xs font-medium tabular-nums w-8 text-right",style:{color:o},children:[i,"%"]})]})}function dCe({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r}){const i=typeof e=="number"?e:28,a=typeof n=="number"?n:35;let s,o,c;return t<=i?(s="#22a352",o="Good",c=oCe):t<=a?(s="#d4a017",o="Fair",c=lCe):(s="#c62828",o="Bad",c=cCe),l.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${o}${r?" (click for history)":""}`,children:[l.jsx(c,{className:"w-3 h-4"}),l.jsxs("span",{className:"tabular-nums w-12 text-right",style:{color:s},children:[t,"°C"]})]})}function hC(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,a=r>=128?r-128:r,s=String.fromCharCode(65+a);return i?`HT-${s}`:`AMS-${s}`}function hCe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function fCe(t){const e=new Date,n=new Date(e.getTime()+t*60*1e3),r=new Date;r.setHours(0,0,0,0);const i=new Date(n);i.setHours(0,0,0,0);const a=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),s=Math.floor((i.getTime()-r.getTime())/(1e3*60*60*24));return s===0?a:s===1?`Tomorrow ${a}`:n.toLocaleDateString([],{weekday:"short"})+" "+a}function pCe(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 mCe(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 gCe({url:t,printName:e}){const[n,r]=E.useState(!1),[i,a]=E.useState(!1),[s,o]=E.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&o(!0),children:t&&!i?l.jsxs(l.Fragment,{children:[l.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&l.jsx(fm,{className:"w-8 h-8 text-bambu-gray"})]}):l.jsx(fm,{className:"w-8 h-8 text-bambu-gray"})}),s&&t&&l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:l.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[l.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&l.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function xCe({printers:t}){const e=En(),n=E.useMemo(()=>{let i=0,a=0,s=0,o=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?o++:u.connected?u.state==="RUNNING"?i++:a++:s++}),{printing:i,idle:a,offline:s,loading:o,total:t?.length||0}},[t,e]),[,r]=E.useState(0);return E.useEffect(()=>{let i=!1;const a=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(s=>s+1),i=!1}))});return()=>a()},[e]),t?.length?l.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function N6({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i}){const a=En(),s=CR(),[o,c]=E.useState(!1),[u,d]=E.useState(!1),[f,g]=E.useState(!1),[m,x]=E.useState(!1),[v,y]=E.useState(!1),[b,M]=E.useState(!1),[S,A]=E.useState(!1),[T,k]=E.useState(!1),[N,I]=E.useState(null),{data:C}=vt({queryKey:["printerStatus",t.id],queryFn:()=>ke.getPrinterStatus(t.id),refetchInterval:3e4}),[D,F]=E.useState(null);E.useEffect(()=>{C?.wifi_signal!=null&&F(C.wifi_signal)},[C?.wifi_signal]);const O=C?.wifi_signal??D,q=E.useRef(void 0);E.useEffect(()=>{C?.connected!==void 0&&(q.current=C.connected)},[C?.connected]);const R=C?.connected??q.current,W=E.useRef({});E.useEffect(()=>{C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0&&(W.current=C.ams_extruder_map)},[C?.ams_extruder_map]);const K=C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0?C.ams_extruder_map:W.current,G=E.useRef([]);E.useEffect(()=>{C?.ams&&C.ams.length>0&&(G.current=C.ams)},[C?.ams]);const ee=C?.ams&&C.ams.length>0?C.ams:G.current,{data:Z}=vt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ke.getSmartPlugByPrinter(t.id)}),{data:Q}=vt({queryKey:["smartPlugStatus",Z?.id],queryFn:()=>Z?ke.getSmartPlugStatus(Z.id):null,enabled:!!Z,refetchInterval:1e4}),{data:U}=vt({queryKey:["queue",t.id,"pending"],queryFn:()=>ke.getQueue(t.id,"pending")}),$=U?.length||0,{data:X}=vt({queryKey:["archives",t.id,"last"],queryFn:()=>ke.getArchives(t.id,1,0),enabled:C?.connected&&C?.state!=="RUNNING"}),te=X?.[0],fe=e&&R===!1,pe=wt({mutationFn:()=>ke.deletePrinter(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["printers"]})}}),xe=wt({mutationFn:()=>ke.connectPrinter(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Ne=wt({mutationFn:be=>Z?ke.controlSmartPlug(Z.id,be):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugStatus",Z?.id]})}}),ie=wt({mutationFn:be=>Z?ke.updateSmartPlug(Z.id,{auto_off:be}):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),a.invalidateQueries({queryKey:["smart-plugs"]})}});return fe?null:l.jsxs(Nt,{className:"relative",children:[l.jsxs(Rt,{children:[l.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l.jsx("img",{src:pCe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${r==="compact"?"w-10 h-10":"w-14 h-14"}`}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&l.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${C?.connected?"bg-bambu-green":"bg-red-500"}`,title:C?.connected?"Connected":"Offline"})]}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&C?.nozzles&&C.nozzles[0]?.nozzle_diameter&&l.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:C.nozzles[0].nozzle_type||"Nozzle",children:["• ",C.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&l.jsxs("span",{className:"ml-2 text-bambu-gray",children:[l.jsx(_r,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),l.jsxs("div",{className:"relative flex-shrink-0",children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>c(!o),children:l.jsx(sG,{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:()=>{xe.mutate(),c(!1)},children:[l.jsx(Ta,{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:()=>{y(!0),c(!1)},children:[l.jsx(pG,{className:"w-4 h-4"}),"MQTT Debug"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{d(!0),c(!1)},children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&l.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[l.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${C?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[C?.connected?l.jsx(zS,{className:"w-3 h-3"}):l.jsx(xG,{className:"w-3 h-3"}),C?.connected?"Connected":"Offline"]}),C?.connected&&O!=null&&l.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${O>=-50||O>=-60?"bg-bambu-green/20 text-bambu-green":O>=-70?"bg-amber-500/20 text-amber-600":O>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${O} dBm - ${mCe(O).label}`,children:[l.jsx(Qce,{className:"w-3 h-3"}),O,"dBm"]}),C?.connected&&(()=>{const be=C.hms_errors?ade(C.hms_errors):[];return 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 ${be.length>0?be.some(je=>je.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"}),be.length>0?be.length:"OK"]})})(),n&&l.jsxs("button",{onClick:()=>s("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-red-500/20 text-red-400":n.warning_count>0?"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:"All maintenance up to date - Click to view",children:[l.jsx(ad,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),$>0&&l.jsxs("button",{onClick:()=>s("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:`${$} print${$>1?"s":""} in queue`,children:[l.jsx($h,{className:"w-3 h-3"}),$]})]})]}),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:()=>{pe.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(gCe,{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"}),hCe(C.remaining_time*60)]}),l.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",fCe(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:"—"})]}),te?l.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:te.print_name||te.filename,children:["Last: ",te.print_name||te.filename,te.completed_at&&l.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(te.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(cde,{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"]})]})]}),ee&&ee.length>0&&r==="expanded"&&l.jsxs("div",{className:"mt-3 space-y-2",children:[ee.map(be=>{const je=K[String(be.id)],he=be.id>=128?be.id-128:be.id,ht=je!==void 0?je:he,H=t.nozzle_count===2||C?.temperatures?.nozzle_2!==void 0,B=ht===1,re=ht===0,V=be.tray.map(se=>se.tray_color?`#${se.tray_color}`:se.tray_type?"#333":null),J=be.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:[H&&(B||re)&&l.jsx(nCe,{side:B?"L":"R"}),J?l.jsx(iCe,{color:V[0],className:"flex-shrink-0"}):l.jsx(rCe,{colors:V,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(be.id,be.tray.length)}),l.jsx("div",{className:"mt-0.5 text-[10px] flex items-start",children:be.tray.map((se,Ae)=>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:se.tray_type?se.tray_sub_brands||se.tray_type:"—"}),l.jsx("span",{className:"text-bambu-gray/50 truncate",children:se.tray_type&&se.remain>=0?`${se.remain}%`:"—"})]}),Ae<be.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:"·"})]})]},Ae))})]}),(be.humidity!=null||be.temp!=null)&&l.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[be.humidity!=null&&l.jsx(uCe,{humidity:be.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair,onClick:()=>I({amsId:be.id,amsLabel:hC(be.id,be.tray.length),mode:"humidity"})}),be.temp!=null&&l.jsx(dCe,{temp:be.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair,onClick:()=>I({amsId:be.id,amsLabel:hC(be.id,be.tray.length),mode:"temperature"})})]})]})},be.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"})]})]})})]})]}),Z&&r==="expanded"&&l.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(bm,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),l.jsx("span",{className:"text-sm text-white truncate",children:Z.name}),Q&&l.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${Q.state==="ON"?"bg-bambu-green/20 text-bambu-green":Q.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:Q.state||"?"}),Q?.energy?.power!=null&&Q.state==="ON"&&l.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[Q.energy.power,"W"]})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("button",{onClick:()=>M(!0),disabled:Ne.isPending||Q?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Q?.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:Ne.isPending||Q?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Q?.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(VR,{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 ${Z.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:Z.auto_off_executed?"Auto-off done":"Auto-off"}),l.jsx("button",{onClick:()=>ie.mutate(!Z.auto_off),disabled:ie.isPending||Z.auto_off_executed,title:Z.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 ${Z.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":Z.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 ${Z.auto_off||Z.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&l.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[l.jsxs("div",{className:"text-xs text-bambu-gray",children:[l.jsx("p",{children:t.ip_address}),l.jsx("p",{className:"truncate",children:t.serial_number})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>{window.open(`/camera/${t.id}`,`camera-${t.id}`,"width=640,height=400,menubar=no,toolbar=no,location=no,status=no")},disabled:!C?.connected,title:"Open camera in new window",children:l.jsx(bG,{className:"w-4 h-4"})}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>x(!0),title:"Browse printer files",children:[l.jsx(BR,{className:"w-4 h-4"}),"Files"]})]})]})]}),m&&l.jsx(nde,{printerId:t.id,printerName:t.name,onClose:()=>x(!1)}),v&&l.jsx(rde,{printerId:t.id,printerName:t.name,onClose:()=>y(!1)}),b&&Z&&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:()=>{Ne.mutate("on"),M(!1)},onCancel:()=>M(!1)}),S&&Z&&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:()=>{Ne.mutate("off"),A(!1)},onCancel:()=>A(!1)}),T&&l.jsx(ode,{printerName:t.name,errors:C?.hms_errors||[],onClose:()=>k(!1)}),N&&l.jsx(tCe,{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(yCe,{printer:t,onClose:()=>g(!1)})]})}function bCe({onClose:t,onAdd:e}){const[n,r]=E.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0});return E.useEffect(()=>{const i=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:l.jsxs(Rt,{children:[l.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),l.jsxs("form",{onSubmit:i=>{i.preventDefault(),e(n)},className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.name,onChange:i=>r({...n,name:i.target.value}),placeholder:"My Printer"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),l.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.ip_address,onChange:i=>r({...n,ip_address:i.target.value}),placeholder:"192.168.1.100"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),l.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.serial_number,onChange:i=>r({...n,serial_number:i.target.value}),placeholder:"01P00A000000000"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),l.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.access_code,onChange:i=>r({...n,access_code:i.target.value}),placeholder:"From printer settings"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),l.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.model||"",onChange:i=>r({...n,model:i.target.value}),children:[l.jsx("option",{value:"",children:"Select model..."}),l.jsxs("optgroup",{label:"H2 Series",children:[l.jsx("option",{value:"H2C",children:"H2C"}),l.jsx("option",{value:"H2D",children:"H2D"}),l.jsx("option",{value:"H2S",children:"H2S"})]}),l.jsxs("optgroup",{label:"X1 Series",children:[l.jsx("option",{value:"X1E",children:"X1E"}),l.jsx("option",{value:"X1C",children:"X1 Carbon"}),l.jsx("option",{value:"X1",children:"X1"})]}),l.jsxs("optgroup",{label:"P Series",children:[l.jsx("option",{value:"P2S",children:"P2S"}),l.jsx("option",{value:"P1S",children:"P1S"}),l.jsx("option",{value:"P1P",children:"P1P"})]}),l.jsxs("optgroup",{label:"A1 Series",children:[l.jsx("option",{value:"A1",children:"A1"}),l.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"auto_archive",checked:n.auto_archive,onChange:i=>r({...n,auto_archive:i.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),l.jsxs("div",{className:"flex gap-3 pt-4",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function yCe({printer:t,onClose:e}){const n=En(),[r,i]=E.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=wt({mutationFn:o=>ke.updatePrinter(t.id,o),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});E.useEffect(()=>{const o=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]);const s=o=>{o.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),a.mutate(c)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:l.jsxs(Rt,{children:[l.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),l.jsxs("form",{onSubmit:s,className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:o=>i({...r,name:o.target.value}),placeholder:"My Printer"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),l.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:o=>i({...r,ip_address:o.target.value}),placeholder:"192.168.1.100"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),l.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),l.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:o=>i({...r,access_code:o.target.value}),placeholder:"Leave empty to keep current"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),l.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model,onChange:o=>i({...r,model:o.target.value}),children:[l.jsx("option",{value:"",children:"Select model..."}),l.jsxs("optgroup",{label:"H2 Series",children:[l.jsx("option",{value:"H2C",children:"H2C"}),l.jsx("option",{value:"H2D",children:"H2D"}),l.jsx("option",{value:"H2S",children:"H2S"})]}),l.jsxs("optgroup",{label:"X1 Series",children:[l.jsx("option",{value:"X1E",children:"X1E"}),l.jsx("option",{value:"X1C",children:"X1 Carbon"}),l.jsx("option",{value:"X1",children:"X1"})]}),l.jsxs("optgroup",{label:"P Series",children:[l.jsx("option",{value:"P2S",children:"P2S"}),l.jsx("option",{value:"P1S",children:"P1S"}),l.jsx("option",{value:"P1P",children:"P1P"})]}),l.jsxs("optgroup",{label:"A1 Series",children:[l.jsx("option",{value:"A1",children:"A1"}),l.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),l.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.location,onChange:o=>i({...r,location:o.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:o=>i({...r,auto_archive:o.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),l.jsxs("div",{className:"flex gap-3 pt-4",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function vCe(t){const{data:e}=vt({queryKey:["printerStatus",t],queryFn:()=>ke.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function _Ce({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=vCe(t.id),{data:a}=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}),a&&l.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:a.state||"?"})]}),l.jsxs("button",{onClick:()=>n(e.id),disabled:r||a?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[l.jsx(bd,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function wCe(){const[t,e]=E.useState(!1),[n,r]=E.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=E.useState(!1),[s,o]=E.useState(null),[c,u]=E.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=E.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,m]=E.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),x=En(),{data:v,isLoading:y}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:b}=vt({queryKey:["settings"],queryFn:ke.getSettings}),{data:M}=vt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs}),{data:S}=vt({queryKey:["maintenanceOverview"],queryFn:ke.getMaintenanceOverview,staleTime:60*1e3}),A=S?.reduce((R,W)=>(R[W.printer_id]={due_count:W.due_count,warning_count:W.warning_count,total_print_hours:W.total_print_hours},R),{})||{},T=M?.reduce((R,W)=>(W.printer_id&&(R[W.printer_id]=W),R),{})||{},k=wt({mutationFn:ke.createPrinter,onSuccess:()=>{x.invalidateQueries({queryKey:["printers"]}),e(!1)}}),N=wt({mutationFn:R=>ke.controlSmartPlug(R,"on"),onSuccess:()=>{x.invalidateQueries({queryKey:["smart-plugs"]}),o(null)},onError:()=>{o(null)}}),I=()=>{const R=!n;r(R),localStorage.setItem("hideDisconnectedPrinters",String(R))},C=R=>{u(R),localStorage.setItem("printerSortBy",R)},D=()=>{const R=!d;f(R),localStorage.setItem("printerSortAsc",String(R))},F=()=>{const R=g==="expanded"?"compact":"expanded";m(R),localStorage.setItem("printerViewMode",R)},O=E.useMemo(()=>{if(!v)return[];const R=[...v];switch(c){case"name":R.sort((W,K)=>W.name.localeCompare(K.name));break;case"model":R.sort((W,K)=>(W.model||"").localeCompare(K.model||""));break;case"location":R.sort((W,K)=>{const G=W.location||"",ee=K.location||"";return!G&&ee?1:G&&!ee?-1:G.localeCompare(ee)||W.name.localeCompare(K.name)});break;case"status":R.sort((W,K)=>{const G=x.getQueryData(["printerStatus",W.id]),ee=x.getQueryData(["printerStatus",K.id]),Z=Q=>Q?.connected?Q.state==="RUNNING"?0:1:2;return Z(G)-Z(ee)});break}return d||R.reverse(),R},[v,c,d,x]),q=E.useMemo(()=>{if(c!=="location")return null;const R={};return O.forEach(W=>{const K=W.location||"Ungrouped";R[K]||(R[K]=[]),R[K].push(W)}),R},[c,O]);return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),l.jsx(xCe,{printers:v})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("select",{value:c,onChange:R=>C(R.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"name",children:"Name"}),l.jsx("option",{value:"status",children:"Status"}),l.jsx("option",{value:"model",children:"Model"}),l.jsx("option",{value:"location",children:"Location"})]}),l.jsx("button",{onClick:D,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?l.jsx(hm,{className:"w-4 h-4 text-bambu-gray"}):l.jsx(x0,{className:"w-4 h-4 text-bambu-gray"})})]}),l.jsx("button",{onClick:F,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:g==="expanded"?"Switch to compact view":"Switch to expanded view",children:g==="expanded"?l.jsx(Ule,{className:"w-5 h-5 text-bambu-gray"}):l.jsx(cG,{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:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[l.jsx(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:()=>a(!1)}),l.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[l.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),v?.filter(R=>T[R.id]).map(R=>l.jsx(_Ce,{printer:R,plug:T[R.id],onPowerOn:W=>{o(W),N.mutate(W)},isPowering:s===T[R.id]?.id},R.id)),v?.filter(R=>T[R.id]).length===0&&l.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),l.jsxs(Le,{onClick:()=>e(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),y?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):v?.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-12",children:[l.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),l.jsxs(Le,{onClick:()=>e(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):q?l.jsx("div",{className:"space-y-6",children:Object.entries(q).map(([R,W])=>l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),R,l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",W.length,")"]})]}),l.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:W.map(K=>l.jsx(N6,{printer:K,hideIfDisconnected:n,maintenanceInfo:A[K.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},K.id))})]},R))}):l.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:O.map(R=>l.jsx(N6,{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(bCe,{onClose:()=>e(!1),onAdd:R=>k.mutate(R)})]})}const Yj="181",rm={ROTATE:0,DOLLY:1,PAN:2},Kp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},SCe=0,k6=1,MCe=2,FY=1,ECe=2,ic=3,dd=0,qa=1,rl=2,wc=0,im=1,P6=2,R6=3,D6=4,ACe=5,sh=100,TCe=101,CCe=102,NCe=103,kCe=104,PCe=200,RCe=201,DCe=202,jCe=203,I3=204,F3=205,OCe=206,LCe=207,ICe=208,FCe=209,UCe=210,zCe=211,BCe=212,HCe=213,$Ce=214,U3=0,z3=1,B3=2,Tm=3,H3=4,$3=5,V3=6,G3=7,Zj=0,VCe=1,GCe=2,Xu=0,WCe=1,qCe=2,KCe=3,XCe=4,YCe=5,ZCe=6,QCe=7,UY=300,Cm=301,Nm=302,W3=303,q3=304,IM=306,K3=1e3,mc=1001,X3=1002,ws=1003,JCe=1004,Ov=1005,ro=1006,fC=1007,gh=1008,gl=1009,zY=1010,BY=1011,$0=1012,Qj=1013,Qh=1014,gc=1015,og=1016,Jj=1017,eO=1018,V0=1020,HY=35902,$Y=35899,VY=1021,GY=1022,Do=1023,G0=1026,W0=1027,WY=1028,tO=1029,nO=1030,rO=1031,iO=1033,s1=33776,o1=33777,l1=33778,c1=33779,Y3=35840,Z3=35841,Q3=35842,J3=35843,eP=36196,tP=37492,nP=37496,rP=37808,iP=37809,aP=37810,sP=37811,oP=37812,lP=37813,cP=37814,uP=37815,dP=37816,hP=37817,fP=37818,pP=37819,mP=37820,gP=37821,xP=36492,bP=36494,yP=36495,vP=36283,_P=36284,wP=36285,SP=36286,eNe=3200,tNe=3201,qY=0,nNe=1,Lu="",qs="srgb",km="srgb-linear",Cw="linear",qn="srgb",tp=7680,j6=519,rNe=512,iNe=513,aNe=514,KY=515,sNe=516,oNe=517,lNe=518,cNe=519,O6=35044,L6="300 es",ol=2e3,Nw=2001;function XY(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 uNe(){const t=kw("canvas");return t.style.display="block",t}const I6={};function F6(...t){const e="THREE."+t.shift();console.log(e,...t)}function Yt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function zr(...t){const e="THREE."+t.shift();console.error(e,...t)}function q0(...t){const e=t.join(" ");e in I6||(I6[e]=!0,Yt(...t))}function dNe(t,e,n){return new Promise(function(r,i){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}let 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 a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}};const aa=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],u1=Math.PI/180,MP=180/Math.PI;function Wb(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(aa[t&255]+aa[t>>8&255]+aa[t>>16&255]+aa[t>>24&255]+"-"+aa[e&255]+aa[e>>8&255]+"-"+aa[e>>16&15|64]+aa[e>>24&255]+"-"+aa[n&63|128]+aa[n>>8&255]+"-"+aa[n>>16&255]+aa[n>>24&255]+aa[r&255]+aa[r>>8&255]+aa[r>>16&255]+aa[r>>24&255]).toLowerCase()}function gn(t,e,n){return Math.max(e,Math.min(n,t))}function hNe(t,e){return(t%e+e)%e}function pC(t,e,n){return(1-n)*t+n*e}function mx(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function za(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 fNe={DEG2RAD:u1};let cn=class YY{constructor(e=0,n=0){YY.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(gn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},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,a,s,o){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],g=a[s+0],m=a[s+1],x=a[s+2],v=a[s+3];if(o<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(o>=1){e[n+0]=g,e[n+1]=m,e[n+2]=x,e[n+3]=v;return}if(f!==v||c!==g||u!==m||d!==x){let y=c*g+u*m+d*x+f*v;y<0&&(g=-g,m=-m,x=-x,v=-v,y=-y);let b=1-o;if(y<.9995){const M=Math.acos(y),S=Math.sin(M);b=Math.sin(b*M)/S,o=Math.sin(o*M)/S,c=c*b+g*o,u=u*b+m*o,d=d*b+x*o,f=f*b+v*o}else{c=c*b+g*o,u=u*b+m*o,d=d*b+x*o,f=f*b+v*o;const M=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=M,u*=M,d*=M,f*=M}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[s],g=a[s+1],m=a[s+2],x=a[s+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,a=e._z,s=e._order,o=Math.cos,c=Math.sin,u=o(r/2),d=o(i/2),f=o(a/2),g=c(r/2),m=c(i/2),x=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f-g*m*x;break;case"YXZ":this._x=g*d*f+u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f+g*m*x;break;case"ZXY":this._x=g*d*f-u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f-g*m*x;break;case"ZYX":this._x=g*d*f-u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f+g*m*x;break;case"YZX":this._x=g*d*f+u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f-g*m*x;break;case"XZY":this._x=g*d*f-u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f+g*m*x;break;default:Yt("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],s=n[1],o=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+o+f;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(d-c)*m,this._y=(a-u)*m,this._z=(s-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+s)/m,this._z=(a+u)/m}else if(o>f){const m=2*Math.sqrt(1+o-r-f);this._w=(a-u)/m,this._x=(i+s)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(s-i)/m,this._x=(a+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(gn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,o=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+s*o+i*u-a*c,this._y=i*d+s*c+a*o-r*u,this._z=a*d+s*u+r*c-i*o,this._w=s*d-r*o-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,a=-a,s=-s,o=-o);let c=1-n;if(o<.9995){const u=Math.acos(o),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+s*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+s*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Qe=class ZY{constructor(e=0,n=0,r=0){ZY.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(U6.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(U6.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,s=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,c=e.w,u=2*(s*i-o*r),d=2*(o*n-a*i),f=2*(a*r-s*n);return this.x=n+c*u+s*f-o*d,this.y=r+c*d+o*u-a*f,this.z=i+c*f+a*d-s*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this.z=gn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this.z=gn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,o=n.y,c=n.z;return this.x=i*c-a*o,this.y=a*s-r*c,this.z=r*o-i*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return mC.copy(this).projectOnVector(e),this.sub(mC)}reflect(e){return this.sub(mC.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(gn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const mC=new Qe,U6=new Jh;let dn=class QY{constructor(e,n,r,i,a,s,o,c,u){QY.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u)}set(e,n,r,i,a,s,o,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=s,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],m=r[5],x=r[8],v=i[0],y=i[3],b=i[6],M=i[1],S=i[4],A=i[7],T=i[2],k=i[5],N=i[8];return a[0]=s*v+o*M+c*T,a[3]=s*y+o*S+c*k,a[6]=s*b+o*A+c*N,a[1]=u*v+d*M+f*T,a[4]=u*y+d*S+f*k,a[7]=u*b+d*A+f*N,a[2]=g*v+m*M+x*T,a[5]=g*y+m*S+x*k,a[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],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8];return n*s*d-n*o*u-r*a*d+r*o*c+i*a*u-i*s*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=d*s-o*u,g=o*c-d*a,m=u*a-s*c,x=n*f+r*g+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(o*r-i*s)*v,e[3]=g*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-o*n)*v,e[6]=m*v,e[7]=(r*c-u*n)*v,e[8]=(s*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*o)+s+e,-i*u,i*c,-i*(-u*s+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(gC.makeScale(e,n)),this}rotate(e){return this.premultiply(gC.makeRotation(-e)),this}translate(e,n){return this.premultiply(gC.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const gC=new dn,z6=new dn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),B6=new dn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pNe(){const t={enabled:!0,workingColorSpace:km,spaces:{},convert:function(i,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===qn&&(i.r=Sc(i.r),i.g=Sc(i.g),i.b=Sc(i.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===qn&&(i.r=am(i.r),i.g=am(i.g),i.b=am(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Lu?Cw:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,s){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return q0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return q0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[km]:{primaries:e,whitePoint:r,transfer:Cw,toXYZ:z6,fromXYZ:B6,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:qs},outputColorSpaceConfig:{drawingBufferColorSpace:qs}},[qs]:{primaries:e,whitePoint:r,transfer:qn,toXYZ:z6,fromXYZ:B6,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:qs}}}),t}const Cn=pNe();function Sc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function am(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let np,mNe=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),a=i.data;for(let s=0;s<a.length;s++)a[s]=Sc(a[s]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Sc(n[r]/255)*255):n[r]=Sc(n[r]);return{data:n,width:e.width,height:e.height}}else return Yt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},gNe=0,aO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:gNe++}),this.uuid=Wb(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(xC(i[s].image)):a.push(xC(i[s]))}else a=xC(i);r.url=a}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?mNe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Yt("Texture: Unable to serialize Texture."),{})}let xNe=0;const bC=new Qe;let $o=class d1 extends mf{constructor(e=d1.DEFAULT_IMAGE,n=d1.DEFAULT_MAPPING,r=mc,i=mc,a=ro,s=gh,o=Do,c=gl,u=d1.DEFAULT_ANISOTROPY,d=Lu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:xNe++}),this.uuid=Wb(),this.name="",this.source=new aO(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=c,this.offset=new cn(0,0),this.repeat=new cn(1,1),this.center=new cn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new dn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(bC).x}get height(){return this.source.getSize(bC).y}get depth(){return this.source.getSize(bC).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){Yt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Yt(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==UY)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case K3:e.x=e.x-Math.floor(e.x);break;case mc:e.x=e.x<0?0:1;break;case X3: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 K3:e.y=e.y-Math.floor(e.y);break;case mc:e.y=e.y<0?0:1;break;case X3:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};$o.DEFAULT_IMAGE=null;$o.DEFAULT_MAPPING=UY;$o.DEFAULT_ANISOTROPY=1;let Yr=class JY{constructor(e=0,n=0,r=0,i=1){JY.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],m=c[5],x=c[9],v=c[2],y=c[6],b=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-v)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+v)<.1&&Math.abs(x+y)<.1&&Math.abs(u+m+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(m+1)/2,T=(b+1)/2,k=(d+g)/4,N=(f+v)/4,I=(x+y)/4;return S>A&&S>T?S<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(S),i=k/r,a=N/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=k/i,a=I/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=N/a,i=I/a),this.set(r,i,a,n),this}let M=Math.sqrt((y-x)*(y-x)+(f-v)*(f-v)+(g-d)*(g-d));return Math.abs(M)<.001&&(M=1),this.x=(y-x)/M,this.y=(f-v)/M,this.z=(g-d)/M,this.w=Math.acos((u+m+b-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this.z=gn(this.z,e.z,n.z),this.w=gn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this.z=gn(this.z,e,n),this.w=gn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},bNe=class extends mf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ro,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=r.depth,this.scissor=new Yr(0,0,e,n),this.scissorTest=!1,this.viewport=new Yr(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new $o(i);this.textures=[];const s=r.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:ro,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new aO(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 bNe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},eZ=class extends $o{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ws,this.minFilter=ws,this.wrapR=mc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},yNe=class extends $o{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ws,this.minFilter=ws,this.wrapR=mc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tf=class{constructor(e=new Qe(1/0,1/0,1/0),n=new Qe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(vo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(vo.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=vo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,vo):vo.fromBufferAttribute(a,s),vo.applyMatrix4(e.matrixWorld),this.expandByPoint(vo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Lv.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Lv.copy(r.boundingBox)),Lv.applyMatrix4(e.matrixWorld),this.union(Lv)}const i=e.children;for(let a=0,s=i.length;a<s;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,vo),vo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(gx),Iv.subVectors(this.max,gx),rp.subVectors(e.a,gx),ip.subVectors(e.b,gx),ap.subVectors(e.c,gx),hu.subVectors(ip,rp),fu.subVectors(ap,ip),Hd.subVectors(rp,ap);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!yC(n,rp,ip,ap,Iv)||(n=[1,0,0,0,1,0,0,0,1],!yC(n,rp,ip,ap,Iv))?!1:(Fv.crossVectors(hu,fu),n=[Fv.x,Fv.y,Fv.z],yC(n,rp,ip,ap,Iv))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(vo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Vl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Vl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Vl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Vl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Vl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Vl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Vl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Vl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Vl),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const Vl=[new Qe,new Qe,new Qe,new Qe,new Qe,new Qe,new Qe,new Qe],vo=new Qe,Lv=new tf,rp=new Qe,ip=new Qe,ap=new Qe,hu=new Qe,fu=new Qe,Hd=new Qe,gx=new Qe,Iv=new Qe,Fv=new Qe,$d=new Qe;function yC(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){$d.fromArray(t,a);const o=i.x*Math.abs($d.x)+i.y*Math.abs($d.y)+i.z*Math.abs($d.z),c=e.dot($d),u=n.dot($d),d=r.dot($d);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>o)return!1}return!0}const vNe=new tf,xx=new Qe,vC=new Qe;let FM=class{constructor(e=new Qe,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):vNe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;xx.subVectors(e,this.center);const n=xx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(xx,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(vC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(xx.copy(e.center).add(vC)),this.expandByPoint(xx.copy(e.center).sub(vC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const Gl=new Qe,_C=new Qe,Uv=new Qe,pu=new Qe,wC=new Qe,zv=new Qe,SC=new Qe;let sO=class{constructor(e=new Qe,n=new Qe(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Gl)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Gl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Gl.copy(this.origin).addScaledVector(this.direction,n),Gl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){_C.copy(e).add(n).multiplyScalar(.5),Uv.copy(n).sub(e).normalize(),pu.copy(this.origin).sub(_C);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Uv),o=pu.dot(this.direction),c=-pu.dot(Uv),u=pu.lengthSq(),d=Math.abs(1-s*s);let f,g,m,x;if(d>0)if(f=s*c-o,g=s*o-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const v=1/d;f*=v,g*=v,m=f*(f+s*g+2*o)+g*(s*f+g+2*c)+u}else g=a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-s*a+o)),g=f>0?-a:Math.min(Math.max(-a,-c),a),m=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),m=g*(g+2*c)+u):(f=Math.max(0,-(s*a+o)),g=f>0?a:Math.min(Math.max(-a,-c),a),m=-f*f+g*(g+2*c)+u);else g=s>0?-a:a,f=Math.max(0,-(s*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(Uv,g),m}intersectSphere(e,n){Gl.subVectors(e.center,this.origin);const r=Gl.dot(this.direction),i=Gl.dot(Gl)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,c=r+s;return c<0?null:o<0?this.at(c,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,o,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,s=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,s=(e.min.y-g.y)*d),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),f>=0?(o=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Gl)!==null}intersectTriangle(e,n,r,i,a){wC.subVectors(n,e),zv.subVectors(r,e),SC.crossVectors(wC,zv);let s=this.direction.dot(SC),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;pu.subVectors(this.origin,e);const c=o*this.direction.dot(zv.crossVectors(pu,zv));if(c<0)return null;const u=o*this.direction.dot(wC.cross(pu));if(u<0||c+u>s)return null;const d=-o*pu.dot(SC);return d<0?null:this.at(d/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ri=class EP{constructor(e,n,r,i,a,s,o,c,u,d,f,g,m,x,v,y){EP.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u,d,f,g,m,x,v,y)}set(e,n,r,i,a,s,o,c,u,d,f,g,m,x,v,y){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=a,b[5]=s,b[9]=o,b[13]=c,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=m,b[7]=x,b[11]=v,b[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new EP().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/sp.setFromMatrixColumn(e,0).length(),a=1/sp.setFromMatrixColumn(e,1).length(),s=1/sp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*s,n[9]=r[9]*s,n[10]=r[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,s=Math.cos(r),o=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*d,m=s*f,x=o*d,v=o*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+x*u,n[5]=g-v*u,n[9]=-o*c,n[2]=v-g*u,n[6]=x+m*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,m=c*f,x=u*d,v=u*f;n[0]=g+v*o,n[4]=x*o-m,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-o,n[2]=m*o-x,n[6]=v+g*o,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,m=c*f,x=u*d,v=u*f;n[0]=g-v*o,n[4]=-s*f,n[8]=x+m*o,n[1]=m+x*o,n[5]=s*d,n[9]=v-g*o,n[2]=-s*u,n[6]=o,n[10]=s*c}else if(e.order==="ZYX"){const g=s*d,m=s*f,x=o*d,v=o*f;n[0]=c*d,n[4]=x*u-m,n[8]=g*u+v,n[1]=c*f,n[5]=v*u+g,n[9]=m*u-x,n[2]=-u,n[6]=o*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,m=s*u,x=o*c,v=o*u;n[0]=c*d,n[4]=v-g*f,n[8]=x*f+m,n[1]=f,n[5]=s*d,n[9]=-o*d,n[2]=-u*d,n[6]=m*f+x,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*c,m=s*u,x=o*c,v=o*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+v,n[5]=s*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=o*d,n[10]=v*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(_Ne,e,wNe)}lookAt(e,n,r){const i=this.elements;return cs.subVectors(e,n),cs.lengthSq()===0&&(cs.z=1),cs.normalize(),mu.crossVectors(r,cs),mu.lengthSq()===0&&(Math.abs(r.z)===1?cs.x+=1e-4:cs.z+=1e-4,cs.normalize(),mu.crossVectors(r,cs)),mu.normalize(),Bv.crossVectors(cs,mu),i[0]=mu.x,i[4]=Bv.x,i[8]=cs.x,i[1]=mu.y,i[5]=Bv.y,i[9]=cs.y,i[2]=mu.z,i[6]=Bv.z,i[10]=cs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],m=r[13],x=r[2],v=r[6],y=r[10],b=r[14],M=r[3],S=r[7],A=r[11],T=r[15],k=i[0],N=i[4],I=i[8],C=i[12],D=i[1],F=i[5],O=i[9],q=i[13],R=i[2],W=i[6],K=i[10],G=i[14],ee=i[3],Z=i[7],Q=i[11],U=i[15];return a[0]=s*k+o*D+c*R+u*ee,a[4]=s*N+o*F+c*W+u*Z,a[8]=s*I+o*O+c*K+u*Q,a[12]=s*C+o*q+c*G+u*U,a[1]=d*k+f*D+g*R+m*ee,a[5]=d*N+f*F+g*W+m*Z,a[9]=d*I+f*O+g*K+m*Q,a[13]=d*C+f*q+g*G+m*U,a[2]=x*k+v*D+y*R+b*ee,a[6]=x*N+v*F+y*W+b*Z,a[10]=x*I+v*O+y*K+b*Q,a[14]=x*C+v*q+y*G+b*U,a[3]=M*k+S*D+A*R+T*ee,a[7]=M*N+S*F+A*W+T*Z,a[11]=M*I+S*O+A*K+T*Q,a[15]=M*C+S*q+A*G+T*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],s=e[1],o=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],m=e[14],x=e[3],v=e[7],y=e[11],b=e[15];return x*(+a*c*f-i*u*f-a*o*g+r*u*g+i*o*m-r*c*m)+v*(+n*c*m-n*u*g+a*s*g-i*s*m+i*u*d-a*c*d)+y*(+n*u*f-n*o*m-a*s*f+r*s*m+a*o*d-r*u*d)+b*(-i*o*d-n*c*f+n*o*g+i*s*f-r*s*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],m=e[11],x=e[12],v=e[13],y=e[14],b=e[15],M=f*y*u-v*g*u+v*c*m-o*y*m-f*c*b+o*g*b,S=x*g*u-d*y*u-x*c*m+s*y*m+d*c*b-s*g*b,A=d*v*u-x*f*u+x*o*m-s*v*m-d*o*b+s*f*b,T=x*f*c-d*v*c-x*o*g+s*v*g+d*o*y-s*f*y,k=n*M+r*S+i*A+a*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]=M*N,e[1]=(v*g*a-f*y*a-v*i*m+r*y*m+f*i*b-r*g*b)*N,e[2]=(o*y*a-v*c*a+v*i*u-r*y*u-o*i*b+r*c*b)*N,e[3]=(f*c*a-o*g*a-f*i*u+r*g*u+o*i*m-r*c*m)*N,e[4]=S*N,e[5]=(d*y*a-x*g*a+x*i*m-n*y*m-d*i*b+n*g*b)*N,e[6]=(x*c*a-s*y*a-x*i*u+n*y*u+s*i*b-n*c*b)*N,e[7]=(s*g*a-d*c*a+d*i*u-n*g*u-s*i*m+n*c*m)*N,e[8]=A*N,e[9]=(x*f*a-d*v*a-x*r*m+n*v*m+d*r*b-n*f*b)*N,e[10]=(s*v*a-x*o*a+x*r*u-n*v*u-s*r*b+n*o*b)*N,e[11]=(d*o*a-s*f*a-d*r*u+n*f*u+s*r*m-n*o*m)*N,e[12]=T*N,e[13]=(d*v*i-x*f*i+x*r*g-n*v*g-d*r*y+n*f*y)*N,e[14]=(x*o*i-s*v*i-x*r*c+n*v*c+s*r*y-n*o*y)*N,e[15]=(s*f*i-d*o*i+d*r*c-n*f*c-s*r*g+n*o*g)*N,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,s=e.x,o=e.y,c=e.z,u=a*s,d=a*o;return this.set(u*s+r,u*o-i*c,u*c+i*o,0,u*o+i*c,d*o+r,d*c-i*s,0,u*c-i*o,d*c+i*s,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,c=n._w,u=a+a,d=s+s,f=o+o,g=a*u,m=a*d,x=a*f,v=s*d,y=s*f,b=o*f,M=c*u,S=c*d,A=c*f,T=r.x,k=r.y,N=r.z;return i[0]=(1-(v+b))*T,i[1]=(m+A)*T,i[2]=(x-S)*T,i[3]=0,i[4]=(m-A)*k,i[5]=(1-(g+b))*k,i[6]=(y+M)*k,i[7]=0,i[8]=(x+S)*N,i[9]=(y-M)*N,i[10]=(1-(g+v))*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 a=sp.set(i[0],i[1],i[2]).length();const s=sp.set(i[4],i[5],i[6]).length(),o=sp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],_o.copy(this);const u=1/a,d=1/s,f=1/o;return _o.elements[0]*=u,_o.elements[1]*=u,_o.elements[2]*=u,_o.elements[4]*=d,_o.elements[5]*=d,_o.elements[6]*=d,_o.elements[8]*=f,_o.elements[9]*=f,_o.elements[10]*=f,n.setFromRotationMatrix(_o),r.x=a,r.y=s,r.z=o,this}makePerspective(e,n,r,i,a,s,o=ol,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),g=(n+e)/(n-e),m=(r+i)/(r-i);let x,v;if(c)x=a/(s-a),v=s*a/(s-a);else if(o===ol)x=-(s+a)/(s-a),v=-2*s*a/(s-a);else if(o===Nw)x=-s/(s-a),v=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return u[0]=d,u[4]=0,u[8]=g,u[12]=0,u[1]=0,u[5]=f,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=ol,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),g=-(n+e)/(n-e),m=-(r+i)/(r-i);let x,v;if(c)x=1/(s-a),v=s/(s-a);else if(o===ol)x=-2/(s-a),v=-(s+a)/(s-a);else if(o===Nw)x=-1/(s-a),v=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return u[0]=d,u[4]=0,u[8]=0,u[12]=g,u[1]=0,u[5]=f,u[9]=0,u[13]=m,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const sp=new Qe,_o=new ri,_Ne=new Qe(0,0,0),wNe=new Qe(1,1,1),mu=new Qe,Bv=new Qe,cs=new Qe,H6=new ri,$6=new Jh;let hd=class tZ{constructor(e=0,n=0,r=0,i=tZ.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],s=i[4],o=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(gn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-gn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(gn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-gn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(gn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-gn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:Yt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return H6.makeRotationFromQuaternion(e),this.setFromRotationMatrix(H6,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return $6.setFromEuler(this),this.setFromQuaternion($6,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 nZ=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}},SNe=0;const V6=new Qe,op=new Jh,Wl=new ri,Hv=new Qe,bx=new Qe,MNe=new Qe,ENe=new Jh,G6=new Qe(1,0,0),W6=new Qe(0,1,0),q6=new Qe(0,0,1),K6={type:"added"},ANe={type:"removed"},lp={type:"childadded",child:null},MC={type:"childremoved",child:null};let Ns=class h1 extends mf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:SNe++}),this.uuid=Wb(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=h1.DEFAULT_UP.clone();const e=new Qe,n=new hd,r=new Jh,i=new Qe(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ri},normalMatrix:{value:new dn}}),this.matrix=new ri,this.matrixWorld=new ri,this.matrixAutoUpdate=h1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=h1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nZ,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(G6,e)}rotateY(e){return this.rotateOnAxis(W6,e)}rotateZ(e){return this.rotateOnAxis(q6,e)}translateOnAxis(e,n){return V6.copy(e).applyQuaternion(this.quaternion),this.position.add(V6.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(G6,e)}translateY(e){return this.translateOnAxis(W6,e)}translateZ(e){return this.translateOnAxis(q6,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Wl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Hv.copy(e):Hv.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),bx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Wl.lookAt(bx,Hv,this.up):Wl.lookAt(Hv,bx,this.up),this.quaternion.setFromRotationMatrix(Wl),i&&(Wl.extractRotation(i.matrixWorld),op.setFromRotationMatrix(Wl),this.quaternion.premultiply(op.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(zr("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(K6),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(ANe),MC.child=e,this.dispatchEvent(MC),MC.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Wl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Wl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Wl),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(K6),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 s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bx,e,MNe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bx,ENe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,u=this.material.length;c<u;c++)o.push(a(e.materials,this.material[c]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(a(e.animations,c))}}if(n){const o=s(e.geometries),c=s(e.materials),u=s(e.textures),d=s(e.images),f=s(e.shapes),g=s(e.skeletons),m=s(e.animations),x=s(e.nodes);o.length>0&&(r.geometries=o),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),x.length>0&&(r.nodes=x)}return r.object=i,r;function s(o){const c=[];for(const u in o){const d=o[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};Ns.DEFAULT_UP=new Qe(0,1,0);Ns.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ns.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const wo=new Qe,ql=new Qe,EC=new Qe,Kl=new Qe,cp=new Qe,up=new Qe,X6=new Qe,AC=new Qe,TC=new Qe,CC=new Qe,NC=new Yr,kC=new Yr,PC=new Yr;let yx=class Up{constructor(e=new Qe,n=new Qe,r=new Qe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),wo.subVectors(e,n),i.cross(wo);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){wo.subVectors(i,n),ql.subVectors(r,n),EC.subVectors(e,n);const s=wo.dot(wo),o=wo.dot(ql),c=wo.dot(EC),u=ql.dot(ql),d=ql.dot(EC),f=s*u-o*o;if(f===0)return a.set(0,0,0),null;const g=1/f,m=(u*c-o*d)*g,x=(s*d-o*c)*g;return a.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Kl)===null?!1:Kl.x>=0&&Kl.y>=0&&Kl.x+Kl.y<=1}static getInterpolation(e,n,r,i,a,s,o,c){return this.getBarycoord(e,n,r,i,Kl)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,Kl.x),c.addScaledVector(s,Kl.y),c.addScaledVector(o,Kl.z),c)}static getInterpolatedAttribute(e,n,r,i,a,s){return NC.setScalar(0),kC.setScalar(0),PC.setScalar(0),NC.fromBufferAttribute(e,n),kC.fromBufferAttribute(e,r),PC.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(NC,a.x),s.addScaledVector(kC,a.y),s.addScaledVector(PC,a.z),s}static isFrontFacing(e,n,r,i){return wo.subVectors(r,n),ql.subVectors(e,n),wo.cross(ql).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return wo.subVectors(this.c,this.b),ql.subVectors(this.a,this.b),wo.cross(ql).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Up.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Up.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return Up.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Up.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Up.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let s,o;cp.subVectors(i,r),up.subVectors(a,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 s=c/(c-d),n.copy(r).addScaledVector(cp,s);CC.subVectors(e,a);const m=cp.dot(CC),x=up.dot(CC);if(x>=0&&m<=x)return n.copy(a);const v=m*u-c*x;if(v<=0&&u>=0&&x<=0)return o=u/(u-x),n.copy(r).addScaledVector(up,o);const y=d*x-m*f;if(y<=0&&f-d>=0&&m-x>=0)return X6.subVectors(a,i),o=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(X6,o);const b=1/(y+v+g);return s=v*b,o=g*b,n.copy(r).addScaledVector(cp,s).addScaledVector(up,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const rZ={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},$v={h:0,s:0,l:0};function RC(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let _n=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=qs){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Cn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Cn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Cn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Cn.workingColorSpace){if(e=hNe(e,1),n=gn(n,0,1),r=gn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=RC(s,a,e+1/3),this.g=RC(s,a,e),this.b=RC(s,a,e-1/3)}return Cn.colorSpaceToWorking(this,i),this}setStyle(e,n=qs){function r(a){a!==void 0&&parseFloat(a)<1&&Yt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:Yt("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);Yt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=qs){const r=rZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Yt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Sc(e.r),this.g=Sc(e.g),this.b=Sc(e.b),this}copyLinearToSRGB(e){return this.r=am(e.r),this.g=am(e.g),this.b=am(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=qs){return Cn.workingToColorSpace(sa.copy(this),e),Math.round(gn(sa.r*255,0,255))*65536+Math.round(gn(sa.g*255,0,255))*256+Math.round(gn(sa.b*255,0,255))}getHexString(e=qs){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Cn.workingColorSpace){Cn.workingToColorSpace(sa.copy(this),n);const r=sa.r,i=sa.g,a=sa.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let c,u;const d=(o+s)/2;if(o===s)c=0,u=0;else{const f=s-o;switch(u=d<=.5?f/(s+o):f/(2-s-o),s){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Cn.workingColorSpace){return Cn.workingToColorSpace(sa.copy(this),n),e.r=sa.r,e.g=sa.g,e.b=sa.b,e}getStyle(e=qs){Cn.workingToColorSpace(sa.copy(this),e);const n=sa.r,r=sa.g,i=sa.b;return e!==qs?`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($v);const r=pC(gu.h,$v.h,n),i=pC(gu.s,$v.s,n),a=pC(gu.l,$v.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const sa=new _n;_n.NAMES=rZ;let TNe=0,lg=class extends mf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:TNe++}),this.uuid=Wb(),this.name="",this.type="Material",this.blending=im,this.side=dd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=I3,this.blendDst=F3,this.blendEquation=sh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new _n(0,0,0),this.blendAlpha=0,this.depthFunc=Tm,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=j6,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=tp,this.stencilZFail=tp,this.stencilZPass=tp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){Yt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Yt(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==im&&(r.blending=this.blending),this.side!==dd&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==I3&&(r.blendSrc=this.blendSrc),this.blendDst!==F3&&(r.blendDst=this.blendDst),this.blendEquation!==sh&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Tm&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==j6&&(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(a){const s=[];for(const o in a){const c=a[o];delete c.metadata,s.push(c)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},oO=class extends lg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new _n(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hd,this.combine=Zj,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const qr=new Qe,Vv=new cn;let CNe=0,io=class{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:CNe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=O6,this.updateRanges=[],this.gpuType=gc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)Vv.fromBufferAttribute(this,n),Vv.applyMatrix3(e),this.setXY(n,Vv.x,Vv.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.applyMatrix3(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.applyMatrix4(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.applyNormalMatrix(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.transformDirection(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=mx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=za(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=mx(n,this.array)),n}setX(e,n){return this.normalized&&(n=za(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=mx(n,this.array)),n}setY(e,n){return this.normalized&&(n=za(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=mx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=za(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=mx(n,this.array)),n}setW(e,n){return this.normalized&&(n=za(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=za(n,this.array),r=za(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=za(n,this.array),r=za(r,this.array),i=za(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=za(n,this.array),r=za(r,this.array),i=za(i,this.array),a=za(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==O6&&(e.usage=this.usage),e}},iZ=class extends io{constructor(e,n,r){super(new Uint16Array(e),n,r)}},aZ=class extends io{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Io=class extends io{constructor(e,n,r){super(new Float32Array(e),n,r)}},NNe=0;const zs=new ri,DC=new Ns,dp=new Qe,us=new tf,vx=new tf,Ni=new Qe;let El=class sZ extends mf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:NNe++}),this.uuid=Wb(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(XY(e)?aZ:iZ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new dn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return zs.makeRotationFromQuaternion(e),this.applyMatrix4(zs),this}rotateX(e){return zs.makeRotationX(e),this.applyMatrix4(zs),this}rotateY(e){return zs.makeRotationY(e),this.applyMatrix4(zs),this}rotateZ(e){return zs.makeRotationZ(e),this.applyMatrix4(zs),this}translate(e,n,r){return zs.makeTranslation(e,n,r),this.applyMatrix4(zs),this}scale(e,n,r){return zs.makeScale(e,n,r),this.applyMatrix4(zs),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,a=e.length;i<a;i++){const s=e[i];r.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Io(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&Yt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new tf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){zr("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Qe(-1/0,-1/0,-1/0),new Qe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];us.setFromBufferAttribute(a),this.morphTargetsRelative?(Ni.addVectors(this.boundingBox.min,us.min),this.boundingBox.expandByPoint(Ni),Ni.addVectors(this.boundingBox.max,us.max),this.boundingBox.expandByPoint(Ni)):(this.boundingBox.expandByPoint(us.min),this.boundingBox.expandByPoint(us.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 FM);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){zr("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Qe,1/0);return}if(e){const r=this.boundingSphere.center;if(us.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];vx.setFromBufferAttribute(o),this.morphTargetsRelative?(Ni.addVectors(us.min,vx.min),us.expandByPoint(Ni),Ni.addVectors(us.max,vx.max),us.expandByPoint(Ni)):(us.expandByPoint(vx.min),us.expandByPoint(vx.max))}us.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Ni.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Ni));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],c=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)Ni.fromBufferAttribute(o,u),c&&(dp.fromBufferAttribute(e,u),Ni.add(dp)),i=Math.max(i,r.distanceToSquared(Ni))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&zr('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){zr("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new io(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),o=[],c=[];for(let I=0;I<r.count;I++)o[I]=new Qe,c[I]=new Qe;const u=new Qe,d=new Qe,f=new Qe,g=new cn,m=new cn,x=new cn,v=new Qe,y=new Qe;function b(I,C,D){u.fromBufferAttribute(r,I),d.fromBufferAttribute(r,C),f.fromBufferAttribute(r,D),g.fromBufferAttribute(a,I),m.fromBufferAttribute(a,C),x.fromBufferAttribute(a,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)&&(v.copy(d).multiplyScalar(x.y).addScaledVector(f,-m.y).multiplyScalar(F),y.copy(f).multiplyScalar(m.x).addScaledVector(d,-x.x).multiplyScalar(F),o[I].add(v),o[C].add(v),o[D].add(v),c[I].add(y),c[C].add(y),c[D].add(y))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let I=0,C=M.length;I<C;++I){const D=M[I],F=D.start,O=D.count;for(let q=F,R=F+O;q<R;q+=3)b(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const S=new Qe,A=new Qe,T=new Qe,k=new Qe;function N(I){T.fromBufferAttribute(i,I),k.copy(T);const C=o[I];S.copy(C),S.sub(T.multiplyScalar(T.dot(C))).normalize(),A.crossVectors(k,C);const F=A.dot(c[I])<0?-1:1;s.setXYZW(I,S.x,S.y,S.z,F)}for(let I=0,C=M.length;I<C;++I){const D=M[I],F=D.start,O=D.count;for(let q=F,R=F+O;q<R;q+=3)N(e.getX(q+0)),N(e.getX(q+1)),N(e.getX(q+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new io(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new Qe,a=new Qe,s=new Qe,o=new Qe,c=new Qe,u=new Qe,d=new Qe,f=new Qe;if(e)for(let g=0,m=e.count;g<m;g+=3){const x=e.getX(g+0),v=e.getX(g+1),y=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,y),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),o.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,y),o.add(d),c.add(d),u.add(d),r.setXYZ(x,o.x,o.y,o.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Ni.fromBufferAttribute(e,n),Ni.normalize(),e.setXYZ(n,Ni.x,Ni.y,Ni.z)}toNonIndexed(){function e(o,c){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(c.length*d);let m=0,x=0;for(let v=0,y=c.length;v<y;v++){o.isInterleavedBufferAttribute?m=c[v]*o.data.stride+o.offset:m=c[v]*d;for(let b=0;b<d;b++)g[x++]=u[m++]}return new io(g,d,f)}if(this.index===null)return Yt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new sZ,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const a=this.morphAttributes;for(const o in a){const c=[],u=a[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],m=e(g,r);c.push(m)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,c=s.length;o<c;o++){const u=s[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,m=f.length;g<m;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let u=0,d=s.length;u<d;u++){const f=s[u];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const Y6=new ri,Vd=new sO,Gv=new FM,Z6=new Qe,Wv=new Qe,qv=new Qe,Kv=new Qe,jC=new Qe,Xv=new Qe,Q6=new Qe,Yv=new Qe;let xl=class extends Ns{constructor(e=new El,n=new oO){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){Xv.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=o[c],f=a[c];d!==0&&(jC.fromBufferAttribute(f,e),s?Xv.addScaledVector(jC,d):Xv.addScaledVector(jC.sub(n),d))}n.add(Xv)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Gv.copy(r.boundingSphere),Gv.applyMatrix4(a),Vd.copy(e.ray).recast(e.near),!(Gv.containsPoint(Vd.origin)===!1&&(Vd.intersectSphere(Gv,Z6)===null||Vd.origin.distanceToSquared(Z6)>(e.far-e.near)**2))&&(Y6.copy(a).invert(),Vd.copy(e.ray).applyMatrix4(Y6),!(r.boundingBox!==null&&Vd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Vd)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],M=Math.max(y.start,m.start),S=Math.min(o.count,Math.min(y.start+y.count,m.start+m.count));for(let A=M,T=S;A<T;A+=3){const k=o.getX(A),N=o.getX(A+1),I=o.getX(A+2);i=Zv(this,b,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),v=Math.min(o.count,m.start+m.count);for(let y=x,b=v;y<b;y+=3){const M=o.getX(y),S=o.getX(y+1),A=o.getX(y+2);i=Zv(this,s,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],M=Math.max(y.start,m.start),S=Math.min(c.count,Math.min(y.start+y.count,m.start+m.count));for(let A=M,T=S;A<T;A+=3){const k=A,N=A+1,I=A+2;i=Zv(this,b,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),v=Math.min(c.count,m.start+m.count);for(let y=x,b=v;y<b;y+=3){const M=y,S=y+1,A=y+2;i=Zv(this,s,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}};function kNe(t,e,n,r,i,a,s,o){let c;if(e.side===qa?c=r.intersectTriangle(s,a,i,!0,o):c=r.intersectTriangle(i,a,s,e.side===dd,o),c===null)return null;Yv.copy(o),Yv.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Yv);return u<n.near||u>n.far?null:{distance:u,point:Yv.clone(),object:t}}function Zv(t,e,n,r,i,a,s,o,c,u){t.getVertexPosition(o,Wv),t.getVertexPosition(c,qv),t.getVertexPosition(u,Kv);const d=kNe(t,e,n,r,Wv,qv,Kv,Q6);if(d){const f=new Qe;yx.getBarycoord(Q6,Wv,qv,Kv,f),i&&(d.uv=yx.getInterpolatedAttribute(i,o,c,u,f,new cn)),a&&(d.uv1=yx.getInterpolatedAttribute(a,o,c,u,f,new cn)),s&&(d.normal=yx.getInterpolatedAttribute(s,o,c,u,f,new Qe),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:o,b:c,c:u,normal:new Qe,materialIndex:0};yx.getNormal(Wv,qv,Kv,g.normal),d.face=g,d.barycoord=f}return d}let lO=class oZ extends El{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],d=[],f=[];let g=0,m=0;x("z","y","x",-1,-1,r,n,e,s,a,0),x("z","y","x",1,-1,r,n,-e,s,a,1),x("x","z","y",1,1,e,r,n,i,s,2),x("x","z","y",1,-1,e,r,-n,i,s,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Io(u,3)),this.setAttribute("normal",new Io(d,3)),this.setAttribute("uv",new Io(f,2));function x(v,y,b,M,S,A,T,k,N,I,C){const D=A/N,F=T/I,O=A/2,q=T/2,R=k/2,W=N+1,K=I+1;let G=0,ee=0;const Z=new Qe;for(let Q=0;Q<K;Q++){const U=Q*F-q;for(let $=0;$<W;$++){const X=$*D-O;Z[v]=X*M,Z[y]=U*S,Z[b]=R,u.push(Z.x,Z.y,Z.z),Z[v]=0,Z[y]=0,Z[b]=k>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push($/N),f.push(1-Q/I),G+=1}}for(let Q=0;Q<I;Q++)for(let U=0;U<N;U++){const $=g+U+W*Q,X=g+U+W*(Q+1),te=g+(U+1)+W*(Q+1),fe=g+(U+1)+W*Q;c.push($,X,fe),c.push(X,te,fe),ee+=6}o.addGroup(m,ee,C),m+=ee,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Pm(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(Yt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function va(t){const e={};for(let n=0;n<t.length;n++){const r=Pm(t[n]);for(const i in r)e[i]=r[i]}return e}function PNe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function lZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Cn.workingColorSpace}const RNe={clone:Pm,merge:va};var DNe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,jNe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let Oc=class extends lg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=DNe,this.fragmentShader=jNe,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Pm(e.uniforms),this.uniformsGroups=PNe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const s=this.uniforms[i].value;s&&s.isTexture?n.uniforms[i]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[i]={type:"m4",value:s.toArray()}:n.uniforms[i]={value:s}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}},cZ=class extends Ns{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ri,this.projectionMatrix=new ri,this.projectionMatrixInverse=new ri,this.coordinateSystem=ol,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const xu=new Qe,J6=new cn,eH=new cn;let Ys=class extends cZ{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=MP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(u1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return MP*2*Math.atan(Math.tan(u1*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,n,r){xu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(xu.x,xu.y).multiplyScalar(-e/xu.z),xu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(xu.x,xu.y).multiplyScalar(-e/xu.z)}getViewSize(e,n){return this.getViewBounds(e,J6,eH),n.subVectors(eH,J6)}setViewOffset(e,n,r,i,a,s){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(u1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const s=this.view;if(this.view!==null&&this.view.enabled){const c=s.fullWidth,u=s.fullHeight;a+=s.offsetX*i/c,n-=s.offsetY*r/u,i*=s.width/c,r*=s.height/u}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const hp=-90,fp=1;let ONe=class extends Ns{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ys(hp,fp,e,n);i.layers=this.layers,this.add(i);const a=new Ys(hp,fp,e,n);a.layers=this.layers,this.add(a);const s=new Ys(hp,fp,e,n);s.layers=this.layers,this.add(s);const o=new Ys(hp,fp,e,n);o.layers=this.layers,this.add(o);const c=new Ys(hp,fp,e,n);c.layers=this.layers,this.add(c);const u=new Ys(hp,fp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,o,c]=n;for(const u of n)this.remove(u);if(e===ol)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Nw)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},uZ=class extends $o{constructor(e=[],n=Cm,r,i,a,s,o,c,u,d){super(e,n,r,i,a,s,o,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},LNe=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 uZ(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 lO(5,5,5),a=new Oc({name:"CubemapFromEquirect",uniforms:Pm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:qa,blending:wc});a.uniforms.tEquirect.value=n;const s=new xl(i,a),o=n.minFilter;return n.minFilter===gh&&(n.minFilter=ro),new ONe(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}},Lx=class extends Ns{constructor(){super(),this.isGroup=!0,this.type="Group"}};const INe={type:"move"};let OC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lx,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Lx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Qe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Qe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Qe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Qe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,s=null;const o=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const v of e.hand.values()){const y=n.getJointPose(v,r),b=this._getHandJoint(u,v);y!==null&&(b.matrix.fromArray(y.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=y.radius),b.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),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&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(INe)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Lx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},FNe=class extends Ns{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new hd,this.environmentIntensity=1,this.environmentRotation=new hd,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}},UNe=class extends $o{constructor(e=null,n=1,r=1,i,a,s,o,c,u=ws,d=ws,f,g){super(null,s,o,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const LC=new Qe,zNe=new Qe,BNe=new dn;let Nu=class{constructor(e=new Qe(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=LC.subVectors(r,n).cross(zNe.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 a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||BNe.getNormalMatrix(e),i=this.coplanarPoint(LC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const Gd=new FM,HNe=new cn(.5,.5),Qv=new Qe;let cO=class{constructor(e=new Nu,n=new Nu,r=new Nu,i=new Nu,a=new Nu,s=new Nu){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=ol,r=!1){const i=this.planes,a=e.elements,s=a[0],o=a[1],c=a[2],u=a[3],d=a[4],f=a[5],g=a[6],m=a[7],x=a[8],v=a[9],y=a[10],b=a[11],M=a[12],S=a[13],A=a[14],T=a[15];if(i[0].setComponents(u-s,m-d,b-x,T-M).normalize(),i[1].setComponents(u+s,m+d,b+x,T+M).normalize(),i[2].setComponents(u+o,m+f,b+v,T+S).normalize(),i[3].setComponents(u-o,m-f,b-v,T-S).normalize(),r)i[4].setComponents(c,g,y,A).normalize(),i[5].setComponents(u-c,m-g,b-y,T-A).normalize();else if(i[4].setComponents(u-c,m-g,b-y,T-A).normalize(),n===ol)i[5].setComponents(u+c,m+g,b+y,T+A).normalize();else if(n===Nw)i[5].setComponents(c,g,y,A).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),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=HNe.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 a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(Qv.x=i.normal.x>0?e.max.x:e.min.x,Qv.y=i.normal.y>0?e.max.y:e.min.y,Qv.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Qv)<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)}},dZ=class extends lg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _n(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};const Pw=new Qe,Rw=new Qe,tH=new ri,_x=new sO,Jv=new FM,IC=new Qe,nH=new Qe;let $Ne=class extends Ns{constructor(e=new El,n=new dZ){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)Pw.fromBufferAttribute(n,i-1),Rw.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=Pw.distanceTo(Rw);e.setAttribute("lineDistance",new Io(r,1))}else Yt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,s=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Jv.copy(r.boundingSphere),Jv.applyMatrix4(i),Jv.radius+=a,e.ray.intersectsSphere(Jv)===!1)return;tH.copy(i).invert(),_x.copy(e.ray).applyMatrix4(tH);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,u=this.isLineSegments?2:1,d=r.index,g=r.attributes.position;if(d!==null){const m=Math.max(0,s.start),x=Math.min(d.count,s.start+s.count);for(let v=m,y=x-1;v<y;v+=u){const b=d.getX(v),M=d.getX(v+1),S=e_(this,e,_x,c,b,M,v);S&&n.push(S)}if(this.isLineLoop){const v=d.getX(x-1),y=d.getX(m),b=e_(this,e,_x,c,v,y,x-1);b&&n.push(b)}}else{const m=Math.max(0,s.start),x=Math.min(g.count,s.start+s.count);for(let v=m,y=x-1;v<y;v+=u){const b=e_(this,e,_x,c,v,v+1,v);b&&n.push(b)}if(this.isLineLoop){const v=e_(this,e,_x,c,x-1,m,x-1);v&&n.push(v)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}};function e_(t,e,n,r,i,a,s){const o=t.geometry.attributes.position;if(Pw.fromBufferAttribute(o,i),Rw.fromBufferAttribute(o,a),n.distanceSqToSegment(Pw,Rw,IC,nH)>r)return;IC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(IC);if(!(u<e.near||u>e.far))return{distance:u,point:nH.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const rH=new Qe,iH=new Qe;let VNe=class extends $Ne{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)rH.fromBufferAttribute(n,i),iH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+rH.distanceTo(iH);e.setAttribute("lineDistance",new Io(r,1))}else Yt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},hZ=class extends $o{constructor(e,n,r=Qh,i,a,s,o=ws,c=ws,u,d=G0,f=1){if(d!==G0&&d!==W0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:f};super(g,i,a,s,o,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new aO(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 fZ extends $o{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let uO=class pZ 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 a=e/2,s=n/2,o=Math.floor(r),c=Math.floor(i),u=o+1,d=c+1,f=e/o,g=n/c,m=[],x=[],v=[],y=[];for(let b=0;b<d;b++){const M=b*g-s;for(let S=0;S<u;S++){const A=S*f-a;x.push(A,-M,0),v.push(0,0,1),y.push(S/o),y.push(1-b/c)}}for(let b=0;b<c;b++)for(let M=0;M<o;M++){const S=M+u*b,A=M+u*(b+1),T=M+1+u*(b+1),k=M+1+u*b;m.push(S,A,k),m.push(A,T,k)}this.setIndex(m),this.setAttribute("position",new Io(x,3)),this.setAttribute("normal",new Io(v,3)),this.setAttribute("uv",new Io(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pZ(e.width,e.height,e.widthSegments,e.heightSegments)}};class GNe extends lg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new _n(16777215),this.specular=new _n(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _n(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qY,this.normalScale=new cn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hd,this.combine=Zj,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 WNe=class extends lg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=eNe,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}},qNe=class extends lg{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},mZ=class extends Ns{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new _n(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const FC=new ri,aH=new Qe,sH=new Qe;let KNe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new cn(512,512),this.mapType=gl,this.map=null,this.mapPass=null,this.matrix=new ri,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new cO,this._frameExtents=new cn(1,1),this._viewportCount=1,this._viewports=[new Yr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;aH.setFromMatrixPosition(e.matrixWorld),n.position.copy(aH),sH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(sH),n.updateMatrixWorld(),FC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(FC,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(FC)}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}},gZ=class extends cZ{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,s=r+e,o=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,s=a+u*this.view.width,o-=d*this.view.offsetY,c=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class XNe extends KNe{constructor(){super(new gZ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class oH extends mZ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ns.DEFAULT_UP),this.updateMatrix(),this.target=new Ns,this.shadow=new XNe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let YNe=class extends mZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},ZNe=class extends Ys{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},lH=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=gn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(gn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class QNe extends VNe{constructor(e=10,n=10,r=4473924,i=8947848){r=new _n(r),i=new _n(i);const a=n/2,s=e/n,o=e/2,c=[],u=[];for(let g=0,m=0,x=-o;g<=n;g++,x+=s){c.push(-o,0,x,o,0,x),c.push(x,0,-o,x,0,o);const v=g===a?r:i;v.toArray(u,m),m+=3,v.toArray(u,m),m+=3,v.toArray(u,m),m+=3,v.toArray(u,m),m+=3}const d=new El;d.setAttribute("position",new Io(c,3)),d.setAttribute("color",new Io(u,3));const f=new dZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class JNe extends mf{constructor(e,n=null){super(),this.object=e,this.domElement=n,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Yt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function cH(t,e,n,r){const i=eke(r);switch(n){case VY:return t*e;case WY:return t*e/i.components*i.byteLength;case tO:return t*e/i.components*i.byteLength;case nO:return t*e*2/i.components*i.byteLength;case rO:return t*e*2/i.components*i.byteLength;case GY:return t*e*3/i.components*i.byteLength;case Do:return t*e*4/i.components*i.byteLength;case iO:return t*e*4/i.components*i.byteLength;case s1:case o1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case l1:case c1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Z3:case J3:return Math.max(t,16)*Math.max(e,8)/4;case Y3:case Q3:return Math.max(t,8)*Math.max(e,8)/2;case eP:case tP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case nP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case rP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case iP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case aP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case sP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case oP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case lP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case cP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case uP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case dP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case hP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case fP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case pP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case mP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case gP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case xP:case bP:case yP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case vP:case _P:return Math.ceil(t/4)*Math.ceil(e/4)*8;case wP:case SP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function eke(t){switch(t){case gl:case zY:return{byteLength:1,components:1};case $0:case BY:case og:return{byteLength:2,components:1};case Jj:case eO:return{byteLength:2,components:4};case Qh:case Qj:case gc:return{byteLength:4,components:1};case HY:case $Y:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Yj}}));typeof window<"u"&&(window.__THREE__?Yt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Yj);function xZ(){let t=null,e=!1,n=null,r=null;function i(a,s){n(a,s),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function tke(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],v=f[m];v.start<=x.start+x.count+1?x.count=Math.max(x.count,v.start+v.count-x.start):(++g,f[g]=v)}f.length=g+1;for(let m=0,x=f.length;m<x;m++){const v=f[m];t.bufferSubData(u,v.start*d.BYTES_PER_ELEMENT,d,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(t.deleteBuffer(c.buffer),e.delete(o))}function s(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const u=e.get(o);if(u===void 0)e.set(o,n(o,c));else if(u.version<o.version){if(u.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,o,c),u.version=o.version}}return{get:i,remove:a,update:s}}var nke=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,rke=`#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`,ike=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,ake=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,ske=`#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`,oke=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,lke=`#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`,cke=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,uke=`#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`,dke=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,hke=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,fke=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,pke=`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`,mke=`#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`,gke=`#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`,xke=`#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`,bke=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,yke=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,vke=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,_ke=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,wke=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,Ske=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,Mke=`#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`,Eke=`#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`,Ake=`#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`,Tke=`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`,Cke=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,Nke=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,kke=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,Pke=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,Rke="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dke=`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 );
- }`,jke=`#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`,Oke=`#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`,Lke=`#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`,Ike=`#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`,Fke=`#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`,Uke=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,zke=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,Bke=`#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`,Hke=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,$ke=`#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
- }`,Vke=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,Gke=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,Wke=`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`,qke=`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`,Kke=`#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`,Xke=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,Yke=`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`,Zke=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,Qke=`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`,Jke=`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`,e3e=`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 );
- }`,t3e=`
- 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`,n3e=`#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`,r3e=`#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`,i3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,a3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,s3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,o3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,l3e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,c3e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,u3e=`#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`,d3e=`#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`,h3e=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,f3e=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,p3e=`#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`,m3e=`#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`,g3e=`#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`,x3e=`#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`,b3e=`#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`,y3e=`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;`,v3e=`#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`,_3e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,w3e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,S3e=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,M3e=`#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`,E3e=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,A3e=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,T3e=`#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`,C3e=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,N3e=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,k3e=`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 );
- }`,P3e=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,R3e=`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;`,D3e=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,j3e=`#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`,O3e=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,L3e=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,I3e=`#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`,F3e=`#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`,U3e=`#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`,z3e=`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;
- }`,B3e=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,H3e=`#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`,$3e=`#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`,V3e=`#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`,G3e=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,W3e=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,q3e=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,K3e=`#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; }`,X3e=`#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`,Y3e=`#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`,Z3e=`#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`,Q3e=`#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`,J3e=`#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`,ePe=`#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 tPe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,nPe=`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>
- }`,rPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,iPe=`#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>
- }`,aPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,sPe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,oPe=`#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;
- }`,lPe=`#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
- }`,cPe=`#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;
- }`,uPe=`#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 );
- }`,dPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,hPe=`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>
- }`,fPe=`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>
- }`,pPe=`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>
- }`,mPe=`#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>
- }`,gPe=`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>
- }`,xPe=`#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>
- }`,bPe=`#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>
- }`,yPe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,vPe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,_Pe=`#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
- }`,wPe=`#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
- }`,SPe=`#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>
- }`,MPe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,EPe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,APe=`#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>
- }`,TPe=`#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>
- }`,CPe=`#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>
- }`,NPe=`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>
- }`,kPe=`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>
- }`,PPe=`#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>
- }`,RPe=`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>
- }`,DPe=`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>
- }`,jPe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,on={alphahash_fragment:nke,alphahash_pars_fragment:rke,alphamap_fragment:ike,alphamap_pars_fragment:ake,alphatest_fragment:ske,alphatest_pars_fragment:oke,aomap_fragment:lke,aomap_pars_fragment:cke,batching_pars_vertex:uke,batching_vertex:dke,begin_vertex:hke,beginnormal_vertex:fke,bsdfs:pke,iridescence_fragment:mke,bumpmap_pars_fragment:gke,clipping_planes_fragment:xke,clipping_planes_pars_fragment:bke,clipping_planes_pars_vertex:yke,clipping_planes_vertex:vke,color_fragment:_ke,color_pars_fragment:wke,color_pars_vertex:Ske,color_vertex:Mke,common:Eke,cube_uv_reflection_fragment:Ake,defaultnormal_vertex:Tke,displacementmap_pars_vertex:Cke,displacementmap_vertex:Nke,emissivemap_fragment:kke,emissivemap_pars_fragment:Pke,colorspace_fragment:Rke,colorspace_pars_fragment:Dke,envmap_fragment:jke,envmap_common_pars_fragment:Oke,envmap_pars_fragment:Lke,envmap_pars_vertex:Ike,envmap_physical_pars_fragment:Kke,envmap_vertex:Fke,fog_vertex:Uke,fog_pars_vertex:zke,fog_fragment:Bke,fog_pars_fragment:Hke,gradientmap_pars_fragment:$ke,lightmap_pars_fragment:Vke,lights_lambert_fragment:Gke,lights_lambert_pars_fragment:Wke,lights_pars_begin:qke,lights_toon_fragment:Xke,lights_toon_pars_fragment:Yke,lights_phong_fragment:Zke,lights_phong_pars_fragment:Qke,lights_physical_fragment:Jke,lights_physical_pars_fragment:e3e,lights_fragment_begin:t3e,lights_fragment_maps:n3e,lights_fragment_end:r3e,logdepthbuf_fragment:i3e,logdepthbuf_pars_fragment:a3e,logdepthbuf_pars_vertex:s3e,logdepthbuf_vertex:o3e,map_fragment:l3e,map_pars_fragment:c3e,map_particle_fragment:u3e,map_particle_pars_fragment:d3e,metalnessmap_fragment:h3e,metalnessmap_pars_fragment:f3e,morphinstance_vertex:p3e,morphcolor_vertex:m3e,morphnormal_vertex:g3e,morphtarget_pars_vertex:x3e,morphtarget_vertex:b3e,normal_fragment_begin:y3e,normal_fragment_maps:v3e,normal_pars_fragment:_3e,normal_pars_vertex:w3e,normal_vertex:S3e,normalmap_pars_fragment:M3e,clearcoat_normal_fragment_begin:E3e,clearcoat_normal_fragment_maps:A3e,clearcoat_pars_fragment:T3e,iridescence_pars_fragment:C3e,opaque_fragment:N3e,packing:k3e,premultiplied_alpha_fragment:P3e,project_vertex:R3e,dithering_fragment:D3e,dithering_pars_fragment:j3e,roughnessmap_fragment:O3e,roughnessmap_pars_fragment:L3e,shadowmap_pars_fragment:I3e,shadowmap_pars_vertex:F3e,shadowmap_vertex:U3e,shadowmask_pars_fragment:z3e,skinbase_vertex:B3e,skinning_pars_vertex:H3e,skinning_vertex:$3e,skinnormal_vertex:V3e,specularmap_fragment:G3e,specularmap_pars_fragment:W3e,tonemapping_fragment:q3e,tonemapping_pars_fragment:K3e,transmission_fragment:X3e,transmission_pars_fragment:Y3e,uv_pars_fragment:Z3e,uv_pars_vertex:Q3e,uv_vertex:J3e,worldpos_vertex:ePe,background_vert:tPe,background_frag:nPe,backgroundCube_vert:rPe,backgroundCube_frag:iPe,cube_vert:aPe,cube_frag:sPe,depth_vert:oPe,depth_frag:lPe,distanceRGBA_vert:cPe,distanceRGBA_frag:uPe,equirect_vert:dPe,equirect_frag:hPe,linedashed_vert:fPe,linedashed_frag:pPe,meshbasic_vert:mPe,meshbasic_frag:gPe,meshlambert_vert:xPe,meshlambert_frag:bPe,meshmatcap_vert:yPe,meshmatcap_frag:vPe,meshnormal_vert:_Pe,meshnormal_frag:wPe,meshphong_vert:SPe,meshphong_frag:MPe,meshphysical_vert:EPe,meshphysical_frag:APe,meshtoon_vert:TPe,meshtoon_frag:CPe,points_vert:NPe,points_frag:kPe,shadow_vert:PPe,shadow_frag:RPe,sprite_vert:DPe,sprite_frag:jPe},Et={common:{diffuse:{value:new _n(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new dn}},envmap:{envMap:{value:null},envMapRotation:{value:new dn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new dn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new dn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new dn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new dn},normalScale:{value:new cn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new dn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new dn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new dn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new dn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new _n(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new _n(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0},uvTransform:{value:new dn}},sprite:{diffuse:{value:new _n(16777215)},opacity:{value:1},center:{value:new cn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}}},nl={basic:{uniforms:va([Et.common,Et.specularmap,Et.envmap,Et.aomap,Et.lightmap,Et.fog]),vertexShader:on.meshbasic_vert,fragmentShader:on.meshbasic_frag},lambert:{uniforms:va([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 _n(0)}}]),vertexShader:on.meshlambert_vert,fragmentShader:on.meshlambert_frag},phong:{uniforms:va([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 _n(0)},specular:{value:new _n(1118481)},shininess:{value:30}}]),vertexShader:on.meshphong_vert,fragmentShader:on.meshphong_frag},standard:{uniforms:va([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 _n(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:on.meshphysical_vert,fragmentShader:on.meshphysical_frag},toon:{uniforms:va([Et.common,Et.aomap,Et.lightmap,Et.emissivemap,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.gradientmap,Et.fog,Et.lights,{emissive:{value:new _n(0)}}]),vertexShader:on.meshtoon_vert,fragmentShader:on.meshtoon_frag},matcap:{uniforms:va([Et.common,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.fog,{matcap:{value:null}}]),vertexShader:on.meshmatcap_vert,fragmentShader:on.meshmatcap_frag},points:{uniforms:va([Et.points,Et.fog]),vertexShader:on.points_vert,fragmentShader:on.points_frag},dashed:{uniforms:va([Et.common,Et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:on.linedashed_vert,fragmentShader:on.linedashed_frag},depth:{uniforms:va([Et.common,Et.displacementmap]),vertexShader:on.depth_vert,fragmentShader:on.depth_frag},normal:{uniforms:va([Et.common,Et.bumpmap,Et.normalmap,Et.displacementmap,{opacity:{value:1}}]),vertexShader:on.meshnormal_vert,fragmentShader:on.meshnormal_frag},sprite:{uniforms:va([Et.sprite,Et.fog]),vertexShader:on.sprite_vert,fragmentShader:on.sprite_frag},background:{uniforms:{uvTransform:{value:new dn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:on.background_vert,fragmentShader:on.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new dn}},vertexShader:on.backgroundCube_vert,fragmentShader:on.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:on.cube_vert,fragmentShader:on.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:on.equirect_vert,fragmentShader:on.equirect_frag},distanceRGBA:{uniforms:va([Et.common,Et.displacementmap,{referencePosition:{value:new Qe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:on.distanceRGBA_vert,fragmentShader:on.distanceRGBA_frag},shadow:{uniforms:va([Et.lights,Et.fog,{color:{value:new _n(0)},opacity:{value:1}}]),vertexShader:on.shadow_vert,fragmentShader:on.shadow_frag}};nl.physical={uniforms:va([nl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new dn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new dn},clearcoatNormalScale:{value:new cn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new dn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new dn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new dn},sheen:{value:0},sheenColor:{value:new _n(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new dn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new dn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new dn},transmissionSamplerSize:{value:new cn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new dn},attenuationDistance:{value:0},attenuationColor:{value:new _n(0)},specularColor:{value:new _n(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new dn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new dn},anisotropyVector:{value:new cn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new dn}}]),vertexShader:on.meshphysical_vert,fragmentShader:on.meshphysical_frag};const t_={r:0,b:0,g:0},Wd=new hd,OPe=new ri;function LPe(t,e,n,r,i,a,s){const o=new _n(0);let c=a===!0?0:1,u,d,f=null,g=0,m=null;function x(S){let A=S.isScene===!0?S.background:null;return A&&A.isTexture&&(A=(S.backgroundBlurriness>0?n:e).get(A)),A}function v(S){let A=!1;const T=x(S);T===null?b(o,c):T&&T.isColor&&(b(T,1),A=!0);const k=t.xr.getEnvironmentBlendMode();k==="additive"?r.buffers.color.setClear(0,0,0,1,s):k==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function y(S,A){const T=x(A);T&&(T.isCubeTexture||T.mapping===IM)?(d===void 0&&(d=new xl(new lO(1,1,1),new Oc({name:"BackgroundCubeMaterial",uniforms:Pm(nl.backgroundCube.uniforms),vertexShader:nl.backgroundCube.vertexShader,fragmentShader:nl.backgroundCube.fragmentShader,side:qa,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,N,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Wd.copy(A.backgroundRotation),Wd.x*=-1,Wd.y*=-1,Wd.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Wd.y*=-1,Wd.z*=-1),d.material.uniforms.envMap.value=T,d.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(OPe.makeRotationFromEuler(Wd)),d.material.toneMapped=Cn.getTransfer(T.colorSpace)!==qn,(f!==T||g!==T.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=T,g=T.version,m=t.toneMapping),d.layers.enableAll(),S.unshift(d,d.geometry,d.material,0,0,null)):T&&T.isTexture&&(u===void 0&&(u=new xl(new uO(2,2),new Oc({name:"BackgroundMaterial",uniforms:Pm(nl.background.uniforms),vertexShader:nl.background.vertexShader,fragmentShader:nl.background.fragmentShader,side:dd,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=T,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.toneMapped=Cn.getTransfer(T.colorSpace)!==qn,T.matrixAutoUpdate===!0&&T.updateMatrix(),u.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||g!==T.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=T,g=T.version,m=t.toneMapping),u.layers.enableAll(),S.unshift(u,u.geometry,u.material,0,0,null))}function b(S,A){S.getRGB(t_,lZ(t)),r.buffers.color.setClear(t_.r,t_.g,t_.b,A,s)}function M(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return o},setClearColor:function(S,A=1){o.set(S),c=A,b(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(S){c=S,b(o,c)},render:v,addToRenderList:y,dispose:M}}function IPe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let a=i,s=!1;function o(D,F,O,q,R){let W=!1;const K=f(q,O,F);a!==K&&(a=K,u(a.object)),W=m(D,q,O,R),W&&x(D,q,O,R),R!==null&&e.update(R,t.ELEMENT_ARRAY_BUFFER),(W||s)&&(s=!1,A(D,F,O,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,O){const q=O.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=[],O=[],q=[];for(let R=0;R<n;R++)F[R]=0,O[R]=0,q[R]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:O,attributeDivisors:q,object:D,attributes:{},index:null}}function m(D,F,O,q){const R=a.attributes,W=F.attributes;let K=0;const G=O.getAttributes();for(const ee in G)if(G[ee].location>=0){const Q=R[ee];let U=W[ee];if(U===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(U=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(U=D.instanceColor)),Q===void 0||Q.attribute!==U||U&&Q.data!==U.data)return!0;K++}return a.attributesNum!==K||a.index!==q}function x(D,F,O,q){const R={},W=F.attributes;let K=0;const G=O.getAttributes();for(const ee in G)if(G[ee].location>=0){let Q=W[ee];Q===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(Q=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(Q=D.instanceColor));const U={};U.attribute=Q,Q&&Q.data&&(U.data=Q.data),R[ee]=U,K++}a.attributes=R,a.attributesNum=K,a.index=q}function v(){const D=a.newAttributes;for(let F=0,O=D.length;F<O;F++)D[F]=0}function y(D){b(D,0)}function b(D,F){const O=a.newAttributes,q=a.enabledAttributes,R=a.attributeDivisors;O[D]=1,q[D]===0&&(t.enableVertexAttribArray(D),q[D]=1),R[D]!==F&&(t.vertexAttribDivisor(D,F),R[D]=F)}function M(){const D=a.newAttributes,F=a.enabledAttributes;for(let O=0,q=F.length;O<q;O++)F[O]!==D[O]&&(t.disableVertexAttribArray(O),F[O]=0)}function S(D,F,O,q,R,W,K){K===!0?t.vertexAttribIPointer(D,F,O,R,W):t.vertexAttribPointer(D,F,O,q,R,W)}function A(D,F,O,q){v();const R=q.attributes,W=O.getAttributes(),K=F.defaultAttributeValues;for(const G in W){const ee=W[G];if(ee.location>=0){let Z=R[G];if(Z===void 0&&(G==="instanceMatrix"&&D.instanceMatrix&&(Z=D.instanceMatrix),G==="instanceColor"&&D.instanceColor&&(Z=D.instanceColor)),Z!==void 0){const Q=Z.normalized,U=Z.itemSize,$=e.get(Z);if($===void 0)continue;const X=$.buffer,te=$.type,fe=$.bytesPerElement,pe=te===t.INT||te===t.UNSIGNED_INT||Z.gpuType===Qj;if(Z.isInterleavedBufferAttribute){const xe=Z.data,Ne=xe.stride,ie=Z.offset;if(xe.isInstancedInterleavedBuffer){for(let be=0;be<ee.locationSize;be++)b(ee.location+be,xe.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let be=0;be<ee.locationSize;be++)y(ee.location+be);t.bindBuffer(t.ARRAY_BUFFER,X);for(let be=0;be<ee.locationSize;be++)S(ee.location+be,U/ee.locationSize,te,Q,Ne*fe,(ie+U/ee.locationSize*be)*fe,pe)}else{if(Z.isInstancedBufferAttribute){for(let xe=0;xe<ee.locationSize;xe++)b(ee.location+xe,Z.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let xe=0;xe<ee.locationSize;xe++)y(ee.location+xe);t.bindBuffer(t.ARRAY_BUFFER,X);for(let xe=0;xe<ee.locationSize;xe++)S(ee.location+xe,U/ee.locationSize,te,Q,U*fe,U/ee.locationSize*xe*fe,pe)}}else if(K!==void 0){const Q=K[G];if(Q!==void 0)switch(Q.length){case 2:t.vertexAttrib2fv(ee.location,Q);break;case 3:t.vertexAttrib3fv(ee.location,Q);break;case 4:t.vertexAttrib4fv(ee.location,Q);break;default:t.vertexAttrib1fv(ee.location,Q)}}}}M()}function T(){I();for(const D in r){const F=r[D];for(const O in F){const q=F[O];for(const R in q)d(q[R].object),delete q[R];delete F[O]}delete r[D]}}function k(D){if(r[D.id]===void 0)return;const F=r[D.id];for(const O in F){const q=F[O];for(const R in q)d(q[R].object),delete q[R];delete F[O]}delete r[D.id]}function N(D){for(const F in r){const O=r[F];if(O[D.id]===void 0)continue;const q=O[D.id];for(const R in q)d(q[R].object),delete q[R];delete O[D.id]}}function I(){C(),s=!0,a!==i&&(a=i,u(a.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:v,enableAttribute:y,disableUnusedAttributes:M}}function FPe(t,e,n){let r;function i(u){r=u}function a(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function s(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function o(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let 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++)s(u[x],d[x],g[x]);else{m.multiDrawArraysInstancedWEBGL(r,u,0,d,0,g,0,f);let x=0;for(let v=0;v<f;v++)x+=d[v]*g[v];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=s,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function UPe(t,e,n,r){let i;function a(){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 s(N){return!(N!==Do&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(N){const I=N===og&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==gl&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==gc&&!I)}function c(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=c(u);d!==u&&(Yt("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),y=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),M=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),S=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=x>0,k=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:s,textureTypeReadable:o,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:g,maxTextures:m,maxVertexTextures:x,maxTextureSize:v,maxCubemapSize:y,maxAttributes:b,maxVertexUniforms:M,maxVaryings:S,maxFragmentUniforms:A,vertexTextures:T,maxSamples:k}}function zPe(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new Nu,o=new dn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const m=f.length!==0||g||r!==0||i;return i=g,r=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,m){const x=f.clippingPlanes,v=f.clipIntersection,y=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const M=a?0:r,S=M*4;let A=b.clippingState||null;c.value=A,A=d(x,g,S,m);for(let T=0;T!==S;++T)A[T]=n[T];b.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=M}};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 v=f!==null?f.length:0;let y=null;if(v!==0){if(y=c.value,x!==!0||y===null){const b=m+v*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(y===null||y.length<b)&&(y=new Float32Array(b));for(let S=0,A=m;S!==v;++S,A+=4)s.copy(f[S]).applyMatrix4(M,o),s.normal.toArray(y,A),y[A+3]=s.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,y}}function BPe(t){let e=new WeakMap;function n(s,o){return o===W3?s.mapping=Cm:o===q3&&(s.mapping=Nm),s}function r(s){if(s&&s.isTexture){const o=s.mapping;if(o===W3||o===q3)if(e.has(s)){const c=e.get(s).texture;return n(c,s.mapping)}else{const c=s.image;if(c&&c.height>0){const u=new LNe(c.height);return u.fromEquirectangularTexture(t,s),e.set(s,u),s.addEventListener("dispose",i),n(u.texture,s.mapping)}else return null}}return s}function i(s){const o=s.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const zu=4,uH=[.125,.215,.35,.446,.526,.582],oh=20,HPe=256,wx=new gZ,dH=new _n;let UC=null,zC=0,BC=0,HC=!1;const $Pe=new Qe;let hH=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,a={}){const{size:s=256,position:o=$Pe}=a;UC=this._renderer.getRenderTarget(),zC=this._renderer.getActiveCubeFace(),BC=this._renderer.getActiveMipmapLevel(),HC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,o),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=mH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=pH(),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(UC,zC,BC),this._renderer.xr.enabled=HC,e.scissorTest=!1,pp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Cm||e.mapping===Nm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),UC=this._renderer.getRenderTarget(),zC=this._renderer.getActiveCubeFace(),BC=this._renderer.getActiveMipmapLevel(),HC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:ro,minFilter:ro,generateMipmaps:!1,type:og,format:Do,colorSpace:km,depthBuffer:!1},i=fH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=fH(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=VPe(a)),this._blurMaterial=WPe(a,e,n),this._ggxMaterial=GPe(a,e,n)}return i}_compileMaterial(e){const n=new xl(new El,e);this._renderer.compile(n,wx)}_sceneToCubeUV(e,n,r,i,a){const c=new Ys(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(dH),f.toneMapping=Xu,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new xl(new lO,new oO({name:"PMREM.Background",side:qa,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,y=v.material;let b=!1;const M=e.background;M?M.isColor&&(y.color.copy(M),e.background=null,b=!0):(y.color.copy(dH),b=!0);for(let S=0;S<6;S++){const A=S%3;A===0?(c.up.set(0,u[S],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[S],a.y,a.z)):A===1?(c.up.set(0,0,u[S]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[S],a.z)):(c.up.set(0,u[S],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[S]));const T=this._cubeSize;pp(i,A*T,S>2?T:0,T,T),f.setRenderTarget(i),b&&f.render(v,c),f.render(e,c)}f.toneMapping=m,f.autoClear=g,e.background=M}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Cm||e.mapping===Nm;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=mH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=pH());const a=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;const o=a.uniforms;o.envMap.value=e;const c=this._cubeSize;pp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(s,wx)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[r];o.material=s;const c=s.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),g=.05+u*.95,m=f*g,{_lodMax:x}=this,v=this._sizeLods[r],y=3*v*(r>x-zu?r-x+zu:0),b=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=m,c.mipInt.value=x-n,pp(a,y,b,3*v,2*v),i.setRenderTarget(a),i.render(o,wx),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,pp(e,y,b,3*v,2*v),i.setRenderTarget(e),i.render(o,wx)}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,o){const c=this._renderer,u=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&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(a)?Math.PI/(2*m):2*Math.PI/(2*oh-1),v=a/x,y=isFinite(a)?1+Math.floor(d*v):oh;y>oh&&Yt(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${oh}`);const b=[];let M=0;for(let N=0;N<oh;++N){const I=N/v,C=Math.exp(-I*I/2);b.push(C),N===0?M+=C:N<y&&(M+=2*C)}for(let N=0;N<b.length;N++)b[N]=b[N]/M;g.envMap.value=e.texture,g.samples.value=y,g.weights.value=b,g.latitudinal.value=s==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:S}=this;g.dTheta.value=x,g.mipInt.value=S-r;const A=this._sizeLods[i],T=3*A*(i>S-zu?i-S+zu:0),k=4*(this._cubeSize-A);pp(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,wx)}};function VPe(t){const e=[],n=[],r=[];let i=t;const a=t-zu+1+uH.length;for(let s=0;s<a;s++){const o=Math.pow(2,i);e.push(o);let c=1/o;s>t-zu?c=uH[s-t+zu-1]:s===0&&(c=0),n.push(c);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,v=3,y=2,b=1,M=new Float32Array(v*x*m),S=new Float32Array(y*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];M.set(C,v*x*k),S.set(g,y*x*k);const D=[k,k,k,k,k,k];A.set(D,b*x*k)}const T=new El;T.setAttribute("position",new io(M,v)),T.setAttribute("uv",new io(S,y)),T.setAttribute("faceIndex",new io(A,b)),r.push(new xl(T,null)),i>zu&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function fH(t,e,n){const r=new ef(t,e,n);return r.texture.mapping=IM,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 GPe(t,e,n){return new Oc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:HPe,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:UM(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:wc,depthTest:!1,depthWrite:!1})}function WPe(t,e,n){const r=new Float32Array(oh),i=new Qe(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:UM(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:wc,depthTest:!1,depthWrite:!1})}function pH(){return new Oc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:UM(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:wc,depthTest:!1,depthWrite:!1})}function mH(){return new Oc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:UM(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:wc,depthTest:!1,depthWrite:!1})}function UM(){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 qPe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const c=o.mapping,u=c===W3||c===q3,d=c===Cm||c===Nm;if(u||d){let f=e.get(o);const g=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==g)return n===null&&(n=new hH(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 hH(t)),f=u?n.fromEquirectangular(o):n.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",a),f.texture):null}}}return o}function i(o){let c=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&c++;return c===u}function a(o){const c=o.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function KPe(t){const e={};function n(r){if(e[r]!==void 0)return e[r];const i=t.getExtension(r);return e[r]=i,i}return{has:function(r){return n(r)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(r){const i=n(r);return i===null&&q0("WebGLRenderer: "+r+" extension not supported."),i}}}function XPe(t,e,n,r){const i={},a=new WeakMap;function s(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);g.removeEventListener("dispose",s),delete i[g.id];const m=a.get(g);m&&(e.remove(m),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const m in g)e.update(g[m],t.ARRAY_BUFFER)}function u(f){const g=[],m=f.index,x=f.attributes.position;let v=0;if(m!==null){const M=m.array;v=m.version;for(let S=0,A=M.length;S<A;S+=3){const T=M[S+0],k=M[S+1],N=M[S+2];g.push(T,k,k,N,N,T)}}else if(x!==void 0){const M=x.array;v=x.version;for(let S=0,A=M.length/3-1;S<A;S+=3){const T=S+0,k=S+1,N=S+2;g.push(T,k,k,N,N,T)}}else return;const y=new(XY(g)?aZ:iZ)(g,1);y.version=v;const b=a.get(f);b&&e.remove(b),a.set(f,y)}function d(f){const g=a.get(f);if(g){const m=f.index;m!==null&&g.version<m.version&&u(f)}else u(f);return a.get(f)}return{get:o,update:c,getWireframeAttribute:d}}function YPe(t,e,n){let r;function i(g){r=g}let a,s;function o(g){a=g.type,s=g.bytesPerElement}function c(g,m){t.drawElements(r,m,a,g*s),n.update(m,r,1)}function u(g,m,x){x!==0&&(t.drawElementsInstanced(r,m,a,g*s,x),n.update(m,r,x))}function d(g,m,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,a,g,0,x);let y=0;for(let b=0;b<x;b++)y+=m[b];n.update(y,r,1)}function f(g,m,x,v){if(x===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let b=0;b<g.length;b++)u(g[b]/s,m[b],v[b]);else{y.multiDrawElementsInstancedWEBGL(r,m,0,a,g,0,v,0,x);let b=0;for(let M=0;M<x;M++)b+=m[M]*v[M];n.update(b,r,1)}}this.setMode=i,this.setIndex=o,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function ZPe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:zr("WebGLInfo: Unknown draw mode:",s);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function QPe(t,e,n){const r=new WeakMap,i=new Yr;function a(s,o,c){const u=s.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=d!==void 0?d.length:0;let g=r.get(o);if(g===void 0||g.count!==f){let 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,v=o.morphAttributes.normal!==void 0,y=o.morphAttributes.color!==void 0,b=o.morphAttributes.position||[],M=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let A=0;x===!0&&(A=1),v===!0&&(A=2),y===!0&&(A=3);let T=o.attributes.position.count*A,k=1;T>e.maxTextureSize&&(k=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const N=new Float32Array(T*k*4*f),I=new eZ(N,T,k,f);I.type=gc,I.needsUpdate=!0;const C=A*4;for(let F=0;F<f;F++){const O=b[F],q=M[F],R=S[F],W=T*k*4*F;for(let K=0;K<O.count;K++){const G=K*C;x===!0&&(i.fromBufferAttribute(O,K),N[W+G+0]=i.x,N[W+G+1]=i.y,N[W+G+2]=i.z,N[W+G+3]=0),v===!0&&(i.fromBufferAttribute(q,K),N[W+G+4]=i.x,N[W+G+5]=i.y,N[W+G+6]=i.z,N[W+G+7]=0),y===!0&&(i.fromBufferAttribute(R,K),N[W+G+8]=i.x,N[W+G+9]=i.y,N[W+G+10]=i.z,N[W+G+11]=R.itemSize===4?i.w:1)}}g={count:f,texture:I,size:new cn(T,k)},r.set(o,g),o.addEventListener("dispose",D)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let x=0;for(let y=0;y<u.length;y++)x+=u[y];const v=o.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",v),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:a}}function JPe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function s(){i=new WeakMap}function o(c){const u=c.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:s}}const bZ=new $o,gH=new hZ(1,1),yZ=new eZ,vZ=new yNe,_Z=new uZ,xH=[],bH=[],yH=new Float32Array(16),vH=new Float32Array(9),_H=new Float32Array(4);function cg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=xH[i];if(a===void 0&&(a=new Float32Array(i),xH[i]=a),e!==0){r.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function pi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function mi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function zM(t,e){let n=bH[e];n===void 0&&(n=new Int32Array(e),bH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function eRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function tRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(pi(n,e))return;t.uniform2fv(this.addr,e),mi(n,e)}}function nRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(pi(n,e))return;t.uniform3fv(this.addr,e),mi(n,e)}}function rRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(pi(n,e))return;t.uniform4fv(this.addr,e),mi(n,e)}}function iRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(pi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),mi(n,e)}else{if(pi(n,r))return;_H.set(r),t.uniformMatrix2fv(this.addr,!1,_H),mi(n,r)}}function aRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(pi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),mi(n,e)}else{if(pi(n,r))return;vH.set(r),t.uniformMatrix3fv(this.addr,!1,vH),mi(n,r)}}function sRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(pi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),mi(n,e)}else{if(pi(n,r))return;yH.set(r),t.uniformMatrix4fv(this.addr,!1,yH),mi(n,r)}}function oRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function lRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(pi(n,e))return;t.uniform2iv(this.addr,e),mi(n,e)}}function cRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(pi(n,e))return;t.uniform3iv(this.addr,e),mi(n,e)}}function uRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(pi(n,e))return;t.uniform4iv(this.addr,e),mi(n,e)}}function dRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function hRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(pi(n,e))return;t.uniform2uiv(this.addr,e),mi(n,e)}}function fRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(pi(n,e))return;t.uniform3uiv(this.addr,e),mi(n,e)}}function pRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(pi(n,e))return;t.uniform4uiv(this.addr,e),mi(n,e)}}function mRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let a;this.type===t.SAMPLER_2D_SHADOW?(gH.compareFunction=KY,a=gH):a=bZ,n.setTexture2D(e||a,i)}function gRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||vZ,i)}function xRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||_Z,i)}function bRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||yZ,i)}function yRe(t){switch(t){case 5126:return eRe;case 35664:return tRe;case 35665:return nRe;case 35666:return rRe;case 35674:return iRe;case 35675:return aRe;case 35676:return sRe;case 5124:case 35670:return oRe;case 35667:case 35671:return lRe;case 35668:case 35672:return cRe;case 35669:case 35673:return uRe;case 5125:return dRe;case 36294:return hRe;case 36295:return fRe;case 36296:return pRe;case 35678:case 36198:case 36298:case 36306:case 35682:return mRe;case 35679:case 36299:case 36307:return gRe;case 35680:case 36300:case 36308:case 36293:return xRe;case 36289:case 36303:case 36311:case 36292:return bRe}}function vRe(t,e){t.uniform1fv(this.addr,e)}function _Re(t,e){const n=cg(e,this.size,2);t.uniform2fv(this.addr,n)}function wRe(t,e){const n=cg(e,this.size,3);t.uniform3fv(this.addr,n)}function SRe(t,e){const n=cg(e,this.size,4);t.uniform4fv(this.addr,n)}function MRe(t,e){const n=cg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function ERe(t,e){const n=cg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function ARe(t,e){const n=cg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function TRe(t,e){t.uniform1iv(this.addr,e)}function CRe(t,e){t.uniform2iv(this.addr,e)}function NRe(t,e){t.uniform3iv(this.addr,e)}function kRe(t,e){t.uniform4iv(this.addr,e)}function PRe(t,e){t.uniform1uiv(this.addr,e)}function RRe(t,e){t.uniform2uiv(this.addr,e)}function DRe(t,e){t.uniform3uiv(this.addr,e)}function jRe(t,e){t.uniform4uiv(this.addr,e)}function ORe(t,e,n){const r=this.cache,i=e.length,a=zM(n,i);pi(r,a)||(t.uniform1iv(this.addr,a),mi(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||bZ,a[s])}function LRe(t,e,n){const r=this.cache,i=e.length,a=zM(n,i);pi(r,a)||(t.uniform1iv(this.addr,a),mi(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||vZ,a[s])}function IRe(t,e,n){const r=this.cache,i=e.length,a=zM(n,i);pi(r,a)||(t.uniform1iv(this.addr,a),mi(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||_Z,a[s])}function FRe(t,e,n){const r=this.cache,i=e.length,a=zM(n,i);pi(r,a)||(t.uniform1iv(this.addr,a),mi(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||yZ,a[s])}function URe(t){switch(t){case 5126:return vRe;case 35664:return _Re;case 35665:return wRe;case 35666:return SRe;case 35674:return MRe;case 35675:return ERe;case 35676:return ARe;case 5124:case 35670:return TRe;case 35667:case 35671:return CRe;case 35668:case 35672:return NRe;case 35669:case 35673:return kRe;case 5125:return PRe;case 36294:return RRe;case 36295:return DRe;case 36296:return jRe;case 35678:case 36198:case 36298:case 36306:case 35682:return ORe;case 35679:case 36299:case 36307:return LRe;case 35680:case 36300:case 36308:case 36293:return IRe;case 36289:case 36303:case 36311:case 36292:return FRe}}let zRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=yRe(n.type)}},BRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=URe(n.type)}},HRe=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const o=i[a];o.setValue(e,n[o.id],r)}}};const $C=/(\w+)(\])?(\[|\.)?/g;function wH(t,e){t.seq.push(e),t.map[e.id]=e}function $Re(t,e,n){const r=t.name,i=r.length;for($C.lastIndex=0;;){const a=$C.exec(r),s=$C.lastIndex;let o=a[1];const c=a[2]==="]",u=a[3];if(c&&(o=o|0),u===void 0||u==="["&&s+2===i){wH(n,u===void 0?new zRe(o,t,e):new BRe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new HRe(o),wH(n,f)),n=f}}}let f1=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),s=e.getUniformLocation(n,a.name);$Re(a,s,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,s=n.length;a!==s;++a){const o=n[a],c=r[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}};function SH(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const VRe=37297;let GRe=0;function WRe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const o=s+1;r.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return r.join(`
- `)}const MH=new dn;function qRe(t){Cn._getMatrix(MH,Cn.workingColorSpace,t);const e=`mat3( ${MH.elements.map(n=>n.toFixed(4))} )`;switch(Cn.getTransfer(t)){case Cw:return[e,"LinearTransferOETF"];case qn:return[e,"sRGBTransferOETF"];default:return Yt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function EH(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const s=/ERROR: 0:(\d+)/.exec(a);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
- `+a+`
- `+WRe(t.getShaderSource(e),o)}else return a}function KRe(t,e){const n=qRe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function XRe(t,e){let n;switch(e){case WCe:n="Linear";break;case qCe:n="Reinhard";break;case KCe:n="Cineon";break;case XCe:n="ACESFilmic";break;case ZCe:n="AgX";break;case QCe:n="Neutral";break;case YCe:n="Custom";break;default:Yt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const n_=new Qe;function YRe(){Cn.getLuminanceCoefficients(n_);const t=n_.x.toFixed(4),e=n_.y.toFixed(4),n=n_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function ZRe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ix).join(`
- `)}function QRe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function JRe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function Ix(t){return t!==""}function AH(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 TH(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const eDe=/^[ \t]*#include +<([\w\d./]+)>/gm;function AP(t){return t.replace(eDe,nDe)}const tDe=new Map;function nDe(t,e){let n=on[e];if(n===void 0){const r=tDe.get(e);if(r!==void 0)n=on[r],Yt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return AP(n)}const rDe=/#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 CH(t){return t.replace(rDe,iDe)}function iDe(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function NH(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 aDe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===FY?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===ECe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ic&&(e="SHADOWMAP_TYPE_VSM"),e}function sDe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Cm:case Nm:e="ENVMAP_TYPE_CUBE";break;case IM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function oDe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Nm:e="ENVMAP_MODE_REFRACTION";break}return e}function lDe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case Zj:e="ENVMAP_BLENDING_MULTIPLY";break;case VCe:e="ENVMAP_BLENDING_MIX";break;case GCe:e="ENVMAP_BLENDING_ADD";break}return e}function cDe(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 uDe(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const c=aDe(n),u=sDe(n),d=oDe(n),f=lDe(n),g=cDe(n),m=ZRe(n),x=QRe(a),v=i.createProgram();let y,b,M=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Ix).join(`
- `),y.length>0&&(y+=`
- `),b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Ix).join(`
- `),b.length>0&&(b+=`
- `)):(y=[NH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Ix).join(`
- `),b=[NH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Xu?"#define TONE_MAPPING":"",n.toneMapping!==Xu?on.tonemapping_pars_fragment:"",n.toneMapping!==Xu?XRe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",on.colorspace_pars_fragment,KRe("linearToOutputTexel",n.outputColorSpace),YRe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Ix).join(`
- `)),s=AP(s),s=AH(s,n),s=TH(s,n),o=AP(o),o=AH(o,n),o=TH(o,n),s=CH(s),o=CH(o),n.isRawShaderMaterial!==!0&&(M=`#version 300 es
- `,y=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+y,b=["#define varying in",n.glslVersion===L6?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===L6?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+b);const S=M+y+s,A=M+b+o,T=SH(i,i.VERTEX_SHADER,S),k=SH(i,i.FRAGMENT_SHADER,A);i.attachShader(v,T),i.attachShader(v,k),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function N(F){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(v)||"",q=i.getShaderInfoLog(T)||"",R=i.getShaderInfoLog(k)||"",W=O.trim(),K=q.trim(),G=R.trim();let ee=!0,Z=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(ee=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,T,k);else{const Q=EH(i,T,"vertex"),U=EH(i,k,"fragment");zr("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
- Material Name: `+F.name+`
- Material Type: `+F.type+`
- Program Info Log: `+W+`
- `+Q+`
- `+U)}else W!==""?Yt("WebGLProgram: Program Info Log:",W):(K===""||G==="")&&(Z=!1);Z&&(F.diagnostics={runnable:ee,programLog:W,vertexShader:{log:K,prefix:y},fragmentShader:{log:G,prefix:b}})}i.deleteShader(T),i.deleteShader(k),I=new f1(i,v),C=JRe(i,v)}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(v,VRe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=GRe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=k,this}let dDe=0,hDe=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),s=this._getShaderCacheForMaterial(e);return s.has(i)===!1&&(s.add(i),i.usedTimes++),s.has(a)===!1&&(s.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new fDe(e),n.set(e,r)),r}},fDe=class{constructor(e){this.id=dDe++,this.code=e,this.usedTimes=0}};function pDe(t,e,n,r,i,a,s){const o=new nZ,c=new hDe,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 v(C){return u.add(C),C===0?"uv":`uv${C}`}function y(C,D,F,O,q){const R=O.fog,W=q.geometry,K=C.isMeshStandardMaterial?O.environment:null,G=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),ee=G&&G.mapping===IM?G.image.height:null,Z=x[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&Yt("WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const Q=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=Q!==void 0?Q.length:0;let $=0;W.morphAttributes.position!==void 0&&($=1),W.morphAttributes.normal!==void 0&&($=2),W.morphAttributes.color!==void 0&&($=3);let X,te,fe,pe;if(Z){const St=nl[Z];X=St.vertexShader,te=St.fragmentShader}else X=C.vertexShader,te=C.fragmentShader,c.update(C),fe=c.getVertexShaderID(C),pe=c.getFragmentShaderID(C);const xe=t.getRenderTarget(),Ne=t.state.buffers.depth.getReversed(),ie=q.isInstancedMesh===!0,be=q.isBatchedMesh===!0,je=!!C.map,he=!!C.matcap,ht=!!G,H=!!C.aoMap,B=!!C.lightMap,re=!!C.bumpMap,V=!!C.normalMap,J=!!C.displacementMap,se=!!C.emissiveMap,Ae=!!C.metalnessMap,Pe=!!C.roughnessMap,Se=C.anisotropy>0,z=C.clearcoat>0,L=C.dispersion>0,ne=C.iridescence>0,ve=C.sheen>0,we=C.transmission>0,ye=Se&&!!C.anisotropyMap,nt=z&&!!C.clearcoatMap,Be=z&&!!C.clearcoatNormalMap,ue=z&&!!C.clearcoatRoughnessMap,Ve=ne&&!!C.iridescenceMap,Fe=ne&&!!C.iridescenceThicknessMap,oe=ve&&!!C.sheenColorMap,Je=ve&&!!C.sheenRoughnessMap,He=!!C.specularMap,Ke=!!C.specularColorMap,ct=!!C.specularIntensityMap,de=we&&!!C.transmissionMap,Ye=we&&!!C.thicknessMap,ge=!!C.gradientMap,Ue=!!C.alphaMap,Ce=C.alphaTest>0,_e=!!C.alphaHash,ce=!!C.extensions;let st=Xu;C.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(st=t.toneMapping);const xt={shaderID:Z,shaderType:C.type,shaderName:C.name,vertexShader:X,fragmentShader:te,defines:C.defines,customVertexShaderID:fe,customFragmentShaderID:pe,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:be,batchingColor:be&&q._colorsTexture!==null,instancing:ie,instancingColor:ie&&q.instanceColor!==null,instancingMorph:ie&&q.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:km,alphaToCoverage:!!C.alphaToCoverage,map:je,matcap:he,envMap:ht,envMapMode:ht&&G.mapping,envMapCubeUVHeight:ee,aoMap:H,lightMap:B,bumpMap:re,normalMap:V,displacementMap:g&&J,emissiveMap:se,normalMapObjectSpace:V&&C.normalMapType===nNe,normalMapTangentSpace:V&&C.normalMapType===qY,metalnessMap:Ae,roughnessMap:Pe,anisotropy:Se,anisotropyMap:ye,clearcoat:z,clearcoatMap:nt,clearcoatNormalMap:Be,clearcoatRoughnessMap:ue,dispersion:L,iridescence:ne,iridescenceMap:Ve,iridescenceThicknessMap:Fe,sheen:ve,sheenColorMap:oe,sheenRoughnessMap:Je,specularMap:He,specularColorMap:Ke,specularIntensityMap:ct,transmission:we,transmissionMap:de,thicknessMap:Ye,gradientMap:ge,opaque:C.transparent===!1&&C.blending===im&&C.alphaToCoverage===!1,alphaMap:Ue,alphaTest:Ce,alphaHash:_e,combine:C.combine,mapUv:je&&v(C.map.channel),aoMapUv:H&&v(C.aoMap.channel),lightMapUv:B&&v(C.lightMap.channel),bumpMapUv:re&&v(C.bumpMap.channel),normalMapUv:V&&v(C.normalMap.channel),displacementMapUv:J&&v(C.displacementMap.channel),emissiveMapUv:se&&v(C.emissiveMap.channel),metalnessMapUv:Ae&&v(C.metalnessMap.channel),roughnessMapUv:Pe&&v(C.roughnessMap.channel),anisotropyMapUv:ye&&v(C.anisotropyMap.channel),clearcoatMapUv:nt&&v(C.clearcoatMap.channel),clearcoatNormalMapUv:Be&&v(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ue&&v(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Ve&&v(C.iridescenceMap.channel),iridescenceThicknessMapUv:Fe&&v(C.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&v(C.sheenColorMap.channel),sheenRoughnessMapUv:Je&&v(C.sheenRoughnessMap.channel),specularMapUv:He&&v(C.specularMap.channel),specularColorMapUv:Ke&&v(C.specularColorMap.channel),specularIntensityMapUv:ct&&v(C.specularIntensityMap.channel),transmissionMapUv:de&&v(C.transmissionMap.channel),thicknessMapUv:Ye&&v(C.thicknessMap.channel),alphaMapUv:Ue&&v(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(V||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:Ne,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:$,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:s.numPlanes,numClipIntersection:s.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:st,decodeVideoTexture:je&&C.map.isVideoTexture===!0&&Cn.getTransfer(C.map.colorSpace)===qn,decodeVideoTextureEmissive:se&&C.emissiveMap.isVideoTexture===!0&&Cn.getTransfer(C.emissiveMap.colorSpace)===qn,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===rl,flipSided:C.side===qa,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:ce&&C.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ce&&C.extensions.multiDraw===!0||be)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return xt.vertexUv1s=u.has(1),xt.vertexUv2s=u.has(2),xt.vertexUv3s=u.has(3),u.clear(),xt}function b(C){const D=[];if(C.shaderID?D.push(C.shaderID):(D.push(C.customVertexShaderID),D.push(C.customFragmentShaderID)),C.defines!==void 0)for(const F in C.defines)D.push(F),D.push(C.defines[F]);return C.isRawShaderMaterial===!1&&(M(D,C),S(D,C),D.push(t.outputColorSpace)),D.push(C.customProgramCacheKey),D.join()}function M(C,D){C.push(D.precision),C.push(D.outputColorSpace),C.push(D.envMapMode),C.push(D.envMapCubeUVHeight),C.push(D.mapUv),C.push(D.alphaMapUv),C.push(D.lightMapUv),C.push(D.aoMapUv),C.push(D.bumpMapUv),C.push(D.normalMapUv),C.push(D.displacementMapUv),C.push(D.emissiveMapUv),C.push(D.metalnessMapUv),C.push(D.roughnessMapUv),C.push(D.anisotropyMapUv),C.push(D.clearcoatMapUv),C.push(D.clearcoatNormalMapUv),C.push(D.clearcoatRoughnessMapUv),C.push(D.iridescenceMapUv),C.push(D.iridescenceThicknessMapUv),C.push(D.sheenColorMapUv),C.push(D.sheenRoughnessMapUv),C.push(D.specularMapUv),C.push(D.specularColorMapUv),C.push(D.specularIntensityMapUv),C.push(D.transmissionMapUv),C.push(D.thicknessMapUv),C.push(D.combine),C.push(D.fogExp2),C.push(D.sizeAttenuation),C.push(D.morphTargetsCount),C.push(D.morphAttributeCount),C.push(D.numDirLights),C.push(D.numPointLights),C.push(D.numSpotLights),C.push(D.numSpotLightMaps),C.push(D.numHemiLights),C.push(D.numRectAreaLights),C.push(D.numDirLightShadows),C.push(D.numPointLightShadows),C.push(D.numSpotLightShadows),C.push(D.numSpotLightShadowsWithMaps),C.push(D.numLightProbes),C.push(D.shadowMapType),C.push(D.toneMapping),C.push(D.numClippingPlanes),C.push(D.numClipIntersection),C.push(D.depthPacking)}function S(C,D){o.disableAll(),D.supportsVertexTextures&&o.enable(0),D.instancing&&o.enable(1),D.instancingColor&&o.enable(2),D.instancingMorph&&o.enable(3),D.matcap&&o.enable(4),D.envMap&&o.enable(5),D.normalMapObjectSpace&&o.enable(6),D.normalMapTangentSpace&&o.enable(7),D.clearcoat&&o.enable(8),D.iridescence&&o.enable(9),D.alphaTest&&o.enable(10),D.vertexColors&&o.enable(11),D.vertexAlphas&&o.enable(12),D.vertexUv1s&&o.enable(13),D.vertexUv2s&&o.enable(14),D.vertexUv3s&&o.enable(15),D.vertexTangents&&o.enable(16),D.anisotropy&&o.enable(17),D.alphaHash&&o.enable(18),D.batching&&o.enable(19),D.dispersion&&o.enable(20),D.batchingColor&&o.enable(21),D.gradientMap&&o.enable(22),C.push(o.mask),o.disableAll(),D.fog&&o.enable(0),D.useFog&&o.enable(1),D.flatShading&&o.enable(2),D.logarithmicDepthBuffer&&o.enable(3),D.reversedDepthBuffer&&o.enable(4),D.skinning&&o.enable(5),D.morphTargets&&o.enable(6),D.morphNormals&&o.enable(7),D.morphColors&&o.enable(8),D.premultipliedAlpha&&o.enable(9),D.shadowMapEnabled&&o.enable(10),D.doubleSided&&o.enable(11),D.flipSided&&o.enable(12),D.useDepthPacking&&o.enable(13),D.dithering&&o.enable(14),D.transmission&&o.enable(15),D.sheen&&o.enable(16),D.opaque&&o.enable(17),D.pointsUvs&&o.enable(18),D.decodeVideoTexture&&o.enable(19),D.decodeVideoTextureEmissive&&o.enable(20),D.alphaToCoverage&&o.enable(21),C.push(o.mask)}function A(C){const D=x[C.type];let F;if(D){const O=nl[D];F=RNe.clone(O.uniforms)}else F=C.uniforms;return F}function T(C,D){let F;for(let O=0,q=d.length;O<q;O++){const R=d[O];if(R.cacheKey===D){F=R,++F.usedTimes;break}}return F===void 0&&(F=new uDe(t,D,C,a),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:y,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:N,programs:d,dispose:I}}function mDe(){let t=new WeakMap;function e(s){return t.has(s)}function n(s){let o=t.get(s);return o===void 0&&(o={},t.set(s,o)),o}function r(s){t.delete(s)}function i(s,o,c){t.get(s)[o]=c}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function gDe(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 kH(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 PH(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(f,g,m,x,v,y){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:m,groupOrder:x,renderOrder:f.renderOrder,z:v,group:y},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=v,b.group=y),e++,b}function o(f,g,m,x,v,y){const b=s(f,g,m,x,v,y);m.transmission>0?r.push(b):m.transparent===!0?i.push(b):n.push(b)}function c(f,g,m,x,v,y){const b=s(f,g,m,x,v,y);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||gDe),r.length>1&&r.sort(g||kH),i.length>1&&i.sort(g||kH)}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:a,push:o,unshift:c,finish:d,sort:u}}function xDe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new PH,t.set(r,[s])):i>=a.length?(s=new PH,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function bDe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Qe,color:new _n};break;case"SpotLight":n={position:new Qe,direction:new Qe,color:new _n,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Qe,color:new _n,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Qe,skyColor:new _n,groundColor:new _n};break;case"RectAreaLight":n={color:new _n,position:new Qe,halfWidth:new Qe,halfHeight:new Qe};break}return t[e.id]=n,n}}}function yDe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let vDe=0;function _De(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function wDe(t){const e=new bDe,n=yDe(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new Qe);const i=new Qe,a=new ri,s=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,v=0,y=0,b=0,M=0,S=0,A=0,T=0,k=0,N=0;u.sort(_De);for(let C=0,D=u.length;C<D;C++){const F=u[C],O=F.color,q=F.intensity,R=F.distance,W=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=O.r*q,f+=O.g*q,g+=O.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 G=F.shadow,ee=n.get(F);ee.shadowIntensity=G.intensity,ee.shadowBias=G.bias,ee.shadowNormalBias=G.normalBias,ee.shadowRadius=G.radius,ee.shadowMapSize=G.mapSize,r.directionalShadow[m]=ee,r.directionalShadowMap[m]=W,r.directionalShadowMatrix[m]=F.shadow.matrix,M++}r.directional[m]=K,m++}else if(F.isSpotLight){const K=e.get(F);K.position.setFromMatrixPosition(F.matrixWorld),K.color.copy(O).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[v]=K;const G=F.shadow;if(F.map&&(r.spotLightMap[T]=F.map,T++,G.updateMatrices(F),F.castShadow&&k++),r.spotLightMatrix[v]=G.matrix,F.castShadow){const ee=n.get(F);ee.shadowIntensity=G.intensity,ee.shadowBias=G.bias,ee.shadowNormalBias=G.normalBias,ee.shadowRadius=G.radius,ee.shadowMapSize=G.mapSize,r.spotShadow[v]=ee,r.spotShadowMap[v]=W,A++}v++}else if(F.isRectAreaLight){const K=e.get(F);K.color.copy(O).multiplyScalar(q),K.halfWidth.set(F.width*.5,0,0),K.halfHeight.set(0,F.height*.5,0),r.rectArea[y]=K,y++}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 G=F.shadow,ee=n.get(F);ee.shadowIntensity=G.intensity,ee.shadowBias=G.bias,ee.shadowNormalBias=G.normalBias,ee.shadowRadius=G.radius,ee.shadowMapSize=G.mapSize,ee.shadowCameraNear=G.camera.near,ee.shadowCameraFar=G.camera.far,r.pointShadow[x]=ee,r.pointShadowMap[x]=W,r.pointShadowMatrix[x]=F.shadow.matrix,S++}r.point[x]=K,x++}else if(F.isHemisphereLight){const K=e.get(F);K.skyColor.copy(F.color).multiplyScalar(q),K.groundColor.copy(F.groundColor).multiplyScalar(q),r.hemi[b]=K,b++}}y>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!==v||I.rectAreaLength!==y||I.hemiLength!==b||I.numDirectionalShadows!==M||I.numPointShadows!==S||I.numSpotShadows!==A||I.numSpotMaps!==T||I.numLightProbes!==N)&&(r.directional.length=m,r.spot.length=v,r.rectArea.length=y,r.point.length=x,r.hemi.length=b,r.directionalShadow.length=M,r.directionalShadowMap.length=M,r.pointShadow.length=S,r.pointShadowMap.length=S,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=M,r.pointShadowMatrix.length=S,r.spotLightMatrix.length=A+T-k,r.spotLightMap.length=T,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=N,I.directionalLength=m,I.pointLength=x,I.spotLength=v,I.rectAreaLength=y,I.hemiLength=b,I.numDirectionalShadows=M,I.numPointShadows=S,I.numSpotShadows=A,I.numSpotMaps=T,I.numLightProbes=N,r.version=vDe++)}function c(u,d){let f=0,g=0,m=0,x=0,v=0;const y=d.matrixWorldInverse;for(let b=0,M=u.length;b<M;b++){const S=u[b];if(S.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(y),f++}else if(S.isSpotLight){const A=r.spot[m];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(y),A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(y),m++}else if(S.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(y),s.identity(),a.copy(S.matrixWorld),a.premultiply(y),s.extractRotation(a),A.halfWidth.set(S.width*.5,0,0),A.halfHeight.set(0,S.height*.5,0),A.halfWidth.applyMatrix4(s),A.halfHeight.applyMatrix4(s),x++}else if(S.isPointLight){const A=r.point[g];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(y),g++}else if(S.isHemisphereLight){const A=r.hemi[v];A.direction.setFromMatrixPosition(S.matrixWorld),A.direction.transformDirection(y),v++}}}return{setup:o,setupView:c,state:r}}function RH(t){const e=new wDe(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(d){n.push(d)}function s(d){r.push(d)}function o(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:o,setupLightsView:c,pushLight:a,pushShadow:s}}function SDe(t){let e=new WeakMap;function n(i,a=0){const s=e.get(i);let o;return s===void 0?(o=new RH(t),e.set(i,[o])):a>=s.length?(o=new RH(t),s.push(o)):o=s[a],o}function r(){e=new WeakMap}return{get:n,dispose:r}}const MDe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,EDe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function ADe(t,e,n){let r=new cO;const i=new cn,a=new cn,s=new Yr,o=new WNe({depthPacking:tNe}),c=new qNe,u={},d=n.maxTextureSize,f={[dd]:qa,[qa]:dd,[rl]:rl},g=new Oc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new cn},radius:{value:4}},vertexShader:MDe,fragmentShader:EDe}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const x=new El;x.setAttribute("position",new io(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new xl(x,g),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=FY;let b=this.type;this.render=function(k,N,I){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||k.length===0)return;const C=t.getRenderTarget(),D=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),O=t.state;O.setBlending(wc),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const q=b!==ic&&this.type===ic,R=b===ic&&this.type!==ic;for(let W=0,K=k.length;W<K;W++){const G=k[W],ee=G.shadow;if(ee===void 0){Yt("WebGLShadowMap:",G,"has no shadow.");continue}if(ee.autoUpdate===!1&&ee.needsUpdate===!1)continue;i.copy(ee.mapSize);const Z=ee.getFrameExtents();if(i.multiply(Z),a.copy(ee.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Z.x),i.x=a.x*Z.x,ee.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Z.y),i.y=a.y*Z.y,ee.mapSize.y=a.y)),ee.map===null||q===!0||R===!0){const U=this.type!==ic?{minFilter:ws,magFilter:ws}:{};ee.map!==null&&ee.map.dispose(),ee.map=new ef(i.x,i.y,U),ee.map.texture.name=G.name+".shadowMap",ee.camera.updateProjectionMatrix()}t.setRenderTarget(ee.map),t.clear();const Q=ee.getViewportCount();for(let U=0;U<Q;U++){const $=ee.getViewport(U);s.set(a.x*$.x,a.y*$.y,a.x*$.z,a.y*$.w),O.viewport(s),ee.updateMatrices(G,U),r=ee.getFrustum(),A(N,I,ee.camera,G,this.type)}ee.isPointLightShadow!==!0&&this.type===ic&&M(ee,I),ee.needsUpdate=!1}b=this.type,y.needsUpdate=!1,t.setRenderTarget(C,D,F)};function M(k,N){const I=e.update(v);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,v,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,v,null)}function S(k,N,I,C){let D=null;const F=I.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(F!==void 0)D=F;else if(D=I.isPointLight===!0?c:o,t.localClippingEnabled&&N.clipShadows===!0&&Array.isArray(N.clippingPlanes)&&N.clippingPlanes.length!==0||N.displacementMap&&N.displacementScale!==0||N.alphaMap&&N.alphaTest>0||N.map&&N.alphaTest>0||N.alphaToCoverage===!0){const O=D.uuid,q=N.uuid;let R=u[O];R===void 0&&(R={},u[O]=R);let W=R[q];W===void 0&&(W=D.clone(),R[q]=W,N.addEventListener("dispose",T)),D=W}if(D.visible=N.visible,D.wireframe=N.wireframe,C===ic?D.side=N.shadowSide!==null?N.shadowSide:N.side:D.side=N.shadowSide!==null?N.shadowSide:f[N.side],D.alphaMap=N.alphaMap,D.alphaTest=N.alphaToCoverage===!0?.5:N.alphaTest,D.map=N.map,D.clipShadows=N.clipShadows,D.clippingPlanes=N.clippingPlanes,D.clipIntersection=N.clipIntersection,D.displacementMap=N.displacementMap,D.displacementScale=N.displacementScale,D.displacementBias=N.displacementBias,D.wireframeLinewidth=N.wireframeLinewidth,D.linewidth=N.linewidth,I.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const O=t.properties.get(D);O.light=I}return D}function A(k,N,I,C,D){if(k.visible===!1)return;if(k.layers.test(N.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&D===ic)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,k.matrixWorld);const q=e.update(k),R=k.material;if(Array.isArray(R)){const W=q.groups;for(let K=0,G=W.length;K<G;K++){const ee=W[K],Z=R[ee.materialIndex];if(Z&&Z.visible){const Q=S(k,Z,C,D);k.onBeforeShadow(t,k,N,I,q,Q,ee),t.renderBufferDirect(I,null,q,Q,k,ee),k.onAfterShadow(t,k,N,I,q,Q,ee)}}}else if(R.visible){const W=S(k,R,C,D);k.onBeforeShadow(t,k,N,I,q,W,null),t.renderBufferDirect(I,null,q,W,k,null),k.onAfterShadow(t,k,N,I,q,W,null)}}const O=k.children;for(let q=0,R=O.length;q<R;q++)A(O[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 TDe={[U3]:z3,[B3]:V3,[H3]:G3,[Tm]:$3,[z3]:U3,[V3]:B3,[G3]:H3,[$3]:Tm};function CDe(t,e){function n(){let de=!1;const Ye=new Yr;let ge=null;const Ue=new Yr(0,0,0,0);return{setMask:function(Ce){ge!==Ce&&!de&&(t.colorMask(Ce,Ce,Ce,Ce),ge=Ce)},setLocked:function(Ce){de=Ce},setClear:function(Ce,_e,ce,st,xt){xt===!0&&(Ce*=st,_e*=st,ce*=st),Ye.set(Ce,_e,ce,st),Ue.equals(Ye)===!1&&(t.clearColor(Ce,_e,ce,st),Ue.copy(Ye))},reset:function(){de=!1,ge=null,Ue.set(-1,0,0,0)}}}function r(){let de=!1,Ye=!1,ge=null,Ue=null,Ce=null;return{setReversed:function(_e){if(Ye!==_e){const ce=e.get("EXT_clip_control");_e?ce.clipControlEXT(ce.LOWER_LEFT_EXT,ce.ZERO_TO_ONE_EXT):ce.clipControlEXT(ce.LOWER_LEFT_EXT,ce.NEGATIVE_ONE_TO_ONE_EXT),Ye=_e;const st=Ce;Ce=null,this.setClear(st)}},getReversed:function(){return Ye},setTest:function(_e){_e?xe(t.DEPTH_TEST):Ne(t.DEPTH_TEST)},setMask:function(_e){ge!==_e&&!de&&(t.depthMask(_e),ge=_e)},setFunc:function(_e){if(Ye&&(_e=TDe[_e]),Ue!==_e){switch(_e){case U3:t.depthFunc(t.NEVER);break;case z3:t.depthFunc(t.ALWAYS);break;case B3:t.depthFunc(t.LESS);break;case Tm:t.depthFunc(t.LEQUAL);break;case H3:t.depthFunc(t.EQUAL);break;case $3:t.depthFunc(t.GEQUAL);break;case V3:t.depthFunc(t.GREATER);break;case G3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ue=_e}},setLocked:function(_e){de=_e},setClear:function(_e){Ce!==_e&&(Ye&&(_e=1-_e),t.clearDepth(_e),Ce=_e)},reset:function(){de=!1,ge=null,Ue=null,Ce=null,Ye=!1}}}function i(){let de=!1,Ye=null,ge=null,Ue=null,Ce=null,_e=null,ce=null,st=null,xt=null;return{setTest:function(St){de||(St?xe(t.STENCIL_TEST):Ne(t.STENCIL_TEST))},setMask:function(St){Ye!==St&&!de&&(t.stencilMask(St),Ye=St)},setFunc:function(St,Qt,Ot){(ge!==St||Ue!==Qt||Ce!==Ot)&&(t.stencilFunc(St,Qt,Ot),ge=St,Ue=Qt,Ce=Ot)},setOp:function(St,Qt,Ot){(_e!==St||ce!==Qt||st!==Ot)&&(t.stencilOp(St,Qt,Ot),_e=St,ce=Qt,st=Ot)},setLocked:function(St){de=St},setClear:function(St){xt!==St&&(t.clearStencil(St),xt=St)},reset:function(){de=!1,Ye=null,ge=null,Ue=null,Ce=null,_e=null,ce=null,st=null,xt=null}}}const a=new n,s=new r,o=new i,c=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,m=[],x=null,v=!1,y=null,b=null,M=null,S=null,A=null,T=null,k=null,N=new _n(0,0,0),I=0,C=!1,D=null,F=null,O=null,q=null,R=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,G=0;const ee=t.getParameter(t.VERSION);ee.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(ee)[1]),K=G>=1):ee.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),K=G>=2);let Z=null,Q={};const U=t.getParameter(t.SCISSOR_BOX),$=t.getParameter(t.VIEWPORT),X=new Yr().fromArray(U),te=new Yr().fromArray($);function fe(de,Ye,ge,Ue){const Ce=new Uint8Array(4),_e=t.createTexture();t.bindTexture(de,_e),t.texParameteri(de,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(de,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let ce=0;ce<ge;ce++)de===t.TEXTURE_3D||de===t.TEXTURE_2D_ARRAY?t.texImage3D(Ye,0,t.RGBA,1,1,Ue,0,t.RGBA,t.UNSIGNED_BYTE,Ce):t.texImage2D(Ye+ce,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ce);return _e}const pe={};pe[t.TEXTURE_2D]=fe(t.TEXTURE_2D,t.TEXTURE_2D,1),pe[t.TEXTURE_CUBE_MAP]=fe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),pe[t.TEXTURE_2D_ARRAY]=fe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),pe[t.TEXTURE_3D]=fe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),xe(t.DEPTH_TEST),s.setFunc(Tm),re(!1),V(k6),xe(t.CULL_FACE),H(wc);function xe(de){d[de]!==!0&&(t.enable(de),d[de]=!0)}function Ne(de){d[de]!==!1&&(t.disable(de),d[de]=!1)}function ie(de,Ye){return f[de]!==Ye?(t.bindFramebuffer(de,Ye),f[de]=Ye,de===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Ye),de===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Ye),!0):!1}function be(de,Ye){let ge=m,Ue=!1;if(de){ge=g.get(Ye),ge===void 0&&(ge=[],g.set(Ye,ge));const Ce=de.textures;if(ge.length!==Ce.length||ge[0]!==t.COLOR_ATTACHMENT0){for(let _e=0,ce=Ce.length;_e<ce;_e++)ge[_e]=t.COLOR_ATTACHMENT0+_e;ge.length=Ce.length,Ue=!0}}else ge[0]!==t.BACK&&(ge[0]=t.BACK,Ue=!0);Ue&&t.drawBuffers(ge)}function je(de){return x!==de?(t.useProgram(de),x=de,!0):!1}const he={[sh]:t.FUNC_ADD,[TCe]:t.FUNC_SUBTRACT,[CCe]:t.FUNC_REVERSE_SUBTRACT};he[NCe]=t.MIN,he[kCe]=t.MAX;const ht={[PCe]:t.ZERO,[RCe]:t.ONE,[DCe]:t.SRC_COLOR,[I3]:t.SRC_ALPHA,[UCe]:t.SRC_ALPHA_SATURATE,[ICe]:t.DST_COLOR,[OCe]:t.DST_ALPHA,[jCe]:t.ONE_MINUS_SRC_COLOR,[F3]:t.ONE_MINUS_SRC_ALPHA,[FCe]:t.ONE_MINUS_DST_COLOR,[LCe]:t.ONE_MINUS_DST_ALPHA,[zCe]:t.CONSTANT_COLOR,[BCe]:t.ONE_MINUS_CONSTANT_COLOR,[HCe]:t.CONSTANT_ALPHA,[$Ce]:t.ONE_MINUS_CONSTANT_ALPHA};function H(de,Ye,ge,Ue,Ce,_e,ce,st,xt,St){if(de===wc){v===!0&&(Ne(t.BLEND),v=!1);return}if(v===!1&&(xe(t.BLEND),v=!0),de!==ACe){if(de!==y||St!==C){if((b!==sh||A!==sh)&&(t.blendEquation(t.FUNC_ADD),b=sh,A=sh),St)switch(de){case im:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case P6:t.blendFunc(t.ONE,t.ONE);break;case R6:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case D6:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:zr("WebGLState: Invalid blending: ",de);break}else switch(de){case im:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case P6:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case R6:zr("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case D6:zr("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:zr("WebGLState: Invalid blending: ",de);break}M=null,S=null,T=null,k=null,N.set(0,0,0),I=0,y=de,C=St}return}Ce=Ce||Ye,_e=_e||ge,ce=ce||Ue,(Ye!==b||Ce!==A)&&(t.blendEquationSeparate(he[Ye],he[Ce]),b=Ye,A=Ce),(ge!==M||Ue!==S||_e!==T||ce!==k)&&(t.blendFuncSeparate(ht[ge],ht[Ue],ht[_e],ht[ce]),M=ge,S=Ue,T=_e,k=ce),(st.equals(N)===!1||xt!==I)&&(t.blendColor(st.r,st.g,st.b,xt),N.copy(st),I=xt),y=de,C=!1}function B(de,Ye){de.side===rl?Ne(t.CULL_FACE):xe(t.CULL_FACE);let ge=de.side===qa;Ye&&(ge=!ge),re(ge),de.blending===im&&de.transparent===!1?H(wc):H(de.blending,de.blendEquation,de.blendSrc,de.blendDst,de.blendEquationAlpha,de.blendSrcAlpha,de.blendDstAlpha,de.blendColor,de.blendAlpha,de.premultipliedAlpha),s.setFunc(de.depthFunc),s.setTest(de.depthTest),s.setMask(de.depthWrite),a.setMask(de.colorWrite);const Ue=de.stencilWrite;o.setTest(Ue),Ue&&(o.setMask(de.stencilWriteMask),o.setFunc(de.stencilFunc,de.stencilRef,de.stencilFuncMask),o.setOp(de.stencilFail,de.stencilZFail,de.stencilZPass)),se(de.polygonOffset,de.polygonOffsetFactor,de.polygonOffsetUnits),de.alphaToCoverage===!0?xe(t.SAMPLE_ALPHA_TO_COVERAGE):Ne(t.SAMPLE_ALPHA_TO_COVERAGE)}function re(de){D!==de&&(de?t.frontFace(t.CW):t.frontFace(t.CCW),D=de)}function V(de){de!==SCe?(xe(t.CULL_FACE),de!==F&&(de===k6?t.cullFace(t.BACK):de===MCe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ne(t.CULL_FACE),F=de}function J(de){de!==O&&(K&&t.lineWidth(de),O=de)}function se(de,Ye,ge){de?(xe(t.POLYGON_OFFSET_FILL),(q!==Ye||R!==ge)&&(t.polygonOffset(Ye,ge),q=Ye,R=ge)):Ne(t.POLYGON_OFFSET_FILL)}function Ae(de){de?xe(t.SCISSOR_TEST):Ne(t.SCISSOR_TEST)}function Pe(de){de===void 0&&(de=t.TEXTURE0+W-1),Z!==de&&(t.activeTexture(de),Z=de)}function Se(de,Ye,ge){ge===void 0&&(Z===null?ge=t.TEXTURE0+W-1:ge=Z);let Ue=Q[ge];Ue===void 0&&(Ue={type:void 0,texture:void 0},Q[ge]=Ue),(Ue.type!==de||Ue.texture!==Ye)&&(Z!==ge&&(t.activeTexture(ge),Z=ge),t.bindTexture(de,Ye||pe[de]),Ue.type=de,Ue.texture=Ye)}function z(){const de=Q[Z];de!==void 0&&de.type!==void 0&&(t.bindTexture(de.type,null),de.type=void 0,de.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function ne(){try{t.compressedTexImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ve(){try{t.texSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function we(){try{t.texSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ye(){try{t.compressedTexSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function nt(){try{t.compressedTexSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Be(){try{t.texStorage2D(...arguments)}catch(de){de("WebGLState:",de)}}function ue(){try{t.texStorage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Ve(){try{t.texImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Fe(){try{t.texImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function oe(de){X.equals(de)===!1&&(t.scissor(de.x,de.y,de.z,de.w),X.copy(de))}function Je(de){te.equals(de)===!1&&(t.viewport(de.x,de.y,de.z,de.w),te.copy(de))}function He(de,Ye){let ge=u.get(Ye);ge===void 0&&(ge=new WeakMap,u.set(Ye,ge));let Ue=ge.get(de);Ue===void 0&&(Ue=t.getUniformBlockIndex(Ye,de.name),ge.set(de,Ue))}function Ke(de,Ye){const Ue=u.get(Ye).get(de);c.get(Ye)!==Ue&&(t.uniformBlockBinding(Ye,Ue,de.__bindingPointIndex),c.set(Ye,Ue))}function ct(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),s.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Z=null,Q={},f={},g=new WeakMap,m=[],x=null,v=!1,y=null,b=null,M=null,S=null,A=null,T=null,k=null,N=new _n(0,0,0),I=0,C=!1,D=null,F=null,O=null,q=null,R=null,X.set(0,0,t.canvas.width,t.canvas.height),te.set(0,0,t.canvas.width,t.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:xe,disable:Ne,bindFramebuffer:ie,drawBuffers:be,useProgram:je,setBlending:H,setMaterial:B,setFlipSided:re,setCullFace:V,setLineWidth:J,setPolygonOffset:se,setScissorTest:Ae,activeTexture:Pe,bindTexture:Se,unbindTexture:z,compressedTexImage2D:L,compressedTexImage3D:ne,texImage2D:Ve,texImage3D:Fe,updateUBOMapping:He,uniformBlockBinding:Ke,texStorage2D:Be,texStorage3D:ue,texSubImage2D:ve,texSubImage3D:we,compressedTexSubImage2D:ye,compressedTexSubImage3D:nt,scissor:oe,viewport:Je,reset:ct}}function NDe(t,e,n,r,i,a,s){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new cn,d=new WeakMap;let f;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(z,L){return m?new OffscreenCanvas(z,L):kw("canvas")}function v(z,L,ne){let ve=1;const we=Se(z);if((we.width>ne||we.height>ne)&&(ve=ne/Math.max(we.width,we.height)),ve<1)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap||typeof VideoFrame<"u"&&z instanceof VideoFrame){const ye=Math.floor(ve*we.width),nt=Math.floor(ve*we.height);f===void 0&&(f=x(ye,nt));const Be=L?x(ye,nt):f;return Be.width=ye,Be.height=nt,Be.getContext("2d").drawImage(z,0,0,ye,nt),Yt("WebGLRenderer: Texture has been resized from ("+we.width+"x"+we.height+") to ("+ye+"x"+nt+")."),Be}else return"data"in z&&Yt("WebGLRenderer: Image in DataTexture is too big ("+we.width+"x"+we.height+")."),z;return z}function y(z){return z.generateMipmaps}function b(z){t.generateMipmap(z)}function M(z){return z.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:z.isWebGL3DRenderTarget?t.TEXTURE_3D:z.isWebGLArrayRenderTarget||z.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function S(z,L,ne,ve,we=!1){if(z!==null){if(t[z]!==void 0)return t[z];Yt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let ye=L;if(L===t.RED&&(ne===t.FLOAT&&(ye=t.R32F),ne===t.HALF_FLOAT&&(ye=t.R16F),ne===t.UNSIGNED_BYTE&&(ye=t.R8)),L===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.R8UI),ne===t.UNSIGNED_SHORT&&(ye=t.R16UI),ne===t.UNSIGNED_INT&&(ye=t.R32UI),ne===t.BYTE&&(ye=t.R8I),ne===t.SHORT&&(ye=t.R16I),ne===t.INT&&(ye=t.R32I)),L===t.RG&&(ne===t.FLOAT&&(ye=t.RG32F),ne===t.HALF_FLOAT&&(ye=t.RG16F),ne===t.UNSIGNED_BYTE&&(ye=t.RG8)),L===t.RG_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.RG8UI),ne===t.UNSIGNED_SHORT&&(ye=t.RG16UI),ne===t.UNSIGNED_INT&&(ye=t.RG32UI),ne===t.BYTE&&(ye=t.RG8I),ne===t.SHORT&&(ye=t.RG16I),ne===t.INT&&(ye=t.RG32I)),L===t.RGB_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.RGB8UI),ne===t.UNSIGNED_SHORT&&(ye=t.RGB16UI),ne===t.UNSIGNED_INT&&(ye=t.RGB32UI),ne===t.BYTE&&(ye=t.RGB8I),ne===t.SHORT&&(ye=t.RGB16I),ne===t.INT&&(ye=t.RGB32I)),L===t.RGBA_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.RGBA8UI),ne===t.UNSIGNED_SHORT&&(ye=t.RGBA16UI),ne===t.UNSIGNED_INT&&(ye=t.RGBA32UI),ne===t.BYTE&&(ye=t.RGBA8I),ne===t.SHORT&&(ye=t.RGBA16I),ne===t.INT&&(ye=t.RGBA32I)),L===t.RGB&&(ne===t.UNSIGNED_INT_5_9_9_9_REV&&(ye=t.RGB9_E5),ne===t.UNSIGNED_INT_10F_11F_11F_REV&&(ye=t.R11F_G11F_B10F)),L===t.RGBA){const nt=we?Cw:Cn.getTransfer(ve);ne===t.FLOAT&&(ye=t.RGBA32F),ne===t.HALF_FLOAT&&(ye=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ye=nt===qn?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ye=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ye=t.RGB5_A1)}return(ye===t.R16F||ye===t.R32F||ye===t.RG16F||ye===t.RG32F||ye===t.RGBA16F||ye===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function A(z,L){let ne;return z?L===null||L===Qh||L===V0?ne=t.DEPTH24_STENCIL8:L===gc?ne=t.DEPTH32F_STENCIL8:L===$0&&(ne=t.DEPTH24_STENCIL8,Yt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Qh||L===V0?ne=t.DEPTH_COMPONENT24:L===gc?ne=t.DEPTH_COMPONENT32F:L===$0&&(ne=t.DEPTH_COMPONENT16),ne}function T(z,L){return y(z)===!0||z.isFramebufferTexture&&z.minFilter!==ws&&z.minFilter!==ro?Math.log2(Math.max(L.width,L.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?L.mipmaps.length:1}function k(z){const L=z.target;L.removeEventListener("dispose",k),I(L),L.isVideoTexture&&d.delete(L)}function N(z){const L=z.target;L.removeEventListener("dispose",N),D(L)}function I(z){const L=r.get(z);if(L.__webglInit===void 0)return;const ne=z.source,ve=g.get(ne);if(ve){const we=ve[L.__cacheKey];we.usedTimes--,we.usedTimes===0&&C(z),Object.keys(ve).length===0&&g.delete(ne)}r.remove(z)}function C(z){const L=r.get(z);t.deleteTexture(L.__webglTexture);const ne=z.source,ve=g.get(ne);delete ve[L.__cacheKey],s.memory.textures--}function D(z){const L=r.get(z);if(z.depthTexture&&(z.depthTexture.dispose(),r.remove(z.depthTexture)),z.isWebGLCubeRenderTarget)for(let ve=0;ve<6;ve++){if(Array.isArray(L.__webglFramebuffer[ve]))for(let we=0;we<L.__webglFramebuffer[ve].length;we++)t.deleteFramebuffer(L.__webglFramebuffer[ve][we]);else t.deleteFramebuffer(L.__webglFramebuffer[ve]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[ve])}else{if(Array.isArray(L.__webglFramebuffer))for(let ve=0;ve<L.__webglFramebuffer.length;ve++)t.deleteFramebuffer(L.__webglFramebuffer[ve]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ve=0;ve<L.__webglColorRenderbuffer.length;ve++)L.__webglColorRenderbuffer[ve]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[ve]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const ne=z.textures;for(let ve=0,we=ne.length;ve<we;ve++){const ye=r.get(ne[ve]);ye.__webglTexture&&(t.deleteTexture(ye.__webglTexture),s.memory.textures--),r.remove(ne[ve])}r.remove(z)}let F=0;function O(){F=0}function q(){const z=F;return z>=i.maxTextures&&Yt("WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+i.maxTextures),F+=1,z}function R(z){const L=[];return L.push(z.wrapS),L.push(z.wrapT),L.push(z.wrapR||0),L.push(z.magFilter),L.push(z.minFilter),L.push(z.anisotropy),L.push(z.internalFormat),L.push(z.format),L.push(z.type),L.push(z.generateMipmaps),L.push(z.premultiplyAlpha),L.push(z.flipY),L.push(z.unpackAlignment),L.push(z.colorSpace),L.join()}function W(z,L){const ne=r.get(z);if(z.isVideoTexture&&Ae(z),z.isRenderTargetTexture===!1&&z.isExternalTexture!==!0&&z.version>0&&ne.__version!==z.version){const ve=z.image;if(ve===null)Yt("WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)Yt("WebGLRenderer: Texture marked for update but image is incomplete");else{pe(ne,z,L);return}}else z.isExternalTexture&&(ne.__webglTexture=z.sourceTexture?z.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+L)}function K(z,L){const ne=r.get(z);if(z.isRenderTargetTexture===!1&&z.version>0&&ne.__version!==z.version){pe(ne,z,L);return}else z.isExternalTexture&&(ne.__webglTexture=z.sourceTexture?z.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+L)}function G(z,L){const ne=r.get(z);if(z.isRenderTargetTexture===!1&&z.version>0&&ne.__version!==z.version){pe(ne,z,L);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+L)}function ee(z,L){const ne=r.get(z);if(z.version>0&&ne.__version!==z.version){xe(ne,z,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+L)}const Z={[K3]:t.REPEAT,[mc]:t.CLAMP_TO_EDGE,[X3]:t.MIRRORED_REPEAT},Q={[ws]:t.NEAREST,[JCe]:t.NEAREST_MIPMAP_NEAREST,[Ov]:t.NEAREST_MIPMAP_LINEAR,[ro]:t.LINEAR,[fC]:t.LINEAR_MIPMAP_NEAREST,[gh]:t.LINEAR_MIPMAP_LINEAR},U={[rNe]:t.NEVER,[cNe]:t.ALWAYS,[iNe]:t.LESS,[KY]:t.LEQUAL,[aNe]:t.EQUAL,[lNe]:t.GEQUAL,[sNe]:t.GREATER,[oNe]:t.NOTEQUAL};function $(z,L){if(L.type===gc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===ro||L.magFilter===fC||L.magFilter===Ov||L.magFilter===gh||L.minFilter===ro||L.minFilter===fC||L.minFilter===Ov||L.minFilter===gh)&&Yt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(z,t.TEXTURE_WRAP_S,Z[L.wrapS]),t.texParameteri(z,t.TEXTURE_WRAP_T,Z[L.wrapT]),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,Z[L.wrapR]),t.texParameteri(z,t.TEXTURE_MAG_FILTER,Q[L.magFilter]),t.texParameteri(z,t.TEXTURE_MIN_FILTER,Q[L.minFilter]),L.compareFunction&&(t.texParameteri(z,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(z,t.TEXTURE_COMPARE_FUNC,U[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===ws||L.minFilter!==Ov&&L.minFilter!==gh||L.type===gc&&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(z,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function X(z,L){let ne=!1;z.__webglInit===void 0&&(z.__webglInit=!0,L.addEventListener("dispose",k));const ve=L.source;let we=g.get(ve);we===void 0&&(we={},g.set(ve,we));const ye=R(L);if(ye!==z.__cacheKey){we[ye]===void 0&&(we[ye]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,ne=!0),we[ye].usedTimes++;const nt=we[z.__cacheKey];nt!==void 0&&(we[z.__cacheKey].usedTimes--,nt.usedTimes===0&&C(L)),z.__cacheKey=ye,z.__webglTexture=we[ye].texture}return ne}function te(z,L,ne){return Math.floor(Math.floor(z/ne)/L)}function fe(z,L,ne,ve){const ye=z.updateRanges;if(ye.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,ne,ve,L.data);else{ye.sort((Fe,oe)=>Fe.start-oe.start);let nt=0;for(let Fe=1;Fe<ye.length;Fe++){const oe=ye[nt],Je=ye[Fe],He=oe.start+oe.count,Ke=te(Je.start,L.width,4),ct=te(oe.start,L.width,4);Je.start<=He+1&&Ke===ct&&te(Je.start+Je.count-1,L.width,4)===Ke?oe.count=Math.max(oe.count,Je.start+Je.count-oe.start):(++nt,ye[nt]=Je)}ye.length=nt+1;const Be=t.getParameter(t.UNPACK_ROW_LENGTH),ue=t.getParameter(t.UNPACK_SKIP_PIXELS),Ve=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Fe=0,oe=ye.length;Fe<oe;Fe++){const Je=ye[Fe],He=Math.floor(Je.start/4),Ke=Math.ceil(Je.count/4),ct=He%L.width,de=Math.floor(He/L.width),Ye=Ke,ge=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ct),t.pixelStorei(t.UNPACK_SKIP_ROWS,de),n.texSubImage2D(t.TEXTURE_2D,0,ct,de,Ye,ge,ne,ve,L.data)}z.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Be),t.pixelStorei(t.UNPACK_SKIP_PIXELS,ue),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ve)}}function pe(z,L,ne){let ve=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ve=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ve=t.TEXTURE_3D);const we=X(z,L),ye=L.source;n.bindTexture(ve,z.__webglTexture,t.TEXTURE0+ne);const nt=r.get(ye);if(ye.version!==nt.__version||we===!0){n.activeTexture(t.TEXTURE0+ne);const Be=Cn.getPrimaries(Cn.workingColorSpace),ue=L.colorSpace===Lu?null:Cn.getPrimaries(L.colorSpace),Ve=L.colorSpace===Lu||Be===ue?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);let Fe=v(L.image,!1,i.maxTextureSize);Fe=Pe(L,Fe);const oe=a.convert(L.format,L.colorSpace),Je=a.convert(L.type);let He=S(L.internalFormat,oe,Je,L.colorSpace,L.isVideoTexture);$(ve,L);let Ke;const ct=L.mipmaps,de=L.isVideoTexture!==!0,Ye=nt.__version===void 0||we===!0,ge=ye.dataReady,Ue=T(L,Fe);if(L.isDepthTexture)He=A(L.format===W0,L.type),Ye&&(de?n.texStorage2D(t.TEXTURE_2D,1,He,Fe.width,Fe.height):n.texImage2D(t.TEXTURE_2D,0,He,Fe.width,Fe.height,0,oe,Je,null));else if(L.isDataTexture)if(ct.length>0){de&&Ye&&n.texStorage2D(t.TEXTURE_2D,Ue,He,ct[0].width,ct[0].height);for(let Ce=0,_e=ct.length;Ce<_e;Ce++)Ke=ct[Ce],de?ge&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ke.width,Ke.height,oe,Je,Ke.data):n.texImage2D(t.TEXTURE_2D,Ce,He,Ke.width,Ke.height,0,oe,Je,Ke.data);L.generateMipmaps=!1}else de?(Ye&&n.texStorage2D(t.TEXTURE_2D,Ue,He,Fe.width,Fe.height),ge&&fe(L,Fe,oe,Je)):n.texImage2D(t.TEXTURE_2D,0,He,Fe.width,Fe.height,0,oe,Je,Fe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){de&&Ye&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,He,ct[0].width,ct[0].height,Fe.depth);for(let Ce=0,_e=ct.length;Ce<_e;Ce++)if(Ke=ct[Ce],L.format!==Do)if(oe!==null)if(de){if(ge)if(L.layerUpdates.size>0){const ce=cH(Ke.width,Ke.height,L.format,L.type);for(const st of L.layerUpdates){const xt=Ke.data.subarray(st*ce/Ke.data.BYTES_PER_ELEMENT,(st+1)*ce/Ke.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,st,Ke.width,Ke.height,1,oe,xt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ke.width,Ke.height,Fe.depth,oe,Ke.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ce,He,Ke.width,Ke.height,Fe.depth,0,Ke.data,0,0);else Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else de?ge&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ke.width,Ke.height,Fe.depth,oe,Je,Ke.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ce,He,Ke.width,Ke.height,Fe.depth,0,oe,Je,Ke.data)}else{de&&Ye&&n.texStorage2D(t.TEXTURE_2D,Ue,He,ct[0].width,ct[0].height);for(let Ce=0,_e=ct.length;Ce<_e;Ce++)Ke=ct[Ce],L.format!==Do?oe!==null?de?ge&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ce,0,0,Ke.width,Ke.height,oe,Ke.data):n.compressedTexImage2D(t.TEXTURE_2D,Ce,He,Ke.width,Ke.height,0,Ke.data):Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):de?ge&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ke.width,Ke.height,oe,Je,Ke.data):n.texImage2D(t.TEXTURE_2D,Ce,He,Ke.width,Ke.height,0,oe,Je,Ke.data)}else if(L.isDataArrayTexture)if(de){if(Ye&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,He,Fe.width,Fe.height,Fe.depth),ge)if(L.layerUpdates.size>0){const Ce=cH(Fe.width,Fe.height,L.format,L.type);for(const _e of L.layerUpdates){const ce=Fe.data.subarray(_e*Ce/Fe.data.BYTES_PER_ELEMENT,(_e+1)*Ce/Fe.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,_e,Fe.width,Fe.height,1,oe,Je,ce)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Fe.width,Fe.height,Fe.depth,oe,Je,Fe.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,He,Fe.width,Fe.height,Fe.depth,0,oe,Je,Fe.data);else if(L.isData3DTexture)de?(Ye&&n.texStorage3D(t.TEXTURE_3D,Ue,He,Fe.width,Fe.height,Fe.depth),ge&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Fe.width,Fe.height,Fe.depth,oe,Je,Fe.data)):n.texImage3D(t.TEXTURE_3D,0,He,Fe.width,Fe.height,Fe.depth,0,oe,Je,Fe.data);else if(L.isFramebufferTexture){if(Ye)if(de)n.texStorage2D(t.TEXTURE_2D,Ue,He,Fe.width,Fe.height);else{let Ce=Fe.width,_e=Fe.height;for(let ce=0;ce<Ue;ce++)n.texImage2D(t.TEXTURE_2D,ce,He,Ce,_e,0,oe,Je,null),Ce>>=1,_e>>=1}}else if(ct.length>0){if(de&&Ye){const Ce=Se(ct[0]);n.texStorage2D(t.TEXTURE_2D,Ue,He,Ce.width,Ce.height)}for(let Ce=0,_e=ct.length;Ce<_e;Ce++)Ke=ct[Ce],de?ge&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,oe,Je,Ke):n.texImage2D(t.TEXTURE_2D,Ce,He,oe,Je,Ke);L.generateMipmaps=!1}else if(de){if(Ye){const Ce=Se(Fe);n.texStorage2D(t.TEXTURE_2D,Ue,He,Ce.width,Ce.height)}ge&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe,Je,Fe)}else n.texImage2D(t.TEXTURE_2D,0,He,oe,Je,Fe);y(L)&&b(ve),nt.__version=ye.version,L.onUpdate&&L.onUpdate(L)}z.__version=L.version}function xe(z,L,ne){if(L.image.length!==6)return;const ve=X(z,L),we=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,z.__webglTexture,t.TEXTURE0+ne);const ye=r.get(we);if(we.version!==ye.__version||ve===!0){n.activeTexture(t.TEXTURE0+ne);const nt=Cn.getPrimaries(Cn.workingColorSpace),Be=L.colorSpace===Lu?null:Cn.getPrimaries(L.colorSpace),ue=L.colorSpace===Lu||nt===Be?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ue);const Ve=L.isCompressedTexture||L.image[0].isCompressedTexture,Fe=L.image[0]&&L.image[0].isDataTexture,oe=[];for(let _e=0;_e<6;_e++)!Ve&&!Fe?oe[_e]=v(L.image[_e],!0,i.maxCubemapSize):oe[_e]=Fe?L.image[_e].image:L.image[_e],oe[_e]=Pe(L,oe[_e]);const Je=oe[0],He=a.convert(L.format,L.colorSpace),Ke=a.convert(L.type),ct=S(L.internalFormat,He,Ke,L.colorSpace),de=L.isVideoTexture!==!0,Ye=ye.__version===void 0||ve===!0,ge=we.dataReady;let Ue=T(L,Je);$(t.TEXTURE_CUBE_MAP,L);let Ce;if(Ve){de&&Ye&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,ct,Je.width,Je.height);for(let _e=0;_e<6;_e++){Ce=oe[_e].mipmaps;for(let ce=0;ce<Ce.length;ce++){const st=Ce[ce];L.format!==Do?He!==null?de?ge&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,0,0,st.width,st.height,He,st.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,ct,st.width,st.height,0,st.data):Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,0,0,st.width,st.height,He,Ke,st.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,ct,st.width,st.height,0,He,Ke,st.data)}}}else{if(Ce=L.mipmaps,de&&Ye){Ce.length>0&&Ue++;const _e=Se(oe[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,ct,_e.width,_e.height)}for(let _e=0;_e<6;_e++)if(Fe){de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,oe[_e].width,oe[_e].height,He,Ke,oe[_e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,ct,oe[_e].width,oe[_e].height,0,He,Ke,oe[_e].data);for(let ce=0;ce<Ce.length;ce++){const xt=Ce[ce].image[_e].image;de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,0,0,xt.width,xt.height,He,Ke,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,ct,xt.width,xt.height,0,He,Ke,xt.data)}}else{de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,He,Ke,oe[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,ct,He,Ke,oe[_e]);for(let ce=0;ce<Ce.length;ce++){const st=Ce[ce];de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,0,0,He,Ke,st.image[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,ct,He,Ke,st.image[_e])}}}y(L)&&b(t.TEXTURE_CUBE_MAP),ye.__version=we.version,L.onUpdate&&L.onUpdate(L)}z.__version=L.version}function Ne(z,L,ne,ve,we,ye){const nt=a.convert(ne.format,ne.colorSpace),Be=a.convert(ne.type),ue=S(ne.internalFormat,nt,Be,ne.colorSpace),Ve=r.get(L),Fe=r.get(ne);if(Fe.__renderTarget=L,!Ve.__hasExternalTextures){const oe=Math.max(1,L.width>>ye),Je=Math.max(1,L.height>>ye);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ye,ue,oe,Je,L.depth,0,nt,Be,null):n.texImage2D(we,ye,ue,oe,Je,0,nt,Be,null)}n.bindFramebuffer(t.FRAMEBUFFER,z),se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ve,we,Fe.__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,ve,we,Fe.__webglTexture,ye),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ie(z,L,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,z),L.depthBuffer){const ve=L.depthTexture,we=ve&&ve.isDepthTexture?ve.type:null,ye=A(L.stencilBuffer,we),nt=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Be=J(L);se(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Be,ye,L.width,L.height):ne?t.renderbufferStorageMultisample(t.RENDERBUFFER,Be,ye,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ye,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,nt,t.RENDERBUFFER,z)}else{const ve=L.textures;for(let we=0;we<ve.length;we++){const ye=ve[we],nt=a.convert(ye.format,ye.colorSpace),Be=a.convert(ye.type),ue=S(ye.internalFormat,nt,Be,ye.colorSpace),Ve=J(L);ne&&se(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,ue,L.width,L.height):se(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,ue,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ue,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function be(z,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,z),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ve=r.get(L.depthTexture);ve.__renderTarget=L,(!ve.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),W(L.depthTexture,0);const we=ve.__webglTexture,ye=J(L);if(L.depthTexture.format===G0)se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0);else if(L.depthTexture.format===W0)se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0);else throw new Error("Unknown depthTexture format")}function je(z){const L=r.get(z),ne=z.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==z.depthTexture){const ve=z.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ve){const we=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ve.removeEventListener("dispose",we)};ve.addEventListener("dispose",we),L.__depthDisposeCallback=we}L.__boundDepthTexture=ve}if(z.depthTexture&&!L.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");const ve=z.texture.mipmaps;ve&&ve.length>0?be(L.__webglFramebuffer[0],z):be(L.__webglFramebuffer,z)}else if(ne){L.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ve]),L.__webglDepthbuffer[ve]===void 0)L.__webglDepthbuffer[ve]=t.createRenderbuffer(),ie(L.__webglDepthbuffer[ve],z,!1);else{const we=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ye=L.__webglDepthbuffer[ve];t.bindRenderbuffer(t.RENDERBUFFER,ye),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ye)}}else{const ve=z.texture.mipmaps;if(ve&&ve.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),ie(L.__webglDepthbuffer,z,!1);else{const we=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ye=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ye),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ye)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(z,L,ne){const ve=r.get(z);L!==void 0&&Ne(ve.__webglFramebuffer,z,z.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&je(z)}function ht(z){const L=z.texture,ne=r.get(z),ve=r.get(L);z.addEventListener("dispose",N);const we=z.textures,ye=z.isWebGLCubeRenderTarget===!0,nt=we.length>1;if(nt||(ve.__webglTexture===void 0&&(ve.__webglTexture=t.createTexture()),ve.__version=L.version,s.memory.textures++),ye){ne.__webglFramebuffer=[];for(let Be=0;Be<6;Be++)if(L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer[Be]=[];for(let ue=0;ue<L.mipmaps.length;ue++)ne.__webglFramebuffer[Be][ue]=t.createFramebuffer()}else ne.__webglFramebuffer[Be]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Be=0;Be<L.mipmaps.length;Be++)ne.__webglFramebuffer[Be]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(nt)for(let Be=0,ue=we.length;Be<ue;Be++){const Ve=r.get(we[Be]);Ve.__webglTexture===void 0&&(Ve.__webglTexture=t.createTexture(),s.memory.textures++)}if(z.samples>0&&se(z)===!1){ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Be=0;Be<we.length;Be++){const ue=we[Be];ne.__webglColorRenderbuffer[Be]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[Be]);const Ve=a.convert(ue.format,ue.colorSpace),Fe=a.convert(ue.type),oe=S(ue.internalFormat,Ve,Fe,ue.colorSpace,z.isXRRenderTarget===!0),Je=J(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,Je,oe,z.width,z.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Be,t.RENDERBUFFER,ne.__webglColorRenderbuffer[Be])}t.bindRenderbuffer(t.RENDERBUFFER,null),z.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),ie(ne.__webglDepthRenderbuffer,z,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ye){n.bindTexture(t.TEXTURE_CUBE_MAP,ve.__webglTexture),$(t.TEXTURE_CUBE_MAP,L);for(let Be=0;Be<6;Be++)if(L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)Ne(ne.__webglFramebuffer[Be][ue],z,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,ue);else Ne(ne.__webglFramebuffer[Be],z,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0);y(L)&&b(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(nt){for(let Be=0,ue=we.length;Be<ue;Be++){const Ve=we[Be],Fe=r.get(Ve);let oe=t.TEXTURE_2D;(z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(oe=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(oe,Fe.__webglTexture),$(oe,Ve),Ne(ne.__webglFramebuffer,z,Ve,t.COLOR_ATTACHMENT0+Be,oe,0),y(Ve)&&b(oe)}n.unbindTexture()}else{let Be=t.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(Be=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Be,ve.__webglTexture),$(Be,L),L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)Ne(ne.__webglFramebuffer[ue],z,L,t.COLOR_ATTACHMENT0,Be,ue);else Ne(ne.__webglFramebuffer,z,L,t.COLOR_ATTACHMENT0,Be,0);y(L)&&b(Be),n.unbindTexture()}z.depthBuffer&&je(z)}function H(z){const L=z.textures;for(let ne=0,ve=L.length;ne<ve;ne++){const we=L[ne];if(y(we)){const ye=M(z),nt=r.get(we).__webglTexture;n.bindTexture(ye,nt),b(ye),n.unbindTexture()}}}const B=[],re=[];function V(z){if(z.samples>0){if(se(z)===!1){const L=z.textures,ne=z.width,ve=z.height;let we=t.COLOR_BUFFER_BIT;const ye=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,nt=r.get(z),Be=L.length>1;if(Be)for(let Ve=0;Ve<L.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,nt.__webglMultisampledFramebuffer);const ue=z.texture.mipmaps;ue&&ue.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,nt.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,nt.__webglFramebuffer);for(let Ve=0;Ve<L.length;Ve++){if(z.resolveDepthBuffer&&(z.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),z.stencilBuffer&&z.resolveStencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),Be){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,nt.__webglColorRenderbuffer[Ve]);const Fe=r.get(L[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Fe,0)}t.blitFramebuffer(0,0,ne,ve,0,0,ne,ve,we,t.NEAREST),c===!0&&(B.length=0,re.length=0,B.push(t.COLOR_ATTACHMENT0+Ve),z.depthBuffer&&z.resolveDepthBuffer===!1&&(B.push(ye),re.push(ye),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,re)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,B))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Be)for(let Ve=0;Ve<L.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,nt.__webglColorRenderbuffer[Ve]);const Fe=r.get(L[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,Fe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,nt.__webglMultisampledFramebuffer)}else if(z.depthBuffer&&z.resolveDepthBuffer===!1&&c){const L=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function J(z){return Math.min(i.maxSamples,z.samples)}function se(z){const L=r.get(z);return z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ae(z){const L=s.render.frame;d.get(z)!==L&&(d.set(z,L),z.update())}function Pe(z,L){const ne=z.colorSpace,ve=z.format,we=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||ne!==km&&ne!==Lu&&(Cn.getTransfer(ne)===qn?(ve!==Do||we!==gl)&&Yt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):zr("WebGLTextures: Unsupported texture color space:",ne)),L}function Se(z){return typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement?(u.width=z.naturalWidth||z.width,u.height=z.naturalHeight||z.height):typeof VideoFrame<"u"&&z instanceof VideoFrame?(u.width=z.displayWidth,u.height=z.displayHeight):(u.width=z.width,u.height=z.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=O,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=ee,this.rebindTextures=he,this.setupRenderTarget=ht,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=V,this.setupDepthRenderbuffer=je,this.setupFrameBufferTexture=Ne,this.useMultisampledRTT=se}function kDe(t,e){function n(r,i=Lu){let a;const s=Cn.getTransfer(i);if(r===gl)return t.UNSIGNED_BYTE;if(r===Jj)return t.UNSIGNED_SHORT_4_4_4_4;if(r===eO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===HY)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===$Y)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===zY)return t.BYTE;if(r===BY)return t.SHORT;if(r===$0)return t.UNSIGNED_SHORT;if(r===Qj)return t.INT;if(r===Qh)return t.UNSIGNED_INT;if(r===gc)return t.FLOAT;if(r===og)return t.HALF_FLOAT;if(r===VY)return t.ALPHA;if(r===GY)return t.RGB;if(r===Do)return t.RGBA;if(r===G0)return t.DEPTH_COMPONENT;if(r===W0)return t.DEPTH_STENCIL;if(r===WY)return t.RED;if(r===tO)return t.RED_INTEGER;if(r===nO)return t.RG;if(r===rO)return t.RG_INTEGER;if(r===iO)return t.RGBA_INTEGER;if(r===s1||r===o1||r===l1||r===c1)if(s===qn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===s1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===o1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===l1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===c1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===s1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===o1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===l1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===c1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Y3||r===Z3||r===Q3||r===J3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===Y3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Z3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Q3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===J3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===eP||r===tP||r===nP)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===eP||r===tP)return s===qn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===nP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===rP||r===iP||r===aP||r===sP||r===oP||r===lP||r===cP||r===uP||r===dP||r===hP||r===fP||r===pP||r===mP||r===gP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===rP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===iP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===aP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===sP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===oP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===lP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===cP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===uP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===dP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===hP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===fP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===pP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===mP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===gP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===xP||r===bP||r===yP)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===xP)return s===qn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===bP)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===yP)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===vP||r===_P||r===wP||r===SP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===vP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===_P)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===wP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===SP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===V0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const PDe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,RDe=`
- 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 DDe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new fZ(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:PDe,fragmentShader:RDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new xl(new uO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let jDe=class extends mf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,o="local-floor",c=1,u=null,d=null,f=null,g=null,m=null,x=null;const v=typeof XRWebGLBinding<"u",y=new DDe,b={},M=n.getContextAttributes();let S=null,A=null;const T=[],k=[],N=new cn;let I=null;const C=new Ys;C.viewport=new Yr;const D=new Ys;D.viewport=new Yr;const F=[C,D],O=new ZNe;let q=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(pe){let xe=T[pe];return xe===void 0&&(xe=new OC,T[pe]=xe),xe.getTargetRaySpace()},this.getControllerGrip=function(pe){let xe=T[pe];return xe===void 0&&(xe=new OC,T[pe]=xe),xe.getGripSpace()},this.getHand=function(pe){let xe=T[pe];return xe===void 0&&(xe=new OC,T[pe]=xe),xe.getHandSpace()};function W(pe){const xe=k.indexOf(pe.inputSource);if(xe===-1)return;const Ne=T[xe];Ne!==void 0&&(Ne.update(pe.inputSource,pe.frame,u||s),Ne.dispatchEvent({type:pe.type,data:pe.inputSource}))}function K(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",G);for(let pe=0;pe<T.length;pe++){const xe=k[pe];xe!==null&&(k[pe]=null,T[pe].disconnect(xe))}q=null,R=null,y.reset();for(const pe in b)delete b[pe];e.setRenderTarget(S),m=null,g=null,f=null,i=null,A=null,fe.stop(),r.isPresenting=!1,e.setPixelRatio(I),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(pe){a=pe,r.isPresenting===!0&&Yt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(pe){o=pe,r.isPresenting===!0&&Yt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(pe){u=pe},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f===null&&v&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(pe){if(i=pe,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",K),i.addEventListener("inputsourceschange",G),M.xrCompatible!==!0&&await n.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(N),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ne=null,ie=null,be=null;M.depth&&(be=M.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ne=M.stencil?W0:G0,ie=M.stencil?V0:Qh);const je={colorFormat:n.RGBA8,depthFormat:be,scaleFactor:a};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:Do,type:gl,depthTexture:new hZ(g.textureWidth,g.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,Ne),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Ne={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,Ne),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),A=new ef(m.framebufferWidth,m.framebufferHeight,{format:Do,type:gl,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,s=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 y.getDepthTexture()};function G(pe){for(let xe=0;xe<pe.removed.length;xe++){const Ne=pe.removed[xe],ie=k.indexOf(Ne);ie>=0&&(k[ie]=null,T[ie].disconnect(Ne))}for(let xe=0;xe<pe.added.length;xe++){const Ne=pe.added[xe];let ie=k.indexOf(Ne);if(ie===-1){for(let je=0;je<T.length;je++)if(je>=k.length){k.push(Ne),ie=je;break}else if(k[je]===null){k[je]=Ne,ie=je;break}if(ie===-1)break}const be=T[ie];be&&be.connect(Ne)}}const ee=new Qe,Z=new Qe;function Q(pe,xe,Ne){ee.setFromMatrixPosition(xe.matrixWorld),Z.setFromMatrixPosition(Ne.matrixWorld);const ie=ee.distanceTo(Z),be=xe.projectionMatrix.elements,je=Ne.projectionMatrix.elements,he=be[14]/(be[10]-1),ht=be[14]/(be[10]+1),H=(be[9]+1)/be[5],B=(be[9]-1)/be[5],re=(be[8]-1)/be[0],V=(je[8]+1)/je[0],J=he*re,se=he*V,Ae=ie/(-re+V),Pe=Ae*-re;if(xe.matrixWorld.decompose(pe.position,pe.quaternion,pe.scale),pe.translateX(Pe),pe.translateZ(Ae),pe.matrixWorld.compose(pe.position,pe.quaternion,pe.scale),pe.matrixWorldInverse.copy(pe.matrixWorld).invert(),be[10]===-1)pe.projectionMatrix.copy(xe.projectionMatrix),pe.projectionMatrixInverse.copy(xe.projectionMatrixInverse);else{const Se=he+Ae,z=ht+Ae,L=J-Pe,ne=se+(ie-Pe),ve=H*ht/z*Se,we=B*ht/z*Se;pe.projectionMatrix.makePerspective(L,ne,ve,we,Se,z),pe.projectionMatrixInverse.copy(pe.projectionMatrix).invert()}}function U(pe,xe){xe===null?pe.matrixWorld.copy(pe.matrix):pe.matrixWorld.multiplyMatrices(xe.matrixWorld,pe.matrix),pe.matrixWorldInverse.copy(pe.matrixWorld).invert()}this.updateCamera=function(pe){if(i===null)return;let xe=pe.near,Ne=pe.far;y.texture!==null&&(y.depthNear>0&&(xe=y.depthNear),y.depthFar>0&&(Ne=y.depthFar)),O.near=D.near=C.near=xe,O.far=D.far=C.far=Ne,(q!==O.near||R!==O.far)&&(i.updateRenderState({depthNear:O.near,depthFar:O.far}),q=O.near,R=O.far),O.layers.mask=pe.layers.mask|6,C.layers.mask=O.layers.mask&3,D.layers.mask=O.layers.mask&5;const ie=pe.parent,be=O.cameras;U(O,ie);for(let je=0;je<be.length;je++)U(be[je],ie);be.length===2?Q(O,C,D):O.projectionMatrix.copy(C.projectionMatrix),$(pe,O,ie)};function $(pe,xe,Ne){Ne===null?pe.matrix.copy(xe.matrixWorld):(pe.matrix.copy(Ne.matrixWorld),pe.matrix.invert(),pe.matrix.multiply(xe.matrixWorld)),pe.matrix.decompose(pe.position,pe.quaternion,pe.scale),pe.updateMatrixWorld(!0),pe.projectionMatrix.copy(xe.projectionMatrix),pe.projectionMatrixInverse.copy(xe.projectionMatrixInverse),pe.isPerspectiveCamera&&(pe.fov=MP*2*Math.atan(1/pe.projectionMatrix.elements[5]),pe.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(g===null&&m===null))return c},this.setFoveation=function(pe){c=pe,g!==null&&(g.fixedFoveation=pe),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=pe)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(O)},this.getCameraTexture=function(pe){return b[pe]};let X=null;function te(pe,xe){if(d=xe.getViewerPose(u||s),x=xe,d!==null){const Ne=d.views;m!==null&&(e.setRenderTargetFramebuffer(A,m.framebuffer),e.setRenderTarget(A));let ie=!1;Ne.length!==O.cameras.length&&(O.cameras.length=0,ie=!0);for(let ht=0;ht<Ne.length;ht++){const H=Ne[ht];let B=null;if(m!==null)B=m.getViewport(H);else{const V=f.getViewSubImage(g,H);B=V.viewport,ht===0&&(e.setRenderTargetTextures(A,V.colorTexture,V.depthStencilTexture),e.setRenderTarget(A))}let re=F[ht];re===void 0&&(re=new Ys,re.layers.enable(ht),re.viewport=new Yr,F[ht]=re),re.matrix.fromArray(H.transform.matrix),re.matrix.decompose(re.position,re.quaternion,re.scale),re.projectionMatrix.fromArray(H.projectionMatrix),re.projectionMatrixInverse.copy(re.projectionMatrix).invert(),re.viewport.set(B.x,B.y,B.width,B.height),ht===0&&(O.matrix.copy(re.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),ie===!0&&O.cameras.push(re)}const be=i.enabledFeatures;if(be&&be.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){f=r.getBinding();const ht=f.getDepthInformation(Ne[0]);ht&&ht.isValid&&ht.texture&&y.init(ht,i.renderState)}if(be&&be.includes("camera-access")&&v){e.state.unbindTexture(),f=r.getBinding();for(let ht=0;ht<Ne.length;ht++){const H=Ne[ht].camera;if(H){let B=b[H];B||(B=new fZ,b[H]=B);const re=f.getCameraImage(H);B.sourceTexture=re}}}}for(let Ne=0;Ne<T.length;Ne++){const ie=k[Ne],be=T[Ne];ie!==null&&be!==void 0&&be.update(ie,xe,u||s)}X&&X(pe,xe),xe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:xe}),x=null}const fe=new xZ;fe.setAnimationLoop(te),this.setAnimationLoop=function(pe){X=pe},this.dispose=function(){}}};const qd=new hd,ODe=new ri;function LDe(t,e){function n(y,b){y.matrixAutoUpdate===!0&&y.updateMatrix(),b.value.copy(y.matrix)}function r(y,b){b.color.getRGB(y.fogColor.value,lZ(t)),b.isFog?(y.fogNear.value=b.near,y.fogFar.value=b.far):b.isFogExp2&&(y.fogDensity.value=b.density)}function i(y,b,M,S,A){b.isMeshBasicMaterial||b.isMeshLambertMaterial?a(y,b):b.isMeshToonMaterial?(a(y,b),f(y,b)):b.isMeshPhongMaterial?(a(y,b),d(y,b)):b.isMeshStandardMaterial?(a(y,b),g(y,b),b.isMeshPhysicalMaterial&&m(y,b,A)):b.isMeshMatcapMaterial?(a(y,b),x(y,b)):b.isMeshDepthMaterial?a(y,b):b.isMeshDistanceMaterial?(a(y,b),v(y,b)):b.isMeshNormalMaterial?a(y,b):b.isLineBasicMaterial?(s(y,b),b.isLineDashedMaterial&&o(y,b)):b.isPointsMaterial?c(y,b,M,S):b.isSpriteMaterial?u(y,b):b.isShadowMaterial?(y.color.value.copy(b.color),y.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function a(y,b){y.opacity.value=b.opacity,b.color&&y.diffuse.value.copy(b.color),b.emissive&&y.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.bumpMap&&(y.bumpMap.value=b.bumpMap,n(b.bumpMap,y.bumpMapTransform),y.bumpScale.value=b.bumpScale,b.side===qa&&(y.bumpScale.value*=-1)),b.normalMap&&(y.normalMap.value=b.normalMap,n(b.normalMap,y.normalMapTransform),y.normalScale.value.copy(b.normalScale),b.side===qa&&y.normalScale.value.negate()),b.displacementMap&&(y.displacementMap.value=b.displacementMap,n(b.displacementMap,y.displacementMapTransform),y.displacementScale.value=b.displacementScale,y.displacementBias.value=b.displacementBias),b.emissiveMap&&(y.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,y.emissiveMapTransform)),b.specularMap&&(y.specularMap.value=b.specularMap,n(b.specularMap,y.specularMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest);const M=e.get(b),S=M.envMap,A=M.envMapRotation;S&&(y.envMap.value=S,qd.copy(A),qd.x*=-1,qd.y*=-1,qd.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(qd.y*=-1,qd.z*=-1),y.envMapRotation.value.setFromMatrix4(ODe.makeRotationFromEuler(qd)),y.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=b.reflectivity,y.ior.value=b.ior,y.refractionRatio.value=b.refractionRatio),b.lightMap&&(y.lightMap.value=b.lightMap,y.lightMapIntensity.value=b.lightMapIntensity,n(b.lightMap,y.lightMapTransform)),b.aoMap&&(y.aoMap.value=b.aoMap,y.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,y.aoMapTransform))}function s(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform))}function o(y,b){y.dashSize.value=b.dashSize,y.totalSize.value=b.dashSize+b.gapSize,y.scale.value=b.scale}function c(y,b,M,S){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.size.value=b.size*M,y.scale.value=S*.5,b.map&&(y.map.value=b.map,n(b.map,y.uvTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function u(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.rotation.value=b.rotation,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function d(y,b){y.specular.value.copy(b.specular),y.shininess.value=Math.max(b.shininess,1e-4)}function f(y,b){b.gradientMap&&(y.gradientMap.value=b.gradientMap)}function g(y,b){y.metalness.value=b.metalness,b.metalnessMap&&(y.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,y.metalnessMapTransform)),y.roughness.value=b.roughness,b.roughnessMap&&(y.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,y.roughnessMapTransform)),b.envMap&&(y.envMapIntensity.value=b.envMapIntensity)}function m(y,b,M){y.ior.value=b.ior,b.sheen>0&&(y.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),y.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(y.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,y.sheenColorMapTransform)),b.sheenRoughnessMap&&(y.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,y.sheenRoughnessMapTransform))),b.clearcoat>0&&(y.clearcoat.value=b.clearcoat,y.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(y.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,y.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(y.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===qa&&y.clearcoatNormalScale.value.negate())),b.dispersion>0&&(y.dispersion.value=b.dispersion),b.iridescence>0&&(y.iridescence.value=b.iridescence,y.iridescenceIOR.value=b.iridescenceIOR,y.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(y.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,y.iridescenceMapTransform)),b.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),b.transmission>0&&(y.transmission.value=b.transmission,y.transmissionSamplerMap.value=M.texture,y.transmissionSamplerSize.value.set(M.width,M.height),b.transmissionMap&&(y.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,y.transmissionMapTransform)),y.thickness.value=b.thickness,b.thicknessMap&&(y.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=b.attenuationDistance,y.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(y.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(y.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=b.specularIntensity,y.specularColor.value.copy(b.specularColor),b.specularColorMap&&(y.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,y.specularColorMapTransform)),b.specularIntensityMap&&(y.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,b){b.matcap&&(y.matcap.value=b.matcap)}function v(y,b){const M=e.get(b).light;y.referencePosition.value.setFromMatrixPosition(M.matrixWorld),y.nearDistance.value=M.shadow.camera.near,y.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function IDe(t,e,n,r){let i={},a={},s=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const A=S.program;r.uniformBlockBinding(M,A)}function u(M,S){let A=i[M.id];A===void 0&&(x(M),A=d(M),i[M.id]=A,M.addEventListener("dispose",y));const T=S.program;r.updateUBOMapping(M,T);const k=e.render.frame;a[M.id]!==k&&(g(M),a[M.id]=k)}function d(M){const S=f();M.__bindingPointIndex=S;const A=t.createBuffer(),T=M.__size,k=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return zr("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const S=i[M.id],A=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,N=A.length;k<N;k++){const I=Array.isArray(A[k])?A[k]:[A[k]];for(let C=0,D=I.length;C<D;C++){const F=I[C];if(m(F,k,C,T)===!0){const O=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],G=v(K);typeof K=="number"||typeof K=="boolean"?(F.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,O+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+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,O,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,S,A,T){const k=M.value,N=S+"_"+A;if(T[N]===void 0)return typeof k=="number"||typeof k=="boolean"?T[N]=k:T[N]=k.clone(),!0;{const I=T[N];if(typeof k=="number"||typeof k=="boolean"){if(I!==k)return T[N]=k,!0}else if(I.equals(k)===!1)return I.copy(k),!0}return!1}function x(M){const S=M.uniforms;let A=0;const T=16;for(let N=0,I=S.length;N<I;N++){const C=Array.isArray(S[N])?S[N]:[S[N]];for(let D=0,F=C.length;D<F;D++){const O=C[D],q=Array.isArray(O.value)?O.value:[O.value];for(let R=0,W=q.length;R<W;R++){const K=q[R],G=v(K),ee=A%T,Z=ee%G.boundary,Q=ee+Z;A+=Z,Q!==0&&T-Q<G.storage&&(A+=T-Q),O.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=A,A+=G.storage}}}const k=A%T;return k>0&&(A+=T-k),M.__size=A,M.__cache={},this}function v(M){const S={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?Yt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Yt("WebGLRenderer: Unsupported uniform value type.",M),S}function y(M){const S=M.target;S.removeEventListener("dispose",y);const A=s.indexOf(S.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete a[S.id]}function b(){for(const M in i)t.deleteBuffer(i[M]);s=[],i={},a={}}return{bind:c,update:u,dispose:b}}const FDe=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let Xl=null;function UDe(){return Xl===null&&(Xl=new UNe(FDe,32,32,nO,og),Xl.minFilter=ro,Xl.magFilter=ro,Xl.wrapS=mc,Xl.wrapT=mc,Xl.generateMipmaps=!1,Xl.needsUpdate=!0),Xl}let zDe=class{constructor(e={}){const{canvas:n=uNe(),context:r=null,depth:i=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let 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=s;const x=new Set([iO,rO,tO]),v=new Set([gl,Qh,$0,V0,Jj,eO]),y=new Uint32Array(4),b=new Int32Array(4);let M=null,S=null;const A=[],T=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Xu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const k=this;let N=!1;this._outputColorSpace=qs;let I=0,C=0,D=null,F=-1,O=null;const q=new Yr,R=new Yr;let W=null;const K=new _n(0);let G=0,ee=n.width,Z=n.height,Q=1,U=null,$=null;const X=new Yr(0,0,ee,Z),te=new Yr(0,0,ee,Z);let fe=!1;const pe=new cO;let xe=!1,Ne=!1;const ie=new ri,be=new Qe,je=new Yr,he={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ht=!1;function H(){return D===null?Q:1}let B=r;function re(ae,Me){return n.getContext(ae,Me)}try{const ae={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${Yj}`),n.addEventListener("webglcontextlost",Ce,!1),n.addEventListener("webglcontextrestored",_e,!1),n.addEventListener("webglcontextcreationerror",ce,!1),B===null){const Me="webgl2";if(B=re(Me,ae),B===null)throw re(Me)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ae){throw ae("WebGLRenderer: "+ae.message),ae}let V,J,se,Ae,Pe,Se,z,L,ne,ve,we,ye,nt,Be,ue,Ve,Fe,oe,Je,He,Ke,ct,de,Ye;function ge(){V=new KPe(B),V.init(),ct=new kDe(B,V),J=new UPe(B,V,e,ct),se=new CDe(B,V),J.reversedDepthBuffer&&g&&se.buffers.depth.setReversed(!0),Ae=new ZPe(B),Pe=new mDe,Se=new NDe(B,V,se,Pe,J,ct,Ae),z=new BPe(k),L=new qPe(k),ne=new tke(B),de=new IPe(B,ne),ve=new XPe(B,ne,Ae,de),we=new JPe(B,ve,ne,Ae),Je=new QPe(B,J,Se),Ve=new zPe(Pe),ye=new pDe(k,z,L,V,J,de,Ve),nt=new LDe(k,Pe),Be=new xDe,ue=new SDe(V),oe=new LPe(k,z,L,se,we,m,c),Fe=new ADe(k,we,J),Ye=new IDe(B,Ae,J,se),He=new FPe(B,V,Ae),Ke=new YPe(B,V,Ae),Ae.programs=ye.programs,k.capabilities=J,k.extensions=V,k.properties=Pe,k.renderLists=Be,k.shadowMap=Fe,k.state=se,k.info=Ae}ge();const Ue=new jDe(k,B);this.xr=Ue,this.getContext=function(){return B},this.getContextAttributes=function(){return B.getContextAttributes()},this.forceContextLoss=function(){const ae=V.get("WEBGL_lose_context");ae&&ae.loseContext()},this.forceContextRestore=function(){const ae=V.get("WEBGL_lose_context");ae&&ae.restoreContext()},this.getPixelRatio=function(){return Q},this.setPixelRatio=function(ae){ae!==void 0&&(Q=ae,this.setSize(ee,Z,!1))},this.getSize=function(ae){return ae.set(ee,Z)},this.setSize=function(ae,Me,Ie=!0){if(Ue.isPresenting){Yt("WebGLRenderer: Can't change size while VR device is presenting.");return}ee=ae,Z=Me,n.width=Math.floor(ae*Q),n.height=Math.floor(Me*Q),Ie===!0&&(n.style.width=ae+"px",n.style.height=Me+"px"),this.setViewport(0,0,ae,Me)},this.getDrawingBufferSize=function(ae){return ae.set(ee*Q,Z*Q).floor()},this.setDrawingBufferSize=function(ae,Me,Ie){ee=ae,Z=Me,Q=Ie,n.width=Math.floor(ae*Ie),n.height=Math.floor(Me*Ie),this.setViewport(0,0,ae,Me)},this.getCurrentViewport=function(ae){return ae.copy(q)},this.getViewport=function(ae){return ae.copy(X)},this.setViewport=function(ae,Me,Ie,Oe){ae.isVector4?X.set(ae.x,ae.y,ae.z,ae.w):X.set(ae,Me,Ie,Oe),se.viewport(q.copy(X).multiplyScalar(Q).round())},this.getScissor=function(ae){return ae.copy(te)},this.setScissor=function(ae,Me,Ie,Oe){ae.isVector4?te.set(ae.x,ae.y,ae.z,ae.w):te.set(ae,Me,Ie,Oe),se.scissor(R.copy(te).multiplyScalar(Q).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(ae){se.setScissorTest(fe=ae)},this.setOpaqueSort=function(ae){U=ae},this.setTransparentSort=function(ae){$=ae},this.getClearColor=function(ae){return ae.copy(oe.getClearColor())},this.setClearColor=function(){oe.setClearColor(...arguments)},this.getClearAlpha=function(){return oe.getClearAlpha()},this.setClearAlpha=function(){oe.setClearAlpha(...arguments)},this.clear=function(ae=!0,Me=!0,Ie=!0){let Oe=0;if(ae){let Te=!1;if(D!==null){const ot=D.texture.format;Te=x.has(ot)}if(Te){const ot=D.texture.type,ft=v.has(ot),yt=oe.getClearColor(),bt=oe.getClearAlpha(),Lt=yt.r,Tt=yt.g,mt=yt.b;ft?(y[0]=Lt,y[1]=Tt,y[2]=mt,y[3]=bt,B.clearBufferuiv(B.COLOR,0,y)):(b[0]=Lt,b[1]=Tt,b[2]=mt,b[3]=bt,B.clearBufferiv(B.COLOR,0,b))}else Oe|=B.COLOR_BUFFER_BIT}Me&&(Oe|=B.DEPTH_BUFFER_BIT),Ie&&(Oe|=B.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B.clear(Oe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Ce,!1),n.removeEventListener("webglcontextrestored",_e,!1),n.removeEventListener("webglcontextcreationerror",ce,!1),oe.dispose(),Be.dispose(),ue.dispose(),Pe.dispose(),z.dispose(),L.dispose(),we.dispose(),de.dispose(),Ye.dispose(),ye.dispose(),Ue.dispose(),Ue.removeEventListener("sessionstart",On),Ue.removeEventListener("sessionend",Mi),si.stop()};function Ce(ae){ae.preventDefault(),F6("WebGLRenderer: Context Lost."),N=!0}function _e(){F6("WebGLRenderer: Context Restored."),N=!1;const ae=Ae.autoReset,Me=Fe.enabled,Ie=Fe.autoUpdate,Oe=Fe.needsUpdate,Te=Fe.type;ge(),Ae.autoReset=ae,Fe.enabled=Me,Fe.autoUpdate=Ie,Fe.needsUpdate=Oe,Fe.type=Te}function ce(ae){zr("WebGLRenderer: A WebGL context could not be created. Reason: ",ae.statusMessage)}function st(ae){const Me=ae.target;Me.removeEventListener("dispose",st),xt(Me)}function xt(ae){St(ae),Pe.remove(ae)}function St(ae){const Me=Pe.get(ae).programs;Me!==void 0&&(Me.forEach(function(Ie){ye.releaseProgram(Ie)}),ae.isShaderMaterial&&ye.releaseShaderCache(ae))}this.renderBufferDirect=function(ae,Me,Ie,Oe,Te,ot){Me===null&&(Me=he);const ft=Te.isMesh&&Te.matrixWorld.determinant()<0,yt=me(ae,Me,Ie,Oe,Te);se.setMaterial(Oe,ft);let bt=Ie.index,Lt=1;if(Oe.wireframe===!0){if(bt=ve.getWireframeAttribute(Ie),bt===void 0)return;Lt=2}const Tt=Ie.drawRange,mt=Ie.attributes.position;let Xt=Tt.start*Lt,Ut=(Tt.start+Tt.count)*Lt;ot!==null&&(Xt=Math.max(Xt,ot.start*Lt),Ut=Math.min(Ut,(ot.start+ot.count)*Lt)),bt!==null?(Xt=Math.max(Xt,0),Ut=Math.min(Ut,bt.count)):mt!=null&&(Xt=Math.max(Xt,0),Ut=Math.min(Ut,mt.count));const an=Ut-Xt;if(an<0||an===1/0)return;de.setup(Te,Oe,yt,Ie,bt);let hn,bn=He;if(bt!==null&&(hn=ne.get(bt),bn=Ke,bn.setIndex(hn)),Te.isMesh)Oe.wireframe===!0?(se.setLineWidth(Oe.wireframeLinewidth*H()),bn.setMode(B.LINES)):bn.setMode(B.TRIANGLES);else if(Te.isLine){let Ft=Oe.linewidth;Ft===void 0&&(Ft=1),se.setLineWidth(Ft*H()),Te.isLineSegments?bn.setMode(B.LINES):Te.isLineLoop?bn.setMode(B.LINE_LOOP):bn.setMode(B.LINE_STRIP)}else Te.isPoints?bn.setMode(B.POINTS):Te.isSprite&&bn.setMode(B.TRIANGLES);if(Te.isBatchedMesh)if(Te._multiDrawInstances!==null)q0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),bn.renderMultiDrawInstances(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount,Te._multiDrawInstances);else if(V.get("WEBGL_multi_draw"))bn.renderMultiDraw(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount);else{const Ft=Te._multiDrawStarts,Jt=Te._multiDrawCounts,tn=Te._multiDrawCount,Ar=bt?ne.get(bt).bytesPerElement:1,Or=Pe.get(Oe).currentProgram.getUniforms();for(let Dn=0;Dn<tn;Dn++)Or.setValue(B,"_gl_DrawID",Dn),bn.render(Ft[Dn]/Ar,Jt[Dn])}else if(Te.isInstancedMesh)bn.renderInstances(Xt,an,Te.count);else if(Ie.isInstancedBufferGeometry){const Ft=Ie._maxInstanceCount!==void 0?Ie._maxInstanceCount:1/0,Jt=Math.min(Ie.instanceCount,Ft);bn.renderInstances(Xt,an,Jt)}else bn.render(Xt,an)};function Qt(ae,Me,Ie){ae.transparent===!0&&ae.side===rl&&ae.forceSinglePass===!1?(ae.side=qa,ae.needsUpdate=!0,jr(ae,Me,Ie),ae.side=dd,ae.needsUpdate=!0,jr(ae,Me,Ie),ae.side=rl):jr(ae,Me,Ie)}this.compile=function(ae,Me,Ie=null){Ie===null&&(Ie=ae),S=ue.get(Ie),S.init(Me),T.push(S),Ie.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Me.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),ae!==Ie&&ae.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Me.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),S.setupLights();const Oe=new Set;return ae.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 yt=ot[ft];Qt(yt,Ie,Te),Oe.add(yt)}else Qt(ot,Ie,Te),Oe.add(ot)}),S=T.pop(),Oe},this.compileAsync=function(ae,Me,Ie=null){const Oe=this.compile(ae,Me,Ie);return new Promise(Te=>{function ot(){if(Oe.forEach(function(ft){Pe.get(ft).currentProgram.isReady()&&Oe.delete(ft)}),Oe.size===0){Te(ae);return}setTimeout(ot,10)}V.get("KHR_parallel_shader_compile")!==null?ot():setTimeout(ot,10)})};let Ot=null;function Vt(ae){Ot&&Ot(ae)}function On(){si.stop()}function Mi(){si.start()}const si=new xZ;si.setAnimationLoop(Vt),typeof self<"u"&&si.setContext(self),this.setAnimationLoop=function(ae){Ot=ae,Ue.setAnimationLoop(ae),ae===null?si.stop():si.start()},Ue.addEventListener("sessionstart",On),Ue.addEventListener("sessionend",Mi),this.render=function(ae,Me){if(Me!==void 0&&Me.isCamera!==!0){zr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(ae.matrixWorldAutoUpdate===!0&&ae.updateMatrixWorld(),Me.parent===null&&Me.matrixWorldAutoUpdate===!0&&Me.updateMatrixWorld(),Ue.enabled===!0&&Ue.isPresenting===!0&&(Ue.cameraAutoUpdate===!0&&Ue.updateCamera(Me),Me=Ue.getCamera()),ae.isScene===!0&&ae.onBeforeRender(k,ae,Me,D),S=ue.get(ae,T.length),S.init(Me),T.push(S),ie.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),pe.setFromProjectionMatrix(ie,ol,Me.reversedDepth),Ne=this.localClippingEnabled,xe=Ve.init(this.clippingPlanes,Ne),M=Be.get(ae,A.length),M.init(),A.push(M),Ue.enabled===!0&&Ue.isPresenting===!0){const ot=k.xr.getDepthSensingMesh();ot!==null&&Ei(ot,Me,-1/0,k.sortObjects)}Ei(ae,Me,0,k.sortObjects),M.finish(),k.sortObjects===!0&&M.sort(U,$),ht=Ue.enabled===!1||Ue.isPresenting===!1||Ue.hasDepthSensing()===!1,ht&&oe.addToRenderList(M,ae),this.info.render.frame++,xe===!0&&Ve.beginShadows();const Ie=S.state.shadowsArray;Fe.render(Ie,ae,Me),xe===!0&&Ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const Oe=M.opaque,Te=M.transmissive;if(S.setupLights(),Me.isArrayCamera){const ot=Me.cameras;if(Te.length>0)for(let ft=0,yt=ot.length;ft<yt;ft++){const bt=ot[ft];ra(Oe,Te,ae,bt)}ht&&oe.render(ae);for(let ft=0,yt=ot.length;ft<yt;ft++){const bt=ot[ft];zi(M,ae,bt,bt.viewport)}}else Te.length>0&&ra(Oe,Te,ae,Me),ht&&oe.render(ae),zi(M,ae,Me);D!==null&&C===0&&(Se.updateMultisampleRenderTarget(D),Se.updateRenderTargetMipmap(D)),ae.isScene===!0&&ae.onAfterRender(k,ae,Me),de.resetDefaultState(),F=-1,O=null,T.pop(),T.length>0?(S=T[T.length-1],xe===!0&&Ve.setGlobalState(k.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?M=A[A.length-1]:M=null};function Ei(ae,Me,Ie,Oe){if(ae.visible===!1)return;if(ae.layers.test(Me.layers)){if(ae.isGroup)Ie=ae.renderOrder;else if(ae.isLOD)ae.autoUpdate===!0&&ae.update(Me);else if(ae.isLight)S.pushLight(ae),ae.castShadow&&S.pushShadow(ae);else if(ae.isSprite){if(!ae.frustumCulled||pe.intersectsSprite(ae)){Oe&&je.setFromMatrixPosition(ae.matrixWorld).applyMatrix4(ie);const ft=we.update(ae),yt=ae.material;yt.visible&&M.push(ae,ft,yt,Ie,je.z,null)}}else if((ae.isMesh||ae.isLine||ae.isPoints)&&(!ae.frustumCulled||pe.intersectsObject(ae))){const ft=we.update(ae),yt=ae.material;if(Oe&&(ae.boundingSphere!==void 0?(ae.boundingSphere===null&&ae.computeBoundingSphere(),je.copy(ae.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),je.copy(ft.boundingSphere.center)),je.applyMatrix4(ae.matrixWorld).applyMatrix4(ie)),Array.isArray(yt)){const bt=ft.groups;for(let Lt=0,Tt=bt.length;Lt<Tt;Lt++){const mt=bt[Lt],Xt=yt[mt.materialIndex];Xt&&Xt.visible&&M.push(ae,ft,Xt,Ie,je.z,mt)}}else yt.visible&&M.push(ae,ft,yt,Ie,je.z,null)}}const ot=ae.children;for(let ft=0,yt=ot.length;ft<yt;ft++)Ei(ot[ft],Me,Ie,Oe)}function zi(ae,Me,Ie,Oe){const{opaque:Te,transmissive:ot,transparent:ft}=ae;S.setupLightsView(Ie),xe===!0&&Ve.setGlobalState(k.clippingPlanes,Ie),Oe&&se.viewport(q.copy(Oe)),Te.length>0&&Hr(Te,Me,Ie),ot.length>0&&Hr(ot,Me,Ie),ft.length>0&&Hr(ft,Me,Ie),se.buffers.depth.setTest(!0),se.buffers.depth.setMask(!0),se.buffers.color.setMask(!0),se.setPolygonOffset(!1)}function ra(ae,Me,Ie,Oe){if((Ie.isScene===!0?Ie.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[Oe.id]===void 0&&(S.state.transmissionRenderTarget[Oe.id]=new ef(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")||V.has("EXT_color_buffer_float")?og:gl,minFilter:gh,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Cn.workingColorSpace}));const ot=S.state.transmissionRenderTarget[Oe.id],ft=Oe.viewport||q;ot.setSize(ft.z*k.transmissionResolutionScale,ft.w*k.transmissionResolutionScale);const yt=k.getRenderTarget(),bt=k.getActiveCubeFace(),Lt=k.getActiveMipmapLevel();k.setRenderTarget(ot),k.getClearColor(K),G=k.getClearAlpha(),G<1&&k.setClearColor(16777215,.5),k.clear(),ht&&oe.render(Ie);const Tt=k.toneMapping;k.toneMapping=Xu;const mt=Oe.viewport;if(Oe.viewport!==void 0&&(Oe.viewport=void 0),S.setupLightsView(Oe),xe===!0&&Ve.setGlobalState(k.clippingPlanes,Oe),Hr(ae,Ie,Oe),Se.updateMultisampleRenderTarget(ot),Se.updateRenderTargetMipmap(ot),V.has("WEBGL_multisampled_render_to_texture")===!1){let Xt=!1;for(let Ut=0,an=Me.length;Ut<an;Ut++){const hn=Me[Ut],{object:bn,geometry:Ft,material:Jt,group:tn}=hn;if(Jt.side===rl&&bn.layers.test(Oe.layers)){const Ar=Jt.side;Jt.side=qa,Jt.needsUpdate=!0,br(bn,Ie,Oe,Ft,Jt,tn),Jt.side=Ar,Jt.needsUpdate=!0,Xt=!0}}Xt===!0&&(Se.updateMultisampleRenderTarget(ot),Se.updateRenderTargetMipmap(ot))}k.setRenderTarget(yt,bt,Lt),k.setClearColor(K,G),mt!==void 0&&(Oe.viewport=mt),k.toneMapping=Tt}function Hr(ae,Me,Ie){const Oe=Me.isScene===!0?Me.overrideMaterial:null;for(let Te=0,ot=ae.length;Te<ot;Te++){const ft=ae[Te],{object:yt,geometry:bt,group:Lt}=ft;let Tt=ft.material;Tt.allowOverride===!0&&Oe!==null&&(Tt=Oe),yt.layers.test(Ie.layers)&&br(yt,Me,Ie,bt,Tt,Lt)}}function br(ae,Me,Ie,Oe,Te,ot){ae.onBeforeRender(k,Me,Ie,Oe,Te,ot),ae.modelViewMatrix.multiplyMatrices(Ie.matrixWorldInverse,ae.matrixWorld),ae.normalMatrix.getNormalMatrix(ae.modelViewMatrix),Te.onBeforeRender(k,Me,Ie,Oe,ae,ot),Te.transparent===!0&&Te.side===rl&&Te.forceSinglePass===!1?(Te.side=qa,Te.needsUpdate=!0,k.renderBufferDirect(Ie,Me,Oe,Te,ae,ot),Te.side=dd,Te.needsUpdate=!0,k.renderBufferDirect(Ie,Me,Oe,Te,ae,ot),Te.side=rl):k.renderBufferDirect(Ie,Me,Oe,Te,ae,ot),ae.onAfterRender(k,Me,Ie,Oe,Te,ot)}function jr(ae,Me,Ie){Me.isScene!==!0&&(Me=he);const Oe=Pe.get(ae),Te=S.state.lights,ot=S.state.shadowsArray,ft=Te.state.version,yt=ye.getParameters(ae,Te.state,ot,Me,Ie),bt=ye.getProgramCacheKey(yt);let Lt=Oe.programs;Oe.environment=ae.isMeshStandardMaterial?Me.environment:null,Oe.fog=Me.fog,Oe.envMap=(ae.isMeshStandardMaterial?L:z).get(ae.envMap||Oe.environment),Oe.envMapRotation=Oe.environment!==null&&ae.envMap===null?Me.environmentRotation:ae.envMapRotation,Lt===void 0&&(ae.addEventListener("dispose",st),Lt=new Map,Oe.programs=Lt);let Tt=Lt.get(bt);if(Tt!==void 0){if(Oe.currentProgram===Tt&&Oe.lightsStateVersion===ft)return Hc(ae,yt),Tt}else yt.uniforms=ye.getUniforms(ae),ae.onBeforeCompile(yt,k),Tt=ye.acquireProgram(yt,bt),Lt.set(bt,Tt),Oe.uniforms=yt.uniforms;const mt=Oe.uniforms;return(!ae.isShaderMaterial&&!ae.isRawShaderMaterial||ae.clipping===!0)&&(mt.clippingPlanes=Ve.uniform),Hc(ae,yt),Oe.needsLights=rt(ae),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=Tt,Oe.uniformsList=null,Tt}function mo(ae){if(ae.uniformsList===null){const Me=ae.currentProgram.getUniforms();ae.uniformsList=f1.seqWithValue(Me.seq,ae.uniforms)}return ae.uniformsList}function Hc(ae,Me){const Ie=Pe.get(ae);Ie.outputColorSpace=Me.outputColorSpace,Ie.batching=Me.batching,Ie.batchingColor=Me.batchingColor,Ie.instancing=Me.instancing,Ie.instancingColor=Me.instancingColor,Ie.instancingMorph=Me.instancingMorph,Ie.skinning=Me.skinning,Ie.morphTargets=Me.morphTargets,Ie.morphNormals=Me.morphNormals,Ie.morphColors=Me.morphColors,Ie.morphTargetsCount=Me.morphTargetsCount,Ie.numClippingPlanes=Me.numClippingPlanes,Ie.numIntersection=Me.numClipIntersection,Ie.vertexAlphas=Me.vertexAlphas,Ie.vertexTangents=Me.vertexTangents,Ie.toneMapping=Me.toneMapping}function me(ae,Me,Ie,Oe,Te){Me.isScene!==!0&&(Me=he),Se.resetTextureUnits();const ot=Me.fog,ft=Oe.isMeshStandardMaterial?Me.environment:null,yt=D===null?k.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:km,bt=(Oe.isMeshStandardMaterial?L:z).get(Oe.envMap||ft),Lt=Oe.vertexColors===!0&&!!Ie.attributes.color&&Ie.attributes.color.itemSize===4,Tt=!!Ie.attributes.tangent&&(!!Oe.normalMap||Oe.anisotropy>0),mt=!!Ie.morphAttributes.position,Xt=!!Ie.morphAttributes.normal,Ut=!!Ie.morphAttributes.color;let an=Xu;Oe.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(an=k.toneMapping);const hn=Ie.morphAttributes.position||Ie.morphAttributes.normal||Ie.morphAttributes.color,bn=hn!==void 0?hn.length:0,Ft=Pe.get(Oe),Jt=S.state.lights;if(xe===!0&&(Ne===!0||ae!==O)){const Ti=ae===O&&Oe.id===F;Ve.setState(Oe,ae,Ti)}let tn=!1;Oe.version===Ft.__version?(Ft.needsLights&&Ft.lightsStateVersion!==Jt.state.version||Ft.outputColorSpace!==yt||Te.isBatchedMesh&&Ft.batching===!1||!Te.isBatchedMesh&&Ft.batching===!0||Te.isBatchedMesh&&Ft.batchingColor===!0&&Te.colorTexture===null||Te.isBatchedMesh&&Ft.batchingColor===!1&&Te.colorTexture!==null||Te.isInstancedMesh&&Ft.instancing===!1||!Te.isInstancedMesh&&Ft.instancing===!0||Te.isSkinnedMesh&&Ft.skinning===!1||!Te.isSkinnedMesh&&Ft.skinning===!0||Te.isInstancedMesh&&Ft.instancingColor===!0&&Te.instanceColor===null||Te.isInstancedMesh&&Ft.instancingColor===!1&&Te.instanceColor!==null||Te.isInstancedMesh&&Ft.instancingMorph===!0&&Te.morphTexture===null||Te.isInstancedMesh&&Ft.instancingMorph===!1&&Te.morphTexture!==null||Ft.envMap!==bt||Oe.fog===!0&&Ft.fog!==ot||Ft.numClippingPlanes!==void 0&&(Ft.numClippingPlanes!==Ve.numPlanes||Ft.numIntersection!==Ve.numIntersection)||Ft.vertexAlphas!==Lt||Ft.vertexTangents!==Tt||Ft.morphTargets!==mt||Ft.morphNormals!==Xt||Ft.morphColors!==Ut||Ft.toneMapping!==an||Ft.morphTargetsCount!==bn)&&(tn=!0):(tn=!0,Ft.__version=Oe.version);let Ar=Ft.currentProgram;tn===!0&&(Ar=jr(Oe,Me,Te));let Or=!1,Dn=!1,go=!1;const Ln=Ar.getUniforms(),Ai=Ft.uniforms;if(se.useProgram(Ar.program)&&(Or=!0,Dn=!0,go=!0),Oe.id!==F&&(F=Oe.id,Dn=!0),Or||O!==ae){se.buffers.depth.getReversed()&&ae.reversedDepth!==!0&&(ae._reversedDepth=!0,ae.updateProjectionMatrix()),Ln.setValue(B,"projectionMatrix",ae.projectionMatrix),Ln.setValue(B,"viewMatrix",ae.matrixWorldInverse);const Bi=Ln.map.cameraPosition;Bi!==void 0&&Bi.setValue(B,be.setFromMatrixPosition(ae.matrixWorld)),J.logarithmicDepthBuffer&&Ln.setValue(B,"logDepthBufFC",2/(Math.log(ae.far+1)/Math.LN2)),(Oe.isMeshPhongMaterial||Oe.isMeshToonMaterial||Oe.isMeshLambertMaterial||Oe.isMeshBasicMaterial||Oe.isMeshStandardMaterial||Oe.isShaderMaterial)&&Ln.setValue(B,"isOrthographic",ae.isOrthographicCamera===!0),O!==ae&&(O=ae,Dn=!0,go=!0)}if(Te.isSkinnedMesh){Ln.setOptional(B,Te,"bindMatrix"),Ln.setOptional(B,Te,"bindMatrixInverse");const Ti=Te.skeleton;Ti&&(Ti.boneTexture===null&&Ti.computeBoneTexture(),Ln.setValue(B,"boneTexture",Ti.boneTexture,Se))}Te.isBatchedMesh&&(Ln.setOptional(B,Te,"batchingTexture"),Ln.setValue(B,"batchingTexture",Te._matricesTexture,Se),Ln.setOptional(B,Te,"batchingIdTexture"),Ln.setValue(B,"batchingIdTexture",Te._indirectTexture,Se),Ln.setOptional(B,Te,"batchingColorTexture"),Te._colorsTexture!==null&&Ln.setValue(B,"batchingColorTexture",Te._colorsTexture,Se));const oi=Ie.morphAttributes;if((oi.position!==void 0||oi.normal!==void 0||oi.color!==void 0)&&Je.update(Te,Ie,Ar),(Dn||Ft.receiveShadow!==Te.receiveShadow)&&(Ft.receiveShadow=Te.receiveShadow,Ln.setValue(B,"receiveShadow",Te.receiveShadow)),Oe.isMeshGouraudMaterial&&Oe.envMap!==null&&(Ai.envMap.value=bt,Ai.flipEnvMap.value=bt.isCubeTexture&&bt.isRenderTargetTexture===!1?-1:1),Oe.isMeshStandardMaterial&&Oe.envMap===null&&Me.environment!==null&&(Ai.envMapIntensity.value=Me.environmentIntensity),Ai.dfgLUT!==void 0&&(Ai.dfgLUT.value=UDe()),Dn&&(Ln.setValue(B,"toneMappingExposure",k.toneMappingExposure),Ft.needsLights&&$e(Ai,go),ot&&Oe.fog===!0&&nt.refreshFogUniforms(Ai,ot),nt.refreshMaterialUniforms(Ai,Oe,Q,Z,S.state.transmissionRenderTarget[ae.id]),f1.upload(B,mo(Ft),Ai,Se)),Oe.isShaderMaterial&&Oe.uniformsNeedUpdate===!0&&(f1.upload(B,mo(Ft),Ai,Se),Oe.uniformsNeedUpdate=!1),Oe.isSpriteMaterial&&Ln.setValue(B,"center",Te.center),Ln.setValue(B,"modelViewMatrix",Te.modelViewMatrix),Ln.setValue(B,"normalMatrix",Te.normalMatrix),Ln.setValue(B,"modelMatrix",Te.matrixWorld),Oe.isShaderMaterial||Oe.isRawShaderMaterial){const Ti=Oe.uniformsGroups;for(let Bi=0,Vo=Ti.length;Bi<Vo;Bi++){const Al=Ti[Bi];Ye.update(Al,Ar),Ye.bind(Al,Ar)}}return Ar}function $e(ae,Me){ae.ambientLightColor.needsUpdate=Me,ae.lightProbe.needsUpdate=Me,ae.directionalLights.needsUpdate=Me,ae.directionalLightShadows.needsUpdate=Me,ae.pointLights.needsUpdate=Me,ae.pointLightShadows.needsUpdate=Me,ae.spotLights.needsUpdate=Me,ae.spotLightShadows.needsUpdate=Me,ae.rectAreaLights.needsUpdate=Me,ae.hemisphereLights.needsUpdate=Me}function rt(ae){return ae.isMeshLambertMaterial||ae.isMeshToonMaterial||ae.isMeshPhongMaterial||ae.isMeshStandardMaterial||ae.isShadowMaterial||ae.isShaderMaterial&&ae.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(ae,Me,Ie){const Oe=Pe.get(ae);Oe.__autoAllocateDepthBuffer=ae.resolveDepthBuffer===!1,Oe.__autoAllocateDepthBuffer===!1&&(Oe.__useRenderToTexture=!1),Pe.get(ae.texture).__webglTexture=Me,Pe.get(ae.depthTexture).__webglTexture=Oe.__autoAllocateDepthBuffer?void 0:Ie,Oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ae,Me){const Ie=Pe.get(ae);Ie.__webglFramebuffer=Me,Ie.__useDefaultFramebuffer=Me===void 0};const it=B.createFramebuffer();this.setRenderTarget=function(ae,Me=0,Ie=0){D=ae,I=Me,C=Ie;let Oe=!0,Te=null,ot=!1,ft=!1;if(ae){const bt=Pe.get(ae);if(bt.__useDefaultFramebuffer!==void 0)se.bindFramebuffer(B.FRAMEBUFFER,null),Oe=!1;else if(bt.__webglFramebuffer===void 0)Se.setupRenderTarget(ae);else if(bt.__hasExternalTextures)Se.rebindTextures(ae,Pe.get(ae.texture).__webglTexture,Pe.get(ae.depthTexture).__webglTexture);else if(ae.depthBuffer){const mt=ae.depthTexture;if(bt.__boundDepthTexture!==mt){if(mt!==null&&Pe.has(mt)&&(ae.width!==mt.image.width||ae.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Se.setupDepthRenderbuffer(ae)}}const Lt=ae.texture;(Lt.isData3DTexture||Lt.isDataArrayTexture||Lt.isCompressedArrayTexture)&&(ft=!0);const Tt=Pe.get(ae).__webglFramebuffer;ae.isWebGLCubeRenderTarget?(Array.isArray(Tt[Me])?Te=Tt[Me][Ie]:Te=Tt[Me],ot=!0):ae.samples>0&&Se.useMultisampledRTT(ae)===!1?Te=Pe.get(ae).__webglMultisampledFramebuffer:Array.isArray(Tt)?Te=Tt[Ie]:Te=Tt,q.copy(ae.viewport),R.copy(ae.scissor),W=ae.scissorTest}else q.copy(X).multiplyScalar(Q).floor(),R.copy(te).multiplyScalar(Q).floor(),W=fe;if(Ie!==0&&(Te=it),se.bindFramebuffer(B.FRAMEBUFFER,Te)&&Oe&&se.drawBuffers(ae,Te),se.viewport(q),se.scissor(R),se.setScissorTest(W),ot){const bt=Pe.get(ae.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+Me,bt.__webglTexture,Ie)}else if(ft){const bt=Me;for(let Lt=0;Lt<ae.textures.length;Lt++){const Tt=Pe.get(ae.textures[Lt]);B.framebufferTextureLayer(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0+Lt,Tt.__webglTexture,Ie,bt)}}else if(ae!==null&&Ie!==0){const bt=Pe.get(ae.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,bt.__webglTexture,Ie)}F=-1},this.readRenderTargetPixels=function(ae,Me,Ie,Oe,Te,ot,ft,yt=0){if(!(ae&&ae.isWebGLRenderTarget)){zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=Pe.get(ae).__webglFramebuffer;if(ae.isWebGLCubeRenderTarget&&ft!==void 0&&(bt=bt[ft]),bt){se.bindFramebuffer(B.FRAMEBUFFER,bt);try{const Lt=ae.textures[yt],Tt=Lt.format,mt=Lt.type;if(!J.textureFormatReadable(Tt)){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}Me>=0&&Me<=ae.width-Oe&&Ie>=0&&Ie<=ae.height-Te&&(ae.textures.length>1&&B.readBuffer(B.COLOR_ATTACHMENT0+yt),B.readPixels(Me,Ie,Oe,Te,ct.convert(Tt),ct.convert(mt),ot))}finally{const Lt=D!==null?Pe.get(D).__webglFramebuffer:null;se.bindFramebuffer(B.FRAMEBUFFER,Lt)}}},this.readRenderTargetPixelsAsync=async function(ae,Me,Ie,Oe,Te,ot,ft,yt=0){if(!(ae&&ae.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=Pe.get(ae).__webglFramebuffer;if(ae.isWebGLCubeRenderTarget&&ft!==void 0&&(bt=bt[ft]),bt)if(Me>=0&&Me<=ae.width-Oe&&Ie>=0&&Ie<=ae.height-Te){se.bindFramebuffer(B.FRAMEBUFFER,bt);const Lt=ae.textures[yt],Tt=Lt.format,mt=Lt.type;if(!J.textureFormatReadable(Tt))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 Xt=B.createBuffer();B.bindBuffer(B.PIXEL_PACK_BUFFER,Xt),B.bufferData(B.PIXEL_PACK_BUFFER,ot.byteLength,B.STREAM_READ),ae.textures.length>1&&B.readBuffer(B.COLOR_ATTACHMENT0+yt),B.readPixels(Me,Ie,Oe,Te,ct.convert(Tt),ct.convert(mt),0);const Ut=D!==null?Pe.get(D).__webglFramebuffer:null;se.bindFramebuffer(B.FRAMEBUFFER,Ut);const an=B.fenceSync(B.SYNC_GPU_COMMANDS_COMPLETE,0);return B.flush(),await dNe(B,an,4),B.bindBuffer(B.PIXEL_PACK_BUFFER,Xt),B.getBufferSubData(B.PIXEL_PACK_BUFFER,0,ot),B.deleteBuffer(Xt),B.deleteSync(an),ot}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ae,Me=null,Ie=0){const Oe=Math.pow(2,-Ie),Te=Math.floor(ae.image.width*Oe),ot=Math.floor(ae.image.height*Oe),ft=Me!==null?Me.x:0,yt=Me!==null?Me.y:0;Se.setTexture2D(ae,0),B.copyTexSubImage2D(B.TEXTURE_2D,Ie,0,0,ft,yt,Te,ot),se.unbindTexture()};const et=B.createFramebuffer(),Mt=B.createFramebuffer();this.copyTextureToTexture=function(ae,Me,Ie=null,Oe=null,Te=0,ot=null){ot===null&&(Te!==0?(q0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ot=Te,Te=0):ot=0);let ft,yt,bt,Lt,Tt,mt,Xt,Ut,an;const hn=ae.isCompressedTexture?ae.mipmaps[ot]:ae.image;if(Ie!==null)ft=Ie.max.x-Ie.min.x,yt=Ie.max.y-Ie.min.y,bt=Ie.isBox3?Ie.max.z-Ie.min.z:1,Lt=Ie.min.x,Tt=Ie.min.y,mt=Ie.isBox3?Ie.min.z:0;else{const oi=Math.pow(2,-Te);ft=Math.floor(hn.width*oi),yt=Math.floor(hn.height*oi),ae.isDataArrayTexture?bt=hn.depth:ae.isData3DTexture?bt=Math.floor(hn.depth*oi):bt=1,Lt=0,Tt=0,mt=0}Oe!==null?(Xt=Oe.x,Ut=Oe.y,an=Oe.z):(Xt=0,Ut=0,an=0);const bn=ct.convert(Me.format),Ft=ct.convert(Me.type);let Jt;Me.isData3DTexture?(Se.setTexture3D(Me,0),Jt=B.TEXTURE_3D):Me.isDataArrayTexture||Me.isCompressedArrayTexture?(Se.setTexture2DArray(Me,0),Jt=B.TEXTURE_2D_ARRAY):(Se.setTexture2D(Me,0),Jt=B.TEXTURE_2D),B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,Me.flipY),B.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Me.premultiplyAlpha),B.pixelStorei(B.UNPACK_ALIGNMENT,Me.unpackAlignment);const tn=B.getParameter(B.UNPACK_ROW_LENGTH),Ar=B.getParameter(B.UNPACK_IMAGE_HEIGHT),Or=B.getParameter(B.UNPACK_SKIP_PIXELS),Dn=B.getParameter(B.UNPACK_SKIP_ROWS),go=B.getParameter(B.UNPACK_SKIP_IMAGES);B.pixelStorei(B.UNPACK_ROW_LENGTH,hn.width),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,hn.height),B.pixelStorei(B.UNPACK_SKIP_PIXELS,Lt),B.pixelStorei(B.UNPACK_SKIP_ROWS,Tt),B.pixelStorei(B.UNPACK_SKIP_IMAGES,mt);const Ln=ae.isDataArrayTexture||ae.isData3DTexture,Ai=Me.isDataArrayTexture||Me.isData3DTexture;if(ae.isDepthTexture){const oi=Pe.get(ae),Ti=Pe.get(Me),Bi=Pe.get(oi.__renderTarget),Vo=Pe.get(Ti.__renderTarget);se.bindFramebuffer(B.READ_FRAMEBUFFER,Bi.__webglFramebuffer),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,Vo.__webglFramebuffer);for(let Al=0;Al<bt;Al++)Ln&&(B.framebufferTextureLayer(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Pe.get(ae).__webglTexture,Te,mt+Al),B.framebufferTextureLayer(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Pe.get(Me).__webglTexture,ot,an+Al)),B.blitFramebuffer(Lt,Tt,ft,yt,Xt,Ut,ft,yt,B.DEPTH_BUFFER_BIT,B.NEAREST);se.bindFramebuffer(B.READ_FRAMEBUFFER,null),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,null)}else if(Te!==0||ae.isRenderTargetTexture||Pe.has(ae)){const oi=Pe.get(ae),Ti=Pe.get(Me);se.bindFramebuffer(B.READ_FRAMEBUFFER,et),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,Mt);for(let Bi=0;Bi<bt;Bi++)Ln?B.framebufferTextureLayer(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,oi.__webglTexture,Te,mt+Bi):B.framebufferTexture2D(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,oi.__webglTexture,Te),Ai?B.framebufferTextureLayer(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Ti.__webglTexture,ot,an+Bi):B.framebufferTexture2D(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,Ti.__webglTexture,ot),Te!==0?B.blitFramebuffer(Lt,Tt,ft,yt,Xt,Ut,ft,yt,B.COLOR_BUFFER_BIT,B.NEAREST):Ai?B.copyTexSubImage3D(Jt,ot,Xt,Ut,an+Bi,Lt,Tt,ft,yt):B.copyTexSubImage2D(Jt,ot,Xt,Ut,Lt,Tt,ft,yt);se.bindFramebuffer(B.READ_FRAMEBUFFER,null),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,null)}else Ai?ae.isDataTexture||ae.isData3DTexture?B.texSubImage3D(Jt,ot,Xt,Ut,an,ft,yt,bt,bn,Ft,hn.data):Me.isCompressedArrayTexture?B.compressedTexSubImage3D(Jt,ot,Xt,Ut,an,ft,yt,bt,bn,hn.data):B.texSubImage3D(Jt,ot,Xt,Ut,an,ft,yt,bt,bn,Ft,hn):ae.isDataTexture?B.texSubImage2D(B.TEXTURE_2D,ot,Xt,Ut,ft,yt,bn,Ft,hn.data):ae.isCompressedTexture?B.compressedTexSubImage2D(B.TEXTURE_2D,ot,Xt,Ut,hn.width,hn.height,bn,hn.data):B.texSubImage2D(B.TEXTURE_2D,ot,Xt,Ut,ft,yt,bn,Ft,hn);B.pixelStorei(B.UNPACK_ROW_LENGTH,tn),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,Ar),B.pixelStorei(B.UNPACK_SKIP_PIXELS,Or),B.pixelStorei(B.UNPACK_SKIP_ROWS,Dn),B.pixelStorei(B.UNPACK_SKIP_IMAGES,go),ot===0&&Me.generateMipmaps&&B.generateMipmap(Jt),se.unbindTexture()},this.initRenderTarget=function(ae){Pe.get(ae).__webglFramebuffer===void 0&&Se.setupRenderTarget(ae)},this.initTexture=function(ae){ae.isCubeTexture?Se.setTextureCube(ae,0):ae.isData3DTexture?Se.setTexture3D(ae,0):ae.isDataArrayTexture||ae.isCompressedArrayTexture?Se.setTexture2DArray(ae,0):Se.setTexture2D(ae,0),se.unbindTexture()},this.resetState=function(){I=0,C=0,D=null,se.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ol}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Cn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Cn._getUnpackColorSpace()}};const DH={type:"change"},dO={type:"start"},wZ={type:"end"},r_=new sO,jH=new Nu,BDe=Math.cos(70*fNe.DEG2RAD),ci=new Qe,Ba=2*Math.PI,Yn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},VC=1e-6;class HDe extends JNe{constructor(e,n=null){super(e,n),this.state=Yn.NONE,this.target=new Qe,this.cursor=new Qe,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:rm.ROTATE,MIDDLE:rm.DOLLY,RIGHT:rm.PAN},this.touches={ONE:Kp.ROTATE,TWO:Kp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Qe,this._lastQuaternion=new Jh,this._lastTargetPosition=new Qe,this._quat=new Jh().setFromUnitVectors(e.up,new Qe(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new lH,this._sphericalDelta=new lH,this._scale=1,this._panOffset=new Qe,this._rotateStart=new cn,this._rotateEnd=new cn,this._rotateDelta=new cn,this._panStart=new cn,this._panEnd=new cn,this._panDelta=new cn,this._dollyStart=new cn,this._dollyEnd=new cn,this._dollyDelta=new cn,this._dollyDirection=new Qe,this._mouse=new cn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=VDe.bind(this),this._onPointerDown=$De.bind(this),this._onPointerUp=GDe.bind(this),this._onContextMenu=QDe.bind(this),this._onMouseWheel=KDe.bind(this),this._onKeyDown=XDe.bind(this),this._onTouchStart=YDe.bind(this),this._onTouchMove=ZDe.bind(this),this._onMouseDown=WDe.bind(this),this._onMouseMove=qDe.bind(this),this._interceptControlDown=JDe.bind(this),this._interceptControlUp=eje.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(DH),this.update(),this.state=Yn.NONE}update(e=null){const n=this.object.position;ci.copy(n).sub(this.target),ci.applyQuaternion(this._quat),this._spherical.setFromVector3(ci),this.autoRotate&&this.state===Yn.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=Ba:r>Math.PI&&(r-=Ba),i<-Math.PI?i+=Ba:i>Math.PI&&(i-=Ba),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=s!=this._spherical.radius}if(ci.setFromSpherical(this._spherical),ci.applyQuaternion(this._quatInverse),n.copy(this.target).add(ci),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){const o=ci.length();s=this._clampDistance(o*this._scale);const c=o-s;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const o=new Qe(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;const u=new Qe(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(o),this.object.updateMatrixWorld(),s=ci.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;s!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position):(r_.origin.copy(this.object.position),r_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(r_.direction))<BDe?this.object.lookAt(this.target):(jH.setFromNormalAndCoplanarPoint(this.object.up,this.target),r_.intersectPlane(jH,this.target))))}else if(this.object.isOrthographicCamera){const s=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>VC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>VC||this._lastTargetPosition.distanceToSquared(this.target)>VC?(this.dispatchEvent(DH),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ba/60*this.autoRotateSpeed*e:Ba/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){ci.setFromMatrixColumn(n,0),ci.multiplyScalar(-e),this._panOffset.add(ci)}_panUp(e,n){this.screenSpacePanning===!0?ci.setFromMatrixColumn(n,1):(ci.setFromMatrixColumn(n,0),ci.crossVectors(this.object.up,ci)),ci.multiplyScalar(e),this._panOffset.add(ci)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ci.copy(i).sub(this.target);let a=ci.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,s=r.width,o=r.height;this._mouse.x=i/s*2-1,this._mouse.y=-(a/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ba*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ba*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(Ba*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(-Ba*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(Ba*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(-Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ba*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ba*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=(e.pageX+n.x)*.5,o=(e.pageY+n.y)*.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new cn,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function $De(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 VDe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function GDe(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(wZ),this.state=Yn.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function WDe(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case rm.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Yn.DOLLY;break;case rm.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Yn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Yn.ROTATE}break;case rm.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Yn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Yn.PAN}break;default:this.state=Yn.NONE}this.state!==Yn.NONE&&this.dispatchEvent(dO)}function qDe(t){switch(this.state){case Yn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Yn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Yn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function KDe(t){this.enabled===!1||this.enableZoom===!1||this.state!==Yn.NONE||(t.preventDefault(),this.dispatchEvent(dO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(wZ))}function XDe(t){this.enabled!==!1&&this._handleKeyDown(t)}function YDe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Kp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Yn.TOUCH_ROTATE;break;case Kp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Yn.TOUCH_PAN;break;default:this.state=Yn.NONE}break;case 2:switch(this.touches.TWO){case Kp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Yn.TOUCH_DOLLY_PAN;break;case Kp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Yn.TOUCH_DOLLY_ROTATE;break;default:this.state=Yn.NONE}break;default:this.state=Yn.NONE}this.state!==Yn.NONE&&this.dispatchEvent(dO)}function ZDe(t){switch(this._trackPointer(t),this.state){case Yn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Yn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Yn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Yn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Yn.NONE}}function QDe(t){this.enabled!==!1&&t.preventDefault()}function JDe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function eje(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function tje(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},s={},o=t[0].morphTargetsRelative,c=new 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;a[m]===void 0&&(a[m]=[]),a[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;s[m]===void 0&&(s[m]=[]),s[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 a){const f=OH(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in s){const f=s[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let g=0;g<f;++g){const m=[];for(let v=0;v<s[d].length;++v)m.push(s[d][v][g]);const x=OH(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 OH(t){let e,n,r,i=-1,a=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const s=new e(a),o=new io(s,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let g=0,m=d.count;g<m;g++)for(let x=0;x<n;x++){const v=d.getComponent(g,x);o.setComponent(g+f,x,v)}}else s.set(d.array,c);c+=d.count*n}return i!==void 0&&(o.gpuType=i),o}function i_(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var GC={exports:{}};var LH;function nje(){return LH||(LH=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function s(u,d){if(!i[u]){if(!r[u]){var f=typeof i_=="function"&&i_;if(!d&&f)return f(u,!0);if(o)return o(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var m=i[u]={exports:{}};r[u][0].call(m.exports,function(x){var v=r[u][1][x];return s(v||x)},m,m.exports,n,r,i,a)}return i[u].exports}for(var o=typeof i_=="function"&&i_,c=0;c<a.length;c++)s(a[c]);return s})({1:[function(n,r,i){var a=n("./utils"),s=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,g,m,x,v,y=[],b=0,M=c.length,S=M,A=a.getTypeOf(c)!=="string";b<c.length;)S=M-b,f=A?(u=c[b++],d=b<M?c[b++]:0,b<M?c[b++]:0):(u=c.charCodeAt(b++),d=b<M?c.charCodeAt(b++):0,b<M?c.charCodeAt(b++):0),g=u>>2,m=(3&u)<<4|d>>4,x=1<S?(15&d)<<2|f>>6:64,v=2<S?63&f:64,y.push(o.charAt(g)+o.charAt(m)+o.charAt(x)+o.charAt(v));return y.join("")},i.decode=function(c){var u,d,f,g,m,x,v=0,y=0,b="data:";if(c.substr(0,b.length)===b)throw new Error("Invalid base64 input, it looks like a data url.");var M,S=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===o.charAt(64)&&S--,c.charAt(c.length-2)===o.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(M=s.uint8array?new Uint8Array(0|S):new Array(0|S);v<c.length;)u=o.indexOf(c.charAt(v++))<<2|(g=o.indexOf(c.charAt(v++)))>>4,d=(15&g)<<4|(m=o.indexOf(c.charAt(v++)))>>2,f=(3&m)<<6|(x=o.indexOf(c.charAt(v++))),M[y++]=u,m!==64&&(M[y++]=d),x!==64&&(M[y++]=f);return M}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),s=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,g,m,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=g,this.compression=m,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new s(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,g){return d.pipe(new o).pipe(new c("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),s=(function(){for(var o,c=[],u=0;u<256;u++){o=u;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;c[u]=o}return c})();r.exports=function(o,c){return o!==void 0&&o.length?a.getTypeOf(o)!=="string"?(function(u,d,f,g){var m=s,x=g+f;u^=-1;for(var v=g;v<x;v++)u=u>>>8^m[255&(u^d[v])];return-1^u})(0|c,o,o.length,0):(function(u,d,f,g){var m=s,x=g+f;u^=-1;for(var v=g;v<x;v++)u=u>>>8^m[255&(u^d.charCodeAt(v))];return-1^u})(0|c,o,o.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),o=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",o.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(m,x){var v,y="";for(v=0;v<x;v++)y+=String.fromCharCode(255&m),m>>>=8;return y}function s(m,x,v,y,b,M){var S,A,T=m.file,k=m.compression,N=M!==u.utf8encode,I=o.transformTo("string",M(T.name)),C=o.transformTo("string",u.utf8encode(T.name)),D=T.comment,F=o.transformTo("string",M(D)),O=o.transformTo("string",u.utf8encode(D)),q=C.length!==T.name.length,R=O.length!==D.length,W="",K="",G="",ee=T.dir,Z=T.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};x&&!v||(Q.crc32=m.crc32,Q.compressedSize=m.compressedSize,Q.uncompressedSize=m.uncompressedSize);var U=0;x&&(U|=8),N||!q&&!R||(U|=2048);var $=0,X=0;ee&&($|=16),b==="UNIX"?(X=798,$|=(function(fe,pe){var xe=fe;return fe||(xe=pe?16893:33204),(65535&xe)<<16})(T.unixPermissions,ee)):(X=20,$|=(function(fe){return 63&(fe||0)})(T.dosPermissions)),S=Z.getUTCHours(),S<<=6,S|=Z.getUTCMinutes(),S<<=5,S|=Z.getUTCSeconds()/2,A=Z.getUTCFullYear()-1980,A<<=4,A|=Z.getUTCMonth()+1,A<<=5,A|=Z.getUTCDate(),q&&(K=a(1,1)+a(d(I),4)+C,W+="up"+a(K.length,2)+K),R&&(G=a(1,1)+a(d(F),4)+O,W+="uc"+a(G.length,2)+G);var te="";return te+=`
- \0`,te+=a(U,2),te+=k.magic,te+=a(S,2),te+=a(A,2),te+=a(Q.crc32,4),te+=a(Q.compressedSize,4),te+=a(Q.uncompressedSize,4),te+=a(I.length,2),te+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+te+I+W,dirRecord:f.CENTRAL_FILE_HEADER+a(X,2)+te+a(F.length,2)+"\0\0\0\0"+a($,4)+a(y,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,v,y){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=v,this.encodeFileName=y,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,v=this.entriesCount,y=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:v?(x+100*(v-y-1))/v: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 v=s(m,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(m){this.accumulate=!1;var x=this.streamFiles&&!m.file.dir,v=s(m,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),x)this.push({data:(function(y){return f.DATA_DESCRIPTOR+a(y.crc32,4)+a(y.compressedSize,4)+a(y.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var m=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var v=this.bytesWritten-m,y=(function(b,M,S,A,T){var k=o.transformTo("string",T(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(b,2)+a(b,2)+a(M,4)+a(S,4)+a(k.length,2)+k})(this.dirRecords.length,v,m,this.zipComment,this.encodeFileName);this.push({data:y,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(m){this._sources.push(m);var x=this;return m.on("data",function(v){x.processChunk(v)}),m.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),m.on("error",function(v){x.error(v)}),this},g.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(m){var x=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var v=0;v<x.length;v++)try{x[v].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 a=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(o,c,u){var d=new s(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{o.forEach(function(g,m){f++;var x=(function(M,S){var A=M||S,T=a[A];if(!T)throw new Error(A+" is not a valid compression method !");return T})(m.options.compression,c.compression),v=m.options.compressionOptions||c.compressionOptions||{},y=m.dir,b=m.date;m._compressWorker(x,v).withStreamInfo("file",{name:g,dir:y,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 a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new a;for(var o in this)typeof this[o]!="function"&&(s[o]=this[o]);return s}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(s,o){return new a().loadAsync(s,o)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),s=n("./external"),o=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(g){return new s.Promise(function(m,x){var v=g.decompressed.getContentWorker().pipe(new u);v.on("error",function(y){x(y)}).on("end",function(){v.streamInfo.crc32!==g.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(g,m){var x=this;return m=a.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),d.isNode&&d.isStream(g)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",g,!0,m.optimizedBinaryString,m.base64).then(function(v){var y=new c(m);return y.load(v),y}).then(function(v){var y=[s.Promise.resolve(v)],b=v.files;if(m.checkCRC32)for(var M=0;M<b.length;M++)y.push(f(b[M]));return s.Promise.all(y)}).then(function(v){for(var y=v.shift(),b=y.files,M=0;M<b.length;M++){var S=b[M],A=S.fileNameStr,T=a.resolve(S.fileNameStr);x.file(T,S.decompressed,{binary:!0,optimizedBinaryString:!0,date:S.date,dir:S.dir,comment:S.fileCommentStr.length?S.fileCommentStr:null,unixPermissions:S.unixPermissions,dosPermissions:S.dosPermissions,createFolders:m.createFolders}),S.dir||(x.file(T).unsafeOriginalName=A)}return y.zipComment.length&&(x.comment=y.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),s=n("../stream/GenericWorker");function o(c,u){s.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(o,s),o.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},o.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function s(o,c,u){a.call(this,c),this._helper=o;var d=this;o.on("data",function(f,g){d.push(f)||d._helper.pause(),u&&u(g)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(s,a),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,s);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,s)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var s=new Buffer(a);return s.fill(0),s},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(T,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=y(T))&&M.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 O=null;O=k instanceof f||k instanceof c?k:x.isNode&&x.isStream(k)?new v(T,k):o.prepareContent(T,k,D.binary,D.optimizedBinaryString,D.base64);var q=new g(T,O,D);this.files[T]=q}var s=n("./utf8"),o=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),g=n("./zipObject"),m=n("./generate"),x=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),y=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},M=function(T,k){return k=k!==void 0?k:d.createFolders,T=b(T),this.files[T]||a.call(this,T,null,{dir:!0,createFolders:k}),this.files[T]};function S(T){return Object.prototype.toString.call(T)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var k,N,I;for(k in this.files)I=this.files[k],(N=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&T(N,I)},filter:function(T){var k=[];return this.forEach(function(N,I){T(N,I)&&k.push(I)}),k},file:function(T,k,N){if(arguments.length!==1)return T=this.root+T,a.call(this,T,k,N),this;if(S(T)){var I=T;return this.filter(function(D,F){return!F.dir&&I.test(D)})}var C=this.files[this.root+T];return C&&!C.dir?C:null},folder:function(T){if(!T)return this;if(S(T))return this.filter(function(C,D){return D.dir&&T.test(C)});var k=this.root+T,N=M.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:s.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 a=n("./DataReader");function s(o){a.call(this,o);for(var c=0;c<this.data.length;c++)o[c]=255&o[c]}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data[this.zero+o]},s.prototype.lastIndexOfSignature=function(o){for(var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===c&&this.data[g+1]===u&&this.data[g+2]===d&&this.data[g+3]===f)return g-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.readData(4);return c===g[0]&&u===g[1]&&d===g[2]&&f===g[3]},s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function s(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var c,u=0;for(this.checkOffset(o),c=this.index+o-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=o,u},readString:function(o){return a.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},s.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},s.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},s.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),s=n("../support"),o=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var g=a.getTypeOf(f);return a.checkSupport(g),g!=="string"||s.uint8array?g==="nodebuffer"?new u(f):s.uint8array?new d(a.transformTo("uint8array",f)):new o(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),s=n("../utils");function o(c){a.call(this,"ConvertWorker to "+c),this.destType=c}s.inherits(o,a),o.prototype.processChunk=function(c){this.push({data:s.transformTo(this.destType,c.data),meta:c.meta})},r.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),s=n("../crc32");function o(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,a),o.prototype.processChunk=function(c){this.streamInfo.crc32=s(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function o(c){s.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(o,s),o.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}s.prototype.processChunk.call(this,c)},r.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function o(c){s.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=a.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}a.inherits(o,s),o.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,o){return this._listeners[s].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,o){if(this._listeners[s])for(var c=0;c<this._listeners[s].length;c++)this._listeners[s][c].call(this,o)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var o=this;return s.on("data",function(c){o.processChunk(c)}),s.on("end",function(){o.end()}),s.on("error",function(c){o.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,o){return this.extraStreamInfo[s]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),s=n("./ConvertWorker"),o=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(x,v){return new d.Promise(function(y,b){var M=[],S=x._internalType,A=x._outputType,T=x._mimeType;x.on("data",function(k,N){M.push(k),v&&v(N)}).on("error",function(k){M=[],b(k)}).on("end",function(){try{var k=(function(N,I,C){switch(N){case"blob":return a.newBlob(a.transformTo("arraybuffer",I),C);case"base64":return c.encode(I);default:return a.transformTo(N,I)}})(A,(function(N,I){var C,D=0,F=null,O=0;for(C=0;C<I.length;C++)O+=I[C].length;switch(N){case"string":return I.join("");case"array":return Array.prototype.concat.apply([],I);case"uint8array":for(F=new Uint8Array(O),C=0;C<I.length;C++)F.set(I[C],D),D+=I[C].length;return F;case"nodebuffer":return Buffer.concat(I);default:throw new Error("concat : unsupported type '"+N+"'")}})(S,M),T);y(k)}catch(N){b(N)}M=[]}).resume()})}function m(x,v,y){var b=v;switch(v){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=v,this._mimeType=y,a.checkSupport(b),this._worker=x.pipe(new s(b)),x.lock()}catch(M){this._worker=new o("error"),this._worker.error(M)}}m.prototype={accumulate:function(x){return g(this,x)},on:function(x,v){var y=this;return x==="data"?this._worker.on(x,function(b){v.call(y,b.data,b.meta)}):this._worker.on(x,function(){a.delay(v,arguments,y)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=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 a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(a),i.blob=s.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var a=n("./utils"),s=n("./support"),o=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}i.utf8encode=function(m){return s.nodebuffer?o.newBufferFrom(m,"utf-8"):(function(x){var v,y,b,M,S,A=x.length,T=0;for(M=0;M<A;M++)(64512&(y=x.charCodeAt(M)))==55296&&M+1<A&&(64512&(b=x.charCodeAt(M+1)))==56320&&(y=65536+(y-55296<<10)+(b-56320),M++),T+=y<128?1:y<2048?2:y<65536?3:4;for(v=s.uint8array?new Uint8Array(T):new Array(T),M=S=0;S<T;M++)(64512&(y=x.charCodeAt(M)))==55296&&M+1<A&&(64512&(b=x.charCodeAt(M+1)))==56320&&(y=65536+(y-55296<<10)+(b-56320),M++),y<128?v[S++]=y:(y<2048?v[S++]=192|y>>>6:(y<65536?v[S++]=224|y>>>12:(v[S++]=240|y>>>18,v[S++]=128|y>>>12&63),v[S++]=128|y>>>6&63),v[S++]=128|63&y);return v})(m)},i.utf8decode=function(m){return s.nodebuffer?a.transformTo("nodebuffer",m).toString("utf-8"):(function(x){var v,y,b,M,S=x.length,A=new Array(2*S);for(v=y=0;v<S;)if((b=x[v++])<128)A[y++]=b;else if(4<(M=u[b]))A[y++]=65533,v+=M-1;else{for(b&=M===2?31:M===3?15:7;1<M&&v<S;)b=b<<6|63&x[v++],M--;1<M?A[y++]=65533:b<65536?A[y++]=b:(b-=65536,A[y++]=55296|b>>10&1023,A[y++]=56320|1023&b)}return A.length!==y&&(A.subarray?A=A.subarray(0,y):A.length=y),a.applyFromCharCode(A)})(m=a.transformTo(s.uint8array?"uint8array":"array",m))},a.inherits(f,c),f.prototype.processChunk=function(m){var x=a.transformTo(s.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var v=x;(x=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),x.set(v,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var y=(function(M,S){var A;for((S=S||M.length)>M.length&&(S=M.length),A=S-1;0<=A&&(192&M[A])==128;)A--;return A<0||A===0?S:A+u[M[A]]>S?A:S})(x),b=x;y!==x.length&&(s.uint8array?(b=x.subarray(0,y),this.leftOver=x.subarray(y,x.length)):(b=x.slice(0,y),this.leftOver=x.slice(y,x.length))),this.push({data:i.utf8decode(b),meta: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,a.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 a=n("./support"),s=n("./base64"),o=n("./nodejsUtils"),c=n("./external");function u(v){return v}function d(v,y){for(var b=0;b<v.length;++b)y[b]=255&v.charCodeAt(b);return y}n("setimmediate"),i.newBlob=function(v,y){i.checkSupport("blob");try{return new Blob([v],{type:y})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(v),b.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,y,b){var M=[],S=0,A=v.length;if(A<=b)return String.fromCharCode.apply(null,v);for(;S<A;)y==="array"||y==="nodebuffer"?M.push(String.fromCharCode.apply(null,v.slice(S,Math.min(S+b,A)))):M.push(String.fromCharCode.apply(null,v.subarray(S,Math.min(S+b,A)))),S+=b;return M.join("")},stringifyByChar:function(v){for(var y="",b=0;b<v.length;b++)y+=String.fromCharCode(v[b]);return y},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function g(v){var y=65536,b=i.getTypeOf(v),M=!0;if(b==="uint8array"?M=f.applyCanBeUsed.uint8array:b==="nodebuffer"&&(M=f.applyCanBeUsed.nodebuffer),M)for(;1<y;)try{return f.stringifyByChunk(v,b,y)}catch{y=Math.floor(y/2)}return f.stringifyByChar(v)}function m(v,y){for(var b=0;b<v.length;b++)y[b]=v[b];return y}i.applyFromCharCode=g;var x={};x.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return x.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,o.allocBuffer(v.length))}},x.array={string:g,array:u,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return o.newBufferFrom(v)}},x.arraybuffer={string:function(v){return g(new Uint8Array(v))},array:function(v){return m(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:u,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return o.newBufferFrom(new Uint8Array(v))}},x.uint8array={string:g,array:function(v){return m(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:u,nodebuffer:function(v){return o.newBufferFrom(v)}},x.nodebuffer={string:g,array:function(v){return m(v,new Array(v.length))},arraybuffer:function(v){return x.nodebuffer.uint8array(v).buffer},uint8array:function(v){return m(v,new Uint8Array(v.length))},nodebuffer:u},i.transformTo=function(v,y){if(y=y||"",!v)return y;i.checkSupport(v);var b=i.getTypeOf(y);return x[b][v](y)},i.resolve=function(v){for(var y=v.split("/"),b=[],M=0;M<y.length;M++){var S=y[M];S==="."||S===""&&M!==0&&M!==y.length-1||(S===".."?b.pop():b.push(S))}return b.join("/")},i.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":a.nodebuffer&&o.isBuffer(v)?"nodebuffer":a.uint8array&&v instanceof Uint8Array?"uint8array":a.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(v){if(!a[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(v){var y,b,M="";for(b=0;b<(v||"").length;b++)M+="\\x"+((y=v.charCodeAt(b))<16?"0":"")+y.toString(16).toUpperCase();return M},i.delay=function(v,y,b){setImmediate(function(){v.apply(b||null,y||[])})},i.inherits=function(v,y){function b(){}b.prototype=y.prototype,v.prototype=new b},i.extend=function(){var v,y,b={};for(v=0;v<arguments.length;v++)for(y in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],y)&&b[y]===void 0&&(b[y]=arguments[v][y]);return b},i.prepareContent=function(v,y,b,M,S){return c.Promise.resolve(y).then(function(A){return a.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new c.Promise(function(T,k){var N=new FileReader;N.onload=function(I){T(I.target.result)},N.onerror=function(I){k(I.target.error)},N.readAsArrayBuffer(A)}):A}).then(function(A){var T=i.getTypeOf(A);return T?(T==="arraybuffer"?A=i.transformTo("uint8array",A):T==="string"&&(S?A=s.decode(A):b&&M!==!0&&(A=(function(k){return d(k,a.uint8array?new Uint8Array(k.length):new Array(k.length))})(A))),A):c.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(g)+", expected "+s.pretty(f)+")")}},isSignature:function(f,g){var 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=s.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===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var 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=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function g(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,v;if(m.skip(22),this.fileNameLength=m.readInt(2),v=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(v),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(y){for(var b in d)if(Object.prototype.hasOwnProperty.call(d,b)&&d[b].magic===y)return d[b];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,x,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=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var x,v,y,b=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<b;)x=m.readInt(2),v=m.readInt(2),y=m.readData(v),this.extraFields[x]={id:x,length:v,value:y};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 v=s.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var b=s.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var x=a(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=a(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 a(x,v,y){this.name=x,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=v,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var s=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(x){var v=null,y="string";try{if(!x)throw new Error("No output type specified.");var b=(y=x.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),v=this._decompressWorker();var M=!this._dataBinary;M&&!b&&(v=v.pipe(new c.Utf8EncodeWorker)),!M&&b&&(v=v.pipe(new c.Utf8DecodeWorker))}catch(S){(v=new d("error")).error(S)}return new s(v,y,"")},async:function(x,v){return this.internalStream(x).accumulate(v)},nodeStream:function(x,v){return this.internalStream(x||"nodebuffer").toNodejsStream(v)},_compressWorker:function(x,v){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(y,x,v)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new o(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)a.prototype[f[m]]=g;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var s,o,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),s=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)s="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var v=a.document.createElement("script");v.onreadystatechange=function(){x(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},a.document.documentElement.appendChild(v)}:function(){setTimeout(x,0)};else{var g=new a.MessageChannel;g.port1.onmessage=x,s=function(){g.port2.postMessage(0)}}var m=[];function x(){var v,y;o=!0;for(var b=m.length;b;){for(y=m,m=[],v=-1;++v<b;)y[v]();b=m.length}o=!1}r.exports=function(v){m.push(v)!==1||o||s()}}).call(this,typeof hv<"u"?hv:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function s(){}var o={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==s&&v(this,b)}function g(b,M,S){this.promise=b,typeof M=="function"&&(this.onFulfilled=M,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function m(b,M,S){a(function(){var A;try{A=M(S)}catch(T){return o.reject(b,T)}A===b?o.reject(b,new TypeError("Cannot resolve promise with itself")):o.resolve(b,A)})}function x(b){var M=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof M=="function")return function(){M.apply(b,arguments)}}function v(b,M){var S=!1;function A(N){S||(S=!0,o.reject(b,N))}function T(N){S||(S=!0,o.resolve(b,N))}var k=y(function(){M(T,A)});k.status==="error"&&A(k.value)}function y(b,M){var S={};try{S.value=b(M),S.status="success"}catch(A){S.status="error",S.value=A}return S}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var M=this.constructor;return this.then(function(S){return M.resolve(b()).then(function(){return S})},function(S){return M.resolve(b()).then(function(){throw S})})},f.prototype.catch=function(b){return this.then(null,b)},f.prototype.then=function(b,M){if(typeof b!="function"&&this.state===u||typeof M!="function"&&this.state===c)return this;var S=new this.constructor(s);return this.state!==d?m(S,this.state===u?b:M,this.outcome):this.queue.push(new g(S,b,M)),S},g.prototype.callFulfilled=function(b){o.resolve(this.promise,b)},g.prototype.otherCallFulfilled=function(b){m(this.promise,this.onFulfilled,b)},g.prototype.callRejected=function(b){o.reject(this.promise,b)},g.prototype.otherCallRejected=function(b){m(this.promise,this.onRejected,b)},o.resolve=function(b,M){var S=y(x,M);if(S.status==="error")return o.reject(b,S.value);var A=S.value;if(A)v(b,A);else{b.state=u,b.outcome=M;for(var T=-1,k=b.queue.length;++T<k;)b.queue[T].callFulfilled(M)}return b},o.reject=function(b,M){b.state=c,b.outcome=M;for(var S=-1,A=b.queue.length;++S<A;)b.queue[S].callRejected(M);return b},f.resolve=function(b){return b instanceof this?b:o.resolve(new this(s),b)},f.reject=function(b){var M=new this(s);return o.reject(M,b)},f.all=function(b){var M=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=b.length,A=!1;if(!S)return this.resolve([]);for(var T=new Array(S),k=0,N=-1,I=new this(s);++N<S;)C(b[N],N);return I;function C(D,F){M.resolve(D).then(function(O){T[F]=O,++k!==S||A||(A=!0,o.resolve(I,T))},function(O){A||(A=!0,o.reject(I,O))})}},f.race=function(b){var M=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=b.length,A=!1;if(!S)return this.resolve([]);for(var T=-1,k=new this(s);++T<S;)N=b[T],M.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 a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),s=n("./utils/common"),o=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,g=-1,m=0,x=8;function v(b){if(!(this instanceof v))return new v(b);this.options=s.assign({level:g,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},b||{});var M=this.options;M.raw&&0<M.windowBits?M.windowBits=-M.windowBits:M.gzip&&0<M.windowBits&&M.windowBits<16&&(M.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var S=a.deflateInit2(this.strm,M.level,M.method,M.windowBits,M.memLevel,M.strategy);if(S!==f)throw new Error(c[S]);if(M.header&&a.deflateSetHeader(this.strm,M.header),M.dictionary){var A;if(A=typeof M.dictionary=="string"?o.string2buf(M.dictionary):d.call(M.dictionary)==="[object ArrayBuffer]"?new Uint8Array(M.dictionary):M.dictionary,(S=a.deflateSetDictionary(this.strm,A))!==f)throw new Error(c[S]);this._dict_set=!0}}function y(b,M){var S=new v(M);if(S.push(b,!0),S.err)throw S.msg||c[S.err];return S.result}v.prototype.push=function(b,M){var S,A,T=this.strm,k=this.options.chunkSize;if(this.ended)return!1;A=M===~~M?M:M===!0?4:0,typeof b=="string"?T.input=o.string2buf(b):d.call(b)==="[object ArrayBuffer]"?T.input=new Uint8Array(b):T.input=b,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(k),T.next_out=0,T.avail_out=k),(S=a.deflate(T,A))!==1&&S!==f)return this.onEnd(S),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(s.shrinkBuf(T.output,T.next_out))):this.onData(s.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&S!==1);return A===4?(S=a.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===f):A!==2||(this.onEnd(f),!(T.avail_out=0))},v.prototype.onData=function(b){this.chunks.push(b)},v.prototype.onEnd=function(b){b===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},i.Deflate=v,i.deflate=y,i.deflateRaw=function(b,M){return(M=M||{}).raw=!0,y(b,M)},i.gzip=function(b,M){return(M=M||{}).gzip=!0,y(b,M)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var a=n("./zlib/inflate"),s=n("./utils/common"),o=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),g=Object.prototype.toString;function m(v){if(!(this instanceof m))return new m(v);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},v||{});var y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||v&&v.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&(15&y.windowBits)==0&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var b=a.inflateInit2(this.strm,y.windowBits);if(b!==c.Z_OK)throw new Error(u[b]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(v,y){var b=new m(y);if(b.push(v,!0),b.err)throw b.msg||u[b.err];return b.result}m.prototype.push=function(v,y){var b,M,S,A,T,k,N=this.strm,I=this.options.chunkSize,C=this.options.dictionary,D=!1;if(this.ended)return!1;M=y===~~y?y:y===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof v=="string"?N.input=o.binstring2buf(v):g.call(v)==="[object ArrayBuffer]"?N.input=new Uint8Array(v):N.input=v,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new s.Buf8(I),N.next_out=0,N.avail_out=I),(b=a.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=a.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||M!==c.Z_FINISH&&M!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=o.utf8border(N.output,N.next_out),A=N.next_out-S,T=o.buf2string(N.output,S),N.next_out=A,N.avail_out=I-A,A&&s.arraySet(N.output,N.output,S,A,0),this.onData(T)):this.onData(s.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&&(M=c.Z_FINISH),M===c.Z_FINISH?(b=a.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===c.Z_OK):M!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(N.avail_out=0))},m.prototype.onData=function(v){this.chunks.push(v)},m.prototype.onEnd=function(v){v===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Inflate=m,i.inflate=x,i.inflateRaw=function(v,y){return(y=y||{}).raw=!0,x(v,y)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var s={arraySet:function(c,u,d,f,g){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),g);else for(var 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,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),s=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,g){if(g<65537&&(f.subarray&&o||!f.subarray&&s))return String.fromCharCode.apply(null,a.shrinkBuf(f,g));for(var 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,v,y,b=f.length,M=0;for(v=0;v<b;v++)(64512&(m=f.charCodeAt(v)))==55296&&v+1<b&&(64512&(x=f.charCodeAt(v+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),v++),M+=m<128?1:m<2048?2:m<65536?3:4;for(g=new a.Buf8(M),v=y=0;y<M;v++)(64512&(m=f.charCodeAt(v)))==55296&&v+1<b&&(64512&(x=f.charCodeAt(v+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),v++),m<128?g[y++]=m:(m<2048?g[y++]=192|m>>>6:(m<65536?g[y++]=224|m>>>12:(g[y++]=240|m>>>18,g[y++]=128|m>>>12&63),g[y++]=128|m>>>6&63),g[y++]=128|63&m);return g},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var g=new a.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,v,y,b=g||f.length,M=new Array(2*b);for(m=x=0;m<b;)if((v=f[m++])<128)M[x++]=v;else if(4<(y=c[v]))M[x++]=65533,m+=y-1;else{for(v&=y===2?31:y===3?15:7;1<y&&m<b;)v=v<<6|63&f[m++],y--;1<y?M[x++]=65533:v<65536?M[x++]=v:(v-=65536,M[x++]=55296|v>>10&1023,M[x++]=56320|1023&v)}return d(M,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(a,s,o,c){for(var u=65535&a|0,d=a>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3<o?2e3:o;d=d+(u=u+s[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var a=(function(){for(var s,o=[],c=0;c<256;c++){s=c;for(var u=0;u<8;u++)s=1&s?3988292384^s>>>1:s>>>1;o[c]=s}return o})();r.exports=function(s,o,c,u){var d=a,f=u+c;s^=-1;for(var g=u;g<f;g++)s=s>>>8^d[255&(s^o[g])];return-1^s}},{}],46:[function(n,r,i){var a,s=n("../utils/common"),o=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,g=4,m=0,x=-2,v=-1,y=4,b=2,M=8,S=9,A=286,T=30,k=19,N=2*A+1,I=15,C=3,D=258,F=D+C+1,O=42,q=113,R=1,W=2,K=3,G=4;function ee(H,B){return H.msg=d[B],B}function Z(H){return(H<<1)-(4<H?9:0)}function Q(H){for(var B=H.length;0<=--B;)H[B]=0}function U(H){var B=H.state,re=B.pending;re>H.avail_out&&(re=H.avail_out),re!==0&&(s.arraySet(H.output,B.pending_buf,B.pending_out,re,H.next_out),H.next_out+=re,B.pending_out+=re,H.total_out+=re,H.avail_out-=re,B.pending-=re,B.pending===0&&(B.pending_out=0))}function $(H,B){o._tr_flush_block(H,0<=H.block_start?H.block_start:-1,H.strstart-H.block_start,B),H.block_start=H.strstart,U(H.strm)}function X(H,B){H.pending_buf[H.pending++]=B}function te(H,B){H.pending_buf[H.pending++]=B>>>8&255,H.pending_buf[H.pending++]=255&B}function fe(H,B){var re,V,J=H.max_chain_length,se=H.strstart,Ae=H.prev_length,Pe=H.nice_match,Se=H.strstart>H.w_size-F?H.strstart-(H.w_size-F):0,z=H.window,L=H.w_mask,ne=H.prev,ve=H.strstart+D,we=z[se+Ae-1],ye=z[se+Ae];H.prev_length>=H.good_match&&(J>>=2),Pe>H.lookahead&&(Pe=H.lookahead);do if(z[(re=B)+Ae]===ye&&z[re+Ae-1]===we&&z[re]===z[se]&&z[++re]===z[se+1]){se+=2,re++;do;while(z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&se<ve);if(V=D-(ve-se),se=ve-D,Ae<V){if(H.match_start=B,Pe<=(Ae=V))break;we=z[se+Ae-1],ye=z[se+Ae]}}while((B=ne[B&L])>Se&&--J!=0);return Ae<=H.lookahead?Ae:H.lookahead}function pe(H){var B,re,V,J,se,Ae,Pe,Se,z,L,ne=H.w_size;do{if(J=H.window_size-H.lookahead-H.strstart,H.strstart>=ne+(ne-F)){for(s.arraySet(H.window,H.window,ne,ne,0),H.match_start-=ne,H.strstart-=ne,H.block_start-=ne,B=re=H.hash_size;V=H.head[--B],H.head[B]=ne<=V?V-ne:0,--re;);for(B=re=ne;V=H.prev[--B],H.prev[B]=ne<=V?V-ne:0,--re;);J+=ne}if(H.strm.avail_in===0)break;if(Ae=H.strm,Pe=H.window,Se=H.strstart+H.lookahead,z=J,L=void 0,L=Ae.avail_in,z<L&&(L=z),re=L===0?0:(Ae.avail_in-=L,s.arraySet(Pe,Ae.input,Ae.next_in,L,Se),Ae.state.wrap===1?Ae.adler=c(Ae.adler,Pe,L,Se):Ae.state.wrap===2&&(Ae.adler=u(Ae.adler,Pe,L,Se)),Ae.next_in+=L,Ae.total_in+=L,L),H.lookahead+=re,H.lookahead+H.insert>=C)for(se=H.strstart-H.insert,H.ins_h=H.window[se],H.ins_h=(H.ins_h<<H.hash_shift^H.window[se+1])&H.hash_mask;H.insert&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[se+C-1])&H.hash_mask,H.prev[se&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=se,se++,H.insert--,!(H.lookahead+H.insert<C)););}while(H.lookahead<F&&H.strm.avail_in!==0)}function xe(H,B){for(var re,V;;){if(H.lookahead<F){if(pe(H),H.lookahead<F&&B===f)return R;if(H.lookahead===0)break}if(re=0,H.lookahead>=C&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,re=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),re!==0&&H.strstart-re<=H.w_size-F&&(H.match_length=fe(H,re)),H.match_length>=C)if(V=o._tr_tally(H,H.strstart-H.match_start,H.match_length-C),H.lookahead-=H.match_length,H.match_length<=H.max_lazy_match&&H.lookahead>=C){for(H.match_length--;H.strstart++,H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,re=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart,--H.match_length!=0;);H.strstart++}else H.strstart+=H.match_length,H.match_length=0,H.ins_h=H.window[H.strstart],H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+1])&H.hash_mask;else V=o._tr_tally(H,0,H.window[H.strstart]),H.lookahead--,H.strstart++;if(V&&($(H,!1),H.strm.avail_out===0))return R}return H.insert=H.strstart<C-1?H.strstart:C-1,B===g?($(H,!0),H.strm.avail_out===0?K:G):H.last_lit&&($(H,!1),H.strm.avail_out===0)?R:W}function Ne(H,B){for(var re,V,J;;){if(H.lookahead<F){if(pe(H),H.lookahead<F&&B===f)return R;if(H.lookahead===0)break}if(re=0,H.lookahead>=C&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,re=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),H.prev_length=H.match_length,H.prev_match=H.match_start,H.match_length=C-1,re!==0&&H.prev_length<H.max_lazy_match&&H.strstart-re<=H.w_size-F&&(H.match_length=fe(H,re),H.match_length<=5&&(H.strategy===1||H.match_length===C&&4096<H.strstart-H.match_start)&&(H.match_length=C-1)),H.prev_length>=C&&H.match_length<=H.prev_length){for(J=H.strstart+H.lookahead-C,V=o._tr_tally(H,H.strstart-1-H.prev_match,H.prev_length-C),H.lookahead-=H.prev_length-1,H.prev_length-=2;++H.strstart<=J&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,re=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),--H.prev_length!=0;);if(H.match_available=0,H.match_length=C-1,H.strstart++,V&&($(H,!1),H.strm.avail_out===0))return R}else if(H.match_available){if((V=o._tr_tally(H,0,H.window[H.strstart-1]))&&$(H,!1),H.strstart++,H.lookahead--,H.strm.avail_out===0)return R}else H.match_available=1,H.strstart++,H.lookahead--}return H.match_available&&(V=o._tr_tally(H,0,H.window[H.strstart-1]),H.match_available=0),H.insert=H.strstart<C-1?H.strstart:C-1,B===g?($(H,!0),H.strm.avail_out===0?K:G):H.last_lit&&($(H,!1),H.strm.avail_out===0)?R:W}function ie(H,B,re,V,J){this.good_length=H,this.max_lazy=B,this.nice_length=re,this.max_chain=V,this.func=J}function be(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=M,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*N),this.dyn_dtree=new s.Buf16(2*(2*T+1)),this.bl_tree=new s.Buf16(2*(2*k+1)),Q(this.dyn_ltree),Q(this.dyn_dtree),Q(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(I+1),this.heap=new s.Buf16(2*A+1),Q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*A+1),Q(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function je(H){var B;return H&&H.state?(H.total_in=H.total_out=0,H.data_type=b,(B=H.state).pending=0,B.pending_out=0,B.wrap<0&&(B.wrap=-B.wrap),B.status=B.wrap?O:q,H.adler=B.wrap===2?0:1,B.last_flush=f,o._tr_init(B),m):ee(H,x)}function he(H){var B=je(H);return B===m&&(function(re){re.window_size=2*re.w_size,Q(re.head),re.max_lazy_match=a[re.level].max_lazy,re.good_match=a[re.level].good_length,re.nice_match=a[re.level].nice_length,re.max_chain_length=a[re.level].max_chain,re.strstart=0,re.block_start=0,re.lookahead=0,re.insert=0,re.match_length=re.prev_length=C-1,re.match_available=0,re.ins_h=0})(H.state),B}function ht(H,B,re,V,J,se){if(!H)return x;var Ae=1;if(B===v&&(B=6),V<0?(Ae=0,V=-V):15<V&&(Ae=2,V-=16),J<1||S<J||re!==M||V<8||15<V||B<0||9<B||se<0||y<se)return ee(H,x);V===8&&(V=9);var Pe=new be;return(H.state=Pe).strm=H,Pe.wrap=Ae,Pe.gzhead=null,Pe.w_bits=V,Pe.w_size=1<<Pe.w_bits,Pe.w_mask=Pe.w_size-1,Pe.hash_bits=J+7,Pe.hash_size=1<<Pe.hash_bits,Pe.hash_mask=Pe.hash_size-1,Pe.hash_shift=~~((Pe.hash_bits+C-1)/C),Pe.window=new s.Buf8(2*Pe.w_size),Pe.head=new s.Buf16(Pe.hash_size),Pe.prev=new s.Buf16(Pe.w_size),Pe.lit_bufsize=1<<J+6,Pe.pending_buf_size=4*Pe.lit_bufsize,Pe.pending_buf=new s.Buf8(Pe.pending_buf_size),Pe.d_buf=1*Pe.lit_bufsize,Pe.l_buf=3*Pe.lit_bufsize,Pe.level=B,Pe.strategy=se,Pe.method=re,he(H)}a=[new ie(0,0,0,0,function(H,B){var re=65535;for(re>H.pending_buf_size-5&&(re=H.pending_buf_size-5);;){if(H.lookahead<=1){if(pe(H),H.lookahead===0&&B===f)return R;if(H.lookahead===0)break}H.strstart+=H.lookahead,H.lookahead=0;var V=H.block_start+re;if((H.strstart===0||H.strstart>=V)&&(H.lookahead=H.strstart-V,H.strstart=V,$(H,!1),H.strm.avail_out===0)||H.strstart-H.block_start>=H.w_size-F&&($(H,!1),H.strm.avail_out===0))return R}return H.insert=0,B===g?($(H,!0),H.strm.avail_out===0?K:G):(H.strstart>H.block_start&&($(H,!1),H.strm.avail_out),R)}),new ie(4,4,8,4,xe),new ie(4,5,16,8,xe),new ie(4,6,32,32,xe),new ie(4,4,16,16,Ne),new ie(8,16,32,32,Ne),new ie(8,16,128,128,Ne),new ie(8,32,128,256,Ne),new ie(32,128,258,1024,Ne),new ie(32,258,258,4096,Ne)],i.deflateInit=function(H,B){return ht(H,B,M,15,8,0)},i.deflateInit2=ht,i.deflateReset=he,i.deflateResetKeep=je,i.deflateSetHeader=function(H,B){return H&&H.state?H.state.wrap!==2?x:(H.state.gzhead=B,m):x},i.deflate=function(H,B){var re,V,J,se;if(!H||!H.state||5<B||B<0)return H?ee(H,x):x;if(V=H.state,!H.output||!H.input&&H.avail_in!==0||V.status===666&&B!==g)return ee(H,H.avail_out===0?-5:x);if(V.strm=H,re=V.last_flush,V.last_flush=B,V.status===O)if(V.wrap===2)H.adler=0,X(V,31),X(V,139),X(V,8),V.gzhead?(X(V,(V.gzhead.text?1:0)+(V.gzhead.hcrc?2:0)+(V.gzhead.extra?4:0)+(V.gzhead.name?8:0)+(V.gzhead.comment?16:0)),X(V,255&V.gzhead.time),X(V,V.gzhead.time>>8&255),X(V,V.gzhead.time>>16&255),X(V,V.gzhead.time>>24&255),X(V,V.level===9?2:2<=V.strategy||V.level<2?4:0),X(V,255&V.gzhead.os),V.gzhead.extra&&V.gzhead.extra.length&&(X(V,255&V.gzhead.extra.length),X(V,V.gzhead.extra.length>>8&255)),V.gzhead.hcrc&&(H.adler=u(H.adler,V.pending_buf,V.pending,0)),V.gzindex=0,V.status=69):(X(V,0),X(V,0),X(V,0),X(V,0),X(V,0),X(V,V.level===9?2:2<=V.strategy||V.level<2?4:0),X(V,3),V.status=q);else{var Ae=M+(V.w_bits-8<<4)<<8;Ae|=(2<=V.strategy||V.level<2?0:V.level<6?1:V.level===6?2:3)<<6,V.strstart!==0&&(Ae|=32),Ae+=31-Ae%31,V.status=q,te(V,Ae),V.strstart!==0&&(te(V,H.adler>>>16),te(V,65535&H.adler)),H.adler=1}if(V.status===69)if(V.gzhead.extra){for(J=V.pending;V.gzindex<(65535&V.gzhead.extra.length)&&(V.pending!==V.pending_buf_size||(V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),U(H),J=V.pending,V.pending!==V.pending_buf_size));)X(V,255&V.gzhead.extra[V.gzindex]),V.gzindex++;V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),V.gzindex===V.gzhead.extra.length&&(V.gzindex=0,V.status=73)}else V.status=73;if(V.status===73)if(V.gzhead.name){J=V.pending;do{if(V.pending===V.pending_buf_size&&(V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),U(H),J=V.pending,V.pending===V.pending_buf_size)){se=1;break}se=V.gzindex<V.gzhead.name.length?255&V.gzhead.name.charCodeAt(V.gzindex++):0,X(V,se)}while(se!==0);V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),se===0&&(V.gzindex=0,V.status=91)}else V.status=91;if(V.status===91)if(V.gzhead.comment){J=V.pending;do{if(V.pending===V.pending_buf_size&&(V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),U(H),J=V.pending,V.pending===V.pending_buf_size)){se=1;break}se=V.gzindex<V.gzhead.comment.length?255&V.gzhead.comment.charCodeAt(V.gzindex++):0,X(V,se)}while(se!==0);V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),se===0&&(V.status=103)}else V.status=103;if(V.status===103&&(V.gzhead.hcrc?(V.pending+2>V.pending_buf_size&&U(H),V.pending+2<=V.pending_buf_size&&(X(V,255&H.adler),X(V,H.adler>>8&255),H.adler=0,V.status=q)):V.status=q),V.pending!==0){if(U(H),H.avail_out===0)return V.last_flush=-1,m}else if(H.avail_in===0&&Z(B)<=Z(re)&&B!==g)return ee(H,-5);if(V.status===666&&H.avail_in!==0)return ee(H,-5);if(H.avail_in!==0||V.lookahead!==0||B!==f&&V.status!==666){var Pe=V.strategy===2?(function(Se,z){for(var L;;){if(Se.lookahead===0&&(pe(Se),Se.lookahead===0)){if(z===f)return R;break}if(Se.match_length=0,L=o._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++,L&&($(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,z===g?($(Se,!0),Se.strm.avail_out===0?K:G):Se.last_lit&&($(Se,!1),Se.strm.avail_out===0)?R:W})(V,B):V.strategy===3?(function(Se,z){for(var L,ne,ve,we,ye=Se.window;;){if(Se.lookahead<=D){if(pe(Se),Se.lookahead<=D&&z===f)return R;if(Se.lookahead===0)break}if(Se.match_length=0,Se.lookahead>=C&&0<Se.strstart&&(ne=ye[ve=Se.strstart-1])===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]){we=Se.strstart+D;do;while(ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ve<we);Se.match_length=D-(we-ve),Se.match_length>Se.lookahead&&(Se.match_length=Se.lookahead)}if(Se.match_length>=C?(L=o._tr_tally(Se,1,Se.match_length-C),Se.lookahead-=Se.match_length,Se.strstart+=Se.match_length,Se.match_length=0):(L=o._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++),L&&($(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,z===g?($(Se,!0),Se.strm.avail_out===0?K:G):Se.last_lit&&($(Se,!1),Se.strm.avail_out===0)?R:W})(V,B):a[V.level].func(V,B);if(Pe!==K&&Pe!==G||(V.status=666),Pe===R||Pe===K)return H.avail_out===0&&(V.last_flush=-1),m;if(Pe===W&&(B===1?o._tr_align(V):B!==5&&(o._tr_stored_block(V,0,0,!1),B===3&&(Q(V.head),V.lookahead===0&&(V.strstart=0,V.block_start=0,V.insert=0))),U(H),H.avail_out===0))return V.last_flush=-1,m}return B!==g?m:V.wrap<=0?1:(V.wrap===2?(X(V,255&H.adler),X(V,H.adler>>8&255),X(V,H.adler>>16&255),X(V,H.adler>>24&255),X(V,255&H.total_in),X(V,H.total_in>>8&255),X(V,H.total_in>>16&255),X(V,H.total_in>>24&255)):(te(V,H.adler>>>16),te(V,65535&H.adler)),U(H),0<V.wrap&&(V.wrap=-V.wrap),V.pending!==0?m:1)},i.deflateEnd=function(H){var B;return H&&H.state?(B=H.state.status)!==O&&B!==69&&B!==73&&B!==91&&B!==103&&B!==q&&B!==666?ee(H,x):(H.state=null,B===q?ee(H,-3):m):x},i.deflateSetDictionary=function(H,B){var re,V,J,se,Ae,Pe,Se,z,L=B.length;if(!H||!H.state||(se=(re=H.state).wrap)===2||se===1&&re.status!==O||re.lookahead)return x;for(se===1&&(H.adler=c(H.adler,B,L,0)),re.wrap=0,L>=re.w_size&&(se===0&&(Q(re.head),re.strstart=0,re.block_start=0,re.insert=0),z=new s.Buf8(re.w_size),s.arraySet(z,B,L-re.w_size,re.w_size,0),B=z,L=re.w_size),Ae=H.avail_in,Pe=H.next_in,Se=H.input,H.avail_in=L,H.next_in=0,H.input=B,pe(re);re.lookahead>=C;){for(V=re.strstart,J=re.lookahead-(C-1);re.ins_h=(re.ins_h<<re.hash_shift^re.window[V+C-1])&re.hash_mask,re.prev[V&re.w_mask]=re.head[re.ins_h],re.head[re.ins_h]=V,V++,--J;);re.strstart=V,re.lookahead=C-1,pe(re)}return re.strstart+=re.lookahead,re.block_start=re.strstart,re.insert=re.lookahead,re.lookahead=0,re.match_length=re.prev_length=C-1,re.match_available=0,H.next_in=Pe,H.input=Se,H.avail_in=Ae,re.wrap=se,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(a,s){var o,c,u,d,f,g,m,x,v,y,b,M,S,A,T,k,N,I,C,D,F,O,q,R,W;o=a.state,c=a.next_in,R=a.input,u=c+(a.avail_in-5),d=a.next_out,W=a.output,f=d-(s-a.avail_out),g=d+(a.avail_out-257),m=o.dmax,x=o.wsize,v=o.whave,y=o.wnext,b=o.window,M=o.hold,S=o.bits,A=o.lencode,T=o.distcode,k=(1<<o.lenbits)-1,N=(1<<o.distbits)-1;e:do{S<15&&(M+=R[c++]<<S,S+=8,M+=R[c++]<<S,S+=8),I=A[M&k];t:for(;;){if(M>>>=C=I>>>24,S-=C,(C=I>>>16&255)===0)W[d++]=65535&I;else{if(!(16&C)){if((64&C)==0){I=A[(65535&I)+(M&(1<<C)-1)];continue t}if(32&C){o.mode=12;break e}a.msg="invalid literal/length code",o.mode=30;break e}D=65535&I,(C&=15)&&(S<C&&(M+=R[c++]<<S,S+=8),D+=M&(1<<C)-1,M>>>=C,S-=C),S<15&&(M+=R[c++]<<S,S+=8,M+=R[c++]<<S,S+=8),I=T[M&N];n:for(;;){if(M>>>=C=I>>>24,S-=C,!(16&(C=I>>>16&255))){if((64&C)==0){I=T[(65535&I)+(M&(1<<C)-1)];continue n}a.msg="invalid distance code",o.mode=30;break e}if(F=65535&I,S<(C&=15)&&(M+=R[c++]<<S,(S+=8)<C&&(M+=R[c++]<<S,S+=8)),m<(F+=M&(1<<C)-1)){a.msg="invalid distance too far back",o.mode=30;break e}if(M>>>=C,S-=C,(C=d-f)<F){if(v<(C=F-C)&&o.sane){a.msg="invalid distance too far back",o.mode=30;break e}if(q=b,(O=0)===y){if(O+=x-C,C<D){for(D-=C;W[d++]=b[O++],--C;);O=d-F,q=W}}else if(y<C){if(O+=x+y-C,(C-=y)<D){for(D-=C;W[d++]=b[O++],--C;);if(O=0,y<D){for(D-=C=y;W[d++]=b[O++],--C;);O=d-F,q=W}}}else if(O+=y-C,C<D){for(D-=C;W[d++]=b[O++],--C;);O=d-F,q=W}for(;2<D;)W[d++]=q[O++],W[d++]=q[O++],W[d++]=q[O++],D-=3;D&&(W[d++]=q[O++],1<D&&(W[d++]=q[O++]))}else{for(O=d-F;W[d++]=W[O++],W[d++]=W[O++],W[d++]=W[O++],2<(D-=3););D&&(W[d++]=W[O++],1<D&&(W[d++]=W[O++]))}break}}break}}while(c<u&&d<g);c-=D=S>>3,M&=(1<<(S-=D<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<g?g-d+257:257-(d-g),o.hold=M,o.bits=S}},{}],49:[function(n,r,i){var a=n("../utils/common"),s=n("./adler32"),o=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,g=0,m=-2,x=1,v=852,y=592;function b(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<24)}function M(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function S(O){var q;return O&&O.state?(q=O.state,O.total_in=O.total_out=q.total=0,O.msg="",q.wrap&&(O.adler=1&q.wrap),q.mode=x,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new a.Buf32(v),q.distcode=q.distdyn=new a.Buf32(y),q.sane=1,q.back=-1,g):m}function A(O){var q;return O&&O.state?((q=O.state).wsize=0,q.whave=0,q.wnext=0,S(O)):m}function T(O,q){var R,W;return O&&O.state?(W=O.state,q<0?(R=0,q=-q):(R=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?m:(W.window!==null&&W.wbits!==q&&(W.window=null),W.wrap=R,W.wbits=q,A(O))):m}function k(O,q){var R,W;return O?(W=new M,(O.state=W).window=null,(R=T(O,q))!==g&&(O.state=null),R):m}var N,I,C=!0;function D(O){if(C){var q;for(N=new a.Buf32(512),I=new a.Buf32(32),q=0;q<144;)O.lens[q++]=8;for(;q<256;)O.lens[q++]=9;for(;q<280;)O.lens[q++]=7;for(;q<288;)O.lens[q++]=8;for(u(d,O.lens,0,288,N,0,O.work,{bits:9}),q=0;q<32;)O.lens[q++]=5;u(f,O.lens,0,32,I,0,O.work,{bits:5}),C=!1}O.lencode=N,O.lenbits=9,O.distcode=I,O.distbits=5}function F(O,q,R,W){var K,G=O.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new a.Buf8(G.wsize)),W>=G.wsize?(a.arraySet(G.window,q,R-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(W<(K=G.wsize-G.wnext)&&(K=W),a.arraySet(G.window,q,R-W,K,G.wnext),(W-=K)?(a.arraySet(G.window,q,R-W,W,0),G.wnext=W,G.whave=G.wsize):(G.wnext+=K,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=K))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=S,i.inflateInit=function(O){return k(O,15)},i.inflateInit2=k,i.inflate=function(O,q){var R,W,K,G,ee,Z,Q,U,$,X,te,fe,pe,xe,Ne,ie,be,je,he,ht,H,B,re,V,J=0,se=new a.Buf8(4),Ae=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return m;(R=O.state).mode===12&&(R.mode=13),ee=O.next_out,K=O.output,Q=O.avail_out,G=O.next_in,W=O.input,Z=O.avail_in,U=R.hold,$=R.bits,X=Z,te=Q,B=g;e:for(;;)switch(R.mode){case x:if(R.wrap===0){R.mode=13;break}for(;$<16;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(2&R.wrap&&U===35615){se[R.check=0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0),$=U=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&U)<<8)+(U>>8))%31){O.msg="incorrect header check",R.mode=30;break}if((15&U)!=8){O.msg="unknown compression method",R.mode=30;break}if($-=4,H=8+(15&(U>>>=4)),R.wbits===0)R.wbits=H;else if(H>R.wbits){O.msg="invalid window size",R.mode=30;break}R.dmax=1<<H,O.adler=R.check=1,R.mode=512&U?10:12,$=U=0;break;case 2:for(;$<16;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(R.flags=U,(255&R.flags)!=8){O.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){O.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=U>>8&1),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0)),$=U=0,R.mode=3;case 3:for(;$<32;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.head&&(R.head.time=U),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,se[2]=U>>>16&255,se[3]=U>>>24&255,R.check=o(R.check,se,4,0)),$=U=0,R.mode=4;case 4:for(;$<16;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.head&&(R.head.xflags=255&U,R.head.os=U>>8),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0)),$=U=0,R.mode=5;case 5:if(1024&R.flags){for(;$<16;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.length=U,R.head&&(R.head.extra_len=U),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0)),$=U=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(Z<(fe=R.length)&&(fe=Z),fe&&(R.head&&(H=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),a.arraySet(R.head.extra,W,G,fe,H)),512&R.flags&&(R.check=o(R.check,W,fe,G)),Z-=fe,G+=fe,R.length-=fe),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(Z===0)break e;for(fe=0;H=W[G+fe++],R.head&&H&&R.length<65536&&(R.head.name+=String.fromCharCode(H)),H&&fe<Z;);if(512&R.flags&&(R.check=o(R.check,W,fe,G)),Z-=fe,G+=fe,H)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(Z===0)break e;for(fe=0;H=W[G+fe++],R.head&&H&&R.length<65536&&(R.head.comment+=String.fromCharCode(H)),H&&fe<Z;);if(512&R.flags&&(R.check=o(R.check,W,fe,G)),Z-=fe,G+=fe,H)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;$<16;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(U!==(65535&R.check)){O.msg="header crc mismatch",R.mode=30;break}$=U=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),O.adler=R.check=0,R.mode=12;break;case 10:for(;$<32;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}O.adler=R.check=b(U),$=U=0,R.mode=11;case 11:if(R.havedict===0)return O.next_out=ee,O.avail_out=Q,O.next_in=G,O.avail_in=Z,R.hold=U,R.bits=$,2;O.adler=R.check=1,R.mode=12;case 12:if(q===5||q===6)break e;case 13:if(R.last){U>>>=7&$,$-=7&$,R.mode=27;break}for(;$<3;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}switch(R.last=1&U,$-=1,3&(U>>>=1)){case 0:R.mode=14;break;case 1:if(D(R),R.mode=20,q!==6)break;U>>>=2,$-=2;break e;case 2:R.mode=17;break;case 3:O.msg="invalid block type",R.mode=30}U>>>=2,$-=2;break;case 14:for(U>>>=7&$,$-=7&$;$<32;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if((65535&U)!=(U>>>16^65535)){O.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&U,$=U=0,R.mode=15,q===6)break e;case 15:R.mode=16;case 16:if(fe=R.length){if(Z<fe&&(fe=Z),Q<fe&&(fe=Q),fe===0)break e;a.arraySet(K,W,G,fe,ee),Z-=fe,G+=fe,Q-=fe,ee+=fe,R.length-=fe;break}R.mode=12;break;case 17:for(;$<14;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(R.nlen=257+(31&U),U>>>=5,$-=5,R.ndist=1+(31&U),U>>>=5,$-=5,R.ncode=4+(15&U),U>>>=4,$-=4,286<R.nlen||30<R.ndist){O.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;$<3;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.lens[Ae[R.have++]]=7&U,U>>>=3,$-=3}for(;R.have<19;)R.lens[Ae[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,re={bits:R.lenbits},B=u(0,R.lens,0,19,R.lencode,0,R.work,re),R.lenbits=re.bits,B){O.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;ie=(J=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,be=65535&J,!((Ne=J>>>24)<=$);){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(be<16)U>>>=Ne,$-=Ne,R.lens[R.have++]=be;else{if(be===16){for(V=Ne+2;$<V;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(U>>>=Ne,$-=Ne,R.have===0){O.msg="invalid bit length repeat",R.mode=30;break}H=R.lens[R.have-1],fe=3+(3&U),U>>>=2,$-=2}else if(be===17){for(V=Ne+3;$<V;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}$-=Ne,H=0,fe=3+(7&(U>>>=Ne)),U>>>=3,$-=3}else{for(V=Ne+7;$<V;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}$-=Ne,H=0,fe=11+(127&(U>>>=Ne)),U>>>=7,$-=7}if(R.have+fe>R.nlen+R.ndist){O.msg="invalid bit length repeat",R.mode=30;break}for(;fe--;)R.lens[R.have++]=H}}if(R.mode===30)break;if(R.lens[256]===0){O.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,re={bits:R.lenbits},B=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,re),R.lenbits=re.bits,B){O.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,re={bits:R.distbits},B=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,re),R.distbits=re.bits,B){O.msg="invalid distances set",R.mode=30;break}if(R.mode=20,q===6)break e;case 20:R.mode=21;case 21:if(6<=Z&&258<=Q){O.next_out=ee,O.avail_out=Q,O.next_in=G,O.avail_in=Z,R.hold=U,R.bits=$,c(O,te),ee=O.next_out,K=O.output,Q=O.avail_out,G=O.next_in,W=O.input,Z=O.avail_in,U=R.hold,$=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;ie=(J=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,be=65535&J,!((Ne=J>>>24)<=$);){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(ie&&(240&ie)==0){for(je=Ne,he=ie,ht=be;ie=(J=R.lencode[ht+((U&(1<<je+he)-1)>>je)])>>>16&255,be=65535&J,!(je+(Ne=J>>>24)<=$);){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}U>>>=je,$-=je,R.back+=je}if(U>>>=Ne,$-=Ne,R.back+=Ne,R.length=be,ie===0){R.mode=26;break}if(32&ie){R.back=-1,R.mode=12;break}if(64&ie){O.msg="invalid literal/length code",R.mode=30;break}R.extra=15&ie,R.mode=22;case 22:if(R.extra){for(V=R.extra;$<V;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.length+=U&(1<<R.extra)-1,U>>>=R.extra,$-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;ie=(J=R.distcode[U&(1<<R.distbits)-1])>>>16&255,be=65535&J,!((Ne=J>>>24)<=$);){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if((240&ie)==0){for(je=Ne,he=ie,ht=be;ie=(J=R.distcode[ht+((U&(1<<je+he)-1)>>je)])>>>16&255,be=65535&J,!(je+(Ne=J>>>24)<=$);){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}U>>>=je,$-=je,R.back+=je}if(U>>>=Ne,$-=Ne,R.back+=Ne,64&ie){O.msg="invalid distance code",R.mode=30;break}R.offset=be,R.extra=15&ie,R.mode=24;case 24:if(R.extra){for(V=R.extra;$<V;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.offset+=U&(1<<R.extra)-1,U>>>=R.extra,$-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){O.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(Q===0)break e;if(fe=te-Q,R.offset>fe){if((fe=R.offset-fe)>R.whave&&R.sane){O.msg="invalid distance too far back",R.mode=30;break}pe=fe>R.wnext?(fe-=R.wnext,R.wsize-fe):R.wnext-fe,fe>R.length&&(fe=R.length),xe=R.window}else xe=K,pe=ee-R.offset,fe=R.length;for(Q<fe&&(fe=Q),Q-=fe,R.length-=fe;K[ee++]=xe[pe++],--fe;);R.length===0&&(R.mode=21);break;case 26:if(Q===0)break e;K[ee++]=R.length,Q--,R.mode=21;break;case 27:if(R.wrap){for(;$<32;){if(Z===0)break e;Z--,U|=W[G++]<<$,$+=8}if(te-=Q,O.total_out+=te,R.total+=te,te&&(O.adler=R.check=R.flags?o(R.check,K,te,ee-te):s(R.check,K,te,ee-te)),te=Q,(R.flags?U:b(U))!==R.check){O.msg="incorrect data check",R.mode=30;break}$=U=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;$<32;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(U!==(4294967295&R.total)){O.msg="incorrect length check",R.mode=30;break}$=U=0}R.mode=29;case 29:B=1;break e;case 30:B=-3;break e;case 31:return-4;case 32:default:return m}return O.next_out=ee,O.avail_out=Q,O.next_in=G,O.avail_in=Z,R.hold=U,R.bits=$,(R.wsize||te!==O.avail_out&&R.mode<30&&(R.mode<27||q!==4))&&F(O,O.output,O.next_out,te-O.avail_out)?(R.mode=31,-4):(X-=O.avail_in,te-=O.avail_out,O.total_in+=X,O.total_out+=te,R.total+=te,R.wrap&&te&&(O.adler=R.check=R.flags?o(R.check,K,te,O.next_out-te):s(R.check,K,te,O.next_out-te)),O.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(X==0&&te===0||q===4)&&B===g&&(B=-5),B)},i.inflateEnd=function(O){if(!O||!O.state)return m;var q=O.state;return q.window&&(q.window=null),O.state=null,g},i.inflateGetHeader=function(O,q){var R;return O&&O.state?(2&(R=O.state).wrap)==0?m:((R.head=q).done=!1,g):m},i.inflateSetDictionary=function(O,q){var R,W=q.length;return O&&O.state?(R=O.state).wrap!==0&&R.mode!==11?m:R.mode===11&&s(1,q,W,0)!==R.check?-3:F(O,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 a=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,g,m,x,v,y,b){var M,S,A,T,k,N,I,C,D,F=b.bits,O=0,q=0,R=0,W=0,K=0,G=0,ee=0,Z=0,Q=0,U=0,$=null,X=0,te=new a.Buf16(16),fe=new a.Buf16(16),pe=null,xe=0;for(O=0;O<=15;O++)te[O]=0;for(q=0;q<m;q++)te[f[g+q]]++;for(K=F,W=15;1<=W&&te[W]===0;W--);if(W<K&&(K=W),W===0)return x[v++]=20971520,x[v++]=20971520,b.bits=1,0;for(R=1;R<W&&te[R]===0;R++);for(K<R&&(K=R),O=Z=1;O<=15;O++)if(Z<<=1,(Z-=te[O])<0)return-1;if(0<Z&&(d===0||W!==1))return-1;for(fe[1]=0,O=1;O<15;O++)fe[O+1]=fe[O]+te[O];for(q=0;q<m;q++)f[g+q]!==0&&(y[fe[f[g+q]]++]=q);if(N=d===0?($=pe=y,19):d===1?($=s,X-=257,pe=o,xe-=257,256):($=c,pe=u,-1),O=R,k=v,ee=q=U=0,A=-1,T=(Q=1<<(G=K))-1,d===1&&852<Q||d===2&&592<Q)return 1;for(;;){for(I=O-ee,D=y[q]<N?(C=0,y[q]):y[q]>N?(C=pe[xe+y[q]],$[X+y[q]]):(C=96,0),M=1<<O-ee,R=S=1<<G;x[k+(U>>ee)+(S-=M)]=I<<24|C<<16|D|0,S!==0;);for(M=1<<O-1;U&M;)M>>=1;if(M!==0?(U&=M-1,U+=M):U=0,q++,--te[O]==0){if(O===W)break;O=f[g+y[q]]}if(K<O&&(U&T)!==A){for(ee===0&&(ee=K),k+=R,Z=1<<(G=O-ee);G+ee<W&&!((Z-=te[G+ee])<=0);)G++,Z<<=1;if(Q+=1<<G,d===1&&852<Q||d===2&&592<Q)return 1;x[A=U&T]=K<<24|G<<16|k-v|0}}return U!==0&&(x[k+U]=O-ee<<24|64<<16|0),b.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),s=0,o=1;function c(J){for(var se=J.length;0<=--se;)J[se]=0}var u=0,d=29,f=256,g=f+1+d,m=30,x=19,v=2*g+1,y=15,b=16,M=7,S=256,A=16,T=17,k=18,N=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],I=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(g+2));c(F);var O=new Array(2*m);c(O);var q=new Array(512);c(q);var R=new Array(256);c(R);var W=new Array(d);c(W);var K,G,ee,Z=new Array(m);function Q(J,se,Ae,Pe,Se){this.static_tree=J,this.extra_bits=se,this.extra_base=Ae,this.elems=Pe,this.max_length=Se,this.has_stree=J&&J.length}function U(J,se){this.dyn_tree=J,this.max_code=0,this.stat_desc=se}function $(J){return J<256?q[J]:q[256+(J>>>7)]}function X(J,se){J.pending_buf[J.pending++]=255&se,J.pending_buf[J.pending++]=se>>>8&255}function te(J,se,Ae){J.bi_valid>b-Ae?(J.bi_buf|=se<<J.bi_valid&65535,X(J,J.bi_buf),J.bi_buf=se>>b-J.bi_valid,J.bi_valid+=Ae-b):(J.bi_buf|=se<<J.bi_valid&65535,J.bi_valid+=Ae)}function fe(J,se,Ae){te(J,Ae[2*se],Ae[2*se+1])}function pe(J,se){for(var Ae=0;Ae|=1&J,J>>>=1,Ae<<=1,0<--se;);return Ae>>>1}function xe(J,se,Ae){var Pe,Se,z=new Array(y+1),L=0;for(Pe=1;Pe<=y;Pe++)z[Pe]=L=L+Ae[Pe-1]<<1;for(Se=0;Se<=se;Se++){var ne=J[2*Se+1];ne!==0&&(J[2*Se]=pe(z[ne]++,ne))}}function Ne(J){var se;for(se=0;se<g;se++)J.dyn_ltree[2*se]=0;for(se=0;se<m;se++)J.dyn_dtree[2*se]=0;for(se=0;se<x;se++)J.bl_tree[2*se]=0;J.dyn_ltree[2*S]=1,J.opt_len=J.static_len=0,J.last_lit=J.matches=0}function ie(J){8<J.bi_valid?X(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 be(J,se,Ae,Pe){var Se=2*se,z=2*Ae;return J[Se]<J[z]||J[Se]===J[z]&&Pe[se]<=Pe[Ae]}function je(J,se,Ae){for(var Pe=J.heap[Ae],Se=Ae<<1;Se<=J.heap_len&&(Se<J.heap_len&&be(se,J.heap[Se+1],J.heap[Se],J.depth)&&Se++,!be(se,Pe,J.heap[Se],J.depth));)J.heap[Ae]=J.heap[Se],Ae=Se,Se<<=1;J.heap[Ae]=Pe}function he(J,se,Ae){var Pe,Se,z,L,ne=0;if(J.last_lit!==0)for(;Pe=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++,Pe===0?fe(J,Se,se):(fe(J,(z=R[Se])+f+1,se),(L=N[z])!==0&&te(J,Se-=W[z],L),fe(J,z=$(--Pe),Ae),(L=I[z])!==0&&te(J,Pe-=Z[z],L)),ne<J.last_lit;);fe(J,S,se)}function ht(J,se){var Ae,Pe,Se,z=se.dyn_tree,L=se.stat_desc.static_tree,ne=se.stat_desc.has_stree,ve=se.stat_desc.elems,we=-1;for(J.heap_len=0,J.heap_max=v,Ae=0;Ae<ve;Ae++)z[2*Ae]!==0?(J.heap[++J.heap_len]=we=Ae,J.depth[Ae]=0):z[2*Ae+1]=0;for(;J.heap_len<2;)z[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(se.max_code=we,Ae=J.heap_len>>1;1<=Ae;Ae--)je(J,z,Ae);for(Se=ve;Ae=J.heap[1],J.heap[1]=J.heap[J.heap_len--],je(J,z,1),Pe=J.heap[1],J.heap[--J.heap_max]=Ae,J.heap[--J.heap_max]=Pe,z[2*Se]=z[2*Ae]+z[2*Pe],J.depth[Se]=(J.depth[Ae]>=J.depth[Pe]?J.depth[Ae]:J.depth[Pe])+1,z[2*Ae+1]=z[2*Pe+1]=Se,J.heap[1]=Se++,je(J,z,1),2<=J.heap_len;);J.heap[--J.heap_max]=J.heap[1],(function(ye,nt){var Be,ue,Ve,Fe,oe,Je,He=nt.dyn_tree,Ke=nt.max_code,ct=nt.stat_desc.static_tree,de=nt.stat_desc.has_stree,Ye=nt.stat_desc.extra_bits,ge=nt.stat_desc.extra_base,Ue=nt.stat_desc.max_length,Ce=0;for(Fe=0;Fe<=y;Fe++)ye.bl_count[Fe]=0;for(He[2*ye.heap[ye.heap_max]+1]=0,Be=ye.heap_max+1;Be<v;Be++)Ue<(Fe=He[2*He[2*(ue=ye.heap[Be])+1]+1]+1)&&(Fe=Ue,Ce++),He[2*ue+1]=Fe,Ke<ue||(ye.bl_count[Fe]++,oe=0,ge<=ue&&(oe=Ye[ue-ge]),Je=He[2*ue],ye.opt_len+=Je*(Fe+oe),de&&(ye.static_len+=Je*(ct[2*ue+1]+oe)));if(Ce!==0){do{for(Fe=Ue-1;ye.bl_count[Fe]===0;)Fe--;ye.bl_count[Fe]--,ye.bl_count[Fe+1]+=2,ye.bl_count[Ue]--,Ce-=2}while(0<Ce);for(Fe=Ue;Fe!==0;Fe--)for(ue=ye.bl_count[Fe];ue!==0;)Ke<(Ve=ye.heap[--Be])||(He[2*Ve+1]!==Fe&&(ye.opt_len+=(Fe-He[2*Ve+1])*He[2*Ve],He[2*Ve+1]=Fe),ue--)}})(J,se),xe(z,we,J.bl_count)}function H(J,se,Ae){var Pe,Se,z=-1,L=se[1],ne=0,ve=7,we=4;for(L===0&&(ve=138,we=3),se[2*(Ae+1)+1]=65535,Pe=0;Pe<=Ae;Pe++)Se=L,L=se[2*(Pe+1)+1],++ne<ve&&Se===L||(ne<we?J.bl_tree[2*Se]+=ne:Se!==0?(Se!==z&&J.bl_tree[2*Se]++,J.bl_tree[2*A]++):ne<=10?J.bl_tree[2*T]++:J.bl_tree[2*k]++,z=Se,we=(ne=0)===L?(ve=138,3):Se===L?(ve=6,3):(ve=7,4))}function B(J,se,Ae){var Pe,Se,z=-1,L=se[1],ne=0,ve=7,we=4;for(L===0&&(ve=138,we=3),Pe=0;Pe<=Ae;Pe++)if(Se=L,L=se[2*(Pe+1)+1],!(++ne<ve&&Se===L)){if(ne<we)for(;fe(J,Se,J.bl_tree),--ne!=0;);else Se!==0?(Se!==z&&(fe(J,Se,J.bl_tree),ne--),fe(J,A,J.bl_tree),te(J,ne-3,2)):ne<=10?(fe(J,T,J.bl_tree),te(J,ne-3,3)):(fe(J,k,J.bl_tree),te(J,ne-11,7));z=Se,we=(ne=0)===L?(ve=138,3):Se===L?(ve=6,3):(ve=7,4)}}c(Z);var re=!1;function V(J,se,Ae,Pe){te(J,(u<<1)+(Pe?1:0),3),(function(Se,z,L,ne){ie(Se),X(Se,L),X(Se,~L),a.arraySet(Se.pending_buf,Se.window,z,L,Se.pending),Se.pending+=L})(J,se,Ae)}i._tr_init=function(J){re||((function(){var se,Ae,Pe,Se,z,L=new Array(y+1);for(Se=Pe=0;Se<d-1;Se++)for(W[Se]=Pe,se=0;se<1<<N[Se];se++)R[Pe++]=Se;for(R[Pe-1]=Se,Se=z=0;Se<16;Se++)for(Z[Se]=z,se=0;se<1<<I[Se];se++)q[z++]=Se;for(z>>=7;Se<m;Se++)for(Z[Se]=z<<7,se=0;se<1<<I[Se]-7;se++)q[256+z++]=Se;for(Ae=0;Ae<=y;Ae++)L[Ae]=0;for(se=0;se<=143;)F[2*se+1]=8,se++,L[8]++;for(;se<=255;)F[2*se+1]=9,se++,L[9]++;for(;se<=279;)F[2*se+1]=7,se++,L[7]++;for(;se<=287;)F[2*se+1]=8,se++,L[8]++;for(xe(F,g+1,L),se=0;se<m;se++)O[2*se+1]=5,O[2*se]=pe(se,5);K=new Q(F,N,f+1,g,y),G=new Q(O,I,0,m,y),ee=new Q(new Array(0),C,0,x,M)})(),re=!0),J.l_desc=new U(J.dyn_ltree,K),J.d_desc=new U(J.dyn_dtree,G),J.bl_desc=new U(J.bl_tree,ee),J.bi_buf=0,J.bi_valid=0,Ne(J)},i._tr_stored_block=V,i._tr_flush_block=function(J,se,Ae,Pe){var Se,z,L=0;0<J.level?(J.strm.data_type===2&&(J.strm.data_type=(function(ne){var ve,we=4093624447;for(ve=0;ve<=31;ve++,we>>>=1)if(1&we&&ne.dyn_ltree[2*ve]!==0)return s;if(ne.dyn_ltree[18]!==0||ne.dyn_ltree[20]!==0||ne.dyn_ltree[26]!==0)return o;for(ve=32;ve<f;ve++)if(ne.dyn_ltree[2*ve]!==0)return o;return s})(J)),ht(J,J.l_desc),ht(J,J.d_desc),L=(function(ne){var ve;for(H(ne,ne.dyn_ltree,ne.l_desc.max_code),H(ne,ne.dyn_dtree,ne.d_desc.max_code),ht(ne,ne.bl_desc),ve=x-1;3<=ve&&ne.bl_tree[2*D[ve]+1]===0;ve--);return ne.opt_len+=3*(ve+1)+5+5+4,ve})(J),Se=J.opt_len+3+7>>>3,(z=J.static_len+3+7>>>3)<=Se&&(Se=z)):Se=z=Ae+5,Ae+4<=Se&&se!==-1?V(J,se,Ae,Pe):J.strategy===4||z===Se?(te(J,2+(Pe?1:0),3),he(J,F,O)):(te(J,4+(Pe?1:0),3),(function(ne,ve,we,ye){var nt;for(te(ne,ve-257,5),te(ne,we-1,5),te(ne,ye-4,4),nt=0;nt<ye;nt++)te(ne,ne.bl_tree[2*D[nt]+1],3);B(ne,ne.dyn_ltree,ve-1),B(ne,ne.dyn_dtree,we-1)})(J,J.l_desc.max_code+1,J.d_desc.max_code+1,L+1),he(J,J.dyn_ltree,J.dyn_dtree)),Ne(J),Pe&&ie(J)},i._tr_tally=function(J,se,Ae){return J.pending_buf[J.d_buf+2*J.last_lit]=se>>>8&255,J.pending_buf[J.d_buf+2*J.last_lit+1]=255&se,J.pending_buf[J.l_buf+J.last_lit]=255&Ae,J.last_lit++,se===0?J.dyn_ltree[2*Ae]++:(J.matches++,se--,J.dyn_ltree[2*(R[Ae]+f+1)]++,J.dyn_dtree[2*$(se)]++),J.last_lit===J.lit_bufsize-1},i._tr_align=function(J){te(J,2,3),fe(J,S,F),(function(se){se.bi_valid===16?(X(se,se.bi_buf),se.bi_buf=0,se.bi_valid=0):8<=se.bi_valid&&(se.pending_buf[se.pending++]=255&se.bi_buf,se.bi_buf>>=8,se.bi_valid-=8)})(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(a){(function(s,o){if(!s.setImmediate){var c,u,d,f,g=1,m={},x=!1,v=s.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(s);y=y&&y.setTimeout?y:s,c={}.toString.call(s.process)==="[object process]"?function(A){process.nextTick(function(){M(A)})}:(function(){if(s.postMessage&&!s.importScripts){var A=!0,T=s.onmessage;return s.onmessage=function(){A=!1},s.postMessage("","*"),s.onmessage=T,A}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",S,!1):s.attachEvent("onmessage",S),function(A){s.postMessage(f+A,"*")}):s.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){M(A.data)},function(A){d.port2.postMessage(A)}):v&&"onreadystatechange"in v.createElement("script")?(u=v.documentElement,function(A){var T=v.createElement("script");T.onreadystatechange=function(){M(A),T.onreadystatechange=null,u.removeChild(T),T=null},u.appendChild(T)}):function(A){setTimeout(M,0,A)},y.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++},y.clearImmediate=b}function b(A){delete m[A]}function M(A){if(x)setTimeout(M,0,A);else{var T=m[A];if(T){x=!0;try{(function(k){var N=k.callback,I=k.args;switch(I.length){case 0:N();break;case 1:N(I[0]);break;case 2:N(I[0],I[1]);break;case 3:N(I[0],I[1],I[2]);break;default:N.apply(o,I)}})(T)}finally{b(A),x=!1}}}}function S(A){A.source===s&&typeof A.data=="string"&&A.data.indexOf(f)===0&&M(+A.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof hv<"u"?hv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(GC)),GC.exports}var rje=nje();const ije=fo(rje);function aje(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 IH=aje;async function FH(t){const e=[],n=t.getElementsByTagName("mesh");for(let r=0;r<n.length;r++){const i=n[r],a=[],s=[],o=i.getElementsByTagName("vertex");for(let u=0;u<o.length;u++){const d=o[u];a.push(parseFloat(d.getAttribute("x")||"0"),parseFloat(d.getAttribute("y")||"0"),parseFloat(d.getAttribute("z")||"0"))}const c=i.getElementsByTagName("triangle");for(let u=0;u<c.length;u++){const d=c[u];s.push(parseInt(d.getAttribute("v1")||"0"),parseInt(d.getAttribute("v2")||"0"),parseInt(d.getAttribute("v3")||"0"))}a.length>0&&s.length>0&&e.push({vertices:a,triangles:s})}return e}async function sje(t){const e=await ije.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(d){const f=d.startsWith("/")?d.slice(1):d,g=e.files[f];if(!g)return null;const m=await g.async("string");return i.parseFromString(m,"application/xml")}const s=Object.keys(e.files).find(d=>d==="3D/3dmodel.model"||d.endsWith("/3dmodel.model"));if(!s){const d=Object.keys(e.files).find(f=>f.endsWith(".model"));if(d){const f=await a(d);if(f){const g=await FH(f);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const o=await a(s);if(!o)return{objects:n,buildItems:r};const c=o.getElementsByTagName("object");for(let d=0;d<c.length;d++){const f=c[d],g=f.getAttribute("id");if(!g)continue;const m=[],x=f.getElementsByTagName("mesh");for(let y=0;y<x.length;y++){const b=x[y],M=[],S=[],A=b.getElementsByTagName("vertex");for(let k=0;k<A.length;k++){const N=A[k];M.push(parseFloat(N.getAttribute("x")||"0"),parseFloat(N.getAttribute("y")||"0"),parseFloat(N.getAttribute("z")||"0"))}const T=b.getElementsByTagName("triangle");for(let k=0;k<T.length;k++){const N=T[k];S.push(parseInt(N.getAttribute("v1")||"0"),parseInt(N.getAttribute("v2")||"0"),parseInt(N.getAttribute("v3")||"0"))}M.length>0&&S.length>0&&m.push({vertices:M,triangles:S})}const v=f.getElementsByTagName("component");for(let y=0;y<v.length;y++){const b=v[y],M=b.getAttribute("p:path")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(M){const S=await a(M);if(S){const A=await FH(S),T=b.getAttribute("transform"),k=IH(T);for(const N of A)if(T){const I=[];for(let C=0;C<N.vertices.length;C+=3){const D=new Qe(N.vertices[C],N.vertices[C+1],N.vertices[C+2]);D.applyMatrix4(k),I.push(D.x,D.y,D.z)}m.push({vertices:I,triangles:N.triangles})}else m.push(N)}}}m.length>0&&n.set(g,{id:g,meshes:m})}const u=o.getElementsByTagName("build");if(u.length>0){const d=u[0].getElementsByTagName("item");for(let f=0;f<d.length;f++){const g=d[f],m=g.getAttribute("objectid");if(!m)continue;const x=IH(g.getAttribute("transform"));r.push({objectId:m,transform:x})}}return{objects:n,buildItems:r}}function UH(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 io(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function oje({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),a=E.useRef(null),s=E.useRef(null),o=E.useRef(null),[c,u]=E.useState(!0),[d,f]=E.useState(null);E.useEffect(()=>{if(!r.current)return;const x=r.current,v=x.clientWidth,y=x.clientHeight,b=new FNe;b.background=new _n(1710618),a.current=b;const M=new Ys(45,v/y,.1,1e4);M.position.set(150,150,150),s.current=M;const S=new zDe({antialias:!0});S.setSize(v,y),S.setPixelRatio(window.devicePixelRatio),x.appendChild(S.domElement),i.current=S;const A=new HDe(M,S.domElement);A.enableDamping=!0,A.dampingFactor=.05,o.current=A;const T=new YNe(16777215,.6);b.add(T);const k=new oH(16777215,.8);k.position.set(100,100,100),b.add(k);const N=new oH(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 QNe(I,C,4473924,3355443);b.add(D);const F=new uO(e.x,e.y),O=new oO({color:44610,transparent:!0,opacity:.15,side:rl}),q=new xl(F,O);q.rotation.x=-Math.PI/2,q.position.y=-.5,b.add(q);let R;const W=()=>{R=requestAnimationFrame(W),A.update(),S.render(b,M)};W(),fetch(t).then(G=>{if(!G.ok)throw new Error("Failed to load file");return G.arrayBuffer()}).then(sje).then(({objects:G,buildItems:ee})=>{if(G.size===0)throw new Error("No meshes found in 3MF file");const Z=new GNe({color:44610,shininess:30,flatShading:!1}),Q=new Lx,U=[];if(ee.length>0)for(const ie of ee){const be=G.get(ie.objectId);if(be)for(const je of be.meshes){const he=[];for(let H=0;H<je.vertices.length;H+=3){const B=new Qe(je.vertices[H],je.vertices[H+1],je.vertices[H+2]);B.applyMatrix4(ie.transform),he.push(B.x,B.y,B.z)}const ht=UH({vertices:he,triangles:je.triangles});U.push(ht)}}else for(const ie of G.values())for(const be of ie.meshes){const je=UH(be);U.push(je)}if(U.length>0){const ie=U.length===1?U[0]:tje(U,!1);if(ie){const be=new xl(ie,Z);Q.add(be)}if(U.length>1)for(const be of U)be.dispose()}const $=new tf().setFromObject(Q),X=$.getCenter(new Qe);Q.position.y=-$.min.y,ee.length===0&&(Q.position.x=-X.x,Q.position.z=-X.z),b.add(Q);const te=new tf().setFromObject(Q),fe=te.getCenter(new Qe),pe=te.getSize(new Qe),Ne=Math.max(pe.x,pe.y,pe.z)*1.8;M.position.set(fe.x+Ne*.7,fe.y+Ne*.5,fe.z+Ne*.7),A.target.copy(fe),A.update(),u(!1)}).catch(G=>{f(G.message),u(!1)});const K=()=>{if(!x)return;const G=x.clientWidth,ee=x.clientHeight;M.aspect=G/ee,M.updateProjectionMatrix(),S.setSize(G,ee)};return window.addEventListener("resize",K),()=>{window.removeEventListener("resize",K),cancelAnimationFrame(R),A.dispose(),S.dispose(),x.removeChild(S.domElement)}},[t,e]);const g=()=>{s.current&&o.current&&(s.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},m=x=>{s.current&&s.current.position.multiplyScalar(x)};return l.jsxs("div",{className:`relative ${n}`,children:[l.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),c&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}),d&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx("p",{className:"text-red-400",children:d})}),!c&&!d&&l.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:l.jsx(Uue,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:l.jsx(Hue,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:g,children:l.jsx(Xm,{className:"w-4 h-4"})})]})]})}const BM="159",mp={ROTATE:0,DOLLY:1,PAN:2},gp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},lje=0,zH=1,cje=2,SZ=1,uje=2,ac=3,fd=0,Ka=1,dc=2,Yu=0,sm=1,BH=2,HH=3,$H=4,dje=5,lh=100,hje=101,fje=102,VH=103,GH=104,pje=200,mje=201,gje=202,xje=203,TP=204,CP=205,bje=206,yje=207,vje=208,_je=209,wje=210,Sje=211,Mje=212,Eje=213,Aje=214,Tje=0,Cje=1,Nje=2,Dw=3,kje=4,Pje=5,Rje=6,Dje=7,hO=0,jje=1,Oje=2,Zu=0,Lje=1,Ije=2,Fje=3,Uje=4,zje=5,MZ=300,Rm=301,Dm=302,NP=303,kP=304,HM=306,PP=1e3,ko=1001,RP=1002,Zi=1003,WH=1004,WC=1005,Zs=1006,Bje=1007,K0=1008,Qu=1009,Hje=1010,$je=1011,fO=1012,EZ=1013,Bu=1014,xc=1015,X0=1016,AZ=1017,TZ=1018,Nh=1020,Vje=1021,Qs=1023,Gje=1024,Wje=1025,kh=1026,jm=1027,qje=1028,CZ=1029,Kje=1030,NZ=1031,kZ=1033,qC=33776,KC=33777,XC=33778,YC=33779,qH=35840,KH=35841,XH=35842,YH=35843,PZ=36196,ZH=37492,QH=37496,JH=37808,e$=37809,t$=37810,n$=37811,r$=37812,i$=37813,a$=37814,s$=37815,o$=37816,l$=37817,c$=37818,u$=37819,d$=37820,h$=37821,ZC=36492,f$=36494,p$=36495,Xje=36283,m$=36284,g$=36285,x$=36286,RZ=3e3,Ph=3001,Yje=3200,Zje=3201,DZ=0,Qje=1,Js="",Qi="srgb",Lc="srgb-linear",pO="display-p3",$M="display-p3-linear",jw="linear",lr="srgb",Ow="rec709",Lw="p3",xp=7680,b$=519,Jje=512,eOe=513,tOe=514,jZ=515,nOe=516,rOe=517,iOe=518,aOe=519,DP=35044,y$="300 es",jP=1035,ll=2e3,Y0=2001;class gf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}}const oa=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let v$=1234567;const Kx=Math.PI/180,Z0=180/Math.PI;function Mc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(oa[t&255]+oa[t>>8&255]+oa[t>>16&255]+oa[t>>24&255]+"-"+oa[e&255]+oa[e>>8&255]+"-"+oa[e>>16&15|64]+oa[e>>24&255]+"-"+oa[n&63|128]+oa[n>>8&255]+"-"+oa[n>>16&255]+oa[n>>24&255]+oa[r&255]+oa[r>>8&255]+oa[r>>16&255]+oa[r>>24&255]).toLowerCase()}function Ji(t,e,n){return Math.max(e,Math.min(n,t))}function mO(t,e){return(t%e+e)%e}function sOe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function oOe(t,e,n){return t!==e?(n-t)/(e-t):0}function Xx(t,e,n){return(1-n)*t+n*e}function lOe(t,e,n,r){return Xx(t,e,1-Math.exp(-n*r))}function cOe(t,e=1){return e-Math.abs(mO(t,e*2)-e)}function uOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function dOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function hOe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function fOe(t,e){return t+Math.random()*(e-t)}function pOe(t){return t*(.5-Math.random())}function mOe(t){t!==void 0&&(v$=t);let e=v$+=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 gOe(t){return t*Kx}function xOe(t){return t*Z0}function OP(t){return(t&t-1)===0&&t!==0}function bOe(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 yOe(t,e,n,r,i){const a=Math.cos,s=Math.sin,o=a(n/2),c=s(n/2),u=a((e+r)/2),d=s((e+r)/2),f=a((e-r)/2),g=s((e-r)/2),m=a((r-e)/2),x=s((r-e)/2);switch(i){case"XYX":t.set(o*d,c*f,c*g,o*u);break;case"YZY":t.set(c*g,o*d,c*f,o*u);break;case"ZXZ":t.set(c*f,c*g,o*d,o*u);break;case"XZX":t.set(o*d,c*x,c*m,o*u);break;case"YXY":t.set(c*m,o*d,c*x,o*u);break;case"ZYZ":t.set(c*x,c*m,o*d,o*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function il(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Kn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const OZ={DEG2RAD:Kx,RAD2DEG:Z0,generateUUID:Mc,clamp:Ji,euclideanModulo:mO,mapLinear:sOe,inverseLerp:oOe,lerp:Xx,damp:lOe,pingpong:cOe,smoothstep:uOe,smootherstep:dOe,randInt:hOe,randFloat:fOe,randFloatSpread:pOe,seededRandom:mOe,degToRad:gOe,radToDeg:xOe,isPowerOfTwo:OP,ceilPowerOfTwo:bOe,floorPowerOfTwo:Iw,setQuaternionFromProperEuler:yOe,normalize:Kn,denormalize:il};class Zt{constructor(e=0,n=0){Zt.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Ji(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fn{constructor(e,n,r,i,a,s,o,c,u){fn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u)}set(e,n,r,i,a,s,o,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=s,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],m=r[5],x=r[8],v=i[0],y=i[3],b=i[6],M=i[1],S=i[4],A=i[7],T=i[2],k=i[5],N=i[8];return a[0]=s*v+o*M+c*T,a[3]=s*y+o*S+c*k,a[6]=s*b+o*A+c*N,a[1]=u*v+d*M+f*T,a[4]=u*y+d*S+f*k,a[7]=u*b+d*A+f*N,a[2]=g*v+m*M+x*T,a[5]=g*y+m*S+x*k,a[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],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8];return n*s*d-n*o*u-r*a*d+r*o*c+i*a*u-i*s*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=d*s-o*u,g=o*c-d*a,m=u*a-s*c,x=n*f+r*g+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(o*r-i*s)*v,e[3]=g*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-o*n)*v,e[6]=m*v,e[7]=(r*c-u*n)*v,e[8]=(s*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*o)+s+e,-i*u,i*c,-i*(-u*s+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(QC.makeScale(e,n)),this}rotate(e){return this.premultiply(QC.makeRotation(-e)),this}translate(e,n){return this.premultiply(QC.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const QC=new fn;function LZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Fw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function vOe(){const t=Fw("canvas");return t.style.display="block",t}const _$={};function Yx(t){t in _$||(_$[t]=!0,console.warn(t))}const w$=new fn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),S$=new fn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),a_={[Lc]:{transfer:jw,primaries:Ow,toReference:t=>t,fromReference:t=>t},[Qi]:{transfer:lr,primaries:Ow,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[$M]:{transfer:jw,primaries:Lw,toReference:t=>t.applyMatrix3(S$),fromReference:t=>t.applyMatrix3(w$)},[pO]:{transfer:lr,primaries:Lw,toReference:t=>t.convertSRGBToLinear().applyMatrix3(S$),fromReference:t=>t.applyMatrix3(w$).convertLinearToSRGB()}},_Oe=new Set([Lc,$M]),Xn={enabled:!0,_workingColorSpace:Lc,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(t){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!t},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!_Oe.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=a_[e].toReference,i=a_[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 a_[t].primaries},getTransfer:function(t){return t===Js?jw:a_[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 IZ{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=Fw("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=Fw("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let s=0;s<a.length;s++)a[s]=om(a[s]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(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 wOe=0;class FZ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:wOe++}),this.uuid=Mc(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(eN(i[s].image)):a.push(eN(i[s]))}else a=eN(i);r.url=a}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?IZ.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 SOe=0;class Xa extends gf{constructor(e=Xa.DEFAULT_IMAGE,n=Xa.DEFAULT_MAPPING,r=ko,i=ko,a=Zs,s=K0,o=Qs,c=Qu,u=Xa.DEFAULT_ANISOTROPY,d=Js){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:SOe++}),this.uuid=Mc(),this.name="",this.source=new FZ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Zt(0,0),this.repeat=new Zt(1,1),this.center=new Zt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Yx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Ph?Qi:Js),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!==MZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case PP:e.x=e.x-Math.floor(e.x);break;case ko:e.x=e.x<0?0:1;break;case RP: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 PP:e.y=e.y-Math.floor(e.y);break;case ko:e.y=e.y<0?0:1;break;case RP:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Yx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Qi?Ph:RZ}set encoding(e){Yx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ph?Qi:Js}}Xa.DEFAULT_IMAGE=null;Xa.DEFAULT_MAPPING=MZ;Xa.DEFAULT_ANISOTROPY=1;class Zn{constructor(e=0,n=0,r=0,i=1){Zn.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],m=c[5],x=c[9],v=c[2],y=c[6],b=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-v)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+v)<.1&&Math.abs(x+y)<.1&&Math.abs(u+m+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(m+1)/2,T=(b+1)/2,k=(d+g)/4,N=(f+v)/4,I=(x+y)/4;return S>A&&S>T?S<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(S),i=k/r,a=N/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=k/i,a=I/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=N/a,i=I/a),this.set(r,i,a,n),this}let M=Math.sqrt((y-x)*(y-x)+(f-v)*(f-v)+(g-d)*(g-d));return Math.abs(M)<.001&&(M=1),this.x=(y-x)/M,this.y=(f-v)/M,this.z=(g-d)/M,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 MOe extends gf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Zn(0,0,e,n),this.scissorTest=!1,this.viewport=new Zn(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Yx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Ph?Qi:Js),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Zs,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Xa(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 FZ(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 MOe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class UZ extends Xa{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Zi,this.minFilter=Zi,this.wrapR=ko,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class EOe extends Xa{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Zi,this.minFilter=Zi,this.wrapR=ko,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class rf{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,s,o){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const g=a[s+0],m=a[s+1],x=a[s+2],v=a[s+3];if(o===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(o===1){e[n+0]=g,e[n+1]=m,e[n+2]=x,e[n+3]=v;return}if(f!==v||c!==g||u!==m||d!==x){let y=1-o;const b=c*g+u*m+d*x+f*v,M=b>=0?1:-1,S=1-b*b;if(S>Number.EPSILON){const T=Math.sqrt(S),k=Math.atan2(T,b*M);y=Math.sin(y*k)/T,o=Math.sin(o*k)/T}const A=o*M;if(c=c*y+g*A,u=u*y+m*A,d=d*y+x*A,f=f*y+v*A,y===1-o){const T=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=T,u*=T,d*=T,f*=T}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[s],g=a[s+1],m=a[s+2],x=a[s+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,a=e._z,s=e._order,o=Math.cos,c=Math.sin,u=o(r/2),d=o(i/2),f=o(a/2),g=c(r/2),m=c(i/2),x=c(a/2);switch(s){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: "+s)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],s=n[1],o=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+o+f;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(d-c)*m,this._y=(a-u)*m,this._z=(s-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+s)/m,this._z=(a+u)/m}else if(o>f){const m=2*Math.sqrt(1+o-r-f);this._w=(a-u)/m,this._x=(i+s)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(s-i)/m,this._x=(a+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ji(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,o=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+s*o+i*u-a*c,this._y=i*d+s*c+a*o-r*u,this._z=a*d+s*u+r*c-i*o,this._w=s*d-r*o-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,s=this._w;let o=s*e._w+r*e._x+i*e._y+a*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=s,this._x=r,this._y=i,this._z=a,this;const c=1-o*o;if(c<=Number.EPSILON){const m=1-n;return this._w=m*s+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,o),f=Math.sin((1-n)*d)/u,g=Math.sin(n*d)/u;return this._w=s*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=a*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class De{constructor(e=0,n=0,r=0){De.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(M$.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(M$.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,s=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,c=e.w,u=2*(s*i-o*r),d=2*(o*n-a*i),f=2*(a*r-s*n);return this.x=n+c*u+s*f-o*d,this.y=r+c*d+o*u-a*f,this.z=i+c*f+a*d-s*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,o=n.y,c=n.z;return this.x=i*c-a*o,this.y=a*s-r*c,this.z=r*o-i*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return tN.copy(this).projectOnVector(e),this.sub(tN)}reflect(e){return this.sub(tN.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Ji(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(n),this.y=r*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const tN=new De,M$=new rf;class ao{constructor(e=new De(1/0,1/0,1/0),n=new De(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(So.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(So.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=So.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,So):So.fromBufferAttribute(a,s),So.applyMatrix4(e.matrixWorld),this.expandByPoint(So);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 a=0,s=i.length;a<s;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,So),So.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Sx),o_.subVectors(this.max,Sx),yp.subVectors(e.a,Sx),vp.subVectors(e.b,Sx),_p.subVectors(e.c,Sx),bu.subVectors(vp,yp),yu.subVectors(_p,vp),Kd.subVectors(yp,_p);let n=[0,-bu.z,bu.y,0,-yu.z,yu.y,0,-Kd.z,Kd.y,bu.z,0,-bu.x,yu.z,0,-yu.x,Kd.z,0,-Kd.x,-bu.y,bu.x,0,-yu.y,yu.x,0,-Kd.y,Kd.x,0];return!nN(n,yp,vp,_p,o_)||(n=[1,0,0,0,1,0,0,0,1],!nN(n,yp,vp,_p,o_))?!1:(l_.crossVectors(bu,yu),n=[l_.x,l_.y,l_.z],nN(n,yp,vp,_p,o_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,So).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(So).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Yl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Yl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Yl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Yl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Yl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Yl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Yl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Yl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Yl),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Yl=[new De,new De,new De,new De,new De,new De,new De,new De],So=new De,s_=new ao,yp=new De,vp=new De,_p=new De,bu=new De,yu=new De,Kd=new De,Sx=new De,o_=new De,l_=new De,Xd=new De;function nN(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){Xd.fromArray(t,a);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 AOe=new ao,Mx=new De,rN=new De;class ul{constructor(e=new De,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):AOe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Mx.subVectors(e,this.center);const n=Mx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Mx,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(Mx.copy(e.center).add(rN)),this.expandByPoint(Mx.copy(e.center).sub(rN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Zl=new De,iN=new De,c_=new De,vu=new De,aN=new De,u_=new De,sN=new De;class gO{constructor(e=new De,n=new De(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Zl)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Zl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Zl.copy(this.origin).addScaledVector(this.direction,n),Zl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){iN.copy(e).add(n).multiplyScalar(.5),c_.copy(n).sub(e).normalize(),vu.copy(this.origin).sub(iN);const a=e.distanceTo(n)*.5,s=-this.direction.dot(c_),o=vu.dot(this.direction),c=-vu.dot(c_),u=vu.lengthSq(),d=Math.abs(1-s*s);let f,g,m,x;if(d>0)if(f=s*c-o,g=s*o-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const v=1/d;f*=v,g*=v,m=f*(f+s*g+2*o)+g*(s*f+g+2*c)+u}else g=a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-s*a+o)),g=f>0?-a:Math.min(Math.max(-a,-c),a),m=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),m=g*(g+2*c)+u):(f=Math.max(0,-(s*a+o)),g=f>0?a:Math.min(Math.max(-a,-c),a),m=-f*f+g*(g+2*c)+u);else g=s>0?-a:a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(iN).addScaledVector(c_,g),m}intersectSphere(e,n){Zl.subVectors(e.center,this.origin);const r=Zl.dot(this.direction),i=Zl.dot(Zl)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,c=r+s;return c<0?null:o<0?this.at(c,n):this.at(o,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,o,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,s=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,s=(e.min.y-g.y)*d),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),f>=0?(o=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Zl)!==null}intersectTriangle(e,n,r,i,a){aN.subVectors(n,e),u_.subVectors(r,e),sN.crossVectors(aN,u_);let s=this.direction.dot(sN),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;vu.subVectors(this.origin,e);const c=o*this.direction.dot(u_.crossVectors(vu,u_));if(c<0)return null;const u=o*this.direction.dot(aN.cross(vu));if(u<0||c+u>s)return null;const d=-o*vu.dot(sN);return d<0?null:this.at(d/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ar{constructor(e,n,r,i,a,s,o,c,u,d,f,g,m,x,v,y){ar.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u,d,f,g,m,x,v,y)}set(e,n,r,i,a,s,o,c,u,d,f,g,m,x,v,y){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=a,b[5]=s,b[9]=o,b[13]=c,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=m,b[7]=x,b[11]=v,b[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ar().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(),a=1/wp.setFromMatrixColumn(e,1).length(),s=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]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*s,n[9]=r[9]*s,n[10]=r[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,s=Math.cos(r),o=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*d,m=s*f,x=o*d,v=o*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+x*u,n[5]=g-v*u,n[9]=-o*c,n[2]=v-g*u,n[6]=x+m*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,m=c*f,x=u*d,v=u*f;n[0]=g+v*o,n[4]=x*o-m,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-o,n[2]=m*o-x,n[6]=v+g*o,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,m=c*f,x=u*d,v=u*f;n[0]=g-v*o,n[4]=-s*f,n[8]=x+m*o,n[1]=m+x*o,n[5]=s*d,n[9]=v-g*o,n[2]=-s*u,n[6]=o,n[10]=s*c}else if(e.order==="ZYX"){const g=s*d,m=s*f,x=o*d,v=o*f;n[0]=c*d,n[4]=x*u-m,n[8]=g*u+v,n[1]=c*f,n[5]=v*u+g,n[9]=m*u-x,n[2]=-u,n[6]=o*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,m=s*u,x=o*c,v=o*u;n[0]=c*d,n[4]=v-g*f,n[8]=x*f+m,n[1]=f,n[5]=s*d,n[9]=-o*d,n[2]=-u*d,n[6]=m*f+x,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*c,m=s*u,x=o*c,v=o*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+v,n[5]=s*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=o*d,n[10]=v*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(TOe,e,COe)}lookAt(e,n,r){const i=this.elements;return ds.subVectors(e,n),ds.lengthSq()===0&&(ds.z=1),ds.normalize(),_u.crossVectors(r,ds),_u.lengthSq()===0&&(Math.abs(r.z)===1?ds.x+=1e-4:ds.z+=1e-4,ds.normalize(),_u.crossVectors(r,ds)),_u.normalize(),d_.crossVectors(ds,_u),i[0]=_u.x,i[4]=d_.x,i[8]=ds.x,i[1]=_u.y,i[5]=d_.y,i[9]=ds.y,i[2]=_u.z,i[6]=d_.z,i[10]=ds.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],m=r[13],x=r[2],v=r[6],y=r[10],b=r[14],M=r[3],S=r[7],A=r[11],T=r[15],k=i[0],N=i[4],I=i[8],C=i[12],D=i[1],F=i[5],O=i[9],q=i[13],R=i[2],W=i[6],K=i[10],G=i[14],ee=i[3],Z=i[7],Q=i[11],U=i[15];return a[0]=s*k+o*D+c*R+u*ee,a[4]=s*N+o*F+c*W+u*Z,a[8]=s*I+o*O+c*K+u*Q,a[12]=s*C+o*q+c*G+u*U,a[1]=d*k+f*D+g*R+m*ee,a[5]=d*N+f*F+g*W+m*Z,a[9]=d*I+f*O+g*K+m*Q,a[13]=d*C+f*q+g*G+m*U,a[2]=x*k+v*D+y*R+b*ee,a[6]=x*N+v*F+y*W+b*Z,a[10]=x*I+v*O+y*K+b*Q,a[14]=x*C+v*q+y*G+b*U,a[3]=M*k+S*D+A*R+T*ee,a[7]=M*N+S*F+A*W+T*Z,a[11]=M*I+S*O+A*K+T*Q,a[15]=M*C+S*q+A*G+T*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],s=e[1],o=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],m=e[14],x=e[3],v=e[7],y=e[11],b=e[15];return x*(+a*c*f-i*u*f-a*o*g+r*u*g+i*o*m-r*c*m)+v*(+n*c*m-n*u*g+a*s*g-i*s*m+i*u*d-a*c*d)+y*(+n*u*f-n*o*m-a*s*f+r*s*m+a*o*d-r*u*d)+b*(-i*o*d-n*c*f+n*o*g+i*s*f-r*s*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],m=e[11],x=e[12],v=e[13],y=e[14],b=e[15],M=f*y*u-v*g*u+v*c*m-o*y*m-f*c*b+o*g*b,S=x*g*u-d*y*u-x*c*m+s*y*m+d*c*b-s*g*b,A=d*v*u-x*f*u+x*o*m-s*v*m-d*o*b+s*f*b,T=x*f*c-d*v*c-x*o*g+s*v*g+d*o*y-s*f*y,k=n*M+r*S+i*A+a*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]=M*N,e[1]=(v*g*a-f*y*a-v*i*m+r*y*m+f*i*b-r*g*b)*N,e[2]=(o*y*a-v*c*a+v*i*u-r*y*u-o*i*b+r*c*b)*N,e[3]=(f*c*a-o*g*a-f*i*u+r*g*u+o*i*m-r*c*m)*N,e[4]=S*N,e[5]=(d*y*a-x*g*a+x*i*m-n*y*m-d*i*b+n*g*b)*N,e[6]=(x*c*a-s*y*a-x*i*u+n*y*u+s*i*b-n*c*b)*N,e[7]=(s*g*a-d*c*a+d*i*u-n*g*u-s*i*m+n*c*m)*N,e[8]=A*N,e[9]=(x*f*a-d*v*a-x*r*m+n*v*m+d*r*b-n*f*b)*N,e[10]=(s*v*a-x*o*a+x*r*u-n*v*u-s*r*b+n*o*b)*N,e[11]=(d*o*a-s*f*a-d*r*u+n*f*u+s*r*m-n*o*m)*N,e[12]=T*N,e[13]=(d*v*i-x*f*i+x*r*g-n*v*g-d*r*y+n*f*y)*N,e[14]=(x*o*i-s*v*i-x*r*c+n*v*c+s*r*y-n*o*y)*N,e[15]=(s*f*i-d*o*i+d*r*c-n*f*c-s*r*g+n*o*g)*N,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,s=e.x,o=e.y,c=e.z,u=a*s,d=a*o;return this.set(u*s+r,u*o-i*c,u*c+i*o,0,u*o+i*c,d*o+r,d*c-i*s,0,u*c-i*o,d*c+i*s,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,c=n._w,u=a+a,d=s+s,f=o+o,g=a*u,m=a*d,x=a*f,v=s*d,y=s*f,b=o*f,M=c*u,S=c*d,A=c*f,T=r.x,k=r.y,N=r.z;return i[0]=(1-(v+b))*T,i[1]=(m+A)*T,i[2]=(x-S)*T,i[3]=0,i[4]=(m-A)*k,i[5]=(1-(g+b))*k,i[6]=(y+M)*k,i[7]=0,i[8]=(x+S)*N,i[9]=(y-M)*N,i[10]=(1-(g+v))*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 a=wp.set(i[0],i[1],i[2]).length();const s=wp.set(i[4],i[5],i[6]).length(),o=wp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],Mo.copy(this);const u=1/a,d=1/s,f=1/o;return Mo.elements[0]*=u,Mo.elements[1]*=u,Mo.elements[2]*=u,Mo.elements[4]*=d,Mo.elements[5]*=d,Mo.elements[6]*=d,Mo.elements[8]*=f,Mo.elements[9]*=f,Mo.elements[10]*=f,n.setFromRotationMatrix(Mo),r.x=a,r.y=s,r.z=o,this}makePerspective(e,n,r,i,a,s,o=ll){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),g=(r+i)/(r-i);let m,x;if(o===ll)m=-(s+a)/(s-a),x=-2*s*a/(s-a);else if(o===Y0)m=-s/(s-a),x=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=g,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=ll){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(s-a),g=(n+e)*u,m=(r+i)*d;let x,v;if(o===ll)x=(s+a)*f,v=-2*f;else if(o===Y0)x=a*f,v=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-g,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=v,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const wp=new De,Mo=new ar,TOe=new De(0,0,0),COe=new De(1,1,1),_u=new De,d_=new De,ds=new De,E$=new ar,A$=new rf;class qb{constructor(e=0,n=0,r=0,i=qb.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],s=i[4],o=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Ji(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Ji(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Ji(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Ji(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(Ji(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Ji(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,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 E$.makeRotationFromQuaternion(e),this.setFromRotationMatrix(E$,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return A$.setFromEuler(this),this.setFromQuaternion(A$,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}qb.DEFAULT_ORDER="XYZ";class zZ{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 NOe=0;const T$=new De,Sp=new rf,Ql=new ar,h_=new De,Ex=new De,kOe=new De,POe=new rf,C$=new De(1,0,0),N$=new De(0,1,0),k$=new De(0,0,1),ROe={type:"added"},DOe={type:"removed"};class Aa extends gf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:NOe++}),this.uuid=Mc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Aa.DEFAULT_UP.clone();const e=new De,n=new qb,r=new rf,i=new De(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ar},normalMatrix:{value:new fn}}),this.matrix=new ar,this.matrixWorld=new ar,this.matrixAutoUpdate=Aa.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Aa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new zZ,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(C$,e)}rotateY(e){return this.rotateOnAxis(N$,e)}rotateZ(e){return this.rotateOnAxis(k$,e)}translateOnAxis(e,n){return T$.copy(e).applyQuaternion(this.quaternion),this.position.add(T$.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(C$,e)}translateY(e){return this.translateOnAxis(N$,e)}translateZ(e){return this.translateOnAxis(k$,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ql.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?h_.copy(e):h_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Ex.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ql.lookAt(Ex,h_,this.up):Ql.lookAt(h_,Ex,this.up),this.quaternion.setFromRotationMatrix(Ql),i&&(Ql.extractRotation(i.matrixWorld),Sp.setFromRotationMatrix(Ql),this.quaternion.premultiply(Sp.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(ROe)):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(DOe)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ql.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ql.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ql),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ex,e,kOe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ex,POe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const a=n[r];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let a=0,s=i.length;a<s;a++){const o=i[a];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function a(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,u=this.material.length;c<u;c++)o.push(a(e.materials,this.material[c]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(a(e.animations,c))}}if(n){const o=s(e.geometries),c=s(e.materials),u=s(e.textures),d=s(e.images),f=s(e.shapes),g=s(e.skeletons),m=s(e.animations),x=s(e.nodes);o.length>0&&(r.geometries=o),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),x.length>0&&(r.nodes=x)}return r.object=i,r;function s(o){const c=[];for(const u in o){const d=o[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Aa.DEFAULT_UP=new De(0,1,0);Aa.DEFAULT_MATRIX_AUTO_UPDATE=!0;Aa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Eo=new De,Jl=new De,oN=new De,ec=new De,Mp=new De,Ep=new De,P$=new De,lN=new De,cN=new De,uN=new De;let f_=!1;class Ao{constructor(e=new De,n=new De,r=new De){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Eo.subVectors(e,n),i.cross(Eo);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){Eo.subVectors(i,n),Jl.subVectors(r,n),oN.subVectors(e,n);const s=Eo.dot(Eo),o=Eo.dot(Jl),c=Eo.dot(oN),u=Jl.dot(Jl),d=Jl.dot(oN),f=s*u-o*o;if(f===0)return a.set(-2,-1,-1);const g=1/f,m=(u*c-o*d)*g,x=(s*d-o*c)*g;return a.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,ec),ec.x>=0&&ec.y>=0&&ec.x+ec.y<=1}static getUV(e,n,r,i,a,s,o,c){return f_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),f_=!0),this.getInterpolation(e,n,r,i,a,s,o,c)}static getInterpolation(e,n,r,i,a,s,o,c){return this.getBarycoord(e,n,r,i,ec),c.setScalar(0),c.addScaledVector(a,ec.x),c.addScaledVector(s,ec.y),c.addScaledVector(o,ec.z),c}static isFrontFacing(e,n,r,i){return Eo.subVectors(r,n),Jl.subVectors(e,n),Eo.cross(Jl).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Eo.subVectors(this.c,this.b),Jl.subVectors(this.a,this.b),Eo.cross(Jl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ao.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Ao.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return f_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),f_=!0),Ao.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Ao.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Ao.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ao.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let s,o;Mp.subVectors(i,r),Ep.subVectors(a,r),lN.subVectors(e,r);const c=Mp.dot(lN),u=Ep.dot(lN);if(c<=0&&u<=0)return n.copy(r);cN.subVectors(e,i);const d=Mp.dot(cN),f=Ep.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 s=c/(c-d),n.copy(r).addScaledVector(Mp,s);uN.subVectors(e,a);const m=Mp.dot(uN),x=Ep.dot(uN);if(x>=0&&m<=x)return n.copy(a);const v=m*u-c*x;if(v<=0&&u>=0&&x<=0)return o=u/(u-x),n.copy(r).addScaledVector(Ep,o);const y=d*x-m*f;if(y<=0&&f-d>=0&&m-x>=0)return P$.subVectors(a,i),o=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(P$,o);const b=1/(y+v+g);return s=v*b,o=g*b,n.copy(r).addScaledVector(Mp,s).addScaledVector(Ep,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const BZ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},wu={h:0,s:0,l:0},p_={h:0,s:0,l:0};function dN(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let $t=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Qi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Xn.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Xn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Xn.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Xn.workingColorSpace){if(e=mO(e,1),n=Ji(n,0,1),r=Ji(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=dN(s,a,e+1/3),this.g=dN(s,a,e),this.b=dN(s,a,e-1/3)}return Xn.toWorkingColorSpace(this,i),this}setStyle(e,n=Qi){function r(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Qi){const r=BZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=om(e.r),this.g=om(e.g),this.b=om(e.b),this}copyLinearToSRGB(e){return this.r=JC(e.r),this.g=JC(e.g),this.b=JC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Qi){return Xn.fromWorkingColorSpace(la.copy(this),e),Math.round(Ji(la.r*255,0,255))*65536+Math.round(Ji(la.g*255,0,255))*256+Math.round(Ji(la.b*255,0,255))}getHexString(e=Qi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Xn.workingColorSpace){Xn.fromWorkingColorSpace(la.copy(this),n);const r=la.r,i=la.g,a=la.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let c,u;const d=(o+s)/2;if(o===s)c=0,u=0;else{const f=s-o;switch(u=d<=.5?f/(s+o):f/(2-s-o),s){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Xn.workingColorSpace){return Xn.fromWorkingColorSpace(la.copy(this),n),e.r=la.r,e.g=la.g,e.b=la.b,e}getStyle(e=Qi){Xn.fromWorkingColorSpace(la.copy(this),e);const n=la.r,r=la.g,i=la.b;return e!==Qi?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(wu),this.setHSL(wu.h+e,wu.s+n,wu.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(wu),e.getHSL(p_);const r=Xx(wu.h,p_.h,n),i=Xx(wu.s,p_.s,n),a=Xx(wu.l,p_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const la=new $t;$t.NAMES=BZ;let jOe=0;class ug extends gf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:jOe++}),this.uuid=Mc(),this.name="",this.type="Material",this.blending=sm,this.side=fd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=TP,this.blendDst=CP,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=b$,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!==sm&&(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!==TP&&(r.blendSrc=this.blendSrc),this.blendDst!==CP&&(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!==b$&&(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(a){const s=[];for(const o in a){const c=a[o];delete c.metadata,s.push(c)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class HZ extends ug{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new $t(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=hO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Kr=new De,m_=new Zt;class Ss{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=DP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=xc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)m_.fromBufferAttribute(this,n),m_.applyMatrix3(e),this.setXY(n,m_.x,m_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.applyMatrix3(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.applyMatrix4(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.applyNormalMatrix(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.transformDirection(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=il(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Kn(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=il(n,this.array)),n}setX(e,n){return this.normalized&&(n=Kn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=il(n,this.array)),n}setY(e,n){return this.normalized&&(n=Kn(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=il(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Kn(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=il(n,this.array)),n}setW(e,n){return this.normalized&&(n=Kn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Kn(n,this.array),r=Kn(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=Kn(n,this.array),r=Kn(r,this.array),i=Kn(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Kn(n,this.array),r=Kn(r,this.array),i=Kn(i,this.array),a=Kn(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==DP&&(e.usage=this.usage),e}}class $Z extends Ss{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class VZ extends Ss{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Br extends Ss{constructor(e,n,r){super(new Float32Array(e),n,r)}}let OOe=0;const Bs=new ar,hN=new Aa,Ap=new De,hs=new ao,Ax=new ao,ki=new De;class ga extends gf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:OOe++}),this.uuid=Mc(),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(LZ(e)?VZ:$Z)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new fn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Bs.makeRotationFromQuaternion(e),this.applyMatrix4(Bs),this}rotateX(e){return Bs.makeRotationX(e),this.applyMatrix4(Bs),this}rotateY(e){return Bs.makeRotationY(e),this.applyMatrix4(Bs),this}rotateZ(e){return Bs.makeRotationZ(e),this.applyMatrix4(Bs),this}translate(e,n,r){return Bs.makeTranslation(e,n,r),this.applyMatrix4(Bs),this}scale(e,n,r){return Bs.makeScale(e,n,r),this.applyMatrix4(Bs),this}lookAt(e){return 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 a=e[r];n.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new Br(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ao);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new De(-1/0,-1/0,-1/0),new De(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];hs.setFromBufferAttribute(a),this.morphTargetsRelative?(ki.addVectors(this.boundingBox.min,hs.min),this.boundingBox.expandByPoint(ki),ki.addVectors(this.boundingBox.max,hs.max),this.boundingBox.expandByPoint(ki)):(this.boundingBox.expandByPoint(hs.min),this.boundingBox.expandByPoint(hs.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ul);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new De,1/0);return}if(e){const r=this.boundingSphere.center;if(hs.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];Ax.setFromBufferAttribute(o),this.morphTargetsRelative?(ki.addVectors(hs.min,Ax.min),hs.expandByPoint(ki),ki.addVectors(hs.max,Ax.max),hs.expandByPoint(ki)):(hs.expandByPoint(Ax.min),hs.expandByPoint(Ax.max))}hs.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)ki.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(ki));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],c=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)ki.fromBufferAttribute(o,u),c&&(Ap.fromBufferAttribute(e,u),ki.add(Ap)),i=Math.max(i,r.distanceToSquared(ki))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,s=n.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ss(new Float32Array(4*o),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let D=0;D<o;D++)u[D]=new De,d[D]=new De;const f=new De,g=new De,m=new De,x=new Zt,v=new Zt,y=new Zt,b=new De,M=new De;function S(D,F,O){f.fromArray(i,D*3),g.fromArray(i,F*3),m.fromArray(i,O*3),x.fromArray(s,D*2),v.fromArray(s,F*2),y.fromArray(s,O*2),g.sub(f),m.sub(f),v.sub(x),y.sub(x);const q=1/(v.x*y.y-y.x*v.y);isFinite(q)&&(b.copy(g).multiplyScalar(y.y).addScaledVector(m,-v.y).multiplyScalar(q),M.copy(m).multiplyScalar(v.x).addScaledVector(g,-y.x).multiplyScalar(q),u[D].add(b),u[F].add(b),u[O].add(b),d[D].add(M),d[F].add(M),d[O].add(M))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let D=0,F=A.length;D<F;++D){const O=A[D],q=O.start,R=O.count;for(let W=q,K=q+R;W<K;W+=3)S(r[W+0],r[W+1],r[W+2])}const T=new De,k=new De,N=new De,I=new De;function C(D){N.fromArray(a,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 O=A[D],q=O.start,R=O.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 Ss(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,a=new De,s=new De,o=new De,c=new De,u=new De,d=new De,f=new De;if(e)for(let g=0,m=e.count;g<m;g+=3){const x=e.getX(g+0),v=e.getX(g+1),y=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,y),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),o.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,y),o.add(d),c.add(d),u.add(d),r.setXYZ(x,o.x,o.y,o.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)ki.fromBufferAttribute(e,n),ki.normalize(),e.setXYZ(n,ki.x,ki.y,ki.z)}toNonIndexed(){function e(o,c){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(c.length*d);let m=0,x=0;for(let v=0,y=c.length;v<y;v++){o.isInterleavedBufferAttribute?m=c[v]*o.data.stride+o.offset:m=c[v]*d;for(let b=0;b<d;b++)g[x++]=u[m++]}return new Ss(g,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ga,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const a=this.morphAttributes;for(const o in a){const c=[],u=a[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],m=e(g,r);c.push(m)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,c=s.length;o<c;o++){const u=s[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,m=f.length;g<m;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let u=0,d=s.length;u<d;u++){const f=s[u];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const R$=new ar,Yd=new gO,g_=new ul,D$=new De,Tp=new De,Cp=new De,Np=new De,fN=new De,x_=new De,b_=new Zt,y_=new Zt,v_=new Zt,j$=new De,O$=new De,L$=new De,__=new De,w_=new De;class jo extends Aa{constructor(e=new ga,n=new HZ){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){x_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=o[c],f=a[c];d!==0&&(fN.fromBufferAttribute(f,e),s?x_.addScaledVector(fN,d):x_.addScaledVector(fN.sub(n),d))}n.add(x_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),g_.copy(r.boundingSphere),g_.applyMatrix4(a),Yd.copy(e.ray).recast(e.near),!(g_.containsPoint(Yd.origin)===!1&&(Yd.intersectSphere(g_,D$)===null||Yd.origin.distanceToSquared(D$)>(e.far-e.near)**2))&&(R$.copy(a).invert(),Yd.copy(e.ray).applyMatrix4(R$),!(r.boundingBox!==null&&Yd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Yd)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],M=Math.max(y.start,m.start),S=Math.min(o.count,Math.min(y.start+y.count,m.start+m.count));for(let A=M,T=S;A<T;A+=3){const k=o.getX(A),N=o.getX(A+1),I=o.getX(A+2);i=S_(this,b,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),v=Math.min(o.count,m.start+m.count);for(let y=x,b=v;y<b;y+=3){const M=o.getX(y),S=o.getX(y+1),A=o.getX(y+2);i=S_(this,s,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],M=Math.max(y.start,m.start),S=Math.min(c.count,Math.min(y.start+y.count,m.start+m.count));for(let A=M,T=S;A<T;A+=3){const k=A,N=A+1,I=A+2;i=S_(this,b,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),v=Math.min(c.count,m.start+m.count);for(let y=x,b=v;y<b;y+=3){const M=y,S=y+1,A=y+2;i=S_(this,s,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}}function LOe(t,e,n,r,i,a,s,o){let c;if(e.side===Ka?c=r.intersectTriangle(s,a,i,!0,o):c=r.intersectTriangle(i,a,s,e.side===fd,o),c===null)return null;w_.copy(o),w_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(w_);return u<n.near||u>n.far?null:{distance:u,point:w_.clone(),object:t}}function S_(t,e,n,r,i,a,s,o,c,u){t.getVertexPosition(o,Tp),t.getVertexPosition(c,Cp),t.getVertexPosition(u,Np);const d=LOe(t,e,n,r,Tp,Cp,Np,__);if(d){i&&(b_.fromBufferAttribute(i,o),y_.fromBufferAttribute(i,c),v_.fromBufferAttribute(i,u),d.uv=Ao.getInterpolation(__,Tp,Cp,Np,b_,y_,v_,new Zt)),a&&(b_.fromBufferAttribute(a,o),y_.fromBufferAttribute(a,c),v_.fromBufferAttribute(a,u),d.uv1=Ao.getInterpolation(__,Tp,Cp,Np,b_,y_,v_,new Zt),d.uv2=d.uv1),s&&(j$.fromBufferAttribute(s,o),O$.fromBufferAttribute(s,c),L$.fromBufferAttribute(s,u),d.normal=Ao.getInterpolation(__,Tp,Cp,Np,j$,O$,L$,new De),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:o,b:c,c:u,normal:new De,materialIndex:0};Ao.getNormal(Tp,Cp,Np,f.normal),d.face=f}return d}class Kb extends ga{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],d=[],f=[];let g=0,m=0;x("z","y","x",-1,-1,r,n,e,s,a,0),x("z","y","x",1,-1,r,n,-e,s,a,1),x("x","z","y",1,1,e,r,n,i,s,2),x("x","z","y",1,-1,e,r,-n,i,s,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Br(u,3)),this.setAttribute("normal",new Br(d,3)),this.setAttribute("uv",new Br(f,2));function x(v,y,b,M,S,A,T,k,N,I,C){const D=A/N,F=T/I,O=A/2,q=T/2,R=k/2,W=N+1,K=I+1;let G=0,ee=0;const Z=new De;for(let Q=0;Q<K;Q++){const U=Q*F-q;for(let $=0;$<W;$++){const X=$*D-O;Z[v]=X*M,Z[y]=U*S,Z[b]=R,u.push(Z.x,Z.y,Z.z),Z[v]=0,Z[y]=0,Z[b]=k>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push($/N),f.push(1-Q/I),G+=1}}for(let Q=0;Q<I;Q++)for(let U=0;U<N;U++){const $=g+U+W*Q,X=g+U+W*(Q+1),te=g+(U+1)+W*(Q+1),fe=g+(U+1)+W*Q;c.push($,X,fe),c.push(X,te,fe),ee+=6}o.addGroup(m,ee,C),m+=ee,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kb(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function 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 _a(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 IOe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function GZ(t){return t.getRenderTarget()===null?t.outputColorSpace:Xn.workingColorSpace}const xO={clone:Om,merge:_a};var FOe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,UOe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class pd extends ug{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=FOe,this.fragmentShader=UOe,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=IOe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const s=this.uniforms[i].value;s&&s.isTexture?n.uniforms[i]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[i]={type:"m4",value:s.toArray()}:n.uniforms[i]={value:s}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}}class WZ extends Aa{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ar,this.projectionMatrix=new ar,this.projectionMatrixInverse=new ar,this.coordinateSystem=ll}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class ms extends WZ{constructor(e=50,n=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=Z0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Kx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Z0*2*Math.atan(Math.tan(Kx*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,a,s){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Kx*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const s=this.view;if(this.view!==null&&this.view.enabled){const c=s.fullWidth,u=s.fullHeight;a+=s.offsetX*i/c,n-=s.offsetY*r/u,i*=s.width/c,r*=s.height/u}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const kp=-90,Pp=1;class zOe extends Aa{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ms(kp,Pp,e,n);i.layers=this.layers,this.add(i);const a=new ms(kp,Pp,e,n);a.layers=this.layers,this.add(a);const s=new ms(kp,Pp,e,n);s.layers=this.layers,this.add(s);const o=new ms(kp,Pp,e,n);o.layers=this.layers,this.add(o);const c=new ms(kp,Pp,e,n);c.layers=this.layers,this.add(c);const u=new ms(kp,Pp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,o,c]=n;for(const u of n)this.remove(u);if(e===ll)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Y0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class qZ extends Xa{constructor(e,n,r,i,a,s,o,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Rm,super(e,n,r,i,a,s,o,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class BOe extends nf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];n.encoding!==void 0&&(Yx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Ph?Qi:Js),this.texture=new qZ(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:Zs}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new Kb(5,5,5),a=new pd({name:"CubemapFromEquirect",uniforms:Om(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ka,blending:Yu});a.uniforms.tEquirect.value=n;const s=new jo(i,a),o=n.minFilter;return n.minFilter===K0&&(n.minFilter=Zs),new zOe(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}}const pN=new De,HOe=new De,$Oe=new fn;class ku{constructor(e=new De(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=pN.subVectors(r,n).cross(HOe.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 a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||$Oe.getNormalMatrix(e),i=this.coplanarPoint(pN).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Zd=new ul,M_=new De;class VM{constructor(e=new ku,n=new ku,r=new ku,i=new ku,a=new ku,s=new ku){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=ll){const r=this.planes,i=e.elements,a=i[0],s=i[1],o=i[2],c=i[3],u=i[4],d=i[5],f=i[6],g=i[7],m=i[8],x=i[9],v=i[10],y=i[11],b=i[12],M=i[13],S=i[14],A=i[15];if(r[0].setComponents(c-a,g-u,y-m,A-b).normalize(),r[1].setComponents(c+a,g+u,y+m,A+b).normalize(),r[2].setComponents(c+s,g+d,y+x,A+M).normalize(),r[3].setComponents(c-s,g-d,y-x,A-M).normalize(),r[4].setComponents(c-o,g-f,y-v,A-S).normalize(),n===ll)r[5].setComponents(c+o,g+f,y+v,A+S).normalize();else if(n===Y0)r[5].setComponents(o,f,v,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Zd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Zd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Zd)}intersectsSprite(e){return Zd.center.set(0,0,0),Zd.radius=.7071067811865476,Zd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Zd)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(M_.x=i.normal.x>0?e.max.x:e.min.x,M_.y=i.normal.y>0?e.max.y:e.min.y,M_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(M_)<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 KZ(){let t=null,e=!1,n=null,r=null;function i(a,s){n(a,s),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function VOe(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 v;if(f instanceof Float32Array)v=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)v=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)v=t.SHORT;else if(f instanceof Uint32Array)v=t.UNSIGNED_INT;else if(f instanceof Int32Array)v=t.INT;else if(f instanceof Int8Array)v=t.BYTE;else if(f instanceof Uint8Array)v=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)v=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:m}}function a(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 v=0,y=x.length;v<y;v++){const b=x[v];n?t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g,b.start,b.count):t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g.subarray(b.start,b.start+b.count))}d.clearUpdateRanges()}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 s(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function o(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const g=r.get(u);(!g||g.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,u,d),f.version=u.version}}return{get:s,remove:o,update:c}}class bO extends ga{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,s=n/2,o=Math.floor(r),c=Math.floor(i),u=o+1,d=c+1,f=e/o,g=n/c,m=[],x=[],v=[],y=[];for(let b=0;b<d;b++){const M=b*g-s;for(let S=0;S<u;S++){const A=S*f-a;x.push(A,-M,0),v.push(0,0,1),y.push(S/o),y.push(1-b/c)}}for(let b=0;b<c;b++)for(let M=0;M<o;M++){const S=M+u*b,A=M+u*(b+1),T=M+1+u*(b+1),k=M+1+u*b;m.push(S,A,k),m.push(A,T,k)}this.setIndex(m),this.setAttribute("position",new Br(x,3)),this.setAttribute("normal",new Br(v,3)),this.setAttribute("uv",new Br(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bO(e.width,e.height,e.widthSegments,e.heightSegments)}}var GOe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,WOe=`#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`,qOe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,KOe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,XOe=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,YOe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,ZOe=`#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`,QOe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,JOe=`#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`,eLe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,tLe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,nLe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,rLe=`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`,iLe=`#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`,aLe=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,sLe=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,oLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,lLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,cLe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,uLe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,dLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,hLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,fLe=`#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`,pLe=`#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`,mLe=`#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`,gLe=`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`,xLe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,bLe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,yLe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,vLe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,_Le="gl_FragColor = linearToOutputTexel( gl_FragColor );",wLe=`
- 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 );
- }`,SLe=`#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`,MLe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,ELe=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,ALe=`#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`,TLe=`#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`,CLe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,NLe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,kLe=`#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`,PLe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,RLe=`#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
- }`,DLe=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,jLe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,OLe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,LLe=`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`,ILe=`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`,FLe=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,ULe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,zLe=`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`,BLe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,HLe=`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`,$Le=`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`,VLe=`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 );
- }`,GLe=`
- 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`,WLe=`#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`,qLe=`#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`,KLe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,XLe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,YLe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,ZLe=`#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`,QLe=`#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`,JLe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,e4e=`#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`,t4e=`#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`,n4e=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,r4e=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,i4e=`#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`,a4e=`#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`,s4e=`#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`,o4e=`#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`,l4e=`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;`,c4e=`#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`,u4e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,d4e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,h4e=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,f4e=`#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`,p4e=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,m4e=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,g4e=`#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`,x4e=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,b4e=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,y4e=`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 );
- }`,v4e=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,_4e=`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;`,w4e=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,S4e=`#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`,M4e=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,E4e=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,A4e=`#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`,T4e=`#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`,C4e=`#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`,N4e=`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;
- }`,k4e=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,P4e=`#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`,R4e=`#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`,D4e=`#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`,j4e=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,O4e=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,L4e=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,I4e=`#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; }`,F4e=`#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`,U4e=`#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`,z4e=`#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`,B4e=`#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`,H4e=`#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`,$4e=`#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 V4e=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,G4e=`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>
- }`,W4e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,q4e=`#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>
- }`,K4e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,X4e=`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>
- }`,Y4e=`#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;
- }`,Z4e=`#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
- }`,Q4e=`#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;
- }`,J4e=`#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 );
- }`,eIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,tIe=`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>
- }`,nIe=`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>
- }`,rIe=`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>
- }`,iIe=`#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>
- }`,aIe=`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>
- }`,sIe=`#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>
- }`,oIe=`#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>
- }`,lIe=`#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;
- }`,cIe=`#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>
- }`,uIe=`#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
- }`,dIe=`#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
- }`,hIe=`#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>
- }`,fIe=`#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>
- }`,pIe=`#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
- }`,mIe=`#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>
- }`,gIe=`#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>
- }`,xIe=`#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>
- }`,bIe=`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>
- }`,yIe=`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>
- }`,vIe=`#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>
- }`,_Ie=`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>
- }`,wIe=`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>
- }`,SIe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,ln={alphahash_fragment:GOe,alphahash_pars_fragment:WOe,alphamap_fragment:qOe,alphamap_pars_fragment:KOe,alphatest_fragment:XOe,alphatest_pars_fragment:YOe,aomap_fragment:ZOe,aomap_pars_fragment:QOe,batching_pars_vertex:JOe,batching_vertex:eLe,begin_vertex:tLe,beginnormal_vertex:nLe,bsdfs:rLe,iridescence_fragment:iLe,bumpmap_pars_fragment:aLe,clipping_planes_fragment:sLe,clipping_planes_pars_fragment:oLe,clipping_planes_pars_vertex:lLe,clipping_planes_vertex:cLe,color_fragment:uLe,color_pars_fragment:dLe,color_pars_vertex:hLe,color_vertex:fLe,common:pLe,cube_uv_reflection_fragment:mLe,defaultnormal_vertex:gLe,displacementmap_pars_vertex:xLe,displacementmap_vertex:bLe,emissivemap_fragment:yLe,emissivemap_pars_fragment:vLe,colorspace_fragment:_Le,colorspace_pars_fragment:wLe,envmap_fragment:SLe,envmap_common_pars_fragment:MLe,envmap_pars_fragment:ELe,envmap_pars_vertex:ALe,envmap_physical_pars_fragment:FLe,envmap_vertex:TLe,fog_vertex:CLe,fog_pars_vertex:NLe,fog_fragment:kLe,fog_pars_fragment:PLe,gradientmap_pars_fragment:RLe,lightmap_fragment:DLe,lightmap_pars_fragment:jLe,lights_lambert_fragment:OLe,lights_lambert_pars_fragment:LLe,lights_pars_begin:ILe,lights_toon_fragment:ULe,lights_toon_pars_fragment:zLe,lights_phong_fragment:BLe,lights_phong_pars_fragment:HLe,lights_physical_fragment:$Le,lights_physical_pars_fragment:VLe,lights_fragment_begin:GLe,lights_fragment_maps:WLe,lights_fragment_end:qLe,logdepthbuf_fragment:KLe,logdepthbuf_pars_fragment:XLe,logdepthbuf_pars_vertex:YLe,logdepthbuf_vertex:ZLe,map_fragment:QLe,map_pars_fragment:JLe,map_particle_fragment:e4e,map_particle_pars_fragment:t4e,metalnessmap_fragment:n4e,metalnessmap_pars_fragment:r4e,morphcolor_vertex:i4e,morphnormal_vertex:a4e,morphtarget_pars_vertex:s4e,morphtarget_vertex:o4e,normal_fragment_begin:l4e,normal_fragment_maps:c4e,normal_pars_fragment:u4e,normal_pars_vertex:d4e,normal_vertex:h4e,normalmap_pars_fragment:f4e,clearcoat_normal_fragment_begin:p4e,clearcoat_normal_fragment_maps:m4e,clearcoat_pars_fragment:g4e,iridescence_pars_fragment:x4e,opaque_fragment:b4e,packing:y4e,premultiplied_alpha_fragment:v4e,project_vertex:_4e,dithering_fragment:w4e,dithering_pars_fragment:S4e,roughnessmap_fragment:M4e,roughnessmap_pars_fragment:E4e,shadowmap_pars_fragment:A4e,shadowmap_pars_vertex:T4e,shadowmap_vertex:C4e,shadowmask_pars_fragment:N4e,skinbase_vertex:k4e,skinning_pars_vertex:P4e,skinning_vertex:R4e,skinnormal_vertex:D4e,specularmap_fragment:j4e,specularmap_pars_fragment:O4e,tonemapping_fragment:L4e,tonemapping_pars_fragment:I4e,transmission_fragment:F4e,transmission_pars_fragment:U4e,uv_pars_fragment:z4e,uv_pars_vertex:B4e,uv_vertex:H4e,worldpos_vertex:$4e,background_vert:V4e,background_frag:G4e,backgroundCube_vert:W4e,backgroundCube_frag:q4e,cube_vert:K4e,cube_frag:X4e,depth_vert:Y4e,depth_frag:Z4e,distanceRGBA_vert:Q4e,distanceRGBA_frag:J4e,equirect_vert:eIe,equirect_frag:tIe,linedashed_vert:nIe,linedashed_frag:rIe,meshbasic_vert:iIe,meshbasic_frag:aIe,meshlambert_vert:sIe,meshlambert_frag:oIe,meshmatcap_vert:lIe,meshmatcap_frag:cIe,meshnormal_vert:uIe,meshnormal_frag:dIe,meshphong_vert:hIe,meshphong_frag:fIe,meshphysical_vert:pIe,meshphysical_frag:mIe,meshtoon_vert:gIe,meshtoon_frag:xIe,points_vert:bIe,points_frag:yIe,shadow_vert:vIe,shadow_frag:_Ie,sprite_vert:wIe,sprite_frag:SIe},_t={common:{diffuse:{value:new $t(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fn},normalScale:{value:new Zt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new fn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new fn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new fn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new fn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new $t(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new $t(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0},uvTransform:{value:new fn}},sprite:{diffuse:{value:new $t(16777215)},opacity:{value:1},center:{value:new Zt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}}},Va={basic:{uniforms:_a([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.fog]),vertexShader:ln.meshbasic_vert,fragmentShader:ln.meshbasic_frag},lambert:{uniforms:_a([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new $t(0)}}]),vertexShader:ln.meshlambert_vert,fragmentShader:ln.meshlambert_frag},phong:{uniforms:_a([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new $t(0)},specular:{value:new $t(1118481)},shininess:{value:30}}]),vertexShader:ln.meshphong_vert,fragmentShader:ln.meshphong_frag},standard:{uniforms:_a([_t.common,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.roughnessmap,_t.metalnessmap,_t.fog,_t.lights,{emissive:{value:new $t(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag},toon:{uniforms:_a([_t.common,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.gradientmap,_t.fog,_t.lights,{emissive:{value:new $t(0)}}]),vertexShader:ln.meshtoon_vert,fragmentShader:ln.meshtoon_frag},matcap:{uniforms:_a([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,{matcap:{value:null}}]),vertexShader:ln.meshmatcap_vert,fragmentShader:ln.meshmatcap_frag},points:{uniforms:_a([_t.points,_t.fog]),vertexShader:ln.points_vert,fragmentShader:ln.points_frag},dashed:{uniforms:_a([_t.common,_t.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ln.linedashed_vert,fragmentShader:ln.linedashed_frag},depth:{uniforms:_a([_t.common,_t.displacementmap]),vertexShader:ln.depth_vert,fragmentShader:ln.depth_frag},normal:{uniforms:_a([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,{opacity:{value:1}}]),vertexShader:ln.meshnormal_vert,fragmentShader:ln.meshnormal_frag},sprite:{uniforms:_a([_t.sprite,_t.fog]),vertexShader:ln.sprite_vert,fragmentShader:ln.sprite_frag},background:{uniforms:{uvTransform:{value:new fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ln.background_vert,fragmentShader:ln.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:ln.backgroundCube_vert,fragmentShader:ln.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ln.cube_vert,fragmentShader:ln.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ln.equirect_vert,fragmentShader:ln.equirect_frag},distanceRGBA:{uniforms:_a([_t.common,_t.displacementmap,{referencePosition:{value:new De},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ln.distanceRGBA_vert,fragmentShader:ln.distanceRGBA_frag},shadow:{uniforms:_a([_t.lights,_t.fog,{color:{value:new $t(0)},opacity:{value:1}}]),vertexShader:ln.shadow_vert,fragmentShader:ln.shadow_frag}};Va.physical={uniforms:_a([Va.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fn},clearcoatNormalScale:{value:new Zt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fn},sheen:{value:0},sheenColor:{value:new $t(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new fn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new fn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new fn},transmissionSamplerSize:{value:new Zt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fn},attenuationDistance:{value:0},attenuationColor:{value:new $t(0)},specularColor:{value:new $t(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fn},anisotropyVector:{value:new Zt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fn}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag};const E_={r:0,b:0,g:0};function MIe(t,e,n,r,i,a,s){const o=new $t(0);let c=a===!0?0:1,u,d,f=null,g=0,m=null;function x(y,b){let M=!1,S=b.isScene===!0?b.background:null;S&&S.isTexture&&(S=(b.backgroundBlurriness>0?n:e).get(S)),S===null?v(o,c):S&&S.isColor&&(v(S,1),M=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,s):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||M)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),S&&(S.isCubeTexture||S.mapping===HM)?(d===void 0&&(d=new jo(new Kb(1,1,1),new pd({name:"BackgroundCubeMaterial",uniforms:Om(Va.backgroundCube.uniforms),vertexShader:Va.backgroundCube.vertexShader,fragmentShader:Va.backgroundCube.fragmentShader,side:Ka,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,k,N){this.matrixWorld.copyPosition(N.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=S,d.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,d.material.toneMapped=Xn.getTransfer(S.colorSpace)!==lr,(f!==S||g!==S.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=S,g=S.version,m=t.toneMapping),d.layers.enableAll(),y.unshift(d,d.geometry,d.material,0,0,null)):S&&S.isTexture&&(u===void 0&&(u=new jo(new bO(2,2),new pd({name:"BackgroundMaterial",uniforms:Om(Va.background.uniforms),vertexShader:Va.background.vertexShader,fragmentShader:Va.background.fragmentShader,side:fd,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=S,u.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,u.material.toneMapped=Xn.getTransfer(S.colorSpace)!==lr,S.matrixAutoUpdate===!0&&S.updateMatrix(),u.material.uniforms.uvTransform.value.copy(S.matrix),(f!==S||g!==S.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=S,g=S.version,m=t.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null))}function v(y,b){y.getRGB(E_,GZ(t)),r.buffers.color.setClear(E_.r,E_.g,E_.b,b,s)}return{getClearColor:function(){return o},setClearColor:function(y,b=1){o.set(y),c=b,v(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(y){c=y,v(o,c)},render:x}}function EIe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),s=r.isWebGL2||a!==null,o={},c=y(null);let u=c,d=!1;function f(R,W,K,G,ee){let Z=!1;if(s){const Q=v(G,K,W);u!==Q&&(u=Q,m(u.object)),Z=b(R,G,K,ee),Z&&M(R,G,K,ee)}else{const Q=W.wireframe===!0;(u.geometry!==G.id||u.program!==K.id||u.wireframe!==Q)&&(u.geometry=G.id,u.program=K.id,u.wireframe=Q,Z=!0)}ee!==null&&n.update(ee,t.ELEMENT_ARRAY_BUFFER),(Z||d)&&(d=!1,I(R,W,K,G),ee!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(ee).buffer))}function g(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function m(R){return r.isWebGL2?t.bindVertexArray(R):a.bindVertexArrayOES(R)}function x(R){return r.isWebGL2?t.deleteVertexArray(R):a.deleteVertexArrayOES(R)}function v(R,W,K){const G=K.wireframe===!0;let ee=o[R.id];ee===void 0&&(ee={},o[R.id]=ee);let Z=ee[W.id];Z===void 0&&(Z={},ee[W.id]=Z);let Q=Z[G];return Q===void 0&&(Q=y(g()),Z[G]=Q),Q}function y(R){const W=[],K=[],G=[];for(let ee=0;ee<i;ee++)W[ee]=0,K[ee]=0,G[ee]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:K,attributeDivisors:G,object:R,attributes:{},index:null}}function b(R,W,K,G){const ee=u.attributes,Z=W.attributes;let Q=0;const U=K.getAttributes();for(const $ in U)if(U[$].location>=0){const te=ee[$];let fe=Z[$];if(fe===void 0&&($==="instanceMatrix"&&R.instanceMatrix&&(fe=R.instanceMatrix),$==="instanceColor"&&R.instanceColor&&(fe=R.instanceColor)),te===void 0||te.attribute!==fe||fe&&te.data!==fe.data)return!0;Q++}return u.attributesNum!==Q||u.index!==G}function M(R,W,K,G){const ee={},Z=W.attributes;let Q=0;const U=K.getAttributes();for(const $ in U)if(U[$].location>=0){let te=Z[$];te===void 0&&($==="instanceMatrix"&&R.instanceMatrix&&(te=R.instanceMatrix),$==="instanceColor"&&R.instanceColor&&(te=R.instanceColor));const fe={};fe.attribute=te,te&&te.data&&(fe.data=te.data),ee[$]=fe,Q++}u.attributes=ee,u.attributesNum=Q,u.index=G}function S(){const R=u.newAttributes;for(let W=0,K=R.length;W<K;W++)R[W]=0}function A(R){T(R,0)}function T(R,W){const K=u.newAttributes,G=u.enabledAttributes,ee=u.attributeDivisors;K[R]=1,G[R]===0&&(t.enableVertexAttribArray(R),G[R]=1),ee[R]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,W),ee[R]=W)}function k(){const R=u.newAttributes,W=u.enabledAttributes;for(let K=0,G=W.length;K<G;K++)W[K]!==R[K]&&(t.disableVertexAttribArray(K),W[K]=0)}function N(R,W,K,G,ee,Z,Q){Q===!0?t.vertexAttribIPointer(R,W,K,ee,Z):t.vertexAttribPointer(R,W,K,G,ee,Z)}function I(R,W,K,G){if(r.isWebGL2===!1&&(R.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;S();const ee=G.attributes,Z=K.getAttributes(),Q=W.defaultAttributeValues;for(const U in Z){const $=Z[U];if($.location>=0){let X=ee[U];if(X===void 0&&(U==="instanceMatrix"&&R.instanceMatrix&&(X=R.instanceMatrix),U==="instanceColor"&&R.instanceColor&&(X=R.instanceColor)),X!==void 0){const te=X.normalized,fe=X.itemSize,pe=n.get(X);if(pe===void 0)continue;const xe=pe.buffer,Ne=pe.type,ie=pe.bytesPerElement,be=r.isWebGL2===!0&&(Ne===t.INT||Ne===t.UNSIGNED_INT||X.gpuType===EZ);if(X.isInterleavedBufferAttribute){const je=X.data,he=je.stride,ht=X.offset;if(je.isInstancedInterleavedBuffer){for(let H=0;H<$.locationSize;H++)T($.location+H,je.meshPerAttribute);R.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=je.meshPerAttribute*je.count)}else for(let H=0;H<$.locationSize;H++)A($.location+H);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let H=0;H<$.locationSize;H++)N($.location+H,fe/$.locationSize,Ne,te,he*ie,(ht+fe/$.locationSize*H)*ie,be)}else{if(X.isInstancedBufferAttribute){for(let je=0;je<$.locationSize;je++)T($.location+je,X.meshPerAttribute);R.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=X.meshPerAttribute*X.count)}else for(let je=0;je<$.locationSize;je++)A($.location+je);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let je=0;je<$.locationSize;je++)N($.location+je,fe/$.locationSize,Ne,te,fe*ie,fe/$.locationSize*je*ie,be)}}else if(Q!==void 0){const te=Q[U];if(te!==void 0)switch(te.length){case 2:t.vertexAttrib2fv($.location,te);break;case 3:t.vertexAttrib3fv($.location,te);break;case 4:t.vertexAttrib4fv($.location,te);break;default:t.vertexAttrib1fv($.location,te)}}}}k()}function C(){O();for(const R in o){const W=o[R];for(const K in W){const G=W[K];for(const ee in G)x(G[ee].object),delete G[ee];delete W[K]}delete o[R]}}function D(R){if(o[R.id]===void 0)return;const W=o[R.id];for(const K in W){const G=W[K];for(const ee in G)x(G[ee].object),delete G[ee];delete W[K]}delete o[R.id]}function F(R){for(const W in o){const K=o[W];if(K[R.id]===void 0)continue;const G=K[R.id];for(const ee in G)x(G[ee].object),delete G[ee];delete K[R.id]}}function O(){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:O,resetDefaultState:q,dispose:C,releaseStatesOfGeometry:D,releaseStatesOfProgram:F,initAttributes:S,enableAttribute:A,disableUnusedAttributes:k}}function AIe(t,e,n,r){const i=r.isWebGL2;let a;function s(d){a=d}function o(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,g){if(g===0)return;let 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](a,d,f,g),n.update(f,a,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(a,d,0,f,0,g);let x=0;for(let v=0;v<g;v++)x+=f[v];n.update(x,a,1)}}this.setMode=s,this.render=o,this.renderInstances=c,this.renderMultiDraw=u}function TIe(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 a(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 s=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let o=n.precision!==void 0?n.precision:"highp";const c=a(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);const u=s||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),y=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),b=t.getParameter(t.MAX_VARYING_VECTORS),M=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),S=g>0,A=s||e.has("OES_texture_float"),T=S&&A,k=s?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:o,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:m,maxCubemapSize:x,maxAttributes:v,maxVertexUniforms:y,maxVaryings:b,maxFragmentUniforms:M,vertexTextures:S,floatFragmentTextures:A,floatVertexTextures:T,maxSamples:k}}function CIe(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new ku,o=new fn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const m=f.length!==0||g||r!==0||i;return i=g,r=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,m){const x=f.clippingPlanes,v=f.clipIntersection,y=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const M=a?0:r,S=M*4;let A=b.clippingState||null;c.value=A,A=d(x,g,S,m);for(let T=0;T!==S;++T)A[T]=n[T];b.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=M}};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 v=f!==null?f.length:0;let y=null;if(v!==0){if(y=c.value,x!==!0||y===null){const b=m+v*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(y===null||y.length<b)&&(y=new Float32Array(b));for(let S=0,A=m;S!==v;++S,A+=4)s.copy(f[S]).applyMatrix4(M,o),s.normal.toArray(y,A),y[A+3]=s.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,y}}function NIe(t){let e=new WeakMap;function n(s,o){return o===NP?s.mapping=Rm:o===kP&&(s.mapping=Dm),s}function r(s){if(s&&s.isTexture){const o=s.mapping;if(o===NP||o===kP)if(e.has(s)){const c=e.get(s).texture;return n(c,s.mapping)}else{const c=s.image;if(c&&c.height>0){const u=new BOe(c.height/2);return u.fromEquirectangularTexture(t,s),e.set(s,u),s.addEventListener("dispose",i),n(u.texture,s.mapping)}else return null}}return s}function i(s){const o=s.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}class kIe extends WZ{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,s=r+e,o=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,s=a+u*this.view.width,o-=d*this.view.offsetY,c=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const Xp=4,I$=[.125,.215,.35,.446,.526,.582],ch=20,mN=new kIe,F$=new $t;let gN=null,xN=0,bN=0;const ah=(1+Math.sqrt(5))/2,Rp=1/ah,U$=[new De(1,1,1),new De(-1,1,1),new De(1,1,-1),new De(-1,1,-1),new De(0,ah,Rp),new De(0,ah,-Rp),new De(Rp,0,ah),new De(-Rp,0,ah),new De(ah,Rp,0),new De(-ah,Rp,0)];class z${constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,n=0,r=.1,i=100){gN=this._renderer.getRenderTarget(),xN=this._renderer.getActiveCubeFace(),bN=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,r,i,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=$$(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=H$(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(gN,xN,bN),e.scissorTest=!1,A_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Rm||e.mapping===Dm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),gN=this._renderer.getRenderTarget(),xN=this._renderer.getActiveCubeFace(),bN=this._renderer.getActiveMipmapLevel();const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:Zs,minFilter:Zs,generateMipmaps:!1,type:X0,format:Qs,colorSpace:Lc,depthBuffer:!1},i=B$(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=B$(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=PIe(a)),this._blurMaterial=RIe(a,e,n)}return i}_compileMaterial(e){const n=new jo(this._lodPlanes[0],e);this._renderer.compile(n,mN)}_sceneToCubeUV(e,n,r,i){const o=new ms(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(F$),d.toneMapping=Zu,d.autoClear=!1;const m=new HZ({name:"PMREM.Background",side:Ka,depthWrite:!1,depthTest:!1}),x=new jo(new Kb,m);let v=!1;const y=e.background;y?y.isColor&&(m.color.copy(y),e.background=null,v=!0):(m.color.copy(F$),v=!0);for(let b=0;b<6;b++){const M=b%3;M===0?(o.up.set(0,c[b],0),o.lookAt(u[b],0,0)):M===1?(o.up.set(0,0,c[b]),o.lookAt(0,u[b],0)):(o.up.set(0,c[b],0),o.lookAt(0,0,u[b]));const S=this._cubeSize;A_(i,M*S,b>2?S:0,S,S),d.setRenderTarget(i),v&&d.render(x,o),d.render(e,o)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=g,d.autoClear=f,e.background=y}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Rm||e.mapping===Dm;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=$$()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=H$());const a=i?this._cubemapMaterial:this._equirectMaterial,s=new jo(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=e;const c=this._cubeSize;A_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(s,mN)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const a=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),s=U$[(i-1)%U$.length];this._blur(e,i-1,i,a,s)}n.autoClear=r}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,o){const c=this._renderer,u=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new jo(this._lodPlanes[i],u),g=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*ch-1),v=a/x,y=isFinite(a)?1+Math.floor(d*v):ch;y>ch&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${ch}`);const b=[];let M=0;for(let N=0;N<ch;++N){const I=N/v,C=Math.exp(-I*I/2);b.push(C),N===0?M+=C:N<y&&(M+=2*C)}for(let N=0;N<b.length;N++)b[N]=b[N]/M;g.envMap.value=e.texture,g.samples.value=y,g.weights.value=b,g.latitudinal.value=s==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:S}=this;g.dTheta.value=x,g.mipInt.value=S-r;const A=this._sizeLods[i],T=3*A*(i>S-Xp?i-S+Xp:0),k=4*(this._cubeSize-A);A_(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,mN)}}function PIe(t){const e=[],n=[],r=[];let i=t;const a=t-Xp+1+I$.length;for(let s=0;s<a;s++){const o=Math.pow(2,i);n.push(o);let c=1/o;s>t-Xp?c=I$[s-t+Xp-1]:s===0&&(c=0),r.push(c);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,v=3,y=2,b=1,M=new Float32Array(v*x*m),S=new Float32Array(y*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];M.set(C,v*x*k),S.set(g,y*x*k);const D=[k,k,k,k,k,k];A.set(D,b*x*k)}const T=new ga;T.setAttribute("position",new Ss(M,v)),T.setAttribute("uv",new Ss(S,y)),T.setAttribute("faceIndex",new Ss(A,b)),e.push(T),i>Xp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function B$(t,e,n){const r=new nf(t,e,n);return r.texture.mapping=HM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function A_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function RIe(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:yO(),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 H$(){return new pd({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:yO(),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 $$(){return new pd({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:yO(),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 yO(){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 DIe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const c=o.mapping,u=c===NP||c===kP,d=c===Rm||c===Dm;if(u||d)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let f=e.get(o);return n===null&&(n=new z$(t)),f=u?n.fromEquirectangular(o,f):n.fromCubemap(o,f),e.set(o,f),f.texture}else{if(e.has(o))return e.get(o).texture;{const f=o.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new z$(t));const g=u?n.fromEquirectangular(o):n.fromCubemap(o);return e.set(o,g),o.addEventListener("dispose",a),g.texture}else return null}}}return o}function i(o){let c=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&c++;return c===u}function a(o){const c=o.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function jIe(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 OIe(t,e,n,r){const i={},a=new WeakMap;function s(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);for(const x in g.morphAttributes){const v=g.morphAttributes[x];for(let y=0,b=v.length;y<b;y++)e.remove(v[y])}g.removeEventListener("dispose",s),delete i[g.id];const m=a.get(g);m&&(e.remove(m),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const x in g)e.update(g[x],t.ARRAY_BUFFER);const m=f.morphAttributes;for(const x in m){const v=m[x];for(let y=0,b=v.length;y<b;y++)e.update(v[y],t.ARRAY_BUFFER)}}function u(f){const g=[],m=f.index,x=f.attributes.position;let v=0;if(m!==null){const M=m.array;v=m.version;for(let S=0,A=M.length;S<A;S+=3){const T=M[S+0],k=M[S+1],N=M[S+2];g.push(T,k,k,N,N,T)}}else if(x!==void 0){const M=x.array;v=x.version;for(let S=0,A=M.length/3-1;S<A;S+=3){const T=S+0,k=S+1,N=S+2;g.push(T,k,k,N,N,T)}}else return;const y=new(LZ(g)?VZ:$Z)(g,1);y.version=v;const b=a.get(f);b&&e.remove(b),a.set(f,y)}function d(f){const g=a.get(f);if(g){const m=f.index;m!==null&&g.version<m.version&&u(f)}else u(f);return a.get(f)}return{get:o,update:c,getWireframeAttribute:d}}function LIe(t,e,n,r){const i=r.isWebGL2;let a;function s(m){a=m}let o,c;function u(m){o=m.type,c=m.bytesPerElement}function d(m,x){t.drawElements(a,x,o,m*c),n.update(x,a,1)}function f(m,x,v){if(v===0)return;let y,b;if(i)y=t,b="drawElementsInstanced";else if(y=e.get("ANGLE_instanced_arrays"),b="drawElementsInstancedANGLE",y===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}y[b](a,x,o,m*c,v),n.update(x,a,v)}function g(m,x,v){if(v===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let b=0;b<v;b++)this.render(m[b]/c,x[b]);else{y.multiDrawElementsWEBGL(a,x,0,o,m,0,v);let b=0;for(let M=0;M<v;M++)b+=x[M];n.update(b,a,1)}}this.setMode=s,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=g}function IIe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",s);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function FIe(t,e){return t[0]-e[0]}function UIe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function zIe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,s=new Zn,o=[];for(let u=0;u<8;u++)o[u]=[u,0];function c(u,d,f){const g=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,v=x!==void 0?x.length:0;let y=a.get(d);if(y===void 0||y.count!==v){let W=function(){q.dispose(),a.delete(d),d.removeEventListener("dispose",W)};var m=W;y!==void 0&&y.texture.dispose();const S=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,T=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],N=d.morphAttributes.normal||[],I=d.morphAttributes.color||[];let C=0;S===!0&&(C=1),A===!0&&(C=2),T===!0&&(C=3);let D=d.attributes.position.count*C,F=1;D>e.maxTextureSize&&(F=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const O=new Float32Array(D*F*4*v),q=new UZ(O,D,F,v);q.type=xc,q.needsUpdate=!0;const R=C*4;for(let K=0;K<v;K++){const G=k[K],ee=N[K],Z=I[K],Q=D*F*4*K;for(let U=0;U<G.count;U++){const $=U*R;S===!0&&(s.fromBufferAttribute(G,U),O[Q+$+0]=s.x,O[Q+$+1]=s.y,O[Q+$+2]=s.z,O[Q+$+3]=0),A===!0&&(s.fromBufferAttribute(ee,U),O[Q+$+4]=s.x,O[Q+$+5]=s.y,O[Q+$+6]=s.z,O[Q+$+7]=0),T===!0&&(s.fromBufferAttribute(Z,U),O[Q+$+8]=s.x,O[Q+$+9]=s.y,O[Q+$+10]=s.z,O[Q+$+11]=Z.itemSize===4?s.w:1)}}y={count:v,texture:q,size:new Zt(D,F)},a.set(d,y),d.addEventListener("dispose",W)}let b=0;for(let S=0;S<g.length;S++)b+=g[S];const M=d.morphTargetsRelative?1:1-b;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",y.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",y.size)}else{const x=g===void 0?0:g.length;let v=r[d.id];if(v===void 0||v.length!==x){v=[];for(let A=0;A<x;A++)v[A]=[A,0];r[d.id]=v}for(let A=0;A<x;A++){const T=v[A];T[0]=A,T[1]=g[A]}v.sort(UIe);for(let A=0;A<8;A++)A<x&&v[A][1]?(o[A][0]=v[A][0],o[A][1]=v[A][1]):(o[A][0]=Number.MAX_SAFE_INTEGER,o[A][1]=0);o.sort(FIe);const y=d.morphAttributes.position,b=d.morphAttributes.normal;let M=0;for(let A=0;A<8;A++){const T=o[A],k=T[0],N=T[1];k!==Number.MAX_SAFE_INTEGER&&N?(y&&d.getAttribute("morphTarget"+A)!==y[k]&&d.setAttribute("morphTarget"+A,y[k]),b&&d.getAttribute("morphNormal"+A)!==b[k]&&d.setAttribute("morphNormal"+A,b[k]),i[A]=N,M+=N):(y&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),b&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const S=d.morphTargetsRelative?1:1-M;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function BIe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function s(){i=new WeakMap}function o(c){const u=c.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:s}}class XZ extends Xa{constructor(e,n,r,i,a,s,o,c,u,d){if(d=d!==void 0?d:kh,d!==kh&&d!==jm)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===kh&&(r=Bu),r===void 0&&d===jm&&(r=Nh),super(null,i,a,s,o,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Zi,this.minFilter=c!==void 0?c:Zi,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}const YZ=new Xa,ZZ=new XZ(1,1);ZZ.compareFunction=jZ;const QZ=new UZ,JZ=new EOe,eQ=new qZ,V$=[],G$=[],W$=new Float32Array(16),q$=new Float32Array(9),K$=new Float32Array(4);function dg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=V$[i];if(a===void 0&&(a=new Float32Array(i),V$[i]=a),e!==0){r.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function gi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function xi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function GM(t,e){let n=G$[e];n===void 0&&(n=new Int32Array(e),G$[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function HIe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function $Ie(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(gi(n,e))return;t.uniform2fv(this.addr,e),xi(n,e)}}function VIe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(gi(n,e))return;t.uniform3fv(this.addr,e),xi(n,e)}}function GIe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(gi(n,e))return;t.uniform4fv(this.addr,e),xi(n,e)}}function WIe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;K$.set(r),t.uniformMatrix2fv(this.addr,!1,K$),xi(n,r)}}function qIe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;q$.set(r),t.uniformMatrix3fv(this.addr,!1,q$),xi(n,r)}}function KIe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;W$.set(r),t.uniformMatrix4fv(this.addr,!1,W$),xi(n,r)}}function XIe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function YIe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(gi(n,e))return;t.uniform2iv(this.addr,e),xi(n,e)}}function ZIe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(gi(n,e))return;t.uniform3iv(this.addr,e),xi(n,e)}}function QIe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(gi(n,e))return;t.uniform4iv(this.addr,e),xi(n,e)}}function JIe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function e5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(gi(n,e))return;t.uniform2uiv(this.addr,e),xi(n,e)}}function t5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(gi(n,e))return;t.uniform3uiv(this.addr,e),xi(n,e)}}function n5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(gi(n,e))return;t.uniform4uiv(this.addr,e),xi(n,e)}}function r5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const a=this.type===t.SAMPLER_2D_SHADOW?ZZ:YZ;n.setTexture2D(e||a,i)}function i5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||JZ,i)}function a5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||eQ,i)}function s5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||QZ,i)}function o5e(t){switch(t){case 5126:return HIe;case 35664:return $Ie;case 35665:return VIe;case 35666:return GIe;case 35674:return WIe;case 35675:return qIe;case 35676:return KIe;case 5124:case 35670:return XIe;case 35667:case 35671:return YIe;case 35668:case 35672:return ZIe;case 35669:case 35673:return QIe;case 5125:return JIe;case 36294:return e5e;case 36295:return t5e;case 36296:return n5e;case 35678:case 36198:case 36298:case 36306:case 35682:return r5e;case 35679:case 36299:case 36307:return i5e;case 35680:case 36300:case 36308:case 36293:return a5e;case 36289:case 36303:case 36311:case 36292:return s5e}}function l5e(t,e){t.uniform1fv(this.addr,e)}function c5e(t,e){const n=dg(e,this.size,2);t.uniform2fv(this.addr,n)}function u5e(t,e){const n=dg(e,this.size,3);t.uniform3fv(this.addr,n)}function d5e(t,e){const n=dg(e,this.size,4);t.uniform4fv(this.addr,n)}function h5e(t,e){const n=dg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function f5e(t,e){const n=dg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function p5e(t,e){const n=dg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function m5e(t,e){t.uniform1iv(this.addr,e)}function g5e(t,e){t.uniform2iv(this.addr,e)}function x5e(t,e){t.uniform3iv(this.addr,e)}function b5e(t,e){t.uniform4iv(this.addr,e)}function y5e(t,e){t.uniform1uiv(this.addr,e)}function v5e(t,e){t.uniform2uiv(this.addr,e)}function _5e(t,e){t.uniform3uiv(this.addr,e)}function w5e(t,e){t.uniform4uiv(this.addr,e)}function S5e(t,e,n){const r=this.cache,i=e.length,a=GM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||YZ,a[s])}function M5e(t,e,n){const r=this.cache,i=e.length,a=GM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||JZ,a[s])}function E5e(t,e,n){const r=this.cache,i=e.length,a=GM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||eQ,a[s])}function A5e(t,e,n){const r=this.cache,i=e.length,a=GM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||QZ,a[s])}function T5e(t){switch(t){case 5126:return l5e;case 35664:return c5e;case 35665:return u5e;case 35666:return d5e;case 35674:return h5e;case 35675:return f5e;case 35676:return p5e;case 5124:case 35670:return m5e;case 35667:case 35671:return g5e;case 35668:case 35672:return x5e;case 35669:case 35673:return b5e;case 5125:return y5e;case 36294:return v5e;case 36295:return _5e;case 36296:return w5e;case 35678:case 36198:case 36298:case 36306:case 35682:return S5e;case 35679:case 36299:case 36307:return M5e;case 35680:case 36300:case 36308:case 36293:return E5e;case 36289:case 36303:case 36311:case 36292:return A5e}}class C5e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=o5e(n.type)}}class N5e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=T5e(n.type)}}class k5e{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const o=i[a];o.setValue(e,n[o.id],r)}}}const yN=/(\w+)(\])?(\[|\.)?/g;function X$(t,e){t.seq.push(e),t.map[e.id]=e}function P5e(t,e,n){const r=t.name,i=r.length;for(yN.lastIndex=0;;){const a=yN.exec(r),s=yN.lastIndex;let o=a[1];const c=a[2]==="]",u=a[3];if(c&&(o=o|0),u===void 0||u==="["&&s+2===i){X$(n,u===void 0?new C5e(o,t,e):new N5e(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new k5e(o),X$(n,f)),n=f}}}class p1{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),s=e.getUniformLocation(n,a.name);P5e(a,s,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,s=n.length;a!==s;++a){const o=n[a],c=r[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}}function Y$(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const R5e=37297;let D5e=0;function j5e(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const o=s+1;r.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return r.join(`
- `)}function O5e(t){const e=Xn.getPrimaries(Xn.workingColorSpace),n=Xn.getPrimaries(t);let r;switch(e===n?r="":e===Lw&&n===Ow?r="LinearDisplayP3ToLinearSRGB":e===Ow&&n===Lw&&(r="LinearSRGBToLinearDisplayP3"),t){case Lc:case $M:return[r,"LinearTransferOETF"];case Qi:case pO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function Z$(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const s=parseInt(a[1]);return n.toUpperCase()+`
- `+i+`
- `+j5e(t.getShaderSource(e),s)}else return i}function L5e(t,e){const n=O5e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function I5e(t,e){let n;switch(e){case Lje:n="Linear";break;case Ije:n="Reinhard";break;case Fje:n="OptimizedCineon";break;case Uje:n="ACESFilmic";break;case zje:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function F5e(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(Fx).join(`
- `)}function U5e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function z5e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function Fx(t){return t!==""}function Q$(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 J$(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const B5e=/^[ \t]*#include +<([\w\d./]+)>/gm;function LP(t){return t.replace(B5e,$5e)}const H5e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function $5e(t,e){let n=ln[e];if(n===void 0){const r=H5e.get(e);if(r!==void 0)n=ln[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return LP(n)}const V5e=/#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 eV(t){return t.replace(V5e,G5e)}function G5e(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function tV(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 W5e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===SZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===uje?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ac&&(e="SHADOWMAP_TYPE_VSM"),e}function q5e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Rm:case Dm:e="ENVMAP_TYPE_CUBE";break;case HM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function K5e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Dm:e="ENVMAP_MODE_REFRACTION";break}return e}function X5e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case hO:e="ENVMAP_BLENDING_MULTIPLY";break;case jje:e="ENVMAP_BLENDING_MIX";break;case Oje:e="ENVMAP_BLENDING_ADD";break}return e}function Y5e(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 Z5e(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const c=W5e(n),u=q5e(n),d=K5e(n),f=X5e(n),g=Y5e(n),m=n.isWebGL2?"":F5e(n),x=U5e(a),v=i.createProgram();let y,b,M=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Fx).join(`
- `),y.length>0&&(y+=`
- `),b=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Fx).join(`
- `),b.length>0&&(b+=`
- `)):(y=[tV(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(Fx).join(`
- `),b=[m,tV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Zu?"#define TONE_MAPPING":"",n.toneMapping!==Zu?ln.tonemapping_pars_fragment:"",n.toneMapping!==Zu?I5e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",ln.colorspace_pars_fragment,L5e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Fx).join(`
- `)),s=LP(s),s=Q$(s,n),s=J$(s,n),o=LP(o),o=Q$(o,n),o=J$(o,n),s=eV(s),o=eV(o),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(M=`#version 300 es
- `,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+y,b=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===y$?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===y$?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+b);const S=M+y+s,A=M+b+o,T=Y$(i,i.VERTEX_SHADER,S),k=Y$(i,i.FRAGMENT_SHADER,A);i.attachShader(v,T),i.attachShader(v,k),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function N(F){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(v).trim(),q=i.getShaderInfoLog(T).trim(),R=i.getShaderInfoLog(k).trim();let W=!0,K=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,T,k);else{const G=Z$(i,T,"vertex"),ee=Z$(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
- Program Info Log: `+O+`
- `+G+`
- `+ee)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(q===""||R==="")&&(K=!1);K&&(F.diagnostics={runnable:W,programLog:O,vertexShader:{log:q,prefix:y},fragmentShader:{log:R,prefix:b}})}i.deleteShader(T),i.deleteShader(k),I=new p1(i,v),C=z5e(i,v)}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(v,R5e)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=D5e++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=k,this}let Q5e=0;class J5e{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),s=this._getShaderCacheForMaterial(e);return s.has(i)===!1&&(s.add(i),i.usedTimes++),s.has(a)===!1&&(s.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new eFe(e),n.set(e,r)),r}}class eFe{constructor(e){this.id=Q5e++,this.code=e,this.usedTimes=0}}function tFe(t,e,n,r,i,a,s){const o=new zZ,c=new J5e,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 v(C){return C===0?"uv":`uv${C}`}function y(C,D,F,O,q){const R=O.fog,W=q.geometry,K=C.isMeshStandardMaterial?O.environment:null,G=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),ee=G&&G.mapping===HM?G.image.height:null,Z=x[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const Q=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=Q!==void 0?Q.length:0;let $=0;W.morphAttributes.position!==void 0&&($=1),W.morphAttributes.normal!==void 0&&($=2),W.morphAttributes.color!==void 0&&($=3);let X,te,fe,pe;if(Z){const Qt=Va[Z];X=Qt.vertexShader,te=Qt.fragmentShader}else X=C.vertexShader,te=C.fragmentShader,c.update(C),fe=c.getVertexShaderID(C),pe=c.getFragmentShaderID(C);const xe=t.getRenderTarget(),Ne=q.isInstancedMesh===!0,ie=q.isBatchedMesh===!0,be=!!C.map,je=!!C.matcap,he=!!G,ht=!!C.aoMap,H=!!C.lightMap,B=!!C.bumpMap,re=!!C.normalMap,V=!!C.displacementMap,J=!!C.emissiveMap,se=!!C.metalnessMap,Ae=!!C.roughnessMap,Pe=C.anisotropy>0,Se=C.clearcoat>0,z=C.iridescence>0,L=C.sheen>0,ne=C.transmission>0,ve=Pe&&!!C.anisotropyMap,we=Se&&!!C.clearcoatMap,ye=Se&&!!C.clearcoatNormalMap,nt=Se&&!!C.clearcoatRoughnessMap,Be=z&&!!C.iridescenceMap,ue=z&&!!C.iridescenceThicknessMap,Ve=L&&!!C.sheenColorMap,Fe=L&&!!C.sheenRoughnessMap,oe=!!C.specularMap,Je=!!C.specularColorMap,He=!!C.specularIntensityMap,Ke=ne&&!!C.transmissionMap,ct=ne&&!!C.thicknessMap,de=!!C.gradientMap,Ye=!!C.alphaMap,ge=C.alphaTest>0,Ue=!!C.alphaHash,Ce=!!C.extensions,_e=!!W.attributes.uv1,ce=!!W.attributes.uv2,st=!!W.attributes.uv3;let xt=Zu;return C.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(xt=t.toneMapping),{isWebGL2:d,shaderID:Z,shaderType:C.type,shaderName:C.name,vertexShader:X,fragmentShader:te,defines:C.defines,customVertexShaderID:fe,customFragmentShaderID:pe,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:ie,instancing:Ne,instancingColor:Ne&&q.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:Lc,map:be,matcap:je,envMap:he,envMapMode:he&&G.mapping,envMapCubeUVHeight:ee,aoMap:ht,lightMap:H,bumpMap:B,normalMap:re,displacementMap:g&&V,emissiveMap:J,normalMapObjectSpace:re&&C.normalMapType===Qje,normalMapTangentSpace:re&&C.normalMapType===DZ,metalnessMap:se,roughnessMap:Ae,anisotropy:Pe,anisotropyMap:ve,clearcoat:Se,clearcoatMap:we,clearcoatNormalMap:ye,clearcoatRoughnessMap:nt,iridescence:z,iridescenceMap:Be,iridescenceThicknessMap:ue,sheen:L,sheenColorMap:Ve,sheenRoughnessMap:Fe,specularMap:oe,specularColorMap:Je,specularIntensityMap:He,transmission:ne,transmissionMap:Ke,thicknessMap:ct,gradientMap:de,opaque:C.transparent===!1&&C.blending===sm,alphaMap:Ye,alphaTest:ge,alphaHash:Ue,combine:C.combine,mapUv:be&&v(C.map.channel),aoMapUv:ht&&v(C.aoMap.channel),lightMapUv:H&&v(C.lightMap.channel),bumpMapUv:B&&v(C.bumpMap.channel),normalMapUv:re&&v(C.normalMap.channel),displacementMapUv:V&&v(C.displacementMap.channel),emissiveMapUv:J&&v(C.emissiveMap.channel),metalnessMapUv:se&&v(C.metalnessMap.channel),roughnessMapUv:Ae&&v(C.roughnessMap.channel),anisotropyMapUv:ve&&v(C.anisotropyMap.channel),clearcoatMapUv:we&&v(C.clearcoatMap.channel),clearcoatNormalMapUv:ye&&v(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:nt&&v(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Be&&v(C.iridescenceMap.channel),iridescenceThicknessMapUv:ue&&v(C.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&v(C.sheenColorMap.channel),sheenRoughnessMapUv:Fe&&v(C.sheenRoughnessMap.channel),specularMapUv:oe&&v(C.specularMap.channel),specularColorMapUv:Je&&v(C.specularColorMap.channel),specularIntensityMapUv:He&&v(C.specularIntensityMap.channel),transmissionMapUv:Ke&&v(C.transmissionMap.channel),thicknessMapUv:ct&&v(C.thicknessMap.channel),alphaMapUv:Ye&&v(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(re||Pe),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:_e,vertexUv2s:ce,vertexUv3s:st,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(be||Ye),fog:!!R,useFog:C.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:$,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:s.numPlanes,numClipIntersection:s.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:xt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:be&&C.map.isVideoTexture===!0&&Xn.getTransfer(C.map.colorSpace)===lr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===dc,flipSided:C.side===Ka,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&&(M(D,C),S(D,C),D.push(t.outputColorSpace)),D.push(C.customProgramCacheKey),D.join()}function M(C,D){C.push(D.precision),C.push(D.outputColorSpace),C.push(D.envMapMode),C.push(D.envMapCubeUVHeight),C.push(D.mapUv),C.push(D.alphaMapUv),C.push(D.lightMapUv),C.push(D.aoMapUv),C.push(D.bumpMapUv),C.push(D.normalMapUv),C.push(D.displacementMapUv),C.push(D.emissiveMapUv),C.push(D.metalnessMapUv),C.push(D.roughnessMapUv),C.push(D.anisotropyMapUv),C.push(D.clearcoatMapUv),C.push(D.clearcoatNormalMapUv),C.push(D.clearcoatRoughnessMapUv),C.push(D.iridescenceMapUv),C.push(D.iridescenceThicknessMapUv),C.push(D.sheenColorMapUv),C.push(D.sheenRoughnessMapUv),C.push(D.specularMapUv),C.push(D.specularColorMapUv),C.push(D.specularIntensityMapUv),C.push(D.transmissionMapUv),C.push(D.thicknessMapUv),C.push(D.combine),C.push(D.fogExp2),C.push(D.sizeAttenuation),C.push(D.morphTargetsCount),C.push(D.morphAttributeCount),C.push(D.numDirLights),C.push(D.numPointLights),C.push(D.numSpotLights),C.push(D.numSpotLightMaps),C.push(D.numHemiLights),C.push(D.numRectAreaLights),C.push(D.numDirLightShadows),C.push(D.numPointLightShadows),C.push(D.numSpotLightShadows),C.push(D.numSpotLightShadowsWithMaps),C.push(D.numLightProbes),C.push(D.shadowMapType),C.push(D.toneMapping),C.push(D.numClippingPlanes),C.push(D.numClipIntersection),C.push(D.depthPacking)}function S(C,D){o.disableAll(),D.isWebGL2&&o.enable(0),D.supportsVertexTextures&&o.enable(1),D.instancing&&o.enable(2),D.instancingColor&&o.enable(3),D.matcap&&o.enable(4),D.envMap&&o.enable(5),D.normalMapObjectSpace&&o.enable(6),D.normalMapTangentSpace&&o.enable(7),D.clearcoat&&o.enable(8),D.iridescence&&o.enable(9),D.alphaTest&&o.enable(10),D.vertexColors&&o.enable(11),D.vertexAlphas&&o.enable(12),D.vertexUv1s&&o.enable(13),D.vertexUv2s&&o.enable(14),D.vertexUv3s&&o.enable(15),D.vertexTangents&&o.enable(16),D.anisotropy&&o.enable(17),D.alphaHash&&o.enable(18),D.batching&&o.enable(19),C.push(o.mask),o.disableAll(),D.fog&&o.enable(0),D.useFog&&o.enable(1),D.flatShading&&o.enable(2),D.logarithmicDepthBuffer&&o.enable(3),D.skinning&&o.enable(4),D.morphTargets&&o.enable(5),D.morphNormals&&o.enable(6),D.morphColors&&o.enable(7),D.premultipliedAlpha&&o.enable(8),D.shadowMapEnabled&&o.enable(9),D.useLegacyLights&&o.enable(10),D.doubleSided&&o.enable(11),D.flipSided&&o.enable(12),D.useDepthPacking&&o.enable(13),D.dithering&&o.enable(14),D.transmission&&o.enable(15),D.sheen&&o.enable(16),D.opaque&&o.enable(17),D.pointsUvs&&o.enable(18),D.decodeVideoTexture&&o.enable(19),C.push(o.mask)}function A(C){const D=x[C.type];let F;if(D){const O=Va[D];F=xO.clone(O.uniforms)}else F=C.uniforms;return F}function T(C,D){let F;for(let O=0,q=u.length;O<q;O++){const R=u[O];if(R.cacheKey===D){F=R,++F.usedTimes;break}}return F===void 0&&(F=new Z5e(t,D,C,a),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:y,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:N,programs:u,dispose:I}}function nFe(){let t=new WeakMap;function e(a){let s=t.get(a);return s===void 0&&(s={},t.set(a,s)),s}function n(a){t.delete(a)}function r(a,s,o){t.get(a)[s]=o}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function rFe(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 nV(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 rV(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(f,g,m,x,v,y){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:m,groupOrder:x,renderOrder:f.renderOrder,z:v,group:y},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=v,b.group=y),e++,b}function o(f,g,m,x,v,y){const b=s(f,g,m,x,v,y);m.transmission>0?r.push(b):m.transparent===!0?i.push(b):n.push(b)}function c(f,g,m,x,v,y){const b=s(f,g,m,x,v,y);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||rFe),r.length>1&&r.sort(g||nV),i.length>1&&i.sort(g||nV)}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:a,push:o,unshift:c,finish:d,sort:u}}function iFe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new rV,t.set(r,[s])):i>=a.length?(s=new rV,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function aFe(){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 sFe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Zt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Zt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Zt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let oFe=0;function lFe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function cFe(t,e){const n=new aFe,r=sFe(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)i.probe.push(new De);const a=new De,s=new ar,o=new ar;function c(d,f){let g=0,m=0,x=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let v=0,y=0,b=0,M=0,S=0,A=0,T=0,k=0,N=0,I=0,C=0;d.sort(lFe);const D=f===!0?Math.PI:1;for(let O=0,q=d.length;O<q;O++){const R=d[O],W=R.color,K=R.intensity,G=R.distance,ee=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)g+=W.r*K*D,m+=W.g*K*D,x+=W.b*K*D;else if(R.isLightProbe){for(let Z=0;Z<9;Z++)i.probe[Z].addScaledVector(R.sh.coefficients[Z],K);C++}else if(R.isDirectionalLight){const Z=n.get(R);if(Z.color.copy(R.color).multiplyScalar(R.intensity*D),R.castShadow){const Q=R.shadow,U=r.get(R);U.shadowBias=Q.bias,U.shadowNormalBias=Q.normalBias,U.shadowRadius=Q.radius,U.shadowMapSize=Q.mapSize,i.directionalShadow[v]=U,i.directionalShadowMap[v]=ee,i.directionalShadowMatrix[v]=R.shadow.matrix,A++}i.directional[v]=Z,v++}else if(R.isSpotLight){const Z=n.get(R);Z.position.setFromMatrixPosition(R.matrixWorld),Z.color.copy(W).multiplyScalar(K*D),Z.distance=G,Z.coneCos=Math.cos(R.angle),Z.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),Z.decay=R.decay,i.spot[b]=Z;const Q=R.shadow;if(R.map&&(i.spotLightMap[N]=R.map,N++,Q.updateMatrices(R),R.castShadow&&I++),i.spotLightMatrix[b]=Q.matrix,R.castShadow){const U=r.get(R);U.shadowBias=Q.bias,U.shadowNormalBias=Q.normalBias,U.shadowRadius=Q.radius,U.shadowMapSize=Q.mapSize,i.spotShadow[b]=U,i.spotShadowMap[b]=ee,k++}b++}else if(R.isRectAreaLight){const Z=n.get(R);Z.color.copy(W).multiplyScalar(K),Z.halfWidth.set(R.width*.5,0,0),Z.halfHeight.set(0,R.height*.5,0),i.rectArea[M]=Z,M++}else if(R.isPointLight){const Z=n.get(R);if(Z.color.copy(R.color).multiplyScalar(R.intensity*D),Z.distance=R.distance,Z.decay=R.decay,R.castShadow){const Q=R.shadow,U=r.get(R);U.shadowBias=Q.bias,U.shadowNormalBias=Q.normalBias,U.shadowRadius=Q.radius,U.shadowMapSize=Q.mapSize,U.shadowCameraNear=Q.camera.near,U.shadowCameraFar=Q.camera.far,i.pointShadow[y]=U,i.pointShadowMap[y]=ee,i.pointShadowMatrix[y]=R.shadow.matrix,T++}i.point[y]=Z,y++}else if(R.isHemisphereLight){const Z=n.get(R);Z.skyColor.copy(R.color).multiplyScalar(K*D),Z.groundColor.copy(R.groundColor).multiplyScalar(K*D),i.hemi[S]=Z,S++}}M>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=_t.LTC_FLOAT_1,i.rectAreaLTC2=_t.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=_t.LTC_HALF_1,i.rectAreaLTC2=_t.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=m,i.ambient[2]=x;const F=i.hash;(F.directionalLength!==v||F.pointLength!==y||F.spotLength!==b||F.rectAreaLength!==M||F.hemiLength!==S||F.numDirectionalShadows!==A||F.numPointShadows!==T||F.numSpotShadows!==k||F.numSpotMaps!==N||F.numLightProbes!==C)&&(i.directional.length=v,i.spot.length=b,i.rectArea.length=M,i.point.length=y,i.hemi.length=S,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=k+N-I,i.spotLightMap.length=N,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=C,F.directionalLength=v,F.pointLength=y,F.spotLength=b,F.rectAreaLength=M,F.hemiLength=S,F.numDirectionalShadows=A,F.numPointShadows=T,F.numSpotShadows=k,F.numSpotMaps=N,F.numLightProbes=C,i.version=oFe++)}function u(d,f){let g=0,m=0,x=0,v=0,y=0;const b=f.matrixWorldInverse;for(let M=0,S=d.length;M<S;M++){const A=d[M];if(A.isDirectionalLight){const T=i.directional[g];T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(b),g++}else if(A.isSpotLight){const T=i.spot[x];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(b),x++}else if(A.isRectAreaLight){const T=i.rectArea[v];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),o.identity(),s.copy(A.matrixWorld),s.premultiply(b),o.extractRotation(s),T.halfWidth.set(A.width*.5,0,0),T.halfHeight.set(0,A.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),v++}else if(A.isPointLight){const T=i.point[m];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),m++}else if(A.isHemisphereLight){const T=i.hemi[y];T.direction.setFromMatrixPosition(A.matrixWorld),T.direction.transformDirection(b),y++}}}return{setup:c,setupView:u,state:i}}function iV(t,e){const n=new cFe(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function s(f){r.push(f)}function o(f){i.push(f)}function c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:s,pushShadow:o}}function uFe(t,e){let n=new WeakMap;function r(a,s=0){const o=n.get(a);let c;return o===void 0?(c=new iV(t,e),n.set(a,[c])):s>=o.length?(c=new iV(t,e),o.push(c)):c=o[s],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class dFe extends ug{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Yje,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 hFe extends ug{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const fFe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,pFe=`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 mFe(t,e,n){let r=new VM;const i=new Zt,a=new Zt,s=new Zn,o=new dFe({depthPacking:Zje}),c=new hFe,u={},d=n.maxTextureSize,f={[fd]:Ka,[Ka]:fd,[dc]:dc},g=new pd({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Zt},radius:{value:4}},vertexShader:fFe,fragmentShader:pFe}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const x=new ga;x.setAttribute("position",new Ss(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new jo(x,g),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=SZ;let b=this.type;this.render=function(T,k,N){if(y.enabled===!1||y.autoUpdate===!1&&y.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 O=b!==ac&&this.type===ac,q=b===ac&&this.type!==ac;for(let R=0,W=T.length;R<W;R++){const K=T[R],G=K.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const ee=G.getFrameExtents();if(i.multiply(ee),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/ee.x),i.x=a.x*ee.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/ee.y),i.y=a.y*ee.y,G.mapSize.y=a.y)),G.map===null||O===!0||q===!0){const Q=this.type!==ac?{minFilter:Zi,magFilter:Zi}:{};G.map!==null&&G.map.dispose(),G.map=new nf(i.x,i.y,Q),G.map.texture.name=K.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const Z=G.getViewportCount();for(let Q=0;Q<Z;Q++){const U=G.getViewport(Q);s.set(a.x*U.x,a.y*U.y,a.x*U.z,a.y*U.w),F.viewport(s),G.updateMatrices(K,Q),r=G.getFrustum(),A(k,N,G.camera,K,this.type)}G.isPointLightShadow!==!0&&this.type===ac&&M(G,N),G.needsUpdate=!1}b=this.type,y.needsUpdate=!1,t.setRenderTarget(I,C,D)};function M(T,k){const N=e.update(v);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,v,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,v,null)}function S(T,k,N,I){let C=null;const D=N.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(D!==void 0)C=D;else if(C=N.isPointLight===!0?c:o,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0){const F=C.uuid,O=k.uuid;let q=u[F];q===void 0&&(q={},u[F]=q);let R=q[O];R===void 0&&(R=C.clone(),q[O]=R),C=R}if(C.visible=k.visible,C.wireframe=k.wireframe,I===ac?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===ac)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,T.matrixWorld);const O=e.update(T),q=T.material;if(Array.isArray(q)){const R=O.groups;for(let W=0,K=R.length;W<K;W++){const G=R[W],ee=q[G.materialIndex];if(ee&&ee.visible){const Z=S(T,ee,I,C);T.onBeforeShadow(t,T,k,N,O,Z,G),t.renderBufferDirect(N,null,O,Z,T,G),T.onAfterShadow(t,T,k,N,O,Z,G)}}}else if(q.visible){const R=S(T,q,I,C);T.onBeforeShadow(t,T,k,N,O,R,null),t.renderBufferDirect(N,null,O,R,T,null),T.onAfterShadow(t,T,k,N,O,R,null)}}const F=T.children;for(let O=0,q=F.length;O<q;O++)A(F[O],k,N,I,C)}}function gFe(t,e,n){const r=n.isWebGL2;function i(){let ge=!1;const Ue=new Zn;let Ce=null;const _e=new Zn(0,0,0,0);return{setMask:function(ce){Ce!==ce&&!ge&&(t.colorMask(ce,ce,ce,ce),Ce=ce)},setLocked:function(ce){ge=ce},setClear:function(ce,st,xt,St,Qt){Qt===!0&&(ce*=St,st*=St,xt*=St),Ue.set(ce,st,xt,St),_e.equals(Ue)===!1&&(t.clearColor(ce,st,xt,St),_e.copy(Ue))},reset:function(){ge=!1,Ce=null,_e.set(-1,0,0,0)}}}function a(){let ge=!1,Ue=null,Ce=null,_e=null;return{setTest:function(ce){ce?ie(t.DEPTH_TEST):be(t.DEPTH_TEST)},setMask:function(ce){Ue!==ce&&!ge&&(t.depthMask(ce),Ue=ce)},setFunc:function(ce){if(Ce!==ce){switch(ce){case Tje:t.depthFunc(t.NEVER);break;case Cje:t.depthFunc(t.ALWAYS);break;case Nje:t.depthFunc(t.LESS);break;case Dw:t.depthFunc(t.LEQUAL);break;case kje:t.depthFunc(t.EQUAL);break;case Pje:t.depthFunc(t.GEQUAL);break;case Rje:t.depthFunc(t.GREATER);break;case Dje:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ce=ce}},setLocked:function(ce){ge=ce},setClear:function(ce){_e!==ce&&(t.clearDepth(ce),_e=ce)},reset:function(){ge=!1,Ue=null,Ce=null,_e=null}}}function s(){let ge=!1,Ue=null,Ce=null,_e=null,ce=null,st=null,xt=null,St=null,Qt=null;return{setTest:function(Ot){ge||(Ot?ie(t.STENCIL_TEST):be(t.STENCIL_TEST))},setMask:function(Ot){Ue!==Ot&&!ge&&(t.stencilMask(Ot),Ue=Ot)},setFunc:function(Ot,Vt,On){(Ce!==Ot||_e!==Vt||ce!==On)&&(t.stencilFunc(Ot,Vt,On),Ce=Ot,_e=Vt,ce=On)},setOp:function(Ot,Vt,On){(st!==Ot||xt!==Vt||St!==On)&&(t.stencilOp(Ot,Vt,On),st=Ot,xt=Vt,St=On)},setLocked:function(Ot){ge=Ot},setClear:function(Ot){Qt!==Ot&&(t.clearStencil(Ot),Qt=Ot)},reset:function(){ge=!1,Ue=null,Ce=null,_e=null,ce=null,st=null,xt=null,St=null,Qt=null}}}const o=new i,c=new a,u=new s,d=new WeakMap,f=new WeakMap;let g={},m={},x=new WeakMap,v=[],y=null,b=!1,M=null,S=null,A=null,T=null,k=null,N=null,I=null,C=new $t(0,0,0),D=0,F=!1,O=null,q=null,R=null,W=null,K=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let ee=!1,Z=0;const Q=t.getParameter(t.VERSION);Q.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(Q)[1]),ee=Z>=1):Q.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),ee=Z>=2);let U=null,$={};const X=t.getParameter(t.SCISSOR_BOX),te=t.getParameter(t.VIEWPORT),fe=new Zn().fromArray(X),pe=new Zn().fromArray(te);function xe(ge,Ue,Ce,_e){const ce=new Uint8Array(4),st=t.createTexture();t.bindTexture(ge,st),t.texParameteri(ge,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ge,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let xt=0;xt<Ce;xt++)r&&(ge===t.TEXTURE_3D||ge===t.TEXTURE_2D_ARRAY)?t.texImage3D(Ue,0,t.RGBA,1,1,_e,0,t.RGBA,t.UNSIGNED_BYTE,ce):t.texImage2D(Ue+xt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ce);return st}const Ne={};Ne[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),Ne[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ne[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ne[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),c.setClear(1),u.setClear(0),ie(t.DEPTH_TEST),c.setFunc(Dw),J(!1),se(zH),ie(t.CULL_FACE),re(Yu);function ie(ge){g[ge]!==!0&&(t.enable(ge),g[ge]=!0)}function be(ge){g[ge]!==!1&&(t.disable(ge),g[ge]=!1)}function je(ge,Ue){return m[ge]!==Ue?(t.bindFramebuffer(ge,Ue),m[ge]=Ue,r&&(ge===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Ue),ge===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Ue)),!0):!1}function he(ge,Ue){let Ce=v,_e=!1;if(ge)if(Ce=x.get(Ue),Ce===void 0&&(Ce=[],x.set(Ue,Ce)),ge.isWebGLMultipleRenderTargets){const ce=ge.texture;if(Ce.length!==ce.length||Ce[0]!==t.COLOR_ATTACHMENT0){for(let st=0,xt=ce.length;st<xt;st++)Ce[st]=t.COLOR_ATTACHMENT0+st;Ce.length=ce.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 ht(ge){return y!==ge?(t.useProgram(ge),y=ge,!0):!1}const H={[lh]:t.FUNC_ADD,[hje]:t.FUNC_SUBTRACT,[fje]:t.FUNC_REVERSE_SUBTRACT};if(r)H[VH]=t.MIN,H[GH]=t.MAX;else{const ge=e.get("EXT_blend_minmax");ge!==null&&(H[VH]=ge.MIN_EXT,H[GH]=ge.MAX_EXT)}const B={[pje]:t.ZERO,[mje]:t.ONE,[gje]:t.SRC_COLOR,[TP]:t.SRC_ALPHA,[wje]:t.SRC_ALPHA_SATURATE,[vje]:t.DST_COLOR,[bje]:t.DST_ALPHA,[xje]:t.ONE_MINUS_SRC_COLOR,[CP]:t.ONE_MINUS_SRC_ALPHA,[_je]:t.ONE_MINUS_DST_COLOR,[yje]:t.ONE_MINUS_DST_ALPHA,[Sje]:t.CONSTANT_COLOR,[Mje]:t.ONE_MINUS_CONSTANT_COLOR,[Eje]:t.CONSTANT_ALPHA,[Aje]:t.ONE_MINUS_CONSTANT_ALPHA};function re(ge,Ue,Ce,_e,ce,st,xt,St,Qt,Ot){if(ge===Yu){b===!0&&(be(t.BLEND),b=!1);return}if(b===!1&&(ie(t.BLEND),b=!0),ge!==dje){if(ge!==M||Ot!==F){if((S!==lh||k!==lh)&&(t.blendEquation(t.FUNC_ADD),S=lh,k=lh),Ot)switch(ge){case sm:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case BH:t.blendFunc(t.ONE,t.ONE);break;case HH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case $H:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}else switch(ge){case sm:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case BH:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case HH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case $H:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}A=null,T=null,N=null,I=null,C.set(0,0,0),D=0,M=ge,F=Ot}return}ce=ce||Ue,st=st||Ce,xt=xt||_e,(Ue!==S||ce!==k)&&(t.blendEquationSeparate(H[Ue],H[ce]),S=Ue,k=ce),(Ce!==A||_e!==T||st!==N||xt!==I)&&(t.blendFuncSeparate(B[Ce],B[_e],B[st],B[xt]),A=Ce,T=_e,N=st,I=xt),(St.equals(C)===!1||Qt!==D)&&(t.blendColor(St.r,St.g,St.b,Qt),C.copy(St),D=Qt),M=ge,F=!1}function V(ge,Ue){ge.side===dc?be(t.CULL_FACE):ie(t.CULL_FACE);let Ce=ge.side===Ka;Ue&&(Ce=!Ce),J(Ce),ge.blending===sm&&ge.transparent===!1?re(Yu):re(ge.blending,ge.blendEquation,ge.blendSrc,ge.blendDst,ge.blendEquationAlpha,ge.blendSrcAlpha,ge.blendDstAlpha,ge.blendColor,ge.blendAlpha,ge.premultipliedAlpha),c.setFunc(ge.depthFunc),c.setTest(ge.depthTest),c.setMask(ge.depthWrite),o.setMask(ge.colorWrite);const _e=ge.stencilWrite;u.setTest(_e),_e&&(u.setMask(ge.stencilWriteMask),u.setFunc(ge.stencilFunc,ge.stencilRef,ge.stencilFuncMask),u.setOp(ge.stencilFail,ge.stencilZFail,ge.stencilZPass)),Pe(ge.polygonOffset,ge.polygonOffsetFactor,ge.polygonOffsetUnits),ge.alphaToCoverage===!0?ie(t.SAMPLE_ALPHA_TO_COVERAGE):be(t.SAMPLE_ALPHA_TO_COVERAGE)}function J(ge){O!==ge&&(ge?t.frontFace(t.CW):t.frontFace(t.CCW),O=ge)}function se(ge){ge!==lje?(ie(t.CULL_FACE),ge!==q&&(ge===zH?t.cullFace(t.BACK):ge===cje?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):be(t.CULL_FACE),q=ge}function Ae(ge){ge!==R&&(ee&&t.lineWidth(ge),R=ge)}function Pe(ge,Ue,Ce){ge?(ie(t.POLYGON_OFFSET_FILL),(W!==Ue||K!==Ce)&&(t.polygonOffset(Ue,Ce),W=Ue,K=Ce)):be(t.POLYGON_OFFSET_FILL)}function Se(ge){ge?ie(t.SCISSOR_TEST):be(t.SCISSOR_TEST)}function z(ge){ge===void 0&&(ge=t.TEXTURE0+G-1),U!==ge&&(t.activeTexture(ge),U=ge)}function L(ge,Ue,Ce){Ce===void 0&&(U===null?Ce=t.TEXTURE0+G-1:Ce=U);let _e=$[Ce];_e===void 0&&(_e={type:void 0,texture:void 0},$[Ce]=_e),(_e.type!==ge||_e.texture!==Ue)&&(U!==Ce&&(t.activeTexture(Ce),U=Ce),t.bindTexture(ge,Ue||Ne[ge]),_e.type=ge,_e.texture=Ue)}function ne(){const ge=$[U];ge!==void 0&&ge.type!==void 0&&(t.bindTexture(ge.type,null),ge.type=void 0,ge.texture=void 0)}function ve(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function we(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ye(){try{t.texSubImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function nt(){try{t.texSubImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Be(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ue(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Ve(){try{t.texStorage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Fe(){try{t.texStorage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function oe(){try{t.texImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Je(){try{t.texImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function He(ge){fe.equals(ge)===!1&&(t.scissor(ge.x,ge.y,ge.z,ge.w),fe.copy(ge))}function Ke(ge){pe.equals(ge)===!1&&(t.viewport(ge.x,ge.y,ge.z,ge.w),pe.copy(ge))}function ct(ge,Ue){let Ce=f.get(Ue);Ce===void 0&&(Ce=new WeakMap,f.set(Ue,Ce));let _e=Ce.get(ge);_e===void 0&&(_e=t.getUniformBlockIndex(Ue,ge.name),Ce.set(ge,_e))}function de(ge,Ue){const _e=f.get(Ue).get(ge);d.get(Ue)!==_e&&(t.uniformBlockBinding(Ue,_e,ge.__bindingPointIndex),d.set(Ue,_e))}function Ye(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),g={},U=null,$={},m={},x=new WeakMap,v=[],y=null,b=!1,M=null,S=null,A=null,T=null,k=null,N=null,I=null,C=new $t(0,0,0),D=0,F=!1,O=null,q=null,R=null,W=null,K=null,fe.set(0,0,t.canvas.width,t.canvas.height),pe.set(0,0,t.canvas.width,t.canvas.height),o.reset(),c.reset(),u.reset()}return{buffers:{color:o,depth:c,stencil:u},enable:ie,disable:be,bindFramebuffer:je,drawBuffers:he,useProgram:ht,setBlending:re,setMaterial:V,setFlipSided:J,setCullFace:se,setLineWidth:Ae,setPolygonOffset:Pe,setScissorTest:Se,activeTexture:z,bindTexture:L,unbindTexture:ne,compressedTexImage2D:ve,compressedTexImage3D:we,texImage2D:oe,texImage3D:Je,updateUBOMapping:ct,uniformBlockBinding:de,texStorage2D:Ve,texStorage3D:Fe,texSubImage2D:ye,texSubImage3D:nt,compressedTexSubImage2D:Be,compressedTexSubImage3D:ue,scissor:He,viewport:Ke,reset:Ye}}function xFe(t,e,n,r,i,a,s){const o=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let v;const y=new WeakMap;let b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(z,L){return b?new OffscreenCanvas(z,L):Fw("canvas")}function S(z,L,ne,ve){let we=1;if((z.width>ve||z.height>ve)&&(we=ve/Math.max(z.width,z.height)),we<1||L===!0)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap){const ye=L?Iw:Math.floor,nt=ye(we*z.width),Be=ye(we*z.height);v===void 0&&(v=M(nt,Be));const ue=ne?M(nt,Be):v;return ue.width=nt,ue.height=Be,ue.getContext("2d").drawImage(z,0,0,nt,Be),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+z.width+"x"+z.height+") to ("+nt+"x"+Be+")."),ue}else return"data"in z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+z.width+"x"+z.height+")."),z;return z}function A(z){return OP(z.width)&&OP(z.height)}function T(z){return o?!1:z.wrapS!==ko||z.wrapT!==ko||z.minFilter!==Zi&&z.minFilter!==Zs}function k(z,L){return z.generateMipmaps&&L&&z.minFilter!==Zi&&z.minFilter!==Zs}function N(z){t.generateMipmap(z)}function I(z,L,ne,ve,we=!1){if(o===!1)return L;if(z!==null){if(t[z]!==void 0)return t[z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let ye=L;if(L===t.RED&&(ne===t.FLOAT&&(ye=t.R32F),ne===t.HALF_FLOAT&&(ye=t.R16F),ne===t.UNSIGNED_BYTE&&(ye=t.R8)),L===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.R8UI),ne===t.UNSIGNED_SHORT&&(ye=t.R16UI),ne===t.UNSIGNED_INT&&(ye=t.R32UI),ne===t.BYTE&&(ye=t.R8I),ne===t.SHORT&&(ye=t.R16I),ne===t.INT&&(ye=t.R32I)),L===t.RG&&(ne===t.FLOAT&&(ye=t.RG32F),ne===t.HALF_FLOAT&&(ye=t.RG16F),ne===t.UNSIGNED_BYTE&&(ye=t.RG8)),L===t.RGBA){const nt=we?jw:Xn.getTransfer(ve);ne===t.FLOAT&&(ye=t.RGBA32F),ne===t.HALF_FLOAT&&(ye=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ye=nt===lr?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ye=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ye=t.RGB5_A1)}return(ye===t.R16F||ye===t.R32F||ye===t.RG16F||ye===t.RG32F||ye===t.RGBA16F||ye===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function C(z,L,ne){return k(z,ne)===!0||z.isFramebufferTexture&&z.minFilter!==Zi&&z.minFilter!==Zs?Math.log2(Math.max(L.width,L.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?L.mipmaps.length:1}function D(z){return z===Zi||z===WH||z===WC?t.NEAREST:t.LINEAR}function F(z){const L=z.target;L.removeEventListener("dispose",F),q(L),L.isVideoTexture&&x.delete(L)}function O(z){const L=z.target;L.removeEventListener("dispose",O),W(L)}function q(z){const L=r.get(z);if(L.__webglInit===void 0)return;const ne=z.source,ve=y.get(ne);if(ve){const we=ve[L.__cacheKey];we.usedTimes--,we.usedTimes===0&&R(z),Object.keys(ve).length===0&&y.delete(ne)}r.remove(z)}function R(z){const L=r.get(z);t.deleteTexture(L.__webglTexture);const ne=z.source,ve=y.get(ne);delete ve[L.__cacheKey],s.memory.textures--}function W(z){const L=z.texture,ne=r.get(z),ve=r.get(L);if(ve.__webglTexture!==void 0&&(t.deleteTexture(ve.__webglTexture),s.memory.textures--),z.depthTexture&&z.depthTexture.dispose(),z.isWebGLCubeRenderTarget)for(let we=0;we<6;we++){if(Array.isArray(ne.__webglFramebuffer[we]))for(let ye=0;ye<ne.__webglFramebuffer[we].length;ye++)t.deleteFramebuffer(ne.__webglFramebuffer[we][ye]);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(z.isWebGLMultipleRenderTargets)for(let we=0,ye=L.length;we<ye;we++){const nt=r.get(L[we]);nt.__webglTexture&&(t.deleteTexture(nt.__webglTexture),s.memory.textures--),r.remove(L[we])}r.remove(L),r.remove(z)}let K=0;function G(){K=0}function ee(){const z=K;return z>=c&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+c),K+=1,z}function Z(z){const L=[];return L.push(z.wrapS),L.push(z.wrapT),L.push(z.wrapR||0),L.push(z.magFilter),L.push(z.minFilter),L.push(z.anisotropy),L.push(z.internalFormat),L.push(z.format),L.push(z.type),L.push(z.generateMipmaps),L.push(z.premultiplyAlpha),L.push(z.flipY),L.push(z.unpackAlignment),L.push(z.colorSpace),L.join()}function Q(z,L){const ne=r.get(z);if(z.isVideoTexture&&Pe(z),z.isRenderTargetTexture===!1&&z.version>0&&ne.__version!==z.version){const ve=z.image;if(ve===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(ne,z,L);return}}n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+L)}function U(z,L){const ne=r.get(z);if(z.version>0&&ne.__version!==z.version){ie(ne,z,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+L)}function $(z,L){const ne=r.get(z);if(z.version>0&&ne.__version!==z.version){ie(ne,z,L);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+L)}function X(z,L){const ne=r.get(z);if(z.version>0&&ne.__version!==z.version){be(ne,z,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+L)}const te={[PP]:t.REPEAT,[ko]:t.CLAMP_TO_EDGE,[RP]:t.MIRRORED_REPEAT},fe={[Zi]:t.NEAREST,[WH]:t.NEAREST_MIPMAP_NEAREST,[WC]:t.NEAREST_MIPMAP_LINEAR,[Zs]:t.LINEAR,[Bje]:t.LINEAR_MIPMAP_NEAREST,[K0]:t.LINEAR_MIPMAP_LINEAR},pe={[Jje]:t.NEVER,[aOe]:t.ALWAYS,[eOe]:t.LESS,[jZ]:t.LEQUAL,[tOe]:t.EQUAL,[iOe]:t.GEQUAL,[nOe]:t.GREATER,[rOe]:t.NOTEQUAL};function xe(z,L,ne){if(ne?(t.texParameteri(z,t.TEXTURE_WRAP_S,te[L.wrapS]),t.texParameteri(z,t.TEXTURE_WRAP_T,te[L.wrapT]),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,te[L.wrapR]),t.texParameteri(z,t.TEXTURE_MAG_FILTER,fe[L.magFilter]),t.texParameteri(z,t.TEXTURE_MIN_FILTER,fe[L.minFilter])):(t.texParameteri(z,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(z,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==ko||L.wrapT!==ko)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(z,t.TEXTURE_MAG_FILTER,D(L.magFilter)),t.texParameteri(z,t.TEXTURE_MIN_FILTER,D(L.minFilter)),L.minFilter!==Zi&&L.minFilter!==Zs&&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(z,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(z,t.TEXTURE_COMPARE_FUNC,pe[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ve=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Zi||L.minFilter!==WC&&L.minFilter!==K0||L.type===xc&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===X0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(z,ve.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Ne(z,L){let ne=!1;z.__webglInit===void 0&&(z.__webglInit=!0,L.addEventListener("dispose",F));const ve=L.source;let we=y.get(ve);we===void 0&&(we={},y.set(ve,we));const ye=Z(L);if(ye!==z.__cacheKey){we[ye]===void 0&&(we[ye]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,ne=!0),we[ye].usedTimes++;const nt=we[z.__cacheKey];nt!==void 0&&(we[z.__cacheKey].usedTimes--,nt.usedTimes===0&&R(L)),z.__cacheKey=ye,z.__webglTexture=we[ye].texture}return ne}function ie(z,L,ne){let ve=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ve=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ve=t.TEXTURE_3D);const we=Ne(z,L),ye=L.source;n.bindTexture(ve,z.__webglTexture,t.TEXTURE0+ne);const nt=r.get(ye);if(ye.version!==nt.__version||we===!0){n.activeTexture(t.TEXTURE0+ne);const Be=Xn.getPrimaries(Xn.workingColorSpace),ue=L.colorSpace===Js?null:Xn.getPrimaries(L.colorSpace),Ve=L.colorSpace===Js||Be===ue?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);const Fe=T(L)&&A(L.image)===!1;let oe=S(L.image,Fe,!1,d);oe=Se(L,oe);const Je=A(oe)||o,He=a.convert(L.format,L.colorSpace);let Ke=a.convert(L.type),ct=I(L.internalFormat,He,Ke,L.colorSpace,L.isVideoTexture);xe(ve,L,Je);let de;const Ye=L.mipmaps,ge=o&&L.isVideoTexture!==!0&&ct!==PZ,Ue=nt.__version===void 0||we===!0,Ce=C(L,oe,Je);if(L.isDepthTexture)ct=t.DEPTH_COMPONENT,o?L.type===xc?ct=t.DEPTH_COMPONENT32F:L.type===Bu?ct=t.DEPTH_COMPONENT24:L.type===Nh?ct=t.DEPTH24_STENCIL8:ct=t.DEPTH_COMPONENT16:L.type===xc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===kh&&ct===t.DEPTH_COMPONENT&&L.type!==fO&&L.type!==Bu&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Bu,Ke=a.convert(L.type)),L.format===jm&&ct===t.DEPTH_COMPONENT&&(ct=t.DEPTH_STENCIL,L.type!==Nh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Nh,Ke=a.convert(L.type))),Ue&&(ge?n.texStorage2D(t.TEXTURE_2D,1,ct,oe.width,oe.height):n.texImage2D(t.TEXTURE_2D,0,ct,oe.width,oe.height,0,He,Ke,null));else if(L.isDataTexture)if(Ye.length>0&&Je){ge&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,Ye[0].width,Ye[0].height);for(let _e=0,ce=Ye.length;_e<ce;_e++)de=Ye[_e],ge?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,de.width,de.height,He,Ke,de.data):n.texImage2D(t.TEXTURE_2D,_e,ct,de.width,de.height,0,He,Ke,de.data);L.generateMipmaps=!1}else ge?(Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe.width,oe.height,He,Ke,oe.data)):n.texImage2D(t.TEXTURE_2D,0,ct,oe.width,oe.height,0,He,Ke,oe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ge&&Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,ct,Ye[0].width,Ye[0].height,oe.depth);for(let _e=0,ce=Ye.length;_e<ce;_e++)de=Ye[_e],L.format!==Qs?He!==null?ge?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,_e,0,0,0,de.width,de.height,oe.depth,He,de.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,_e,ct,de.width,de.height,oe.depth,0,de.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?n.texSubImage3D(t.TEXTURE_2D_ARRAY,_e,0,0,0,de.width,de.height,oe.depth,He,Ke,de.data):n.texImage3D(t.TEXTURE_2D_ARRAY,_e,ct,de.width,de.height,oe.depth,0,He,Ke,de.data)}else{ge&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,Ye[0].width,Ye[0].height);for(let _e=0,ce=Ye.length;_e<ce;_e++)de=Ye[_e],L.format!==Qs?He!==null?ge?n.compressedTexSubImage2D(t.TEXTURE_2D,_e,0,0,de.width,de.height,He,de.data):n.compressedTexImage2D(t.TEXTURE_2D,_e,ct,de.width,de.height,0,de.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,de.width,de.height,He,Ke,de.data):n.texImage2D(t.TEXTURE_2D,_e,ct,de.width,de.height,0,He,Ke,de.data)}else if(L.isDataArrayTexture)ge?(Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,ct,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,He,Ke,oe.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ct,oe.width,oe.height,oe.depth,0,He,Ke,oe.data);else if(L.isData3DTexture)ge?(Ue&&n.texStorage3D(t.TEXTURE_3D,Ce,ct,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,He,Ke,oe.data)):n.texImage3D(t.TEXTURE_3D,0,ct,oe.width,oe.height,oe.depth,0,He,Ke,oe.data);else if(L.isFramebufferTexture){if(Ue)if(ge)n.texStorage2D(t.TEXTURE_2D,Ce,ct,oe.width,oe.height);else{let _e=oe.width,ce=oe.height;for(let st=0;st<Ce;st++)n.texImage2D(t.TEXTURE_2D,st,ct,_e,ce,0,He,Ke,null),_e>>=1,ce>>=1}}else if(Ye.length>0&&Je){ge&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,Ye[0].width,Ye[0].height);for(let _e=0,ce=Ye.length;_e<ce;_e++)de=Ye[_e],ge?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,He,Ke,de):n.texImage2D(t.TEXTURE_2D,_e,ct,He,Ke,de);L.generateMipmaps=!1}else ge?(Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,He,Ke,oe)):n.texImage2D(t.TEXTURE_2D,0,ct,He,Ke,oe);k(L,Je)&&N(ve),nt.__version=ye.version,L.onUpdate&&L.onUpdate(L)}z.__version=L.version}function be(z,L,ne){if(L.image.length!==6)return;const ve=Ne(z,L),we=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,z.__webglTexture,t.TEXTURE0+ne);const ye=r.get(we);if(we.version!==ye.__version||ve===!0){n.activeTexture(t.TEXTURE0+ne);const nt=Xn.getPrimaries(Xn.workingColorSpace),Be=L.colorSpace===Js?null:Xn.getPrimaries(L.colorSpace),ue=L.colorSpace===Js||nt===Be?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ue);const Ve=L.isCompressedTexture||L.image[0].isCompressedTexture,Fe=L.image[0]&&L.image[0].isDataTexture,oe=[];for(let _e=0;_e<6;_e++)!Ve&&!Fe?oe[_e]=S(L.image[_e],!1,!0,u):oe[_e]=Fe?L.image[_e].image:L.image[_e],oe[_e]=Se(L,oe[_e]);const Je=oe[0],He=A(Je)||o,Ke=a.convert(L.format,L.colorSpace),ct=a.convert(L.type),de=I(L.internalFormat,Ke,ct,L.colorSpace),Ye=o&&L.isVideoTexture!==!0,ge=ye.__version===void 0||ve===!0;let Ue=C(L,Je,He);xe(t.TEXTURE_CUBE_MAP,L,He);let Ce;if(Ve){Ye&&ge&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,de,Je.width,Je.height);for(let _e=0;_e<6;_e++){Ce=oe[_e].mipmaps;for(let ce=0;ce<Ce.length;ce++){const st=Ce[ce];L.format!==Qs?Ke!==null?Ye?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,0,0,st.width,st.height,Ke,st.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,de,st.width,st.height,0,st.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,0,0,st.width,st.height,Ke,ct,st.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,de,st.width,st.height,0,Ke,ct,st.data)}}}else{Ce=L.mipmaps,Ye&&ge&&(Ce.length>0&&Ue++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,de,oe[0].width,oe[0].height));for(let _e=0;_e<6;_e++)if(Fe){Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,oe[_e].width,oe[_e].height,Ke,ct,oe[_e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,de,oe[_e].width,oe[_e].height,0,Ke,ct,oe[_e].data);for(let ce=0;ce<Ce.length;ce++){const xt=Ce[ce].image[_e].image;Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,0,0,xt.width,xt.height,Ke,ct,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,de,xt.width,xt.height,0,Ke,ct,xt.data)}}else{Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,Ke,ct,oe[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,de,Ke,ct,oe[_e]);for(let ce=0;ce<Ce.length;ce++){const st=Ce[ce];Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,0,0,Ke,ct,st.image[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,de,Ke,ct,st.image[_e])}}}k(L,He)&&N(t.TEXTURE_CUBE_MAP),ye.__version=we.version,L.onUpdate&&L.onUpdate(L)}z.__version=L.version}function je(z,L,ne,ve,we,ye){const nt=a.convert(ne.format,ne.colorSpace),Be=a.convert(ne.type),ue=I(ne.internalFormat,nt,Be,ne.colorSpace);if(!r.get(L).__hasExternalTextures){const Fe=Math.max(1,L.width>>ye),oe=Math.max(1,L.height>>ye);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ye,ue,Fe,oe,L.depth,0,nt,Be,null):n.texImage2D(we,ye,ue,Fe,oe,0,nt,Be,null)}n.bindFramebuffer(t.FRAMEBUFFER,z),Ae(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ve,we,r.get(ne).__webglTexture,0,se(L)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ve,we,r.get(ne).__webglTexture,ye),n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(z,L,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,z),L.depthBuffer&&!L.stencilBuffer){let ve=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ne||Ae(L)){const we=L.depthTexture;we&&we.isDepthTexture&&(we.type===xc?ve=t.DEPTH_COMPONENT32F:we.type===Bu&&(ve=t.DEPTH_COMPONENT24));const ye=se(L);Ae(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ye,ve,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,ve,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,ve,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,z)}else if(L.depthBuffer&&L.stencilBuffer){const ve=se(L);ne&&Ae(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,t.DEPTH24_STENCIL8,L.width,L.height):Ae(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,z)}else{const ve=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let we=0;we<ve.length;we++){const ye=ve[we],nt=a.convert(ye.format,ye.colorSpace),Be=a.convert(ye.type),ue=I(ye.internalFormat,nt,Be,ye.colorSpace),Ve=se(L);ne&&Ae(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,ue,L.width,L.height):Ae(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,ue,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ue,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ht(z,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,z),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),Q(L.depthTexture,0);const ve=r.get(L.depthTexture).__webglTexture,we=se(L);if(L.depthTexture.format===kh)Ae(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0);else if(L.depthTexture.format===jm)Ae(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0);else throw new Error("Unknown depthTexture format")}function H(z){const L=r.get(z),ne=z.isWebGLCubeRenderTarget===!0;if(z.depthTexture&&!L.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");ht(L.__webglFramebuffer,z)}else if(ne){L.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ve]),L.__webglDepthbuffer[ve]=t.createRenderbuffer(),he(L.__webglDepthbuffer[ve],z,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),he(L.__webglDepthbuffer,z,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function B(z,L,ne){const ve=r.get(z);L!==void 0&&je(ve.__webglFramebuffer,z,z.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&H(z)}function re(z){const L=z.texture,ne=r.get(z),ve=r.get(L);z.addEventListener("dispose",O),z.isWebGLMultipleRenderTargets!==!0&&(ve.__webglTexture===void 0&&(ve.__webglTexture=t.createTexture()),ve.__version=L.version,s.memory.textures++);const we=z.isWebGLCubeRenderTarget===!0,ye=z.isWebGLMultipleRenderTargets===!0,nt=A(z)||o;if(we){ne.__webglFramebuffer=[];for(let Be=0;Be<6;Be++)if(o&&L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer[Be]=[];for(let ue=0;ue<L.mipmaps.length;ue++)ne.__webglFramebuffer[Be][ue]=t.createFramebuffer()}else ne.__webglFramebuffer[Be]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Be=0;Be<L.mipmaps.length;Be++)ne.__webglFramebuffer[Be]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(ye)if(i.drawBuffers){const Be=z.texture;for(let ue=0,Ve=Be.length;ue<Ve;ue++){const Fe=r.get(Be[ue]);Fe.__webglTexture===void 0&&(Fe.__webglTexture=t.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&z.samples>0&&Ae(z)===!1){const Be=ye?L:[L];ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let ue=0;ue<Be.length;ue++){const Ve=Be[ue];ne.__webglColorRenderbuffer[ue]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[ue]);const Fe=a.convert(Ve.format,Ve.colorSpace),oe=a.convert(Ve.type),Je=I(Ve.internalFormat,Fe,oe,Ve.colorSpace,z.isXRRenderTarget===!0),He=se(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,He,Je,z.width,z.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ue,t.RENDERBUFFER,ne.__webglColorRenderbuffer[ue])}t.bindRenderbuffer(t.RENDERBUFFER,null),z.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),he(ne.__webglDepthRenderbuffer,z,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,ve.__webglTexture),xe(t.TEXTURE_CUBE_MAP,L,nt);for(let Be=0;Be<6;Be++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)je(ne.__webglFramebuffer[Be][ue],z,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,ue);else je(ne.__webglFramebuffer[Be],z,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0);k(L,nt)&&N(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ye){const Be=z.texture;for(let ue=0,Ve=Be.length;ue<Ve;ue++){const Fe=Be[ue],oe=r.get(Fe);n.bindTexture(t.TEXTURE_2D,oe.__webglTexture),xe(t.TEXTURE_2D,Fe,nt),je(ne.__webglFramebuffer,z,Fe,t.COLOR_ATTACHMENT0+ue,t.TEXTURE_2D,0),k(Fe,nt)&&N(t.TEXTURE_2D)}n.unbindTexture()}else{let Be=t.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(o?Be=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Be,ve.__webglTexture),xe(Be,L,nt),o&&L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)je(ne.__webglFramebuffer[ue],z,L,t.COLOR_ATTACHMENT0,Be,ue);else je(ne.__webglFramebuffer,z,L,t.COLOR_ATTACHMENT0,Be,0);k(L,nt)&&N(Be),n.unbindTexture()}z.depthBuffer&&H(z)}function V(z){const L=A(z)||o,ne=z.isWebGLMultipleRenderTargets===!0?z.texture:[z.texture];for(let ve=0,we=ne.length;ve<we;ve++){const ye=ne[ve];if(k(ye,L)){const nt=z.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Be=r.get(ye).__webglTexture;n.bindTexture(nt,Be),N(nt),n.unbindTexture()}}}function J(z){if(o&&z.samples>0&&Ae(z)===!1){const L=z.isWebGLMultipleRenderTargets?z.texture:[z.texture],ne=z.width,ve=z.height;let we=t.COLOR_BUFFER_BIT;const ye=[],nt=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Be=r.get(z),ue=z.isWebGLMultipleRenderTargets===!0;if(ue)for(let Ve=0;Ve<L.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Be.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Be.__webglFramebuffer);for(let Ve=0;Ve<L.length;Ve++){ye.push(t.COLOR_ATTACHMENT0+Ve),z.depthBuffer&&ye.push(nt);const Fe=Be.__ignoreDepthValues!==void 0?Be.__ignoreDepthValues:!1;if(Fe===!1&&(z.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),z.stencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),ue&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Be.__webglColorRenderbuffer[Ve]),Fe===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[nt]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[nt])),ue){const oe=r.get(L[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,oe,0)}t.blitFramebuffer(0,0,ne,ve,0,0,ne,ve,we,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ye)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),ue)for(let Ve=0;Ve<L.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,Be.__webglColorRenderbuffer[Ve]);const Fe=r.get(L[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,Fe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Be.__webglMultisampledFramebuffer)}}function se(z){return Math.min(f,z.samples)}function Ae(z){const L=r.get(z);return o&&z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Pe(z){const L=s.render.frame;x.get(z)!==L&&(x.set(z,L),z.update())}function Se(z,L){const ne=z.colorSpace,ve=z.format,we=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||z.format===jP||ne!==Lc&&ne!==Js&&(Xn.getTransfer(ne)===lr?o===!1?e.has("EXT_sRGB")===!0&&ve===Qs?(z.format=jP,z.minFilter=Zs,z.generateMipmaps=!1):L=IZ.sRGBToLinear(L):(ve!==Qs||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=ee,this.resetTextureUnits=G,this.setTexture2D=Q,this.setTexture2DArray=U,this.setTexture3D=$,this.setTextureCube=X,this.rebindTextures=B,this.setupRenderTarget=re,this.updateRenderTargetMipmap=V,this.updateMultisampleRenderTarget=J,this.setupDepthRenderbuffer=H,this.setupFrameBufferTexture=je,this.useMultisampledRTT=Ae}function bFe(t,e,n){const r=n.isWebGL2;function i(a,s=Js){let o;const c=Xn.getTransfer(s);if(a===Qu)return t.UNSIGNED_BYTE;if(a===AZ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===TZ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===Hje)return t.BYTE;if(a===$je)return t.SHORT;if(a===fO)return t.UNSIGNED_SHORT;if(a===EZ)return t.INT;if(a===Bu)return t.UNSIGNED_INT;if(a===xc)return t.FLOAT;if(a===X0)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===Vje)return t.ALPHA;if(a===Qs)return t.RGBA;if(a===Gje)return t.LUMINANCE;if(a===Wje)return t.LUMINANCE_ALPHA;if(a===kh)return t.DEPTH_COMPONENT;if(a===jm)return t.DEPTH_STENCIL;if(a===jP)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===qje)return t.RED;if(a===CZ)return t.RED_INTEGER;if(a===Kje)return t.RG;if(a===NZ)return t.RG_INTEGER;if(a===kZ)return t.RGBA_INTEGER;if(a===qC||a===KC||a===XC||a===YC)if(c===lr)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===qC)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===KC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===XC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===YC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===qC)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===KC)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===XC)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===YC)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===qH||a===KH||a===XH||a===YH)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===qH)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===KH)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===XH)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===YH)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===PZ)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===ZH||a===QH)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(a===ZH)return c===lr?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===QH)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===JH||a===e$||a===t$||a===n$||a===r$||a===i$||a===a$||a===s$||a===o$||a===l$||a===c$||a===u$||a===d$||a===h$)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(a===JH)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===e$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===t$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===n$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===r$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===i$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===a$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===s$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===o$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===l$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===c$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===u$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===d$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===h$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===ZC||a===f$||a===p$)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(a===ZC)return c===lr?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===f$)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===p$)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===Xje||a===m$||a===g$||a===x$)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(a===ZC)return o.COMPRESSED_RED_RGTC1_EXT;if(a===m$)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===g$)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===x$)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Nh?r?t.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class yFe extends ms{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Ux extends Aa{constructor(){super(),this.isGroup=!0,this.type="Group"}}const vFe={type:"move"};class vN{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,a=null,s=null;const o=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const v of e.hand.values()){const y=n.getJointPose(v,r),b=this._getHandJoint(u,v);y!==null&&(b.matrix.fromArray(y.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=y.radius),b.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),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&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(vFe)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Ux;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class _Fe extends gf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,o="local-floor",c=1,u=null,d=null,f=null,g=null,m=null,x=null;const v=n.getContextAttributes();let y=null,b=null;const M=[],S=[],A=new Zt;let T=null;const k=new ms;k.layers.enable(1),k.viewport=new Zn;const N=new ms;N.layers.enable(2),N.viewport=new Zn;const I=[k,N],C=new yFe;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(X){let te=M[X];return te===void 0&&(te=new vN,M[X]=te),te.getTargetRaySpace()},this.getControllerGrip=function(X){let te=M[X];return te===void 0&&(te=new vN,M[X]=te),te.getGripSpace()},this.getHand=function(X){let te=M[X];return te===void 0&&(te=new vN,M[X]=te),te.getHandSpace()};function O(X){const te=S.indexOf(X.inputSource);if(te===-1)return;const fe=M[te];fe!==void 0&&(fe.update(X.inputSource,X.frame,u||s),fe.dispatchEvent({type:X.type,data:X.inputSource}))}function q(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",R);for(let X=0;X<M.length;X++){const te=S[X];te!==null&&(S[X]=null,M[X].disconnect(te))}D=null,F=null,e.setRenderTarget(y),m=null,g=null,f=null,i=null,b=null,$.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){a=X,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){o=X,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(X){u=X},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(X){if(i=X,i!==null){if(y=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",q),i.addEventListener("inputsourceschange",R),v.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const te={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,te),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),b=new nf(m.framebufferWidth,m.framebufferHeight,{format:Qs,type:Qu,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let te=null,fe=null,pe=null;v.depth&&(pe=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,te=v.stencil?jm:kh,fe=v.stencil?Nh:Bu);const xe={colorFormat:n.RGBA8,depthFormat:pe,scaleFactor:a};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:Qs,type:Qu,depthTexture:new XZ(g.textureWidth,g.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,te),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Ne=e.properties.get(b);Ne.__ignoreDepthValues=g.ignoreDepthValues}b.isXRRenderTarget=!0,this.setFoveation(c),u=null,s=await i.requestReferenceSpace(o),$.setContext(i),$.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function R(X){for(let te=0;te<X.removed.length;te++){const fe=X.removed[te],pe=S.indexOf(fe);pe>=0&&(S[pe]=null,M[pe].disconnect(fe))}for(let te=0;te<X.added.length;te++){const fe=X.added[te];let pe=S.indexOf(fe);if(pe===-1){for(let Ne=0;Ne<M.length;Ne++)if(Ne>=S.length){S.push(fe),pe=Ne;break}else if(S[Ne]===null){S[Ne]=fe,pe=Ne;break}if(pe===-1)break}const xe=M[pe];xe&&xe.connect(fe)}}const W=new De,K=new De;function G(X,te,fe){W.setFromMatrixPosition(te.matrixWorld),K.setFromMatrixPosition(fe.matrixWorld);const pe=W.distanceTo(K),xe=te.projectionMatrix.elements,Ne=fe.projectionMatrix.elements,ie=xe[14]/(xe[10]-1),be=xe[14]/(xe[10]+1),je=(xe[9]+1)/xe[5],he=(xe[9]-1)/xe[5],ht=(xe[8]-1)/xe[0],H=(Ne[8]+1)/Ne[0],B=ie*ht,re=ie*H,V=pe/(-ht+H),J=V*-ht;te.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(J),X.translateZ(V),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert();const se=ie+V,Ae=be+V,Pe=B-J,Se=re+(pe-J),z=je*be/Ae*se,L=he*be/Ae*se;X.projectionMatrix.makePerspective(Pe,Se,z,L,se,Ae),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}function ee(X,te){te===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(te.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(i===null)return;C.near=N.near=k.near=X.near,C.far=N.far=k.far=X.far,(D!==C.near||F!==C.far)&&(i.updateRenderState({depthNear:C.near,depthFar:C.far}),D=C.near,F=C.far);const te=X.parent,fe=C.cameras;ee(C,te);for(let pe=0;pe<fe.length;pe++)ee(fe[pe],te);fe.length===2?G(C,k,N):C.projectionMatrix.copy(k.projectionMatrix),Z(X,C,te)};function Z(X,te,fe){fe===null?X.matrix.copy(te.matrixWorld):(X.matrix.copy(fe.matrixWorld),X.matrix.invert(),X.matrix.multiply(te.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(te.projectionMatrix),X.projectionMatrixInverse.copy(te.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=Z0*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(g===null&&m===null))return c},this.setFoveation=function(X){c=X,g!==null&&(g.fixedFoveation=X),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=X)};let Q=null;function U(X,te){if(d=te.getViewerPose(u||s),x=te,d!==null){const fe=d.views;m!==null&&(e.setRenderTargetFramebuffer(b,m.framebuffer),e.setRenderTarget(b));let pe=!1;fe.length!==C.cameras.length&&(C.cameras.length=0,pe=!0);for(let xe=0;xe<fe.length;xe++){const Ne=fe[xe];let ie=null;if(m!==null)ie=m.getViewport(Ne);else{const je=f.getViewSubImage(g,Ne);ie=je.viewport,xe===0&&(e.setRenderTargetTextures(b,je.colorTexture,g.ignoreDepthValues?void 0:je.depthStencilTexture),e.setRenderTarget(b))}let be=I[xe];be===void 0&&(be=new ms,be.layers.enable(xe),be.viewport=new Zn,I[xe]=be),be.matrix.fromArray(Ne.transform.matrix),be.matrix.decompose(be.position,be.quaternion,be.scale),be.projectionMatrix.fromArray(Ne.projectionMatrix),be.projectionMatrixInverse.copy(be.projectionMatrix).invert(),be.viewport.set(ie.x,ie.y,ie.width,ie.height),xe===0&&(C.matrix.copy(be.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),pe===!0&&C.cameras.push(be)}}for(let fe=0;fe<M.length;fe++){const pe=S[fe],xe=M[fe];pe!==null&&xe!==void 0&&xe.update(pe,te,u||s)}Q&&Q(X,te),te.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:te}),x=null}const $=new KZ;$.setAnimationLoop(U),this.setAnimationLoop=function(X){Q=X},this.dispose=function(){}}}function wFe(t,e){function n(y,b){y.matrixAutoUpdate===!0&&y.updateMatrix(),b.value.copy(y.matrix)}function r(y,b){b.color.getRGB(y.fogColor.value,GZ(t)),b.isFog?(y.fogNear.value=b.near,y.fogFar.value=b.far):b.isFogExp2&&(y.fogDensity.value=b.density)}function i(y,b,M,S,A){b.isMeshBasicMaterial||b.isMeshLambertMaterial?a(y,b):b.isMeshToonMaterial?(a(y,b),f(y,b)):b.isMeshPhongMaterial?(a(y,b),d(y,b)):b.isMeshStandardMaterial?(a(y,b),g(y,b),b.isMeshPhysicalMaterial&&m(y,b,A)):b.isMeshMatcapMaterial?(a(y,b),x(y,b)):b.isMeshDepthMaterial?a(y,b):b.isMeshDistanceMaterial?(a(y,b),v(y,b)):b.isMeshNormalMaterial?a(y,b):b.isLineBasicMaterial?(s(y,b),b.isLineDashedMaterial&&o(y,b)):b.isPointsMaterial?c(y,b,M,S):b.isSpriteMaterial?u(y,b):b.isShadowMaterial?(y.color.value.copy(b.color),y.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function a(y,b){y.opacity.value=b.opacity,b.color&&y.diffuse.value.copy(b.color),b.emissive&&y.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.bumpMap&&(y.bumpMap.value=b.bumpMap,n(b.bumpMap,y.bumpMapTransform),y.bumpScale.value=b.bumpScale,b.side===Ka&&(y.bumpScale.value*=-1)),b.normalMap&&(y.normalMap.value=b.normalMap,n(b.normalMap,y.normalMapTransform),y.normalScale.value.copy(b.normalScale),b.side===Ka&&y.normalScale.value.negate()),b.displacementMap&&(y.displacementMap.value=b.displacementMap,n(b.displacementMap,y.displacementMapTransform),y.displacementScale.value=b.displacementScale,y.displacementBias.value=b.displacementBias),b.emissiveMap&&(y.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,y.emissiveMapTransform)),b.specularMap&&(y.specularMap.value=b.specularMap,n(b.specularMap,y.specularMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest);const M=e.get(b).envMap;if(M&&(y.envMap.value=M,y.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=b.reflectivity,y.ior.value=b.ior,y.refractionRatio.value=b.refractionRatio),b.lightMap){y.lightMap.value=b.lightMap;const S=t._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=b.lightMapIntensity*S,n(b.lightMap,y.lightMapTransform)}b.aoMap&&(y.aoMap.value=b.aoMap,y.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,y.aoMapTransform))}function s(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform))}function o(y,b){y.dashSize.value=b.dashSize,y.totalSize.value=b.dashSize+b.gapSize,y.scale.value=b.scale}function c(y,b,M,S){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.size.value=b.size*M,y.scale.value=S*.5,b.map&&(y.map.value=b.map,n(b.map,y.uvTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function u(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.rotation.value=b.rotation,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function d(y,b){y.specular.value.copy(b.specular),y.shininess.value=Math.max(b.shininess,1e-4)}function f(y,b){b.gradientMap&&(y.gradientMap.value=b.gradientMap)}function g(y,b){y.metalness.value=b.metalness,b.metalnessMap&&(y.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,y.metalnessMapTransform)),y.roughness.value=b.roughness,b.roughnessMap&&(y.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,y.roughnessMapTransform)),e.get(b).envMap&&(y.envMapIntensity.value=b.envMapIntensity)}function m(y,b,M){y.ior.value=b.ior,b.sheen>0&&(y.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),y.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(y.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,y.sheenColorMapTransform)),b.sheenRoughnessMap&&(y.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,y.sheenRoughnessMapTransform))),b.clearcoat>0&&(y.clearcoat.value=b.clearcoat,y.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(y.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,y.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(y.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===Ka&&y.clearcoatNormalScale.value.negate())),b.iridescence>0&&(y.iridescence.value=b.iridescence,y.iridescenceIOR.value=b.iridescenceIOR,y.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(y.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,y.iridescenceMapTransform)),b.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),b.transmission>0&&(y.transmission.value=b.transmission,y.transmissionSamplerMap.value=M.texture,y.transmissionSamplerSize.value.set(M.width,M.height),b.transmissionMap&&(y.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,y.transmissionMapTransform)),y.thickness.value=b.thickness,b.thicknessMap&&(y.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=b.attenuationDistance,y.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(y.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(y.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=b.specularIntensity,y.specularColor.value.copy(b.specularColor),b.specularColorMap&&(y.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,y.specularColorMapTransform)),b.specularIntensityMap&&(y.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,b){b.matcap&&(y.matcap.value=b.matcap)}function v(y,b){const M=e.get(b).light;y.referencePosition.value.setFromMatrixPosition(M.matrixWorld),y.nearDistance.value=M.shadow.camera.near,y.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function SFe(t,e,n,r){let i={},a={},s=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(M,S){const A=S.program;r.uniformBlockBinding(M,A)}function u(M,S){let A=i[M.id];A===void 0&&(x(M),A=d(M),i[M.id]=A,M.addEventListener("dispose",y));const T=S.program;r.updateUBOMapping(M,T);const k=e.render.frame;a[M.id]!==k&&(g(M),a[M.id]=k)}function d(M){const S=f();M.__bindingPointIndex=S;const A=t.createBuffer(),T=M.__size,k=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const S=i[M.id],A=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,N=A.length;k<N;k++){const I=A[k];if(m(I,k,T)===!0){const C=I.__offset,D=Array.isArray(I.value)?I.value:[I.value];let F=0;for(let O=0;O<D.length;O++){const q=D[O],R=v(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(M,S,A){const T=M.value;if(A[S]===void 0){if(typeof T=="number")A[S]=T;else{const k=Array.isArray(T)?T:[T],N=[];for(let I=0;I<k.length;I++)N.push(k[I].clone());A[S]=N}return!0}else if(typeof T=="number"){if(A[S]!==T)return A[S]=T,!0}else{const k=Array.isArray(A[S])?A[S]:[A[S]],N=Array.isArray(T)?T:[T];for(let I=0;I<k.length;I++){const C=k[I];if(C.equals(N[I])===!1)return C.copy(N[I]),!0}}return!1}function x(M){const S=M.uniforms;let A=0;const T=16;let k=0;for(let N=0,I=S.length;N<I;N++){const C=S[N],D={boundary:0,storage:0},F=Array.isArray(C.value)?C.value:[C.value];for(let O=0,q=F.length;O<q;O++){const R=F[O],W=v(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 O=T-k;k!==0&&O-D.boundary<0&&(A+=T-k,C.__offset=A)}A+=D.storage}return k=A%T,k>0&&(A+=T-k),M.__size=A,M.__cache={},this}function v(M){const S={boundary:0,storage:0};return typeof M=="number"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),S}function y(M){const S=M.target;S.removeEventListener("dispose",y);const A=s.indexOf(S.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete a[S.id]}function b(){for(const M in i)t.deleteBuffer(i[M]);s=[],i={},a={}}return{bind:c,update:u,dispose:b}}class IP{constructor(e={}){const{canvas:n=vOe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=s;const m=new Uint32Array(4),x=new Int32Array(4);let v=null,y=null;const b=[],M=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Qi,this._useLegacyLights=!1,this.toneMapping=Zu,this.toneMappingExposure=1;const S=this;let A=!1,T=0,k=0,N=null,I=-1,C=null;const D=new Zn,F=new Zn;let O=null;const q=new $t(0);let R=0,W=n.width,K=n.height,G=1,ee=null,Z=null;const Q=new Zn(0,0,W,K),U=new Zn(0,0,W,K);let $=!1;const X=new VM;let te=!1,fe=!1,pe=null;const xe=new ar,Ne=new Zt,ie=new De,be={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function je(){return N===null?G:1}let he=r;function ht(me,$e){for(let rt=0;rt<me.length;rt++){const it=me[rt],et=n.getContext(it,$e);if(et!==null)return et}return null}try{const me={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${BM}`),n.addEventListener("webglcontextlost",Ye,!1),n.addEventListener("webglcontextrestored",ge,!1),n.addEventListener("webglcontextcreationerror",Ue,!1),he===null){const $e=["webgl2","webgl","experimental-webgl"];if(S.isWebGL1Renderer===!0&&$e.shift(),he=ht($e,me),he===null)throw ht($e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&he instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),he.getShaderPrecisionFormat===void 0&&(he.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(me){throw console.error("THREE.WebGLRenderer: "+me.message),me}let H,B,re,V,J,se,Ae,Pe,Se,z,L,ne,ve,we,ye,nt,Be,ue,Ve,Fe,oe,Je,He,Ke;function ct(){H=new jIe(he),B=new TIe(he,H,e),H.init(B),Je=new bFe(he,H,B),re=new gFe(he,H,B),V=new IIe(he),J=new nFe,se=new xFe(he,H,re,J,B,Je,V),Ae=new NIe(S),Pe=new DIe(S),Se=new VOe(he,B),He=new EIe(he,H,Se,B),z=new OIe(he,Se,V,He),L=new BIe(he,z,Se,V),Ve=new zIe(he,B,se),nt=new CIe(J),ne=new tFe(S,Ae,Pe,H,B,He,nt),ve=new wFe(S,J),we=new iFe,ye=new uFe(H,B),ue=new MIe(S,Ae,Pe,re,L,g,c),Be=new mFe(S,L,B),Ke=new SFe(he,V,B,re),Fe=new AIe(he,H,V,B),oe=new LIe(he,H,V,B),V.programs=ne.programs,S.capabilities=B,S.extensions=H,S.properties=J,S.renderLists=we,S.shadowMap=Be,S.state=re,S.info=V}ct();const de=new _Fe(S,he);this.xr=de,this.getContext=function(){return he},this.getContextAttributes=function(){return he.getContextAttributes()},this.forceContextLoss=function(){const me=H.get("WEBGL_lose_context");me&&me.loseContext()},this.forceContextRestore=function(){const me=H.get("WEBGL_lose_context");me&&me.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(me){me!==void 0&&(G=me,this.setSize(W,K,!1))},this.getSize=function(me){return me.set(W,K)},this.setSize=function(me,$e,rt=!0){if(de.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=me,K=$e,n.width=Math.floor(me*G),n.height=Math.floor($e*G),rt===!0&&(n.style.width=me+"px",n.style.height=$e+"px"),this.setViewport(0,0,me,$e)},this.getDrawingBufferSize=function(me){return me.set(W*G,K*G).floor()},this.setDrawingBufferSize=function(me,$e,rt){W=me,K=$e,G=rt,n.width=Math.floor(me*rt),n.height=Math.floor($e*rt),this.setViewport(0,0,me,$e)},this.getCurrentViewport=function(me){return me.copy(D)},this.getViewport=function(me){return me.copy(Q)},this.setViewport=function(me,$e,rt,it){me.isVector4?Q.set(me.x,me.y,me.z,me.w):Q.set(me,$e,rt,it),re.viewport(D.copy(Q).multiplyScalar(G).floor())},this.getScissor=function(me){return me.copy(U)},this.setScissor=function(me,$e,rt,it){me.isVector4?U.set(me.x,me.y,me.z,me.w):U.set(me,$e,rt,it),re.scissor(F.copy(U).multiplyScalar(G).floor())},this.getScissorTest=function(){return $},this.setScissorTest=function(me){re.setScissorTest($=me)},this.setOpaqueSort=function(me){ee=me},this.setTransparentSort=function(me){Z=me},this.getClearColor=function(me){return me.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(me=!0,$e=!0,rt=!0){let it=0;if(me){let et=!1;if(N!==null){const Mt=N.texture.format;et=Mt===kZ||Mt===NZ||Mt===CZ}if(et){const Mt=N.texture.type,ae=Mt===Qu||Mt===Bu||Mt===fO||Mt===Nh||Mt===AZ||Mt===TZ,Me=ue.getClearColor(),Ie=ue.getClearAlpha(),Oe=Me.r,Te=Me.g,ot=Me.b;ae?(m[0]=Oe,m[1]=Te,m[2]=ot,m[3]=Ie,he.clearBufferuiv(he.COLOR,0,m)):(x[0]=Oe,x[1]=Te,x[2]=ot,x[3]=Ie,he.clearBufferiv(he.COLOR,0,x))}else it|=he.COLOR_BUFFER_BIT}$e&&(it|=he.DEPTH_BUFFER_BIT),rt&&(it|=he.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),he.clear(it)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Ye,!1),n.removeEventListener("webglcontextrestored",ge,!1),n.removeEventListener("webglcontextcreationerror",Ue,!1),we.dispose(),ye.dispose(),J.dispose(),Ae.dispose(),Pe.dispose(),L.dispose(),He.dispose(),Ke.dispose(),ne.dispose(),de.dispose(),de.removeEventListener("sessionstart",Qt),de.removeEventListener("sessionend",Ot),pe&&(pe.dispose(),pe=null),Vt.stop()};function Ye(me){me.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function ge(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const me=V.autoReset,$e=Be.enabled,rt=Be.autoUpdate,it=Be.needsUpdate,et=Be.type;ct(),V.autoReset=me,Be.enabled=$e,Be.autoUpdate=rt,Be.needsUpdate=it,Be.type=et}function Ue(me){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",me.statusMessage)}function Ce(me){const $e=me.target;$e.removeEventListener("dispose",Ce),_e($e)}function _e(me){ce(me),J.remove(me)}function ce(me){const $e=J.get(me).programs;$e!==void 0&&($e.forEach(function(rt){ne.releaseProgram(rt)}),me.isShaderMaterial&&ne.releaseShaderCache(me))}this.renderBufferDirect=function(me,$e,rt,it,et,Mt){$e===null&&($e=be);const ae=et.isMesh&&et.matrixWorld.determinant()<0,Me=jr(me,$e,rt,it,et);re.setMaterial(it,ae);let Ie=rt.index,Oe=1;if(it.wireframe===!0){if(Ie=z.getWireframeAttribute(rt),Ie===void 0)return;Oe=2}const Te=rt.drawRange,ot=rt.attributes.position;let ft=Te.start*Oe,yt=(Te.start+Te.count)*Oe;Mt!==null&&(ft=Math.max(ft,Mt.start*Oe),yt=Math.min(yt,(Mt.start+Mt.count)*Oe)),Ie!==null?(ft=Math.max(ft,0),yt=Math.min(yt,Ie.count)):ot!=null&&(ft=Math.max(ft,0),yt=Math.min(yt,ot.count));const bt=yt-ft;if(bt<0||bt===1/0)return;He.setup(et,it,Me,rt,Ie);let Lt,Tt=Fe;if(Ie!==null&&(Lt=Se.get(Ie),Tt=oe,Tt.setIndex(Lt)),et.isMesh)it.wireframe===!0?(re.setLineWidth(it.wireframeLinewidth*je()),Tt.setMode(he.LINES)):Tt.setMode(he.TRIANGLES);else if(et.isLine){let mt=it.linewidth;mt===void 0&&(mt=1),re.setLineWidth(mt*je()),et.isLineSegments?Tt.setMode(he.LINES):et.isLineLoop?Tt.setMode(he.LINE_LOOP):Tt.setMode(he.LINE_STRIP)}else et.isPoints?Tt.setMode(he.POINTS):et.isSprite&&Tt.setMode(he.TRIANGLES);if(et.isBatchedMesh)Tt.renderMultiDraw(et._multiDrawStarts,et._multiDrawCounts,et._multiDrawCount);else if(et.isInstancedMesh)Tt.renderInstances(ft,bt,et.count);else if(rt.isInstancedBufferGeometry){const mt=rt._maxInstanceCount!==void 0?rt._maxInstanceCount:1/0,Xt=Math.min(rt.instanceCount,mt);Tt.renderInstances(ft,bt,Xt)}else Tt.render(ft,bt)};function st(me,$e,rt){me.transparent===!0&&me.side===dc&&me.forceSinglePass===!1?(me.side=Ka,me.needsUpdate=!0,ra(me,$e,rt),me.side=fd,me.needsUpdate=!0,ra(me,$e,rt),me.side=dc):ra(me,$e,rt)}this.compile=function(me,$e,rt=null){rt===null&&(rt=me),y=ye.get(rt),y.init(),M.push(y),rt.traverseVisible(function(et){et.isLight&&et.layers.test($e.layers)&&(y.pushLight(et),et.castShadow&&y.pushShadow(et))}),me!==rt&&me.traverseVisible(function(et){et.isLight&&et.layers.test($e.layers)&&(y.pushLight(et),et.castShadow&&y.pushShadow(et))}),y.setupLights(S._useLegacyLights);const it=new Set;return me.traverse(function(et){const Mt=et.material;if(Mt)if(Array.isArray(Mt))for(let ae=0;ae<Mt.length;ae++){const Me=Mt[ae];st(Me,rt,et),it.add(Me)}else st(Mt,rt,et),it.add(Mt)}),M.pop(),y=null,it},this.compileAsync=function(me,$e,rt=null){const it=this.compile(me,$e,rt);return new Promise(et=>{function Mt(){if(it.forEach(function(ae){J.get(ae).currentProgram.isReady()&&it.delete(ae)}),it.size===0){et(me);return}setTimeout(Mt,10)}H.get("KHR_parallel_shader_compile")!==null?Mt():setTimeout(Mt,10)})};let xt=null;function St(me){xt&&xt(me)}function Qt(){Vt.stop()}function Ot(){Vt.start()}const Vt=new KZ;Vt.setAnimationLoop(St),typeof self<"u"&&Vt.setContext(self),this.setAnimationLoop=function(me){xt=me,de.setAnimationLoop(me),me===null?Vt.stop():Vt.start()},de.addEventListener("sessionstart",Qt),de.addEventListener("sessionend",Ot),this.render=function(me,$e){if($e!==void 0&&$e.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;me.matrixWorldAutoUpdate===!0&&me.updateMatrixWorld(),$e.parent===null&&$e.matrixWorldAutoUpdate===!0&&$e.updateMatrixWorld(),de.enabled===!0&&de.isPresenting===!0&&(de.cameraAutoUpdate===!0&&de.updateCamera($e),$e=de.getCamera()),me.isScene===!0&&me.onBeforeRender(S,me,$e,N),y=ye.get(me,M.length),y.init(),M.push(y),xe.multiplyMatrices($e.projectionMatrix,$e.matrixWorldInverse),X.setFromProjectionMatrix(xe),fe=this.localClippingEnabled,te=nt.init(this.clippingPlanes,fe),v=we.get(me,b.length),v.init(),b.push(v),On(me,$e,0,S.sortObjects),v.finish(),S.sortObjects===!0&&v.sort(ee,Z),this.info.render.frame++,te===!0&&nt.beginShadows();const rt=y.state.shadowsArray;if(Be.render(rt,me,$e),te===!0&&nt.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(v,me),y.setupLights(S._useLegacyLights),$e.isArrayCamera){const it=$e.cameras;for(let et=0,Mt=it.length;et<Mt;et++){const ae=it[et];Mi(v,me,ae,ae.viewport)}}else Mi(v,me,$e);N!==null&&(se.updateMultisampleRenderTarget(N),se.updateRenderTargetMipmap(N)),me.isScene===!0&&me.onAfterRender(S,me,$e),He.resetDefaultState(),I=-1,C=null,M.pop(),M.length>0?y=M[M.length-1]:y=null,b.pop(),b.length>0?v=b[b.length-1]:v=null};function On(me,$e,rt,it){if(me.visible===!1)return;if(me.layers.test($e.layers)){if(me.isGroup)rt=me.renderOrder;else if(me.isLOD)me.autoUpdate===!0&&me.update($e);else if(me.isLight)y.pushLight(me),me.castShadow&&y.pushShadow(me);else if(me.isSprite){if(!me.frustumCulled||X.intersectsSprite(me)){it&&ie.setFromMatrixPosition(me.matrixWorld).applyMatrix4(xe);const ae=L.update(me),Me=me.material;Me.visible&&v.push(me,ae,Me,rt,ie.z,null)}}else if((me.isMesh||me.isLine||me.isPoints)&&(!me.frustumCulled||X.intersectsObject(me))){const ae=L.update(me),Me=me.material;if(it&&(me.boundingSphere!==void 0?(me.boundingSphere===null&&me.computeBoundingSphere(),ie.copy(me.boundingSphere.center)):(ae.boundingSphere===null&&ae.computeBoundingSphere(),ie.copy(ae.boundingSphere.center)),ie.applyMatrix4(me.matrixWorld).applyMatrix4(xe)),Array.isArray(Me)){const Ie=ae.groups;for(let Oe=0,Te=Ie.length;Oe<Te;Oe++){const ot=Ie[Oe],ft=Me[ot.materialIndex];ft&&ft.visible&&v.push(me,ae,ft,rt,ie.z,ot)}}else Me.visible&&v.push(me,ae,Me,rt,ie.z,null)}}const Mt=me.children;for(let ae=0,Me=Mt.length;ae<Me;ae++)On(Mt[ae],$e,rt,it)}function Mi(me,$e,rt,it){const et=me.opaque,Mt=me.transmissive,ae=me.transparent;y.setupLightsView(rt),te===!0&&nt.setGlobalState(S.clippingPlanes,rt),Mt.length>0&&si(et,Mt,$e,rt),it&&re.viewport(D.copy(it)),et.length>0&&Ei(et,$e,rt),Mt.length>0&&Ei(Mt,$e,rt),ae.length>0&&Ei(ae,$e,rt),re.buffers.depth.setTest(!0),re.buffers.depth.setMask(!0),re.buffers.color.setMask(!0),re.setPolygonOffset(!1)}function si(me,$e,rt,it){if((rt.isScene===!0?rt.overrideMaterial:null)!==null)return;const Mt=B.isWebGL2;pe===null&&(pe=new nf(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?X0:Qu,minFilter:K0,samples:Mt?4:0})),S.getDrawingBufferSize(Ne),Mt?pe.setSize(Ne.x,Ne.y):pe.setSize(Iw(Ne.x),Iw(Ne.y));const ae=S.getRenderTarget();S.setRenderTarget(pe),S.getClearColor(q),R=S.getClearAlpha(),R<1&&S.setClearColor(16777215,.5),S.clear();const Me=S.toneMapping;S.toneMapping=Zu,Ei(me,rt,it),se.updateMultisampleRenderTarget(pe),se.updateRenderTargetMipmap(pe);let Ie=!1;for(let Oe=0,Te=$e.length;Oe<Te;Oe++){const ot=$e[Oe],ft=ot.object,yt=ot.geometry,bt=ot.material,Lt=ot.group;if(bt.side===dc&&ft.layers.test(it.layers)){const Tt=bt.side;bt.side=Ka,bt.needsUpdate=!0,zi(ft,rt,it,yt,bt,Lt),bt.side=Tt,bt.needsUpdate=!0,Ie=!0}}Ie===!0&&(se.updateMultisampleRenderTarget(pe),se.updateRenderTargetMipmap(pe)),S.setRenderTarget(ae),S.setClearColor(q,R),S.toneMapping=Me}function Ei(me,$e,rt){const it=$e.isScene===!0?$e.overrideMaterial:null;for(let et=0,Mt=me.length;et<Mt;et++){const ae=me[et],Me=ae.object,Ie=ae.geometry,Oe=it===null?ae.material:it,Te=ae.group;Me.layers.test(rt.layers)&&zi(Me,$e,rt,Ie,Oe,Te)}}function zi(me,$e,rt,it,et,Mt){me.onBeforeRender(S,$e,rt,it,et,Mt),me.modelViewMatrix.multiplyMatrices(rt.matrixWorldInverse,me.matrixWorld),me.normalMatrix.getNormalMatrix(me.modelViewMatrix),et.onBeforeRender(S,$e,rt,it,me,Mt),et.transparent===!0&&et.side===dc&&et.forceSinglePass===!1?(et.side=Ka,et.needsUpdate=!0,S.renderBufferDirect(rt,$e,it,et,me,Mt),et.side=fd,et.needsUpdate=!0,S.renderBufferDirect(rt,$e,it,et,me,Mt),et.side=dc):S.renderBufferDirect(rt,$e,it,et,me,Mt),me.onAfterRender(S,$e,rt,it,et,Mt)}function ra(me,$e,rt){$e.isScene!==!0&&($e=be);const it=J.get(me),et=y.state.lights,Mt=y.state.shadowsArray,ae=et.state.version,Me=ne.getParameters(me,et.state,Mt,$e,rt),Ie=ne.getProgramCacheKey(Me);let Oe=it.programs;it.environment=me.isMeshStandardMaterial?$e.environment:null,it.fog=$e.fog,it.envMap=(me.isMeshStandardMaterial?Pe:Ae).get(me.envMap||it.environment),Oe===void 0&&(me.addEventListener("dispose",Ce),Oe=new Map,it.programs=Oe);let Te=Oe.get(Ie);if(Te!==void 0){if(it.currentProgram===Te&&it.lightsStateVersion===ae)return br(me,Me),Te}else Me.uniforms=ne.getUniforms(me),me.onBuild(rt,Me,S),me.onBeforeCompile(Me,S),Te=ne.acquireProgram(Me,Ie),Oe.set(Ie,Te),it.uniforms=Me.uniforms;const ot=it.uniforms;return(!me.isShaderMaterial&&!me.isRawShaderMaterial||me.clipping===!0)&&(ot.clippingPlanes=nt.uniform),br(me,Me),it.needsLights=Hc(me),it.lightsStateVersion=ae,it.needsLights&&(ot.ambientLightColor.value=et.state.ambient,ot.lightProbe.value=et.state.probe,ot.directionalLights.value=et.state.directional,ot.directionalLightShadows.value=et.state.directionalShadow,ot.spotLights.value=et.state.spot,ot.spotLightShadows.value=et.state.spotShadow,ot.rectAreaLights.value=et.state.rectArea,ot.ltc_1.value=et.state.rectAreaLTC1,ot.ltc_2.value=et.state.rectAreaLTC2,ot.pointLights.value=et.state.point,ot.pointLightShadows.value=et.state.pointShadow,ot.hemisphereLights.value=et.state.hemi,ot.directionalShadowMap.value=et.state.directionalShadowMap,ot.directionalShadowMatrix.value=et.state.directionalShadowMatrix,ot.spotShadowMap.value=et.state.spotShadowMap,ot.spotLightMatrix.value=et.state.spotLightMatrix,ot.spotLightMap.value=et.state.spotLightMap,ot.pointShadowMap.value=et.state.pointShadowMap,ot.pointShadowMatrix.value=et.state.pointShadowMatrix),it.currentProgram=Te,it.uniformsList=null,Te}function Hr(me){if(me.uniformsList===null){const $e=me.currentProgram.getUniforms();me.uniformsList=p1.seqWithValue($e.seq,me.uniforms)}return me.uniformsList}function br(me,$e){const rt=J.get(me);rt.outputColorSpace=$e.outputColorSpace,rt.batching=$e.batching,rt.instancing=$e.instancing,rt.instancingColor=$e.instancingColor,rt.skinning=$e.skinning,rt.morphTargets=$e.morphTargets,rt.morphNormals=$e.morphNormals,rt.morphColors=$e.morphColors,rt.morphTargetsCount=$e.morphTargetsCount,rt.numClippingPlanes=$e.numClippingPlanes,rt.numIntersection=$e.numClipIntersection,rt.vertexAlphas=$e.vertexAlphas,rt.vertexTangents=$e.vertexTangents,rt.toneMapping=$e.toneMapping}function jr(me,$e,rt,it,et){$e.isScene!==!0&&($e=be),se.resetTextureUnits();const Mt=$e.fog,ae=it.isMeshStandardMaterial?$e.environment:null,Me=N===null?S.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:Lc,Ie=(it.isMeshStandardMaterial?Pe:Ae).get(it.envMap||ae),Oe=it.vertexColors===!0&&!!rt.attributes.color&&rt.attributes.color.itemSize===4,Te=!!rt.attributes.tangent&&(!!it.normalMap||it.anisotropy>0),ot=!!rt.morphAttributes.position,ft=!!rt.morphAttributes.normal,yt=!!rt.morphAttributes.color;let bt=Zu;it.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(bt=S.toneMapping);const Lt=rt.morphAttributes.position||rt.morphAttributes.normal||rt.morphAttributes.color,Tt=Lt!==void 0?Lt.length:0,mt=J.get(it),Xt=y.state.lights;if(te===!0&&(fe===!0||me!==C)){const Or=me===C&&it.id===I;nt.setState(it,me,Or)}let Ut=!1;it.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Xt.state.version||mt.outputColorSpace!==Me||et.isBatchedMesh&&mt.batching===!1||!et.isBatchedMesh&&mt.batching===!0||et.isInstancedMesh&&mt.instancing===!1||!et.isInstancedMesh&&mt.instancing===!0||et.isSkinnedMesh&&mt.skinning===!1||!et.isSkinnedMesh&&mt.skinning===!0||et.isInstancedMesh&&mt.instancingColor===!0&&et.instanceColor===null||et.isInstancedMesh&&mt.instancingColor===!1&&et.instanceColor!==null||mt.envMap!==Ie||it.fog===!0&&mt.fog!==Mt||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==nt.numPlanes||mt.numIntersection!==nt.numIntersection)||mt.vertexAlphas!==Oe||mt.vertexTangents!==Te||mt.morphTargets!==ot||mt.morphNormals!==ft||mt.morphColors!==yt||mt.toneMapping!==bt||B.isWebGL2===!0&&mt.morphTargetsCount!==Tt)&&(Ut=!0):(Ut=!0,mt.__version=it.version);let an=mt.currentProgram;Ut===!0&&(an=ra(it,$e,et));let hn=!1,bn=!1,Ft=!1;const Jt=an.getUniforms(),tn=mt.uniforms;if(re.useProgram(an.program)&&(hn=!0,bn=!0,Ft=!0),it.id!==I&&(I=it.id,bn=!0),hn||C!==me){Jt.setValue(he,"projectionMatrix",me.projectionMatrix),Jt.setValue(he,"viewMatrix",me.matrixWorldInverse);const Or=Jt.map.cameraPosition;Or!==void 0&&Or.setValue(he,ie.setFromMatrixPosition(me.matrixWorld)),B.logarithmicDepthBuffer&&Jt.setValue(he,"logDepthBufFC",2/(Math.log(me.far+1)/Math.LN2)),(it.isMeshPhongMaterial||it.isMeshToonMaterial||it.isMeshLambertMaterial||it.isMeshBasicMaterial||it.isMeshStandardMaterial||it.isShaderMaterial)&&Jt.setValue(he,"isOrthographic",me.isOrthographicCamera===!0),C!==me&&(C=me,bn=!0,Ft=!0)}if(et.isSkinnedMesh){Jt.setOptional(he,et,"bindMatrix"),Jt.setOptional(he,et,"bindMatrixInverse");const Or=et.skeleton;Or&&(B.floatVertexTextures?(Or.boneTexture===null&&Or.computeBoneTexture(),Jt.setValue(he,"boneTexture",Or.boneTexture,se)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}et.isBatchedMesh&&(Jt.setOptional(he,et,"batchingTexture"),Jt.setValue(he,"batchingTexture",et._matricesTexture,se));const Ar=rt.morphAttributes;if((Ar.position!==void 0||Ar.normal!==void 0||Ar.color!==void 0&&B.isWebGL2===!0)&&Ve.update(et,rt,an),(bn||mt.receiveShadow!==et.receiveShadow)&&(mt.receiveShadow=et.receiveShadow,Jt.setValue(he,"receiveShadow",et.receiveShadow)),it.isMeshGouraudMaterial&&it.envMap!==null&&(tn.envMap.value=Ie,tn.flipEnvMap.value=Ie.isCubeTexture&&Ie.isRenderTargetTexture===!1?-1:1),bn&&(Jt.setValue(he,"toneMappingExposure",S.toneMappingExposure),mt.needsLights&&mo(tn,Ft),Mt&&it.fog===!0&&ve.refreshFogUniforms(tn,Mt),ve.refreshMaterialUniforms(tn,it,G,K,pe),p1.upload(he,Hr(mt),tn,se)),it.isShaderMaterial&&it.uniformsNeedUpdate===!0&&(p1.upload(he,Hr(mt),tn,se),it.uniformsNeedUpdate=!1),it.isSpriteMaterial&&Jt.setValue(he,"center",et.center),Jt.setValue(he,"modelViewMatrix",et.modelViewMatrix),Jt.setValue(he,"normalMatrix",et.normalMatrix),Jt.setValue(he,"modelMatrix",et.matrixWorld),it.isShaderMaterial||it.isRawShaderMaterial){const Or=it.uniformsGroups;for(let Dn=0,go=Or.length;Dn<go;Dn++)if(B.isWebGL2){const Ln=Or[Dn];Ke.update(Ln,an),Ke.bind(Ln,an)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return an}function mo(me,$e){me.ambientLightColor.needsUpdate=$e,me.lightProbe.needsUpdate=$e,me.directionalLights.needsUpdate=$e,me.directionalLightShadows.needsUpdate=$e,me.pointLights.needsUpdate=$e,me.pointLightShadows.needsUpdate=$e,me.spotLights.needsUpdate=$e,me.spotLightShadows.needsUpdate=$e,me.rectAreaLights.needsUpdate=$e,me.hemisphereLights.needsUpdate=$e}function Hc(me){return me.isMeshLambertMaterial||me.isMeshToonMaterial||me.isMeshPhongMaterial||me.isMeshStandardMaterial||me.isShadowMaterial||me.isShaderMaterial&&me.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(me,$e,rt){J.get(me.texture).__webglTexture=$e,J.get(me.depthTexture).__webglTexture=rt;const it=J.get(me);it.__hasExternalTextures=!0,it.__hasExternalTextures&&(it.__autoAllocateDepthBuffer=rt===void 0,it.__autoAllocateDepthBuffer||H.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),it.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(me,$e){const rt=J.get(me);rt.__webglFramebuffer=$e,rt.__useDefaultFramebuffer=$e===void 0},this.setRenderTarget=function(me,$e=0,rt=0){N=me,T=$e,k=rt;let it=!0,et=null,Mt=!1,ae=!1;if(me){const Ie=J.get(me);Ie.__useDefaultFramebuffer!==void 0?(re.bindFramebuffer(he.FRAMEBUFFER,null),it=!1):Ie.__webglFramebuffer===void 0?se.setupRenderTarget(me):Ie.__hasExternalTextures&&se.rebindTextures(me,J.get(me.texture).__webglTexture,J.get(me.depthTexture).__webglTexture);const Oe=me.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(ae=!0);const Te=J.get(me).__webglFramebuffer;me.isWebGLCubeRenderTarget?(Array.isArray(Te[$e])?et=Te[$e][rt]:et=Te[$e],Mt=!0):B.isWebGL2&&me.samples>0&&se.useMultisampledRTT(me)===!1?et=J.get(me).__webglMultisampledFramebuffer:Array.isArray(Te)?et=Te[rt]:et=Te,D.copy(me.viewport),F.copy(me.scissor),O=me.scissorTest}else D.copy(Q).multiplyScalar(G).floor(),F.copy(U).multiplyScalar(G).floor(),O=$;if(re.bindFramebuffer(he.FRAMEBUFFER,et)&&B.drawBuffers&&it&&re.drawBuffers(me,et),re.viewport(D),re.scissor(F),re.setScissorTest(O),Mt){const Ie=J.get(me.texture);he.framebufferTexture2D(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,he.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Ie.__webglTexture,rt)}else if(ae){const Ie=J.get(me.texture),Oe=$e||0;he.framebufferTextureLayer(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,Ie.__webglTexture,rt||0,Oe)}I=-1},this.readRenderTargetPixels=function(me,$e,rt,it,et,Mt,ae){if(!(me&&me.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Me=J.get(me).__webglFramebuffer;if(me.isWebGLCubeRenderTarget&&ae!==void 0&&(Me=Me[ae]),Me){re.bindFramebuffer(he.FRAMEBUFFER,Me);try{const Ie=me.texture,Oe=Ie.format,Te=Ie.type;if(Oe!==Qs&&Je.convert(Oe)!==he.getParameter(he.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ot=Te===X0&&(H.has("EXT_color_buffer_half_float")||B.isWebGL2&&H.has("EXT_color_buffer_float"));if(Te!==Qu&&Je.convert(Te)!==he.getParameter(he.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Te===xc&&(B.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float")))&&!ot){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$e>=0&&$e<=me.width-it&&rt>=0&&rt<=me.height-et&&he.readPixels($e,rt,it,et,Je.convert(Oe),Je.convert(Te),Mt)}finally{const Ie=N!==null?J.get(N).__webglFramebuffer:null;re.bindFramebuffer(he.FRAMEBUFFER,Ie)}}},this.copyFramebufferToTexture=function(me,$e,rt=0){const it=Math.pow(2,-rt),et=Math.floor($e.image.width*it),Mt=Math.floor($e.image.height*it);se.setTexture2D($e,0),he.copyTexSubImage2D(he.TEXTURE_2D,rt,0,0,me.x,me.y,et,Mt),re.unbindTexture()},this.copyTextureToTexture=function(me,$e,rt,it=0){const et=$e.image.width,Mt=$e.image.height,ae=Je.convert(rt.format),Me=Je.convert(rt.type);se.setTexture2D(rt,0),he.pixelStorei(he.UNPACK_FLIP_Y_WEBGL,rt.flipY),he.pixelStorei(he.UNPACK_PREMULTIPLY_ALPHA_WEBGL,rt.premultiplyAlpha),he.pixelStorei(he.UNPACK_ALIGNMENT,rt.unpackAlignment),$e.isDataTexture?he.texSubImage2D(he.TEXTURE_2D,it,me.x,me.y,et,Mt,ae,Me,$e.image.data):$e.isCompressedTexture?he.compressedTexSubImage2D(he.TEXTURE_2D,it,me.x,me.y,$e.mipmaps[0].width,$e.mipmaps[0].height,ae,$e.mipmaps[0].data):he.texSubImage2D(he.TEXTURE_2D,it,me.x,me.y,ae,Me,$e.image),it===0&&rt.generateMipmaps&&he.generateMipmap(he.TEXTURE_2D),re.unbindTexture()},this.copyTextureToTexture3D=function(me,$e,rt,it,et=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Mt=me.max.x-me.min.x+1,ae=me.max.y-me.min.y+1,Me=me.max.z-me.min.z+1,Ie=Je.convert(it.format),Oe=Je.convert(it.type);let Te;if(it.isData3DTexture)se.setTexture3D(it,0),Te=he.TEXTURE_3D;else if(it.isDataArrayTexture)se.setTexture2DArray(it,0),Te=he.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}he.pixelStorei(he.UNPACK_FLIP_Y_WEBGL,it.flipY),he.pixelStorei(he.UNPACK_PREMULTIPLY_ALPHA_WEBGL,it.premultiplyAlpha),he.pixelStorei(he.UNPACK_ALIGNMENT,it.unpackAlignment);const ot=he.getParameter(he.UNPACK_ROW_LENGTH),ft=he.getParameter(he.UNPACK_IMAGE_HEIGHT),yt=he.getParameter(he.UNPACK_SKIP_PIXELS),bt=he.getParameter(he.UNPACK_SKIP_ROWS),Lt=he.getParameter(he.UNPACK_SKIP_IMAGES),Tt=rt.isCompressedTexture?rt.mipmaps[0]:rt.image;he.pixelStorei(he.UNPACK_ROW_LENGTH,Tt.width),he.pixelStorei(he.UNPACK_IMAGE_HEIGHT,Tt.height),he.pixelStorei(he.UNPACK_SKIP_PIXELS,me.min.x),he.pixelStorei(he.UNPACK_SKIP_ROWS,me.min.y),he.pixelStorei(he.UNPACK_SKIP_IMAGES,me.min.z),rt.isDataTexture||rt.isData3DTexture?he.texSubImage3D(Te,et,$e.x,$e.y,$e.z,Mt,ae,Me,Ie,Oe,Tt.data):rt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),he.compressedTexSubImage3D(Te,et,$e.x,$e.y,$e.z,Mt,ae,Me,Ie,Tt.data)):he.texSubImage3D(Te,et,$e.x,$e.y,$e.z,Mt,ae,Me,Ie,Oe,Tt),he.pixelStorei(he.UNPACK_ROW_LENGTH,ot),he.pixelStorei(he.UNPACK_IMAGE_HEIGHT,ft),he.pixelStorei(he.UNPACK_SKIP_PIXELS,yt),he.pixelStorei(he.UNPACK_SKIP_ROWS,bt),he.pixelStorei(he.UNPACK_SKIP_IMAGES,Lt),et===0&&it.generateMipmaps&&he.generateMipmap(Te),re.unbindTexture()},this.initTexture=function(me){me.isCubeTexture?se.setTextureCube(me,0):me.isData3DTexture?se.setTexture3D(me,0):me.isDataArrayTexture||me.isCompressedArrayTexture?se.setTexture2DArray(me,0):se.setTexture2D(me,0),re.unbindTexture()},this.resetState=function(){T=0,k=0,N=null,re.reset(),He.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ll}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===pO?"display-p3":"srgb",n.unpackColorSpace=Xn.workingColorSpace===$M?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Qi?Ph:RZ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ph?Qi:Lc}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class MFe extends IP{}MFe.prototype.isWebGL1Renderer=!0;class vO{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 vO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class EFe 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.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 AFe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=DP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Mc()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,a=this.stride;i<a;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mc()),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=Mc()),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 ya=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++)ya.fromBufferAttribute(this,n),ya.applyMatrix4(e),this.setXYZ(n,ya.x,ya.y,ya.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ya.fromBufferAttribute(this,n),ya.applyNormalMatrix(e),this.setXYZ(n,ya.x,ya.y,ya.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ya.fromBufferAttribute(this,n),ya.transformDirection(e),this.setXYZ(n,ya.x,ya.y,ya.z);return this}setX(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=il(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=il(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=il(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=il(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Kn(n,this.array),r=Kn(r,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this}setXYZ(e,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(n=Kn(n,this.array),r=Kn(r,this.array),i=Kn(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e=e*this.data.stride+this.offset,this.normalized&&(n=Kn(n,this.array),r=Kn(r,this.array),i=Kn(i,this.array),a=Kn(a,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return new Ss(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 a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class TFe extends Xa{constructor(e=null,n=1,r=1,i,a,s,o,c,u=Zi,d=Zi,f,g){super(null,s,o,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function CFe(t,e){return t.z-e.z}function NFe(t,e){return e.z-t.z}class kFe{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const a=r[this.index];i.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=n}reset(){this.list.length=0,this.index=0}}const Dp="batchId",Su=new ar,aV=new ar,PFe=new ar,sV=new ar,_N=new VM,T_=new ao,Qd=new ul,Tx=new De,wN=new kFe,ca=new jo,C_=[];function RFe(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let a=0;a<i;a++)for(let s=0;s<r;s++)e.setComponent(a+n,s,t.getComponent(a,s))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class DFe extends jo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new ga,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 TFe(n,e,e,Qs,xc);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const c=e.getAttribute(o),{array:u,itemSize:d,normalized:f}=c,g=new u.constructor(r*d),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(a):new Uint16Array(a);n.setIndex(new Ss(o,1))}const s=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Dp,new Ss(s,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),a=n.getAttribute(r);if(i.itemSize!==a.itemSize||i.normalized!==a.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ao);const e=this._geometryCount,n=this.boundingBox,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,Su),this.getBoundingBoxAt(i,T_).applyMatrix4(Su),n.union(T_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ul);const e=this._geometryCount,n=this.boundingSphere,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,Su),this.getBoundingSphereAt(i,Qd).applyMatrix4(Su),n.union(Qd))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let a=null;const s=this._reservedRanges,o=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=s[s.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,g=this._active,m=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),g.push(!0);const v=this._geometryCount;this._geometryCount++,PFe.toArray(x,v*16),m.needsUpdate=!0,s.push(i),o.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new ao,sphereInitialized:!1,sphere:new ul});const y=this.geometry.getAttribute(Dp);for(let b=0;b<i.vertexCount;b++)y.setX(i.vertexStart+b,v);return y.needsUpdate=!0,this.setGeometryAt(v,e),v}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),s=n.getIndex(),o=this._reservedRanges[e];if(i&&s.count>o.indexCount||n.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=o.vertexStart,u=o.vertexCount;for(const m in r.attributes){if(m===Dp)continue;const x=n.getAttribute(m),v=r.getAttribute(m);RFe(x,v,c);const y=x.itemSize;for(let b=x.count,M=u;b<M;b++){const S=c+b;for(let A=0;A<y;A++)v.setComponent(S,A,0)}v.needsUpdate=!0}if(i){const m=o.indexStart;for(let x=0;x<s.count;x++)a.setX(m+x,c+s.getX(x));for(let x=s.count,v=o.indexCount;x<v;x++)a.setX(m+x,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],g=n.getAttribute("position");return f.count=i?s.count:g.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.box,s=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const o=s.index,c=s.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let g=d;o&&(g=o.getX(g)),a.expandByPoint(Tx.fromBufferAttribute(c,g))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,T_),T_.getCenter(a.center);const o=s.index,c=s.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,g=u.start+u.count;f<g;f++){let m=f;o&&(m=o.getX(m)),Tx.fromBufferAttribute(c,m),d=Math.max(d,a.center.distanceToSquared(Tx))}a.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,s=this._geometryCount,o=this.matrixWorld,c=this.geometry;ca.material=this.material,ca.geometry.index=c.index,ca.geometry.attributes=c.attributes,ca.geometry.boundingBox===null&&(ca.geometry.boundingBox=new ao),ca.geometry.boundingSphere===null&&(ca.geometry.boundingSphere=new ul);for(let u=0;u<s;u++){if(!r[u]||!i[u])continue;const d=a[u];ca.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ca.matrixWorld).premultiply(o),this.getBoundingBoxAt(u,ca.geometry.boundingBox),this.getBoundingSphereAt(u,ca.geometry.boundingSphere),ca.raycast(e,C_);for(let f=0,g=C_.length;f<g;f++){const m=C_[f];m.object=this,m.batchId=u,n.push(m)}C_.length=0}ca.material=null,ca.geometry.index=null,ca.geometry.attributes={},ca.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),o=s===null?1:s.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(sV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),_N.setFromProjectionMatrix(sV,e.isWebGPURenderer?Y0:ll));let m=0;if(this.sortObjects){aV.copy(this.matrixWorld).invert(),Tx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(aV);for(let y=0,b=c.length;y<b;y++)if(c[y]){this.getMatrixAt(y,Su),this.getBoundingSphereAt(y,Qd).applyMatrix4(Su);let M=!1;if(g&&(M=!_N.intersectsSphere(Qd)),!M){const S=Tx.distanceTo(Qd.center);wN.push(f[y],S)}}const x=wN.list,v=this.customSort;v===null?x.sort(a.transparent?NFe:CFe):v.call(this,x,r);for(let y=0,b=x.length;y<b;y++){const M=x[y];u[m]=M.start*o,d[m]=M.count,m++}wN.reset()}else for(let x=0,v=c.length;x<v;x++)if(c[x]){let y=!1;if(g&&(this.getMatrixAt(x,Su),this.getBoundingSphereAt(x,Qd).applyMatrix4(Su),y=!_N.intersectsSphere(Qd)),!y){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,a,s){this.onBeforeRender(e,null,i,a,s)}}class Xb extends ug{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new $t(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const oV=new De,lV=new De,cV=new ar,SN=new gO,N_=new ul;class jFe extends Aa{constructor(e=new ga,n=new Xb){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)oV.fromBufferAttribute(n,i-1),lV.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=oV.distanceTo(lV);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,a=e.params.Line.threshold,s=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),N_.copy(r.boundingSphere),N_.applyMatrix4(i),N_.radius+=a,e.ray.intersectsSphere(N_)===!1)return;cV.copy(i).invert(),SN.copy(e.ray).applyMatrix4(cV);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,u=new De,d=new De,f=new De,g=new De,m=this.isLineSegments?2:1,x=r.index,y=r.attributes.position;if(x!==null){const b=Math.max(0,s.start),M=Math.min(x.count,s.start+s.count);for(let S=b,A=M-1;S<A;S+=m){const T=x.getX(S),k=x.getX(S+1);if(u.fromBufferAttribute(y,T),d.fromBufferAttribute(y,k),SN.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(g);I<e.near||I>e.far||n.push({distance:I,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const b=Math.max(0,s.start),M=Math.min(y.count,s.start+s.count);for(let S=b,A=M-1;S<A;S+=m){if(u.fromBufferAttribute(y,S),d.fromBufferAttribute(y,S+1),SN.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const k=e.ray.origin.distanceTo(g);k<e.near||k>e.far||n.push({distance:k,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}const uV=new De,dV=new De;class WM extends jFe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)uV.fromBufferAttribute(n,i),dV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+uV.distanceTo(dV);e.setAttribute("lineDistance",new Br(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class OFe extends ga{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new De,a=new De;if(e.index!==null){const s=e.attributes.position,o=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:o.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],g=f.start,m=f.count;for(let x=g,v=g+m;x<v;x+=3)for(let y=0;y<3;y++){const b=o.getX(x+y),M=o.getX(x+(y+1)%3);i.fromBufferAttribute(s,b),a.fromBufferAttribute(s,M),hV(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const s=e.attributes.position;for(let o=0,c=s.count/3;o<c;o++)for(let u=0;u<3;u++){const d=3*o+u,f=3*o+(u+1)%3;i.fromBufferAttribute(s,d),a.fromBufferAttribute(s,f),hV(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Br(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function hV(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 LFe extends ug{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new $t(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new $t(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=DZ,this.normalScale=new Zt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=hO,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 IFe extends Xb{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class tQ extends Aa{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 MN=new ar,fV=new De,pV=new De;class FFe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Zt(512,512),this.map=null,this.mapPass=null,this.matrix=new ar,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new VM,this._frameExtents=new Zt(1,1),this._viewportCount=1,this._viewports=[new Zn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;fV.setFromMatrixPosition(e.matrixWorld),n.position.copy(fV),pV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(pV),n.updateMatrixWorld(),MN.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(MN),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(MN)}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 mV=new ar,Cx=new De,EN=new De;class UFe extends FFe{constructor(){super(new ms(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Zt(4,2),this._viewportCount=6,this._viewports=[new Zn(2,1,1,1),new Zn(0,1,1,1),new Zn(3,1,1,1),new Zn(1,1,1,1),new Zn(3,0,1,1),new Zn(1,0,1,1)],this._cubeDirections=[new De(1,0,0),new De(-1,0,0),new De(0,0,1),new De(0,0,-1),new De(0,1,0),new De(0,-1,0)],this._cubeUps=[new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,0,1),new De(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,a=e.distance||r.far;a!==r.far&&(r.far=a,r.updateProjectionMatrix()),Cx.setFromMatrixPosition(e.matrixWorld),r.position.copy(Cx),EN.copy(r.position),EN.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(EN),r.updateMatrixWorld(),i.makeTranslation(-Cx.x,-Cx.y,-Cx.z),mV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(mV)}}class zFe extends tQ{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 UFe}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 BFe extends tQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class HFe extends ga{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 FP extends AFe{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 gV{constructor(e=1,n=0,r=0){return this.radius=e,this.phi=n,this.theta=r,this}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(Ji(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const xV=new De,k_=new De;class $Fe{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){xV.subVectors(e,this.start),k_.subVectors(this.end,this.start);const r=k_.dot(k_);let a=k_.dot(xV)/r;return n&&(a=Ji(a,0,1)),a}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class VFe extends WM{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 ga;i.setAttribute("position",new Br(n,3)),i.setAttribute("color",new Br(r,3));const a=new Xb({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new $t,a=this.geometry.attributes.color.array;return i.set(e),i.toArray(a,0),i.toArray(a,3),i.set(n),i.toArray(a,6),i.toArray(a,9),i.set(r),i.toArray(a,12),i.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:BM}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=BM);class dl{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),dl.nextNameID=dl.nextNameID||0,this.$name.id=`lil-gui-name-${++dl.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",s=>s.stopPropagation()),this.domElement.addEventListener("keyup",s=>s.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class GFe extends dl{constructor(e,n,r){super(e,n,r,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function UP(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 WFe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:UP,toHexString:UP},Q0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},qFe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=Q0.fromHexString(t);e[0]=(r>>16&255)/255*n,e[1]=(r>>8&255)/255*n,e[2]=(r&255)/255*n},toHexString([t,e,n],r=1){r=255/r;const i=t*r<<16^e*r<<8^n*r<<0;return Q0.toHexString(i)}},KFe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=Q0.fromHexString(t);e.r=(r>>16&255)/255*n,e.g=(r>>8&255)/255*n,e.b=(r&255)/255*n},toHexString({r:t,g:e,b:n},r=1){r=255/r;const i=t*r<<16^e*r<<8^n*r<<0;return Q0.toHexString(i)}},XFe=[WFe,Q0,qFe,KFe];function YFe(t){return XFe.find(e=>e.match(t))}class ZFe extends dl{constructor(e,n,r,i){super(e,n,r,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=YFe(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const a=UP(this.$text.value);a&&this._setValueFromHexString(a)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class AN extends dl{constructor(e,n,r){super(e,n,r,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",i=>{i.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class QFe extends dl{constructor(e,n,r,i,a,s){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const o=s!==void 0;this.step(o?s:this._getImplicitStep(),o),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let M=parseFloat(this.$input.value);isNaN(M)||(this._stepExplicit&&(M=this._snap(M)),this.setValue(this._clamp(M)))},r=M=>{const S=parseFloat(this.$input.value);isNaN(S)||(this._snapClampSetValue(S+M),this.$input.value=this.getValue())},i=M=>{M.key==="Enter"&&this.$input.blur(),M.code==="ArrowUp"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M))),M.code==="ArrowDown"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M)*-1))},a=M=>{this._inputFocused&&(M.preventDefault(),r(this._step*this._normalizeMouseWheel(M)))};let s=!1,o,c,u,d,f;const g=5,m=M=>{o=M.clientX,c=u=M.clientY,s=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",v)},x=M=>{if(s){const S=M.clientX-o,A=M.clientY-c;Math.abs(A)>g?(M.preventDefault(),this.$input.blur(),s=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(S)>g&&v()}if(!s){const S=M.clientY-u;f-=S*this._step*this._arrowKeyMultiplier(M),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=M.clientY},v=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",v)},y=()=>{this._inputFocused=!0},b=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",m),this.$input.addEventListener("focus",y),this.$input.addEventListener("blur",b)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(b,M,S,A,T)=>(b-M)/(S-M)*(T-A)+A,n=b=>{const M=this.$slider.getBoundingClientRect();let S=e(b,M.left,M.right,this._min,this._max);this._snapClampSetValue(S)},r=b=>{this._setDraggingStyle(!0),n(b.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=b=>{n(b.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let s=!1,o,c;const u=b=>{b.preventDefault(),this._setDraggingStyle(!0),n(b.touches[0].clientX),s=!1},d=b=>{b.touches.length>1||(this._hasScrollBar?(o=b.touches[0].clientX,c=b.touches[0].clientY,s=!0):u(b),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=b=>{if(s){const M=b.touches[0].clientX-o,S=b.touches[0].clientY-c;Math.abs(M)>Math.abs(S)?u(b):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else b.preventDefault(),n(b.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},m=this._callOnFinishChange.bind(this),x=400;let v;const y=b=>{if(Math.abs(b.deltaX)<Math.abs(b.deltaY)&&this._hasScrollBar)return;b.preventDefault();const S=this._normalizeMouseWheel(b)*this._step;this._snapClampSetValue(this.getValue()+S),this.$input.value=this.getValue(),clearTimeout(v),v=setTimeout(m,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",y,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class JFe extends dl{constructor(e,n,r,i){super(e,n,r,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(i)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(n=>{const r=document.createElement("option");r.textContent=n,this.$select.appendChild(r)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),n=this._values.indexOf(e);return this.$select.selectedIndex=n,this.$display.textContent=n===-1?e:this._names[n],this}}class eUe extends dl{constructor(e,n,r){super(e,n,r,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("spellcheck","false"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",i=>{i.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const tUe=`.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 nUe(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 bV=!1;class Uw{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:s=!1,injectStyles:o=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!bV&&o&&(nUe(tUe),bV=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=s}add(e,n,r,i,a){if(Object(r)===r)return new JFe(this,e,n,r);const s=e[n];switch(typeof s){case"number":return new QFe(this,e,n,r,i,a);case"boolean":return new GFe(this,e,n);case"string":return new eUe(this,e,n);case"function":return new AN(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,s)}addColor(e,n,r=1){return new ZFe(this,e,n,r)}addFolder(e){const n=new Uw({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=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function TN(t,e,n,r){return new(n||(n=Promise))((function(i,a){function s(u){try{c(r.next(u))}catch(d){a(d)}}function o(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(s,o)}c((r=r.apply(t,[])).next())}))}class _O{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 _O(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 wO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class yV extends wO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Mu extends wO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class vV{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 vV(-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((a=>a.comment))).thumbnails;for(const[a,s]of Object.entries(i))this.metadata.thumbnails[a]=s;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],s=n&&i[1]||void 0,o=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=o.length?`${(r=o[0])===null||r===void 0?void 0:r.toLowerCase()}${o[1]}`:"",u=this.parseParams(o.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new yV(e,c,u,s);case"t0":return new Mu(e,c,s,0);case"t1":return new Mu(e,c,s,1);case"t2":return new Mu(e,c,s,2);case"t3":return new Mu(e,c,s,3);case"t4":return new Mu(e,c,s,4);case"t5":return new Mu(e,c,s,5);case"t6":return new Mu(e,c,s,6);case"t7":return new Mu(e,c,s,7);default:return new wO(e,c,u,s)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,a)=>{if(i%2==0)return n;let s=a[i-1];return s=s.toLowerCase(),this.isAlpha(s)&&(n[s]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof yV){const a=i.params;if(a.z&&(this.curZ=a.z),((n=a.e)!==null&&n!==void 0?n:0)>0&&(a.x!=null||a.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const s=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new vV(this.layers.length,[],r,s))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const a=i.comment;if(!a)continue;const s=a.indexOf("thumbnail begin"),o=a.indexOf("thumbnail end");s>-1?r=_O.parse(a.slice(s+15).trim()):r&&(o==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}zw.prototype.parseGcode=zw.prototype.parseGCode;const _V={type:"change"},CN={type:"start"},wV={type:"end"},P_=new gO,SV=new ku,rUe=Math.cos(70*OZ.DEG2RAD);class iUe 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(B){B.addEventListener("keydown",je),this._domElementKeyEvents=B},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(_V),r.update(),a=i.NONE},this.update=(function(){const B=new De,re=new rf().setFromUnitVectors(e.up,new De(0,1,0)),V=re.clone().invert(),J=new De,se=new rf,Ae=new De,Pe=2*Math.PI;return function(Se=null){const z=r.object.position;B.copy(z).sub(r.target),B.applyQuaternion(re),o.setFromVector3(B),r.autoRotate&&a===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+=Pe:L>Math.PI&&(L-=Pe),ne<-Math.PI?ne+=Pe:ne>Math.PI&&(ne-=Pe),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=ee(o.radius):o.radius=ee(o.radius*u),B.setFromSpherical(o),B.applyQuaternion(V),z.copy(r.target).add(B),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let ve=!1;if(r.zoomToCursor&&k){let we=null;if(r.object.isPerspectiveCamera){const ye=B.length();we=ee(ye*u);const nt=ye-we;r.object.position.addScaledVector(A,nt),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ye=new De(T.x,T.y,0);ye.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ve=!0;const nt=new De(T.x,T.y,0);nt.unproject(r.object),r.object.position.sub(nt).add(ye),r.object.updateMatrixWorld(),we=B.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;we!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(we).add(r.object.position):(P_.origin.copy(r.object.position),P_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(P_.direction))<rUe?e.lookAt(r.target):(SV.setFromNormalAndCoplanarPoint(r.object.up,r.target),P_.intersectPlane(SV,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ve=!0);return u=1,k=!1,!!(ve||J.distanceToSquared(r.object.position)>s||8*(1-se.dot(r.object.quaternion))>s||Ae.distanceToSquared(r.target)>0)&&(r.dispatchEvent(_V),J.copy(r.object.position),se.copy(r.object.quaternion),Ae.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",he),r.domElement.removeEventListener("pointerdown",xe),r.domElement.removeEventListener("pointercancel",ie),r.domElement.removeEventListener("wheel",be),r.domElement.removeEventListener("pointermove",Ne),r.domElement.removeEventListener("pointerup",ie),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 a=i.NONE;const s=1e-6,o=new gV,c=new gV;let u=1;const d=new De,f=new Zt,g=new Zt,m=new Zt,x=new Zt,v=new Zt,y=new Zt,b=new Zt,M=new Zt,S=new Zt,A=new De,T=new Zt;let k=!1;const N=[],I={};function C(){return Math.pow(.95,r.zoomSpeed)}function D(B){c.theta-=B}function F(B){c.phi-=B}const O=(function(){const B=new De;return function(re,V){B.setFromMatrixColumn(V,0),B.multiplyScalar(-re),d.add(B)}})(),q=(function(){const B=new De;return function(re,V){r.screenSpacePanning===!0?B.setFromMatrixColumn(V,1):(B.setFromMatrixColumn(V,0),B.crossVectors(r.object.up,B)),B.multiplyScalar(re),d.add(B)}})(),R=(function(){const B=new De;return function(re,V){const J=r.domElement;if(r.object.isPerspectiveCamera){const se=r.object.position;B.copy(se).sub(r.target);let Ae=B.length();Ae*=Math.tan(r.object.fov/2*Math.PI/180),O(2*re*Ae/J.clientHeight,r.object.matrix),q(2*V*Ae/J.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(re*(r.object.right-r.object.left)/r.object.zoom/J.clientWidth,r.object.matrix),q(V*(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(B){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(B){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G(B){if(!r.zoomToCursor)return;k=!0;const re=r.domElement.getBoundingClientRect(),V=B.clientX-re.left,J=B.clientY-re.top,se=re.width,Ae=re.height;T.x=V/se*2-1,T.y=-J/Ae*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function ee(B){return Math.max(r.minDistance,Math.min(r.maxDistance,B))}function Z(B){f.set(B.clientX,B.clientY)}function Q(B){x.set(B.clientX,B.clientY)}function U(){if(N.length===1)f.set(N[0].pageX,N[0].pageY);else{const B=.5*(N[0].pageX+N[1].pageX),re=.5*(N[0].pageY+N[1].pageY);f.set(B,re)}}function $(){if(N.length===1)x.set(N[0].pageX,N[0].pageY);else{const B=.5*(N[0].pageX+N[1].pageX),re=.5*(N[0].pageY+N[1].pageY);x.set(B,re)}}function X(){const B=N[0].pageX-N[1].pageX,re=N[0].pageY-N[1].pageY,V=Math.sqrt(B*B+re*re);b.set(0,V)}function te(B){if(N.length==1)g.set(B.pageX,B.pageY);else{const V=H(B),J=.5*(B.pageX+V.x),se=.5*(B.pageY+V.y);g.set(J,se)}m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const re=r.domElement;D(2*Math.PI*m.x/re.clientHeight),F(2*Math.PI*m.y/re.clientHeight),f.copy(g)}function fe(B){if(N.length===1)v.set(B.pageX,B.pageY);else{const re=H(B),V=.5*(B.pageX+re.x),J=.5*(B.pageY+re.y);v.set(V,J)}y.subVectors(v,x).multiplyScalar(r.panSpeed),R(y.x,y.y),x.copy(v)}function pe(B){const re=H(B),V=B.pageX-re.x,J=B.pageY-re.y,se=Math.sqrt(V*V+J*J);M.set(0,se),S.set(0,Math.pow(M.y/b.y,r.zoomSpeed)),W(S.y),b.copy(M)}function xe(B){r.enabled!==!1&&(N.length===0&&(r.domElement.setPointerCapture(B.pointerId),r.domElement.addEventListener("pointermove",Ne),r.domElement.addEventListener("pointerup",ie)),(function(re){N.push(re)})(B),B.pointerType==="touch"?(function(re){switch(ht(re),N.length){case 1:switch(r.touches.ONE){case gp.ROTATE:if(r.enableRotate===!1)return;U(),a=i.TOUCH_ROTATE;break;case gp.PAN:if(r.enablePan===!1)return;$(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case gp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&X(),r.enablePan&&$(),a=i.TOUCH_DOLLY_PAN;break;case gp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&X(),r.enableRotate&&U(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(CN)})(B):(function(re){let V;switch(re.button){case 0:V=r.mouseButtons.LEFT;break;case 1:V=r.mouseButtons.MIDDLE;break;case 2:V=r.mouseButtons.RIGHT;break;default:V=-1}switch(V){case mp.DOLLY:if(r.enableZoom===!1)return;(function(J){G(J),b.set(J.clientX,J.clientY)})(re),a=i.DOLLY;break;case mp.ROTATE:if(re.ctrlKey||re.metaKey||re.shiftKey){if(r.enablePan===!1)return;Q(re),a=i.PAN}else{if(r.enableRotate===!1)return;Z(re),a=i.ROTATE}break;case mp.PAN:if(re.ctrlKey||re.metaKey||re.shiftKey){if(r.enableRotate===!1)return;Z(re),a=i.ROTATE}else{if(r.enablePan===!1)return;Q(re),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(CN)})(B))}function Ne(B){r.enabled!==!1&&(B.pointerType==="touch"?(function(re){switch(ht(re),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;te(re),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;fe(re),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(V){r.enableZoom&&pe(V),r.enablePan&&fe(V)})(re),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(V){r.enableZoom&&pe(V),r.enableRotate&&te(V)})(re),r.update();break;default:a=i.NONE}})(B):(function(re){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(V){g.set(V.clientX,V.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()})(re);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(V){M.set(V.clientX,V.clientY),S.subVectors(M,b),S.y>0?W(C()):S.y<0&&K(C()),b.copy(M),r.update()})(re);break;case i.PAN:if(r.enablePan===!1)return;(function(V){v.set(V.clientX,V.clientY),y.subVectors(v,x).multiplyScalar(r.panSpeed),R(y.x,y.y),x.copy(v),r.update()})(re)}})(B))}function ie(B){(function(re){delete I[re.pointerId];for(let V=0;V<N.length;V++)if(N[V].pointerId==re.pointerId)return void N.splice(V,1)})(B),N.length===0&&(r.domElement.releasePointerCapture(B.pointerId),r.domElement.removeEventListener("pointermove",Ne),r.domElement.removeEventListener("pointerup",ie)),r.dispatchEvent(wV),a=i.NONE}function be(B){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(B.preventDefault(),r.dispatchEvent(CN),(function(re){G(re),re.deltaY<0?K(C()):re.deltaY>0&&W(C()),r.update()})(B),r.dispatchEvent(wV))}function je(B){r.enabled!==!1&&r.enablePan!==!1&&(function(re){let V=!1;switch(re.code){case r.keys.UP:re.ctrlKey||re.metaKey||re.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,r.keyPanSpeed),V=!0;break;case r.keys.BOTTOM:re.ctrlKey||re.metaKey||re.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,-r.keyPanSpeed),V=!0;break;case r.keys.LEFT:re.ctrlKey||re.metaKey||re.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(r.keyPanSpeed,0),V=!0;break;case r.keys.RIGHT:re.ctrlKey||re.metaKey||re.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(-r.keyPanSpeed,0),V=!0}V&&(re.preventDefault(),r.update())})(B)}function he(B){r.enabled!==!1&&B.preventDefault()}function ht(B){let re=I[B.pointerId];re===void 0&&(re=new Zt,I[B.pointerId]=re),re.set(B.pageX,B.pageY)}function H(B){const re=B.pointerId===N[0].pointerId?N[1]:N[0];return I[re.pointerId]}r.domElement.addEventListener("contextmenu",he),r.domElement.addEventListener("pointerdown",xe),r.domElement.addEventListener("pointercancel",ie),r.domElement.addEventListener("wheel",be,{passive:!1}),this.update()}}_t.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Zt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Va.line={uniforms:xO.merge([_t.common,_t.fog,_t.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class nQ extends pd{constructor(e){super({type:"LineMaterial",uniforms:xO.clone(Va.line.uniforms),vertexShader:Va.line.vertexShader,fragmentShader:Va.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 MV=new ao,R_=new De;class rQ extends HFe{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 FP(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 FP(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 OFe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ao);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),MV.setFromBufferAttribute(n),this.boundingBox.union(MV))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ul),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)R_.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(R_)),R_.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(R_));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}const EV=new De,AV=new De,Wi=new Zn,qi=new Zn,Xo=new Zn,NN=new De,kN=new ar,Ki=new $Fe,TV=new De,D_=new ao,j_=new ul,Yo=new Zn;let Zo,uh;function CV(t,e,n){return Yo.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Yo.multiplyScalar(1/Yo.w),Yo.x=uh/n.width,Yo.y=uh/n.height,Yo.applyMatrix4(t.projectionMatrixInverse),Yo.multiplyScalar(1/Yo.w),Math.abs(Math.max(Yo.x,Yo.y))}class aUe extends jo{constructor(e=new rQ,n=new nQ({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let s=0,o=0,c=n.count;s<c;s++,o+=2)EV.fromBufferAttribute(n,s),AV.fromBufferAttribute(r,s),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+EV.distanceTo(AV);const a=new FP(i,2,1);return e.setAttribute("instanceDistanceStart",new Hu(a,1,0)),e.setAttribute("instanceDistanceEnd",new Hu(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Zo=e.ray;const s=this.matrixWorld,o=this.geometry,c=this.material;let u,d;uh=c.linewidth+a,o.boundingSphere===null&&o.computeBoundingSphere(),j_.copy(o.boundingSphere).applyMatrix4(s),r?u=.5*uh:u=CV(i,Math.max(i.near,j_.distanceToPoint(Zo.origin)),c.resolution),j_.radius+=u,Zo.intersectsSphere(j_)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),D_.copy(o.boundingBox).applyMatrix4(s),r?d=.5*uh:d=CV(i,Math.max(i.near,D_.distanceToPoint(Zo.origin)),c.resolution),D_.expandByScalar(d),Zo.intersectsBox(D_)!==!1&&(r?(function(f,g){const m=f.matrixWorld,x=f.geometry,v=x.attributes.instanceStart,y=x.attributes.instanceEnd;for(let b=0,M=Math.min(x.instanceCount,v.count);b<M;b++){Ki.start.fromBufferAttribute(v,b),Ki.end.fromBufferAttribute(y,b),Ki.applyMatrix4(m);const S=new De,A=new De;Zo.distanceSqToSegment(Ki.start,Ki.end,A,S),A.distanceTo(S)<.5*uh&&g.push({point:A,pointOnLine:S,distance:Zo.origin.distanceTo(A),object:f,face:null,faceIndex:b,uv:null,uv1:null})}})(this,n):(function(f,g,m){const x=g.projectionMatrix,v=f.material.resolution,y=f.matrixWorld,b=f.geometry,M=b.attributes.instanceStart,S=b.attributes.instanceEnd,A=Math.min(b.instanceCount,M.count),T=-g.near;Zo.at(1,Xo),Xo.w=1,Xo.applyMatrix4(g.matrixWorldInverse),Xo.applyMatrix4(x),Xo.multiplyScalar(1/Xo.w),Xo.x*=v.x/2,Xo.y*=v.y/2,Xo.z=0,NN.copy(Xo),kN.multiplyMatrices(g.matrixWorldInverse,y);for(let k=0,N=A;k<N;k++){if(Wi.fromBufferAttribute(M,k),qi.fromBufferAttribute(S,k),Wi.w=1,qi.w=1,Wi.applyMatrix4(kN),qi.applyMatrix4(kN),Wi.z>T&&qi.z>T)continue;if(Wi.z>T){const O=Wi.z-qi.z,q=(Wi.z-T)/O;Wi.lerp(qi,q)}else if(qi.z>T){const O=qi.z-Wi.z,q=(qi.z-T)/O;qi.lerp(Wi,q)}Wi.applyMatrix4(x),qi.applyMatrix4(x),Wi.multiplyScalar(1/Wi.w),qi.multiplyScalar(1/qi.w),Wi.x*=v.x/2,Wi.y*=v.y/2,qi.x*=v.x/2,qi.y*=v.y/2,Ki.start.copy(Wi),Ki.start.z=0,Ki.end.copy(qi),Ki.end.z=0;const I=Ki.closestPointToPointParameter(NN,!0);Ki.at(I,TV);const C=OZ.lerp(Wi.z,qi.z,I),D=C>=-1&&C<=1,F=NN.distanceTo(TV)<.5*uh;if(D&&F){Ki.start.fromBufferAttribute(M,k),Ki.end.fromBufferAttribute(S,k),Ki.start.applyMatrix4(y),Ki.end.applyMatrix4(y);const O=new De,q=new De;Zo.distanceSqToSegment(Ki.start,Ki.end,q,O),m.push({point:q,pointOnLine:O,distance:Zo.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class sUe extends WM{constructor(e,n,r,i,a=4473924,s=8947848){a=new $t(a),s=new $t(s);const o=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let g=-1*(e=o*n/2);g<=e;g+=n){c.push(g,0,-1*r,g,0,r);const m=g===0?a:s;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?a:s;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 ga;f.setAttribute("position",new Br(c,3)),f.setAttribute("color",new Br(u,3)),super(f,new Xb({vertexColors:!0,toneMapped:!1}))}}function oUe(t,e,n,r){const i=(function(s,o,c){s*=.5,o*=.5,c*=.5;const u=new ga,d=[];return d.push(-s,-o,-c,-s,o,-c,-s,o,-c,s,o,-c,s,o,-c,s,-o,-c,s,-o,-c,-s,-o,-c,-s,-o,c,-s,o,c,-s,o,c,s,o,c,s,o,c,s,-o,c,s,-o,c,-s,-o,c,-s,-o,-c,-s,-o,c,-s,o,-c,-s,o,c,s,o,-c,s,o,c,s,-o,-c,s,-o,c),u.setAttribute("position",new Br(d,3)),u})(t,e,n),a=new WM(i,new IFe({color:new $t(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var Zx=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,s=0,o=n(new Zx.Panel("FPS","#0ff","#002")),c=n(new Zx.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Zx.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){s++;var d=(performance||Date).now();if(c.update(d-i,200),d>=a+1e3&&(o.update(1e3*s/(d-a),100),a=d,s=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};Zx.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,c=48*s,u=3*s,d=2*s,f=3*s,g=15*s,m=74*s,x=30*s,v=document.createElement("canvas");v.width=o,v.height=c,v.style.cssText="width:80px;height:48px";var y=v.getContext("2d");return y.font="bold "+9*s+"px Helvetica,Arial,sans-serif",y.textBaseline="top",y.fillStyle=n,y.fillRect(0,0,o,c),y.fillStyle=e,y.fillText(t,u,d),y.fillRect(f,g,m,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f,g,m,x),{dom:v,update:function(b,M){r=Math.min(r,b),i=Math.max(i,b),y.fillStyle=n,y.globalAlpha=1,y.fillRect(0,0,o,g),y.fillStyle=e,y.fillText(a(b)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),y.drawImage(v,f+s,g,m-s,x,f,g,m-s,x),y.fillRect(f+m-s,g,s,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f+m-s,g,s,a((1-b/M)*x))}}};var lUe=Zx;class NV{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new Uw,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 Uw,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 cUe extends ga{constructor(e=[new De],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const a=new De,s=new De,o=new Zt,c=[],u=[],d=[],f=[];function g(m){const[x,v,y]=(function(b){const M=e[b],S=new De,A=new De,T=new De,k=new De;S.copy(M).sub(e[b-1]||M).normalize().add((e[b+1]||M).clone().sub(M).normalize()).normalize();let N=Number.MAX_VALUE;const I=Math.abs(S.x),C=Math.abs(S.y),D=Math.abs(S.z);return I<=N&&(N=I,A.set(1,0,0)),C<=N&&(N=C,A.set(0,1,0)),D<=N&&A.set(0,0,1),k.crossVectors(S,A).normalize(),A.crossVectors(S,k),T.crossVectors(S,A),[M,A,T]})(m);for(let b=0;b<=i;b++){const M=b/i*Math.PI*2,S=Math.sin(M),A=-Math.cos(M);s.x=A*v.x+S*y.x,s.y=A*v.y+S*y.y,s.z=A*v.z+S*y.z,s.normalize(),u.push(s.x,s.y,s.z),a.x=x.x+n*s.x*.5,a.y=x.y+n*s.y*.5,a.z=x.z+r*s.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let 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 v=(i+1)*(m-1)+(x-1),y=(i+1)*m+(x-1),b=(i+1)*m+x,M=(i+1)*(m-1)+x;f.push(v,y,M),f.push(y,b,M)}})()})(),this.setIndex(f),this.setAttribute("position",new Br(c,3)),this.setAttribute("normal",new Br(u,3)),this.setAttribute("uv",new Br(d,2))}}class Qx{static get initial(){const e=new Qx;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const PN={h:0,s:0,l:0};class lm{constructor(e){var n,r,i,a,s,o,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=Qx.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=lm.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new $t(14737632),this._travelColor=new $t(10027008),this._toolColors={},this.devMode=!1,this._lastRenderTime=0,this._wireframe=!1,this.minLayerThreshold=(n=e.minLayerThreshold)!==null&&n!==void 0?n:this.minLayerThreshold,this.parser=new zw(this.minLayerThreshold),this.scene=new EFe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new $t(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(a=e.renderExtrusion)!==null&&a!==void 0?a:this.renderExtrusion,this.renderTravel=(s=e.renderTravel)!==null&&s!==void 0?s:this.renderTravel,this.nonTravelmoves=(o=e.nonTravelMoves)!==null&&o!==void 0?o:this.nonTravelmoves,this.renderTubes=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new lUe: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"+BM),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 IP({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 IP({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new ms(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 vO(this._backgroundColor,g,f),this.resize(),this.controls=new iUe(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 VFe(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 BFe(13421772,.3*Math.PI),n=new zFe(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 qb(-Math.PI/2,0,0)),this.buildVolume?n.position.set(-this.buildVolume.x/2,0,this.buildVolume.y/2):n.position.set(-100,0,100),n}render(){const e=performance.now();this.group=this.createGroup("allLayers"),this.state=Qx.initial,this.initScene();for(let n=0;n<this.layers.length;n++)this.renderLayer(n);this.batchGeometries(),this.scene.add(this.group),this.renderer.render(this.scene,this.camera),this._lastRenderTime=performance.now()-e}renderAnimated(e=1){return TN(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,a,s,o,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const g of d.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const 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:(a=m.params.r)!==null&&a!==void 0?a:this.state.r,e:(s=m.params.e)!==null&&s!==void 0?s: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 v=((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)&&(v&&this.renderExtrusion||!v&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(f,this.state,x,v,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,x,v))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const s=.1+.7*n/this.layers.length;a.getHSL(PN),a=new $t().setHSL(PN.h,PN.s,s)}if(n==this.layers.length-1){const s=(r=this._topLayerColor)!==null&&r!==void 0?r:a,o=(i=this._lastSegmentColor)!==null&&i!==void 0?i:s,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,s.getHex(),e.height),this.addTubeLine([...u,...c],o.getHex(),e.height)):(this.addLine(e.extrusion,s.getHex()),this.addLine([...u,...c],o.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new sUe(this.buildVolume.x,10,this.buildVolume.y,10));const e=oUe(this.buildVolume.x,this.buildVolume.z,this.buildVolume.y,8947848);e.position.setY(this.buildVolume.z/2),this.scene.add(e)}clear(){this.resetState(),this.parser=new zw(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Qx.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,a){const s=i?e.extrusion:e.travel,o=n.x,c=n.y,u=n.z,d=r.x,f=r.y,g=r.z;let m=r.r,x=r.i,v=r.j;if(m){const W=d-o,K=f-c,G=Math.sqrt(Math.pow(W/2,2)+Math.pow(K/2,2));m=Math.max(m,G);const ee=Math.pow(W,2)+Math.pow(K,2),Z=Math.pow(m,2)-ee/4;let Q=Math.sqrt(Z/ee);(a&&m<0||!a&&m>0)&&(Q=-Q),x=W/2+K*Q,v=K/2-W*Q}const y=o==d&&c==f,b=o+x,M=c+v,S=Math.sqrt(x*x+v*v),A=Math.atan2(-v,-x),T=Math.atan2(f-M,d-b);let k;y?k=2*Math.PI:(k=a?A-T:T-A,k<0&&(k+=2*Math.PI));let N=S*k/1.8;this.inches&&(N*=25),N<1&&(N=1);let I=k/N;I*=a?-1:1;const C=[];C.push({x:o,y:c,z:u});const D=(u-g)/N;let F=o,O=c,q=u,R=A;for(let W=0;W<N-1;W++)R+=I,F=b+S*Math.cos(R),O=M+S*Math.sin(R),q+=D,C.push({x:F,y:O,z:q});C.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<C.length-1;W++)s.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 ga;i.setAttribute("position",new Br(e,3)),this.disposables.push(i);const a=new Xb({color:n});this.disposables.push(a);const s=new WM(i,a);(r=this.group)===null||r===void 0||r.add(s)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let s=0;s<e.length;s+=6){const o=e.slice(s,s+9),c=new De(o[0],o[1],o[2]),u=new De(o[3],o[4],o[5]),d=new De(o[6],o[7],o[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((s=>{var o;const c=new cUe(s,this.extrusionWidth,this.lineHeight||r,4);(o=this._geometries)[n]||(o[n]=[]),this._geometries[n].push(c)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new rQ;this.disposables.push(i);const a=new nQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const s=new aUe(i,a);(r=this.group)===null||r===void 0||r.add(s)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>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 LFe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((o,c)=>3*c.attributes.position.count+o),0),s=new DFe(r.length,a,void 0,i);return this.disposables.push(s),(n=this.group)===null||n===void 0||n.add(s),s}_readFromStream(e){var n,r;return TN(this,void 0,void 0,(function*(){const i=e.getReader();let a,s="",o=0;do{console.debug("reading from stream"),a=yield i.read(),o+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(s+f),s=u.slice(d)}while(!a.done);var c;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new NV(this):typeof this.devMode=="object"&&(this.devGui=new NV(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 uUe=function(t){return new lm(t)};function dUe({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),[a,s]=E.useState(!0),[o,c]=E.useState(null),[u,d]=E.useState(!1),[f,g]=E.useState(0),[m,x]=E.useState(0);E.useEffect(()=>{if(!r.current)return;const b=r.current,M=uUe({canvas:b,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:44610,topLayerColor:65370,lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});i.current=M,s(!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=>{M.processGCode(A);const T=M.layers?.length||0;x(T),g(T),M.render(),s(!1)}).catch(A=>{c(A.message),s(!1)});const S=()=>{if(b.parentElement){const A=b.parentElement.getBoundingClientRect();b.width=A.width,b.height=A.height,M.resize()}};return S(),window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S),M.dispose()}},[t,e]);const v=b=>{if(!i.current)return;const M=Math.max(1,Math.min(b,m));g(M),i.current.render()},y=b=>{v(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"}),a&&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(ale,{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})})})]}),!a&&!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:()=>v(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:y,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),l.jsx("button",{onClick:()=>v(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 hUe({archiveId:t,title:e,onClose:n}){const[r,i]=E.useState(null),[a,s]=E.useState(null),[o,c]=E.useState(!0);E.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),E.useEffect(()=>{ke.getArchiveCapabilities(t).then(d=>{s(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{s({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256}}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${ke.getArchiveForSlicer(t,d)}`;window.location.href=`bambustudioopen://${encodeURIComponent(f)}`};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:u,children:[l.jsx(As,{className:"w-4 h-4"}),"Open in Slicer"]}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),a&&l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[l.jsxs("button",{onClick:()=>a.has_model&&i("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":a.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[l.jsx(fm,{className:"w-4 h-4"}),"3D Model",!a.has_model&&l.jsx("span",{className:"text-xs",children:"(not available)"})]}),l.jsxs("button",{onClick:()=>a.has_gcode&&i("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":a.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[l.jsx(Doe,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&l.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),l.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?l.jsx("div",{className:"w-full h-full flex items-center justify-center",children:l.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?l.jsx(oje,{url:ke.getArchiveDownload(t),buildVolume:a.build_volume,className:"w-full h-full"}):r==="gcode"&&a?l.jsx(dUe,{gcodeUrl:ke.getArchiveGcode(t),buildVolume:a.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 fUe({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const[i,a]=E.useState(null);E.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]);const{data:s,isLoading:o}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),c=wt({mutationFn:()=>{if(!i)throw new Error("No printer selected");return ke.reprintArchive(t,i)},onSuccess:()=>{r(),n()}}),u=s?.filter(d=>d.is_active)||[];return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:l.jsx(Nt,{className:"w-full max-w-md",children:l.jsxs(Rt,{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",l.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u.length===0?l.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):l.jsx("div",{className:"space-y-2 mb-6",children:u.map(d=>l.jsxs("button",{onClick:()=>a(d.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${i===d.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[l.jsx("div",{className:`p-2 rounded-lg ${i===d.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:l.jsx(Ts,{className:`w-5 h-5 ${i===d.id?"text-bambu-green":"text-bambu-gray"}`})}),l.jsxs("div",{className:"text-left",children:[l.jsx("p",{className:"text-white font-medium",children:d.name}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.model||"Unknown model"," • ",d.ip_address]})]})]},d.id))}),c.isError&&l.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:c.error.message||"Failed to start print"}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Le,{onClick:()=>c.mutate(),disabled:!i||c.isPending,className:"flex-1",children:c.isPending?l.jsxs(l.Fragment,{children:[l.jsx(At,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Ts,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function pUe({onClose:t,initialFiles:e}){const n=En(),{showToast:r}=ai(),i=E.useRef(null),[a,s]=E.useState(()=>e?.filter(N=>N.name.endsWith(".3mf")).map(N=>({file:N,status:"pending"}))||[]),[o,c]=E.useState(!1),[u,d]=E.useState(),[f,g]=E.useState(null);E.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=wt({mutationFn:N=>ke.uploadArchivesBulk(N,u),onSuccess:N=>{g(N),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),s(I=>I.map(C=>{const D=N.results.find(O=>O.filename===C.file.name),F=N.errors.find(O=>O.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:()=>{s(N=>N.map(I=>({...I,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),v=E.useCallback(N=>{N.preventDefault(),c(!0)},[]),y=E.useCallback(N=>{N.preventDefault(),c(!1)},[]),b=E.useCallback(N=>{N.preventDefault(),c(!1);const I=Array.from(N.dataTransfer.files).filter(C=>C.name.endsWith(".3mf"));I.length>0&&s(C=>[...C,...I.map(D=>({file:D,status:"pending"}))])},[]),M=E.useCallback(N=>{const I=Array.from(N.target.files||[]).filter(C=>C.name.endsWith(".3mf"));I.length>0&&s(C=>[...C,...I.map(D=>({file:D,status:"pending"}))]),i.current&&(i.current.value="")},[]),S=E.useCallback(N=>{s(I=>I.filter((C,D)=>D!==N))},[]),A=()=>{if(a.length===0)return;const N=a.filter(I=>I.status==="pending");N.length!==0&&(s(I=>I.map(C=>C.status==="pending"?{...C,status:"uploading"}:C)),x.mutate(N.map(I=>I.file)))},T=a.filter(N=>N.status==="pending").length,k=x.isPending;return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:l.jsxs(Rt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"p-4",children:l.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:v,onDragLeave:y,onDrop:b,children:[l.jsx(vs,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),l.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),l.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),l.jsx(Le,{variant:"secondary",onClick:()=>i.current?.click(),disabled:k,children:"Browse Files"}),l.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:M})]})}),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))]})]}),a.length>0&&l.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:l.jsx("div",{className:"space-y-2",children:a.map((N,I)=>l.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[l.jsx(oG,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),l.jsx("span",{className:"flex-1 text-white text-sm truncate",children:N.file.name}),l.jsxs("span",{className:"text-xs text-bambu-gray",children:[(N.file.size/(1024*1024)).toFixed(1)," MB"]}),N.status==="pending"&&l.jsx("button",{onClick:()=>S(I),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:l.jsx(Wt,{className:"w-4 h-4"})}),N.status==="uploading"&&l.jsx(At,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&l.jsx(fi,{className:"w-4 h-4 text-bambu-green"}),N.status==="error"&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs text-red-400",children:N.error}),l.jsx(lo,{className:"w-4 h-4 text-red-400"})]})]},`${N.file.name}-${I}`))})}),f&&l.jsx("div",{className:"px-4 pb-4",children:l.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:l.jsxs("p",{className:"text-sm text-white",children:[l.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&l.jsxs(l.Fragment,{children:[", ",l.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),l.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Le,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&l.jsx(Le,{onClick:A,disabled:T===0||k,className:"flex-1",children:k?l.jsxs(l.Fragment,{children:[l.jsx(At,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):l.jsxs(l.Fragment,{children:[l.jsx(vs,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const mUe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],gUe=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function xUe({archive:t,onClose:e,existingTags:n=[]}){E.useEffect(()=>{const X=te=>{te.key==="Escape"&&e()};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[e]);const r=En(),[i,a]=E.useState(t.print_name||""),[s,o]=E.useState(t.printer_id),[c,u]=E.useState(t.project_id??null),[d,f]=E.useState(t.notes||""),[g,m]=E.useState(t.tags||""),[x,v]=E.useState(t.failure_reason||""),[y,b]=E.useState(t.status),[M,S]=E.useState(t.photos||[]),[A,T]=E.useState(!1),[k,N]=E.useState(!1),I=E.useRef(null),C=E.useRef(null),D=E.useRef(null),{data:F}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:O}=vt({queryKey:["projects"],queryFn:()=>ke.getProjects()}),{data:q}=vt({queryKey:["archives"],queryFn:()=>ke.getArchives(void 0,1e3,0),enabled:n.length===0}),R=n.length>0?n:[...new Set(q?.flatMap(X=>X.tags?.split(",").map(te=>te.trim())||[]).filter(Boolean)||[])].sort(),W=g.split(",").map(X=>X.trim()).filter(Boolean),K=R.filter(X=>!W.includes(X)),G=X=>{if(!W.includes(X)){const te=[...W,X].join(", ");m(te)}D.current!==null&&clearTimeout(D.current),I.current?.focus()},ee=X=>{const te=W.filter(fe=>fe!==X).join(", ");m(te)},Z=wt({mutationFn:X=>ke.updateArchive(t.id,X),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),Q=async X=>{const te=X.target.files?.[0];if(te){T(!0);try{const fe=await ke.uploadArchivePhoto(t.id,te);S(fe.photos),r.invalidateQueries({queryKey:["archives"]})}catch(fe){console.error("Failed to upload photo:",fe)}finally{T(!1),C.current&&(C.current.value="")}}},U=async X=>{try{const te=await ke.deleteArchivePhoto(t.id,X);S(te.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(te){console.error("Failed to delete photo:",te)}},$=X=>{X.preventDefault();const te={print_name:i||void 0,printer_id:s,project_id:c,notes:d||void 0,tags:g||void 0};y!==t.status&&(te.status=y),y==="failed"||y==="aborted"?te.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(te.failure_reason=null),Z.mutate(te)};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:X=>X.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:$,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:X=>a(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),l.jsxs("select",{value:s??"",onChange:X=>o(X.target.value?Number(X.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"}),F?.map(X=>l.jsx("option",{value:X.id,children:X.name},X.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:X=>u(X.target.value?Number(X.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"No project"}),O?.map(X=>l.jsx("option",{value:X.id,children:X.name},X.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:X=>f(X.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:"Add notes about this print..."})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),W.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:W.map(X=>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"}),X,l.jsx("button",{type:"button",onClick:()=>ee(X),className:"ml-0.5 text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-3 h-3"})})]},X))}),l.jsxs("div",{className:"relative",children:[l.jsx("input",{ref:I,type:"text",value:g,onChange:X=>m(X.target.value),onFocus:()=>{D.current!==null&&clearTimeout(D.current),N(!0)},onBlur:()=>{D.current=window.setTimeout(()=>N(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:W.length>0?"Add more tags...":"Add tags..."}),k&&K.length>0&&l.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[l.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),l.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:K.map(X=>l.jsx("button",{type:"button",onClick:()=>G(X),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:X},X))})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),l.jsx("select",{value:y,onChange:X=>{b(X.target.value),X.target.value==="completed"&&v("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:gUe.map(X=>l.jsx("option",{value:X.value,children:X.label},X.value))})]}),(y==="failed"||y==="aborted")&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),l.jsxs("select",{value:x,onChange:X=>v(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"Select reason..."}),mUe.map(X=>l.jsx("option",{value:X,children:X},X))]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(b0,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),l.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[M.map(X=>l.jsxs("div",{className:"relative group",children:[l.jsx("img",{src:ke.getArchivePhotoUrl(t.id,X),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),l.jsx("button",{type:"button",onClick:()=>U(X),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx(Rn,{className:"w-3 h-3 text-white"})})]},X)),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:C,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:Q,className:"hidden",disabled:A}),A?l.jsx(At,{className:"w-6 h-6 text-bambu-gray animate-spin"}):l.jsx(pr,{className:"w-6 h-6 text-bambu-gray"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:Z.isPending,className:"flex-1",children:[l.jsx(Ro,{className:"w-4 h-4"}),Z.isPending?"Saving...":"Save"]})]})]})]})})}function bUe({x:t,y:e,items:n,onClose:r}){const i=E.useRef(null),[a,s]=E.useState(null),o=E.useRef(null),[c,u]=E.useState({x:t,y:e,visible:!1}),[d,f]=E.useState(!1);E.useEffect(()=>{const x=b=>{i.current&&!i.current.contains(b.target)&&r()},v=b=>{b.key==="Escape"&&r()},y=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),document.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v),document.removeEventListener("scroll",y,!0),o.current&&clearTimeout(o.current)}},[r]),E.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const x=i.current.getBoundingClientRect(),v=window.innerWidth,y=window.innerHeight,b=8;let M=t,S=e;t+x.width>v-b&&(M=Math.max(b,v-x.width-b)),M<b&&(M=b),e+x.height>y-b&&(S=Math.max(b,y-x.height-b)),S<b&&(S=b);const A=180,T=v-M-x.width,k=M;f(T<A&&k>A),u({x:M,y:S,visible:!0})}},[t,e]);const g=x=>{o.current&&(clearTimeout(o.current),o.current=null),s(x)},m=()=>{o.current=window.setTimeout(()=>{s(null)},150)};return l.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((x,v)=>{if(x.divider)return l.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const y=x.submenu&&x.submenu.length>0;return l.jsxs("div",{className:"relative",onMouseEnter:()=>y&&g(v),onMouseLeave:()=>y&&m(),children:[l.jsxs("button",{onMouseEnter:()=>y&&g(v),onClick:()=>{y?s(a===v?null:v):x.disabled||(x.onClick(),r())},disabled:x.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${x.disabled?"text-bambu-gray cursor-not-allowed":x.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${y&&a===v?"bg-bambu-dark-tertiary":""}`,children:[x.icon&&l.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:x.icon}),l.jsx("span",{className:"flex-1",children:x.label}),y&&l.jsx(df,{className:"w-4 h-4 text-bambu-gray"})]}),y&&a===v&&l.jsx("div",{className:`absolute top-0 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"}`,onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null)},onMouseLeave:()=>m(),children:x.submenu.map((b,M)=>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]},M))})]},v)})})}function yUe({selectedIds:t,existingTags:e,onClose:n}){const r=En(),{showToast:i}=ai(),[a,s]=E.useState(""),[o,c]=E.useState(new Set),[u,d]=E.useState("add");E.useEffect(()=>{const v=y=>{y.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const f=wt({mutationFn:async()=>{const v=Array.from(o);let y=0;for(const b of t)try{const M=await ke.getArchive(b),S=M.tags?M.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...S,...v])]:A=S.filter(T=>!o.has(T)),await ke.updateArchive(b,{tags:A.join(", ")}),y++}catch(M){throw console.error(`Failed to update archive ${b}:`,M),new Error(`Failed on archive ${b}: ${M instanceof Error?M.message:"Unknown error"}`)}return{count:y,mode:u,tags:v}},onSuccess:({count:v,mode:y,tags:b})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${y==="add"?"Added":"Removed"} ${b.length} tag${b.length!==1?"s":""} ${y==="add"?"to":"from"} ${v} archive${v!==1?"s":""}`),n()},onError:v=>{i(v.message||"Failed to update tags","error")}}),g=v=>{c(y=>{const b=new Set(y);return b.has(v)?b.delete(v):b.add(v),b})},m=()=>{a.trim()&&!o.has(a.trim())&&(c(v=>new Set([...v,a.trim()])),s(""))},x=v=>{v.key==="Enter"&&(v.preventDefault(),m())};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-md",children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(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(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-4 space-y-4",children:[l.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),l.jsx(Le,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:v=>s(v.target.value),onKeyDown:x}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:m,disabled:!a.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(v=>l.jsx("button",{onClick:()=>g(v),className:`px-2 py-1 rounded text-sm transition-colors ${o.has(v)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:v},v))})]}),o.size>0&&l.jsxs("div",{children:[l.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),l.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(v=>l.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[v,l.jsx("button",{onClick:()=>g(v),className:"hover:opacity-70",children:l.jsx(Wt,{className:"w-3 h-3"})})]},v))})]})]}),l.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Le,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Le,{onClick:()=>f.mutate(),disabled:o.size===0||f.isPending,className:"flex-1",children:f.isPending?l.jsxs(l.Fragment,{children:[l.jsx(At,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):l.jsxs(l.Fragment,{children:[l.jsx(E0,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function vUe(t,e){return new Date(t,e+1,0).getDate()}function _Ue(t,e){return new Date(t,e,1).getDay()}const wUe=["January","February","March","April","May","June","July","August","September","October","November","December"],SUe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function MUe({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=E.useState(n.getMonth()),[a,s]=E.useState(n.getFullYear()),[o,c]=E.useState(null),u=E.useMemo(()=>{const b=new Map;return t.forEach(M=>{const S=new Date(M.completed_at||M.created_at),A=`${S.getFullYear()}-${String(S.getMonth()+1).padStart(2,"0")}-${String(S.getDate()).padStart(2,"0")}`,T=b.get(A)||[];T.push(M),b.set(A,T)}),b},[t]),d=vUe(a,r),f=_Ue(a,r),g=()=>{r===0?(i(11),s(a-1)):i(r-1)},m=()=>{r===11?(i(0),s(a+1)):i(r+1)},x=()=>{i(n.getMonth()),s(n.getFullYear())},v=[];for(let b=0;b<f;b++)v.push(null);for(let b=1;b<=d;b++)v.push(b);const y=o?u.get(o)||[]:[];return l.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(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:[wUe[r]," ",a]}),l.jsx("button",{onClick:x,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),l.jsx("button",{onClick: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:SUe.map(b=>l.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:b},b))}),l.jsx("div",{className:"grid grid-cols-7 gap-1",children:v.map((b,M)=>{if(b===null)return l.jsx("div",{className:"aspect-square"},`empty-${M}`);const S=`${a}-${String(r+1).padStart(2,"0")}-${String(b).padStart(2,"0")}`,A=u.get(S)||[],T=A.length>0,k=b===n.getDate()&&r===n.getMonth()&&a===n.getFullYear(),N=S===o,I=A.filter(D=>D.status==="completed").length,C=A.filter(D=>D.status==="failed").length;return l.jsxs("button",{onClick:()=>c(N?null:S),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${N?"bg-bambu-green text-white":k?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":T?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[l.jsx("span",{className:`text-sm font-medium ${k&&!N?"text-bambu-green":""}`,children:b}),T&&l.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[l.jsx("div",{className:`w-2 h-2 rounded-full ${C>0&&I===0?"bg-red-400":C>0?"bg-yellow-400":"bg-green-400"}`}),l.jsx("span",{className:"text-xs font-medium",children:A.length})]})]},b)})}),l.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(b=>{const M=new Date(b.completed_at||b.created_at);return M.getMonth()===r&&M.getFullYear()===a}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(b=>{const M=new Date(b.completed_at||b.created_at);return M.getMonth()===r&&M.getFullYear()===a&&b.status==="completed"}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(b=>{const M=new Date(b.completed_at||b.created_at);return M.getMonth()===r&&M.getFullYear()===a&&b.status==="failed"}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),l.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?l.jsxs(l.Fragment,{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(o+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),y.length>0?l.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:y.map(b=>l.jsxs("button",{onClick:()=>e?.(b),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[b.thumbnail_path?l.jsx("img",{src: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((M,S)=>l.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:M}},S))})]})]})]},b.id))}):l.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):l.jsx("div",{className:"text-center py-8",children:l.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function EUe({archiveId:t,archiveName:e,onClose:n}){const r=ke.getArchiveQRCodeUrl(t,300);E.useEffect(()=>{const a=s=>{s.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-6 flex flex-col items-center",children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),l.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:l.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),l.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),l.jsxs(Le,{onClick:i,className:"w-full",children:[l.jsx(Es,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function AUe({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,s]=E.useState(0),[o,c]=E.useState(!1);if(E.useEffect(()=>{const m=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&s(v=>Math.max(0,v-1)),x.key==="ArrowRight"&&s(v=>Math.min(n.length-1,v+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),E.useEffect(()=>{a>=n.length&&s(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=ke.getArchivePhotoUrl(t,u),f=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${a+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 ",a+1," of ",n.length]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:f,children:[l.jsx(Es,{className:"w-4 h-4"}),"Download"]}),i&&l.jsx(Le,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})}),l.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-6 h-6"})})]})]}),l.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&l.jsx("button",{onClick:()=>s(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 ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&l.jsx("button",{onClick:()=>s(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:()=>s(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:l.jsx("img",{src:ke.getArchivePhotoUrl(t,m),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},m))})]}),o&&l.jsx(Qr,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function Yi(t){this.content=t}Yi.prototype={constructor:Yi,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new Yi(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Yi(n)},addToStart:function(t,e){return new Yi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Yi(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new Yi(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Yi.from(t),t.size?new Yi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Yi.from(t),t.size?new Yi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Yi.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Yi.from=function(t){if(t instanceof Yi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Yi(e)};function iQ(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let s=0;i.text[s]==a.text[s];s++)n++;return n}if(i.content.size||a.content.size){let s=iQ(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function aQ(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let s=t.child(--i),o=e.child(--a),c=s.nodeSize;if(s==o){n-=c,r-=c;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let u=0,d=Math.min(s.text.length,o.text.length);for(;u<d&&s.text[s.text.length-u-1]==o.text[o.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let u=aQ(s.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,a){for(let s=0,o=0;o<n;s++){let c=this.content[s],u=o+c.nodeSize;if(u>e&&r(c,i+o,a||null,s)!==!1&&c.content.size){let d=o+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(o,c)=>{let u=o.isText?o.text.slice(Math.max(e,c)-c,n-c):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!1:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new 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 a=0,s=0;s<n;a++){let o=this.content[a],c=s+o.nodeSize;c>e&&((s<e||c>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=c}return new 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(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new pt(i,a)}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 iQ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return aQ(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),a=r+i.nodeSize;if(a>=e)return a==e?O_(n+1,a):O_(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return 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 a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new 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 zP{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&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 zP.none;if(e instanceof zP)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};tr.none=[];class Hw extends Error{}class kt{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=oQ(this.content,e+this.openStart,n);return r&&new kt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new kt(sQ(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return kt.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new kt(pt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new kt(e,r,i)}}kt.empty=new kt(pt.empty,0,0);function sQ(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(i==e||a.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(sQ(a.content,e-i-1,n-i-1)))}function oQ(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),s=t.maybeChild(i);if(a==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=oQ(s.content,e-a-1,n,s);return o&&t.replaceChild(i,s.copy(o))}function TUe(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 lQ(t,e,n,0)}function lQ(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=lQ(t,e,n,r+1);return a.copy(a.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return Dh(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=CUe(n,t);return Dh(a,uQ(t,s,o,e,r))}else return Dh(a,$w(t,e,r))}function cQ(t,e){if(!e.type.compatibleContent(t.type))throw new Hw("Cannot join "+e.type.name+" onto "+t.type.name)}function BP(t,e,n){let r=t.node(n);return cQ(r,e.node(n)),r}function Rh(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Jx(t,e,n,r){let i=(e||t).node(n),a=0,s=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(Rh(t.nodeAfter,r),a++));for(let o=a;o<s;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 uQ(t,e,n,r,i){let a=t.depth>i&&BP(t,e,i+1),s=r.depth>i&&BP(n,r,i+1),o=[];return Jx(null,t,i,o),a&&s&&e.index(i)==n.index(i)?(cQ(a,s),Rh(Dh(a,uQ(t,e,n,r,i+1)),o)):(a&&Rh(Dh(a,$w(t,e,i+1)),o),Jx(e,n,i,o),s&&Rh(Dh(s,$w(n,r,i+1)),o)),Jx(r,null,i,o),new pt(o)}function $w(t,e,n){let r=[];if(Jx(null,t,n,r),t.depth>n){let i=BP(t,e,n+1);Rh(Dh(i,$w(t,e,n+1)),r)}return Jx(e,null,n,r),new pt(r)}function CUe(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(pt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class J0{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return 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 a=r.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!i||!a[s].isInSet(i.marks))&&(a=a[s--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new 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,a=n;for(let s=e;;){let{index:o,offset:c}=s.content.findIndex(a),u=a-c;if(r.push(s,o,i+c),!u||(s=s.child(o),s.isText))break;a=u-1,i+=c+1}return new J0(n,r,a)}static resolveCached(e,n){let r=kV.get(e);if(r)for(let a=0;a<r.elts.length;a++){let s=r.elts[a];if(s.pos==n)return s}else kV.set(e,r=new NUe);let i=r.elts[r.i]=J0.resolve(e,n);return r.i=(r.i+1)%kUe,i}}class NUe{constructor(){this.elts=[],this.i=0}}const kUe=12,kV=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 PUe=Object.create(null);let Ju=class HP{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||PUe)&&tr.sameSet(this.marks,r||tr.none)}copy(e=null){return e==this.content?this:new HP(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new HP(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return kt.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),o=i.start(s),u=i.node(s).content.cut(i.pos-o,a.pos-o);return new kt(u,i.depth-s,a.depth-s)}replace(e,n,r){return TUe(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return J0.resolveCached(this,e)}resolveNoCache(e){return J0.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),dQ(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,a=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,a),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let c=i;c<a;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),s=a&&a.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=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),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};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):dQ(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 dQ(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class af{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new RUe(e,n);if(r.next==null)return af.empty;let i=hQ(r);r.next&&r.err("Unexpected trailing text");let a=UUe(FUe(i));return zUe(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(s,o){let c=s.matchFragment(e,r);if(c&&(!n||c.validEnd))return pt.from(o.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:d,next:f}=s.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let g=a(f,o.concat(d));if(g)return g}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let s=[];for(let o=i;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:o,next:c}=a.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||c.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
- `)}}af.empty=new af(!0);class RUe{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 hQ(t){let e=[];do e.push(DUe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function DUe(t){let e=[];do e.push(jUe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function jUe(t){let e=IUe(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=OUe(t,e);else break;return e}function PV(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function OUe(t,e){let n=PV(t),r=n;return t.eat(",")&&(t.next!="}"?r=PV(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function LUe(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let s=n[a];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function IUe(t){if(t.eat("(")){let e=hQ(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=LUe(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 FUe(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(s,o,c){let u={term:c,to:o};return e[s].push(u),u}function i(s,o){s.forEach(c=>c.to=o)}function a(s,o){if(s.type=="choice")return s.exprs.reduce((c,u)=>c.concat(a(u,o)),[]);if(s.type=="seq")for(let c=0;;c++){let u=a(s.exprs[c],o);if(c==s.exprs.length-1)return u;i(u,o=n())}else if(s.type=="star"){let c=n();return r(o,c),i(a(s.expr,c),c),[r(c)]}else if(s.type=="plus"){let c=n();return i(a(s.expr,o),c),i(a(s.expr,c),c),[r(c)]}else{if(s.type=="opt")return[r(o)].concat(a(s.expr,o));if(s.type=="range"){let c=o;for(let u=0;u<s.min;u++){let d=n();i(a(s.expr,c),d),c=d}if(s.max==-1)i(a(s.expr,c),c);else for(let u=s.min;u<s.max;u++){let d=n();r(c,d),i(a(s.expr,c),d),c=d}return[r(c)]}else{if(s.type=="name")return[r(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function fQ(t,e){return e-t}function RV(t,e){let n=[];return r(e),n.sort(fQ);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let s=0;s<a.length;s++){let{term:o,to:c}=a[s];!o&&n.indexOf(c)==-1&&r(c)}}}function UUe(t){let e=Object.create(null);return n(RV(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:o,to:c})=>{if(!o)return;let u;for(let d=0;d<i.length;d++)i[d][0]==o&&(u=i[d][1]);RV(t,c).forEach(d=>{u||i.push([o,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new af(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let o=i[s][1].sort(fQ);a.next.push({type:i[s][0],next:e[o.join(",")]||n(o)})}return a}}function zUe(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,s=[];for(let o=0;o<i.next.length;o++){let{type:c,next:u}=i.next[o];s.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function pQ(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 mQ(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let a=t[r];if(a.hasDefault)i=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function gQ(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let a=t[i];a.validate&&a.validate(e[i])}}function xQ(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new HUe(t,r,e[r]);return n}let DV=class bQ{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=xQ(e,r.attrs),this.defaultAttrs=pQ(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==af.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:mQ(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 s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(pt.empty,!0);return a?new Ju(this,e,n.append(a),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){gQ(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((a,s)=>r[a]=new bQ(a,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function BUe(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class HUe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?BUe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class qM{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=xQ(e,i.attrs),this.excluded=null;let a=pQ(this.attrs);this.instance=a?new tr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new tr(this,mQ(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,s)=>r[a]=new qM(a,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){gQ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class yQ{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Yi.from(e.nodes),n.marks=Yi.from(e.marks||{}),this.nodes=DV.compile(this.spec.nodes,this),this.marks=qM.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],s=a.spec.content||"",o=a.spec.marks;if(a.contentMatch=r[s]||(r[s]=af.parse(s,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=o=="_"?null:o?jV(this,o.split(" ")):o==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],s=a.spec.excludes;a.excluded=s==null?[a]:s==""?[]:jV(this,s.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 DV){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 jV(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],s=a;if(a)n.push(a);else for(let o in t.marks){let c=t.marks[o];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function $Ue(t){return t.tag!=null}function VUe(t){return t.style!=null}let e0=class $P{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if($Ue(i))this.tags.push(i);else if(VUe(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new LV(this,n,!1);return r.addAll(e,tr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new LV(this,n,!0);return r.addAll(e,tr.none,n.from,n.to),kt.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(qUe(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let s=a.getAttrs(e);if(s===!1)continue;a.attrs=s||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let s=this.styles[a],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let c=s.getAttrs(n);if(c===!1)continue;s.attrs=c||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<a)break}n.splice(s,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(s=>{r(s=IV(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(s=>{r(s=IV(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $P(e,$P.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},GUe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},_Q={ol:!0,ul:!0},eb=1,VP=2,t0=4;function OV(t,e,n){return e!=null?(e?eb:0)|(e==="full"?VP:0):t&&t.whitespace=="pre"?eb|VP:n&~t0}class L_{constructor(e,n,r,i,a,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=tr.none,this.match=a||(s&t0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(pt.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&eb)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=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 LV{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,s=OV(null,n.preserveWhitespace,0)|(r?t0:0);i?a=new L_(i.type,i.attrs,tr.none,!0,n.topMatch||i.type.contentMatch,s):r?a=new L_(null,null,tr.none,!0,null,s):a=new L_(e.schema.topNodeType,null,tr.none,!0,null,s),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&VP?"full":this.localPreserveWS||(i.options&eb)>0,{schema:s}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
- `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let c=0;c<o.length;c++)c&&this.insertNode(s.linebreakReplacement.create(),n,!0),o[c]&&this.insertNode(s.text(o[c]),n,!/\S/.test(o[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],c=e.previousSibling;(!o||c&&c.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;_Q.hasOwnProperty(s)&&this.parser.normalizeLists&&WUe(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(c?c.ignore:GUe.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(vQ.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?o:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],s=r.getPropertyValue(a);if(s)for(let o=void 0;;){let c=this.parser.matchStyle(a,s,this,o);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)o=c;else break}}return n}addElementByRule(e,n,r,i){let a,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(s,n.attrs||null,r,n.preserveWhitespace);c&&(a=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}a&&this.sync(o)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let s=r?e.childNodes[r]:e.firstChild,o=i==null?null:e.childNodes[i];s!=o;s=s.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(s,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let s=this.open,o=0;s>=0;s--){let c=this.nodes[s],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+o)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;o+=2}}if(!i)return null;this.sync(a);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let s=tr.none;for(let o of i.concat(e.marks))(a.type?a.type.allowsMarkType(o.type):FV(o.type,e.type))&&(s=o.addToSet(s));return a.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=OV(e,a,s.options);s.options&t0&&s.content.length==0&&(o|=t0);let c=tr.none;return r=r.filter(u=>(s.type?s.type.allowsMarkType(u.type):FV(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new L_(e,n,c,i,null,o)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=eb)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),s=(o,c)=>{for(;o>=0;o--){let u=n[o];if(u==""){if(o==n.length-1||o==0)continue;for(;c>=a;c--)if(s(o-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=a?r.node(c-a).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function WUe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&_Q.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function qUe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function IV(t){let e={};for(let n in t)e[n]=t[n];return e}function FV(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],s=o=>{a.push(o);for(let c=0;c<o.edgeCount;c++){let{type:u,next:d}=o.edge(c);if(u==e||a.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class xf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=DN(n).createDocumentFragment());let i=r,a=[];return e.forEach(s=>{if(a.length||s.marks.length){let o=0,c=0;for(;o<a.length&&c<s.marks.length;){let u=s.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[o][0])||u.type.spec.spanning===!1)break;o++,c++}for(;o<a.length;)i=a.pop()[1];for(;c<s.marks.length;){let u=s.marks[c++],d=this.serializeMark(u,s.isInline,n);d&&(a.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=m1(DN(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&m1(DN(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return m1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new xf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=UV(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return UV(e.marks)}}function UV(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 zV=new WeakMap;function KUe(t){let e=zV.get(t);return e===void 0&&zV.set(t,e=XUe(t)),e}function XUe(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function m1(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],a;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=KUe(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:x}=m1(t,g,n,r);if(c.appendChild(m),x){if(o)throw new RangeError("Multiple content holes");o=x}}}return{dom:c,contentDOM:o}}const wQ=65535,SQ=Math.pow(2,16);function YUe(t,e){return t+e*SQ}function BV(t){return t&wQ}function ZUe(t){return(t-(t&wQ))/SQ}const MQ=1,EQ=2,g1=4,AQ=8;class GP{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&AQ)>0}get deletedBefore(){return(this.delInfo&(MQ|g1))>0}get deletedAfter(){return(this.delInfo&(EQ|g1))>0}get deletedAcross(){return(this.delInfo&g1)>0}}class bs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&bs.empty)return bs.empty}recover(e){let n=0,r=BV(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+ZUe(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[o+a],d=this.ranges[o+s],f=c+u;if(e<=f){let g=u?e==c?-1:e==f?1:n:n,m=c+i+(g<0?0:d);if(r)return m;let x=e==(n<0?c:f)?null:YUe(o/3,e-c),v=e==c?EQ:e==f?MQ:g1;return(n<0?e!=c:e!=f)&&(v|=AQ),new GP(m,v,x)}i+=d-u}return r?e+i:new GP(e+i,0,null)}touches(e,n){let r=0,i=BV(n),a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[o+a],d=c+u;if(e<=d&&o==i*3)return!0;r+=this.ranges[o+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let s=this.ranges[i],o=s-(this.inverted?a:0),c=s+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(o,o+u,c,c+d),a+=d-u}}invert(){return new bs(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?bs.empty:new bs(e<0?[0,-e,0]:[0,0,e])}}bs.empty=new bs([]);class tb{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new tb(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new tb;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let a=this.from;a<this.to;a++){let s=this._maps[a],o=s.mapResult(e,n);if(o.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new GP(e,i,null)}}const jN=Object.create(null);class xa{getMap(){return bs.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=jN[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 jN)throw new RangeError("Duplicate use of step JSON ID "+e);return jN[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(a){if(a instanceof Hw)return ei.fail(a.message);throw a}}}function SO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(SO(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return pt.fromArray(r)}class $u extends xa{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new kt(SO(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return ei.fromReplace(e,this.from,this.to,a)}invert(){return new Oo(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new $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))}}xa.jsonID("addMark",$u);class Oo extends xa{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new kt(SO(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 Oo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Oo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Oo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Oo(n.from,n.to,e.markFromJSON(n.mark))}}xa.jsonID("removeMark",Oo);class Vu extends xa{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ei.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ei.fromReplace(e,this.pos,this.pos+1,new kt(pt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Vu(this.pos,n.marks[i]);return new Vu(this.pos,this.mark)}}return new sf(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))}}xa.jsonID("addNodeMark",Vu);class sf extends xa{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ei.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ei.fromReplace(e,this.pos,this.pos+1,new kt(pt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Vu(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new sf(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 sf(n.pos,e.markFromJSON(n.mark))}}xa.jsonID("removeNodeMark",sf);class Oi extends xa{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&WP(e,this.from,this.to)?ei.fail("Structure replace would overwrite content"):ei.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new bs([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?kt.empty:new kt(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?kt.empty:new kt(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,kt.fromJSON(e,n.slice),!!n.structure)}}xa.jsonID("replace",Oi);class Ii extends xa{constructor(e,n,r,i,a,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=s,this.structure=o}apply(e){if(this.structure&&(WP(e,this.from,this.gapFrom)||WP(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 bs([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ii(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new Ii(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ii(n.from,n.to,n.gapFrom,n.gapTo,kt.fromJSON(e,n.slice),n.insert,!!n.structure)}}xa.jsonID("replaceAround",Ii);function WP(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let s=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function QUe(t,e,n,r){let i=[],a=[],s,o;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let g=Math.max(u,e),m=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(x)||(s&&s.to==g&&s.mark.eq(f[v])?s.to=m:i.push(s=new Oo(g,m,f[v])));o&&o.to==g?o.to=m:a.push(o=new $u(g,m,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function JUe(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;a++;let c=null;if(r instanceof qM){let u=s.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(s.marks)&&(c=[r]):c=s.marks;if(c&&c.length){let u=Math.min(o+s.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],g;for(let m=0;m<i.length;m++){let x=i[m];x.step==a-1&&f.eq(i[m].style)&&(g=x)}g?(g.to=u,g.step=a):i.push({style:f,from:Math.max(o,e),to:u,step:a})}}}),i.forEach(s=>t.step(new Oo(s.from,s.to,s.style)))}function MO(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),s=[],o=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=o+u.nodeSize,f=r.matchType(u.type);if(!f)s.push(new Oi(o,d,kt.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new Oo(o,d,u.marks[g]));if(i&&u.isText&&n.whitespace!="pre"){let g,m=/\r?\n|\r/g,x;for(;g=m.exec(u.text);)x||(x=new kt(pt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.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 kt(c,0,0))}for(let c=s.length-1;c>=0;c--)t.step(s[c])}function eze(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function hg(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let s=t.$from.node(r),o=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&s.canReplace(o,c,n))return r;if(r==0||s.type.spec.isolating||!eze(s,o,c))break;o&&(i=1),c<s.childCount&&(a=1)}return null}function tze(t,e,n){let{$from:r,$to:i,depth:a}=e,s=r.before(a+1),o=i.after(a+1),c=s,u=o,d=pt.empty,f=0;for(let x=a,v=!1;x>n;x--)v||r.index(x)>0?(v=!0,d=pt.from(r.node(x).copy(d)),f++):c--;let g=pt.empty,m=0;for(let x=a,v=!1;x>n;x--)v||i.after(x+1)<i.end(x)?(v=!0,g=pt.from(i.node(x).copy(g)),m++):u++;t.step(new Ii(c,u,s,o,new kt(d.append(g),f,m),d.size-f,!0))}function EO(t,e,n=null,r=t){let i=nze(t,e),a=i&&rze(r,e);return a?i.map(HV).concat({type:e,attrs:n}).concat(a.map(HV)):null}function HV(t){return{type:t,attrs:null}}function nze(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let s=a.length?a[0]:e;return n.canReplaceWith(r,i,s)?a:null}function rze(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),s=e.contentMatch.findWrapping(a.type);if(!s)return null;let c=(s.length?s[s.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:s}function ize(t,e,n){let r=pt.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let o=n[s].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=pt.from(n[s].type.create(n[s].attrs,r))}let i=e.start,a=e.end;t.step(new Ii(i,a,i,a,new kt(r,0,0),n.length,!0))}function aze(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(s,o)=>{let c=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,c)&&sze(t.doc,t.mapping.slice(a).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&&CQ(t,s,o,a),MO(t,t.mapping.slice(a).map(o,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(o,1),g=d.map(o+s.nodeSize,1);return t.step(new Ii(f,g,f+1,g-1,new kt(pt.from(r.create(c,null,s.marks)),0,0),1,!0)),u===!0&&TQ(t,s,o,a),!1}})}function TQ(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(i.text);){let c=t.mapping.slice(r).map(n+1+a+s.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function CQ(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+a);t.replaceWith(s,s+1,e.type.schema.text(`
- `))}})}function sze(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function oze(t,e,n,r,i){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let s=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,s);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ii(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new kt(pt.from(s),0,0),1,!0))}function Ec(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,s=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>a;u--,d--){let f=i.node(u),g=i.index(u);if(f.type.spec.isolating)return!1;let m=f.content.cutByIndex(g,f.childCount),x=r&&r[d+1];x&&(m=m.replaceChild(0,x.type.create(x.attrs)));let v=r&&r[d]||f;if(!f.canReplace(g+1,f.childCount)||!v.type.validContent(m))return!1}let o=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(o,o,c?c.type:i.node(a+1).type)}function lze(t,e,n=1,r){let i=t.doc.resolve(e),a=pt.empty,s=pt.empty;for(let o=i.depth,c=i.depth-n,u=n-1;o>c;o--,u--){a=pt.from(i.node(o).copy(a));let d=r&&r[u];s=pt.from(d?d.type.create(d.attrs,s):i.node(o).copy(s))}t.step(new Oi(e,e,new kt(a.append(s),n,n),!0))}function Sd(t,e){let n=t.resolve(e),r=n.index();return NQ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function cze(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let a=e.child(i),s=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function NQ(t,e){return!!(t&&e&&!t.isLeaf&&cze(t,e))}function KM(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,s,o=r.index(i);if(i==r.depth?(a=r.nodeBefore,s=r.nodeAfter):n>0?(a=r.node(i+1),o++,s=r.node(i).maybeChild(o)):(a=r.node(i).maybeChild(o-1),s=r.node(i+1)),a&&!a.isTextblock&&NQ(a,s)&&r.node(i).canReplace(o,o+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function uze(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),s=a.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let o=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);CQ(t,d.node(),d.before(),o)}s.inlineContent&&MO(t,e+n-1,s,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(o),u=c.map(e-n);if(t.step(new Oi(u,c.map(e+n,-1),kt.empty,!0)),r===!0){let d=t.doc.resolve(u);TQ(t,d.node(),d.before(),t.steps.length)}return t}function dze(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a<r.node(i).childCount)return null}return null}function kQ(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let a=0;a<n.openStart;a++)i=i.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let s=r.depth;s>=0;s--){let o=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,c=r.index(s)+(o>0?1:0),u=r.node(s),d=!1;if(a==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return o==0?r.pos:o<0?r.before(s+1):r.after(s+1)}return null}function XM(t,e,n=e,r=kt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return PQ(i,a,r)?new Oi(e,n,r):new hze(i,a,r).fit()}function PQ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class hze{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 a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=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 a=this.placed,s=r.depth,o=i.depth;for(;s&&o&&a.childCount==1;)a=a.firstChild.content,s--,o--;let c=new kt(a,s,o);return e>-1?new Ii(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Oi(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=ON(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let s=i.firstChild;for(let o=this.depth;o>=0;o--){let{type:c,match:u}=this.frontier[o],d,f=null;if(n==1&&(s?u.matchType(s.type)||(f=u.fillBefore(pt.from(s),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:o,parent:a,inject:f};if(n==2&&s&&(d=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:o,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=ON(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new kt(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=ON(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new kt(zx(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new kt(zx(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let v=0;v<a.length;v++)this.openFrontierNode(a[v]);let s=this.unplaced,o=r?r.content:s.content,c=s.openStart-e,u=0,d=[],{match:f,type:g}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}let m=o.size+e-(s.content.size-s.openEnd);for(;u<o.childCount;){let v=o.child(u),y=f.matchType(v.type);if(!y)break;u++,(u>1||c==0||v.content.size)&&(f=y,d.push(RQ(v.mark(g.allowedMarks(v.marks)),u==1?c:0,u==o.childCount?m:-1)))}let x=u==o.childCount;x||(m=-1),this.placed=Bx(this.placed,n,pt.from(d)),this.frontier[n].match=f,x&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,y=o;v<m;v++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=x?e==0?kt.empty:new kt(zx(s.content,e-1,1),e-1,m<0?s.openEnd:e-1):new kt(zx(s.content,e,u),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!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],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=LN(e,n,i,r,a);if(s){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:s,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Bx(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Bx(this.placed,this.depth,pt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(pt.empty,!0);n.childCount&&(this.placed=Bx(this.placed,this.frontier.length,n))}}function zx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(zx(t.firstChild.content,e-1,n)))}function Bx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Bx(t.lastChild.content,e-1,n)))}function ON(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function RQ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,RQ(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 a=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==a.childCount&&!n.compatibleContent(a.type))return null;let o=r.fillBefore(a.content,!0,s);return o&&!fze(n,a.content,s)?o:null}function fze(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function pze(t){return t.spec.defining||t.spec.definingForContent}function mze(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(PQ(i,a,r))return t.step(new Oi(e,n,r));let s=jQ(i,a);s[s.length-1]==0&&s.pop();let o=-(i.depth+1);s.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;s.indexOf(g)>-1?o=g:i.before(g)==m&&s.splice(1,0,-g)}let c=s.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=pze(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 v=0;v<s.length;v++){let y=s[(v+c)%s.length],b=!0;y<0&&(b=!1,y=-y);let M=i.node(y-1),S=i.index(y-1);if(M.canReplaceWith(S,S,x.type,x.marks))return t.replace(i.before(y),b?a.after(y):n,new kt(DQ(r.content,0,r.openStart,m),m,r.openEnd))}}let f=t.steps.length;for(let g=s.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>f));g--){let m=s[g];m<0||(e=i.before(m),n=a.after(m))}}function DQ(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(DQ(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),s=a.fillBefore(t).append(t);t=s.append(a.matchFragment(s).fillBefore(pt.empty,!0))}return t}function gze(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=dze(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new kt(pt.from(r),0,0))}function xze(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=jQ(r,i);for(let s=0;s<a.length;s++){let o=a[s],c=s==a.length-1;if(c&&o==0||r.node(o).type.contentMatch.validEnd)return t.delete(r.start(o),i.end(o));if(o>0&&(c||r.node(o-1).canReplace(r.index(o-1),i.indexAfter(o-1))))return t.delete(r.before(o),i.after(o))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function jQ(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(a<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class cm extends xa{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 a in n.attrs)r[a]=n.attrs[a];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return ei.fromReplace(e,this.pos,this.pos+1,new kt(pt.from(i),0,n.isLeaf?0:1))}getMap(){return bs.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)}}xa.jsonID("attr",cm);class nb extends xa{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 bs.empty}invert(e){return new nb(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new nb(n.attr,n.value)}}xa.jsonID("docAttr",nb);let Lm=class extends Error{};Lm=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Lm.prototype=Object.create(Error.prototype);Lm.prototype.constructor=Lm;Lm.prototype.name="TransformError";class OQ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tb}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Lm(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=kt.empty){let i=XM(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new kt(pt.from(r),0,0))}delete(e,n){return this.replace(e,n,kt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return mze(this,e,n,r),this}replaceRangeWith(e,n,r){return gze(this,e,n,r),this}deleteRange(e,n){return xze(this,e,n),this}lift(e,n){return tze(this,e,n),this}join(e,n=1){return uze(this,e,n),this}wrap(e,n){return ize(this,e,n),this}setBlockType(e,n=e,r,i=null){return aze(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return oze(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new cm(e,n,r)),this}setDocAttribute(e,n){return this.step(new nb(e,n)),this}addNodeMark(e,n){return this.step(new Vu(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof tr)n.isInSet(r.marks)&&this.step(new sf(e,n));else{let i=r.marks,a,s=[];for(;a=n.isInSet(i);)s.push(new sf(e,a)),i=a.removeFromSet(i);for(let o=s.length-1;o>=0;o--)this.step(s[o])}return this}split(e,n=1,r){return lze(this,e,n,r),this}addMark(e,n,r){return QUe(this,e,n,r),this}removeMark(e,n,r){return JUe(this,e,n,r),this}clearIncompatible(e,n,r){return MO(this,e,n,r),this}}const IN=Object.create(null);class un{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new bze(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=kt.empty){let r=n.content.lastChild,i=null;for(let o=0;o<n.openEnd;o++)i=r,r=r.lastChild;let a=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:c,$to:u}=s[o],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),o?kt.empty:n),o==0&&GV(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:s,$to:o}=i[a],c=e.mapping.slice(r),u=c.map(s.pos),d=c.map(o.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),GV(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Kt(e):zp(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let a=e.depth-1;a>=0;a--){let s=n<0?zp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):zp(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ms(e.node(0))}static atStart(e){return zp(e,e,0,0,1)||new Ms(e)}static atEnd(e){return zp(e,e,e.content.size,e.childCount,-1)||new Ms(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=IN[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in IN)throw new RangeError("Duplicate use of selection JSON ID "+e);return IN[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Kt.between(this.$anchor,this.$head).getBookmark()}}un.prototype.visible=!0;class bze{constructor(e,n){this.$from=e,this.$to=n}}let $V=!1;function VV(t){!$V&&!t.parent.inlineContent&&($V=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Kt extends un{constructor(e,n=e){VV(e),VV(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return un.near(r);let i=e.resolve(n.map(this.anchor));return new Kt(i.parent.inlineContent?i:r,r)}replace(e,n=kt.empty){if(super.replace(e,n),n==kt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Kt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new YM(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Kt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=un.findFrom(n,r,!0)||un.findFrom(n,-r,!0);if(a)n=a.$head;else return un.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(un.findFrom(e,-r,!0)||un.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Kt(e,n)}}un.jsonID("text",Kt);class YM{constructor(e,n){this.anchor=e,this.head=n}map(e){return new YM(e.map(this.anchor),e.map(this.head))}resolve(e){return Kt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ht extends un{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=e.resolve(i);return r?un.near(a):new Ht(a)}content(){return new kt(pt.from(this.node),0,0)}eq(e){return e instanceof Ht&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new AO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ht(e.resolve(n.anchor))}static create(e,n){return new Ht(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ht.prototype.visible=!1;un.jsonID("node",Ht);class AO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new YM(r,r):new AO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ht.isSelectable(r)?new Ht(n):un.near(n)}}class Ms extends un{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=kt.empty){if(n==kt.empty){e.delete(0,e.doc.content.size);let r=un.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ms(e)}map(e){return new Ms(e)}eq(e){return e instanceof Ms}getBookmark(){return yze}}un.jsonID("all",Ms);const yze={map(){return this},resolve(t){return new Ms(t)}};function zp(t,e,n,r,i,a=!1){if(e.inlineContent)return Kt.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let o=e.child(s);if(o.isAtom){if(!a&&Ht.isSelectable(o))return Ht.create(t,n-(i<0?o.nodeSize:0))}else{let c=zp(t,o,n+i,i<0?o.childCount:0,i,a);if(c)return c}n+=o.nodeSize*i}return null}function GV(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Oi||i instanceof Ii))return;let a=t.mapping.maps[r],s;a.forEach((o,c,u,d)=>{s==null&&(s=d)}),t.setSelection(un.near(t.doc.resolve(s),n))}const WV=1,I_=2,qV=4;class vze 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|WV)&~I_,this.storedMarks=null,this}get selectionSet(){return(this.updated&WV)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=I_,this}ensureMarks(e){return tr.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&I_)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~I_,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||tr.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let a=this.storedMarks;if(!a){let s=this.doc.resolve(n);a=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(un.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=qV,this}get scrolledIntoView(){return(this.updated&qV)>0}}function KV(t,e){return!e||!t?t:t.bind(e)}class Hx{constructor(e,n,r){this.name=e,this.init=KV(n.init,r),this.apply=KV(n.apply,r)}}const _ze=[new Hx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Hx("selection",{init(t,e){return t.selection||un.atStart(e.doc)},apply(t){return t.selection}}),new Hx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Hx("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class FN{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=_ze.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Hx(r.key,r.spec.state,r))})}}class Yp{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let a=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let c=i?i[s].n:0,u=i?i[s].state:this,d=c<n.length&&o.spec.appendTransaction.call(o,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),a=!0}i&&(i[s]={state:r,n:n.length})}}if(!a)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Yp(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let a=r[i];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new vze(this)}static create(e){let n=new FN(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 FN(this.schema,e.plugins),r=n.fields,i=new Yp(n);for(let a=0;a<r.length;a++){let s=r[a].name;i[s]=this.hasOwnProperty(s)?this[s]:r[a].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new FN(e.schema,e.plugins),a=new Yp(i);return i.fields.forEach(s=>{if(s.name=="doc")a.doc=Ju.fromJSON(e.schema,n.doc);else if(s.name=="selection")a.selection=un.fromJSON(a.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let o in r){let c=r[o],u=c.spec.state;if(c.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){a[s.name]=u.fromJSON.call(c,e,n[o],a);return}}a[s.name]=s.init(e,a)}}),a}}function LQ(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=LQ(i,e,{})),n[r]=i}return n}class Er{constructor(e){this.spec=e,this.props={},e.props&&LQ(e.props,this,this.props),this.key=e.key?e.key.key:IQ("plugin")}getState(e){return e[this.key]}}const UN=Object.create(null);function IQ(t){return t in UN?t+"$"+ ++UN[t]:(UN[t]=0,t+"$")}class Si{constructor(e="key"){this.key=IQ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const TO=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function FQ(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=FQ(t,n);if(!r)return!1;let i=CO(r);if(!i){let s=r.blockRange(),o=s&&hg(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)}let a=i.nodeBefore;if(KQ(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Im(a,"end")||Ht.isSelectable(a)))for(let s=r.depth;;s--){let o=XM(t.doc,r.before(s),r.after(s),kt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let c=t.tr.step(o);c.setSelection(Im(a,"end")?un.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Ht.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},wze=(t,e,n)=>{let r=FQ(t,n);if(!r)return!1;let i=CO(r);return i?zQ(t,i,e):!1},Sze=(t,e,n)=>{let r=HQ(t,n);if(!r)return!1;let i=NO(r);return i?zQ(t,i,e):!1};function zQ(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let s=e.nodeAfter,o=s,c=e.pos+1;for(;!o.isTextblock;c++){if(o.type.spec.isolating)return!1;let d=o.firstChild;if(!d)return!1;o=d}let u=XM(t.doc,a,c,kt.empty);if(!u||u.from!=a||u instanceof Oi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(Kt.create(d.doc,a)),n(d.scrollIntoView())}return!0}function Im(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const BQ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=CO(r)}let s=a&&a.nodeBefore;return!s||!Ht.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,a.pos-s.nodeSize)).scrollIntoView()),!0)};function CO(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 HQ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const $Q=(t,e,n)=>{let r=HQ(t,n);if(!r)return!1;let i=NO(r);if(!i)return!1;let a=i.nodeAfter;if(KQ(t,i,e,1))return!0;if(r.parent.content.size==0&&(Im(a,"start")||Ht.isSelectable(a))){let s=XM(t.doc,r.before(),r.after(),kt.empty);if(s&&s.slice.size<s.to-s.from){if(e){let o=t.tr.step(s);o.setSelection(Im(a,"start")?un.findFrom(o.doc.resolve(o.mapping.map(i.pos)),1):Ht.create(o.doc,o.mapping.map(i.pos))),e(o.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},VQ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=NO(r)}let s=a&&a.nodeAfter;return!s||!Ht.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,a.pos)).scrollIntoView()),!0)};function NO(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 Mze=(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=KM(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Ht.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},Eze=(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=KM(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Aze=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&hg(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},GQ=(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 kO(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 Tze=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),s=kO(i.contentMatchAt(a));if(!s||!i.canReplaceWith(a,a,s))return!1;if(e){let o=n.after(),c=t.tr.replaceWith(o,o,s.createAndFill());c.setSelection(un.near(c.doc.resolve(o),1)),e(c.scrollIntoView())}return!0},WQ=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ms||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=kO(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(s,a.createAndFill());o.setSelection(Kt.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},qQ=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(Ec(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&hg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Cze(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 a=[],s,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=kO(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),a.unshift(c&&o?{type:o}:null),s=m;break}else{if(m==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof Kt||e.selection instanceof Ms)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=Ec(d.doc,f,a.length,a);if(g||(a[0]=o?{type:o}:null,g=Ec(d.doc,f,a.length,a)),!g)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(s).type!=o){let m=d.mapping.map(r.before(s)),x=d.doc.resolve(m);o&&r.node(s-1).canReplaceWith(x.index(),x.index()+1,o)&&d.setNodeMarkup(d.mapping.map(r.before(s)),o)}return n&&n(d.scrollIntoView()),!0}}const Nze=Cze(),kze=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(Ht.create(t.doc,i))),!0)};function Pze(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||Sd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function KQ(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,s,o,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&Pze(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(s=(o=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&o.matchType(s[0]||a.type).validEnd){if(n){let m=e.pos+a.nodeSize,x=pt.empty;for(let b=s.length-1;b>=0;b--)x=pt.from(s[b].create(null,x));x=pt.from(i.copy(x));let v=t.tr.step(new Ii(e.pos-1,m,e.pos,m,new kt(x,1,0),s.length,!0)),y=v.doc.resolve(m+2*s.length);y.nodeAfter&&y.nodeAfter.type==i.type&&Sd(v.doc,y.pos)&&v.join(y.pos),n(v.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:un.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),g=f&&hg(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&Im(a,"start",!0)&&Im(i,"end")){let m=i,x=[];for(;x.push(m),!m.isTextblock;)m=m.lastChild;let v=a,y=1;for(;!v.isTextblock;v=v.firstChild)y++;if(m.canReplace(m.childCount,m.childCount,v.content)){if(n){let b=pt.empty;for(let S=x.length-1;S>=0;S--)b=pt.from(x[S].copy(b));let M=t.tr.step(new Ii(e.pos-x.length,e.pos+a.nodeSize,e.pos+y,e.pos+a.nodeSize-y,new kt(b,x.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function XQ(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(Kt.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const Rze=XQ(-1),Dze=XQ(1);function jze(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a),o=s&&EO(s,t,e);return o?(r&&r(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function XV(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[a];n.doc.nodesBetween(s,o,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:o},$to:{pos:c}}=n.selection.ranges[s];a.setBlockType(o,c,t,e)}r(a.scrollIntoView())}return!0}}function PO(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}PO(TO,UQ,BQ);PO(TO,$Q,VQ);PO(GQ,WQ,qQ,Nze);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Oze(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a);if(!s)return!1;let o=r?n.tr:null;return Lze(o,s,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function Lze(t,e,n,r=null){let i=!1,a=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=s.resolve(e.start-2);a=new Vw(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new Vw(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let o=EO(a,n,r,e);return o?(t&&Ize(t,e,o,i,n),!0):!1}function Ize(t,e,n,r,i){let a=pt.empty;for(let d=n.length-1;d>=0;d--)a=pt.from(n[d].type.create(n[d].attrs,a));t.step(new Ii(e.start-(r?2:0),e.end,e.start,e.end,new kt(a,0,0),n.length,!0));let s=0;for(let d=0;d<n.length;d++)n[d].type==i&&(s=d+1);let o=n.length-s,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,g=!0;d<f;d++,g=!1)!g&&Ec(t.doc,c,o)&&(t.split(c,o),c+=2*o),c+=u.child(d).nodeSize;return t}function Fze(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?Uze(e,n,t,a):zze(e,n,a):!0:!1}}function Uze(t,e,n,r){let i=t.tr,a=r.end,s=r.$to.end(r.depth);a<s&&(i.step(new Ii(a-1,s,a,s,new kt(pt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Vw(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const o=hg(r);if(o==null)return!1;i.lift(r,o);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return Sd(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function zze(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,x=n.endIndex-1,v=n.startIndex;x>v;x--)m-=i.child(x).nodeSize,r.delete(m-1,m+1);let a=r.doc.resolve(n.start),s=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let o=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(o?0:1),d+1,s.content.append(c?pt.empty:pt.from(i))))return!1;let f=a.pos,g=f+s.nodeSize;return r.step(new Ii(f-(o?1:0),g+(c?1:0),f+1,g-1,new kt((o?pt.empty:pt.from(i.copy(pt.empty))).append(c?pt.empty:pt.from(i.copy(pt.empty))),o?0:1,c?0:1),o?0:1)),e(r.scrollIntoView()),!0}function Bze(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!a)return!1;let s=a.startIndex;if(s==0)return!1;let o=a.parent,c=o.child(s-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==o.type,d=pt.from(u?t.create():null),f=new kt(pt.from(t.create(null,pt.from(o.type.create(null,d)))),u?3:1,0),g=a.start,m=a.end;n(e.tr.step(new Ii(g-(u?3:1),m,g,m,f,1,!0)).scrollIntoView())}return!0}}const ea=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Fm=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let qP=null;const oc=function(t,e,n){let r=qP||(qP=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Hze=function(){qP=null},of=function(t,e,n,r){return n&&(YV(t,e,n,r,-1)||YV(t,e,n,r,1))},$ze=/^(img|br|input|textarea|hr)$/i;function YV(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:eo(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Yb(t)||$ze.test(t.nodeName)||t.contentEditable=="false")return!1;e=ea(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((a=s.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?eo(t):0}else return!1}}function eo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Vze(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=eo(t)}else if(t.parentNode&&!Yb(t))e=ea(t),t=t.parentNode;else return null}}function Gze(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Yb(t))e=ea(t)+1,t=t.parentNode;else return null}}function Wze(t,e,n){for(let r=e==0,i=e==eo(t);r||i;){if(t==n)return!0;let a=ea(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==eo(t)}}function Yb(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const ZM=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 qze(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Kze(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(eo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(eo(r.startContainer),r.startOffset)}}}const bl=typeof navigator<"u"?navigator:null,ZV=typeof document<"u"?document:null,Md=bl&&bl.userAgent||"",KP=/Edge\/(\d+)/.exec(Md),YQ=/MSIE \d/.exec(Md),XP=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Md),Ya=!!(YQ||XP||KP),ed=YQ?document.documentMode:XP?+XP[1]:KP?+KP[1]:0,so=!Ya&&/gecko\/(\d+)/i.test(Md);so&&+(/Firefox\/(\d+)/.exec(Md)||[0,0])[1];const YP=!Ya&&/Chrome\/(\d+)/.exec(Md),fa=!!YP,ZQ=YP?+YP[1]:0,ka=!Ya&&!!bl&&/Apple Computer/.test(bl.vendor),Um=ka&&(/Mobile\/\w+/.test(Md)||!!bl&&bl.maxTouchPoints>2),Ks=Um||(bl?/Mac/.test(bl.platform):!1),Xze=bl?/Win/.test(bl.platform):!1,bc=/Android \d/.test(Md),Zb=!!ZV&&"webkitFontSmoothing"in ZV.documentElement.style,Yze=Zb?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Zze(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function tc(t,e){return typeof t=="number"?t:t[e]}function Qze(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 QV(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=Fm(s);continue}let o=s,c=o==a.body,u=c?Zze(a):Qze(o),d=0,f=0;if(e.top<u.top+tc(r,"top")?f=-(u.top-e.top+tc(i,"top")):e.bottom>u.bottom-tc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+tc(i,"top")-u.top:e.bottom-u.bottom+tc(i,"bottom")),e.left<u.left+tc(r,"left")?d=-(u.left-e.left+tc(i,"left")):e.right>u.right-tc(r,"right")&&(d=e.right-u.right+tc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let m=o.scrollLeft,x=o.scrollTop;f&&(o.scrollTop+=f),d&&(o.scrollLeft+=d);let v=o.scrollLeft-m,y=o.scrollTop-x;e={left:e.left-v,top:e.top-y,right:e.right-v,bottom:e.bottom-y}}let g=c?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(g))break;s=g=="absolute"?s.offsetParent:Fm(s)}}function Jze(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let o=t.root.elementFromPoint(a,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let c=o.getBoundingClientRect();if(c.top>=n-20){r=o,i=c.top;break}}return{refDOM:r,refTop:i,stack:QQ(t.dom)}}function QQ(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Fm(r));return e}function eBe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;JQ(n,r==0?0:r-e)}function JQ(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:a}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=a&&(r.scrollLeft=a)}}let jp=null;function tBe(t){if(t.setActive)return t.setActive();if(jp)return t.focus(jp);let e=QQ(t);t.focus(jp==null?{get preventScroll(){return jp={preventScroll:!0},!0}}:void 0),jp||(jp=!1,JQ(e,0))}function eJ(t,e){let n,r=2e8,i,a=0,s=e.top,o=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=oc(d).getClientRects();else continue;for(let m=0;m<g.length;m++){let x=g[m];if(x.top<=s&&x.bottom>=o){s=Math.max(x.bottom,s),o=Math.min(x.top,o);let v=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&v&&(a=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?nBe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:eJ(n,i)}function nBe(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let a=Au(r,1);if(a.top!=a.bottom&&RO(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function RO(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function rBe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function iBe(t,e,n){let{node:r,offset:i}=eJ(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function aBe(t,e,n,r){let i=-1;for(let a=e,s=!1;a!=t.dom;){let o=t.docView.nearestDesc(a,!0),c;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((c=o.dom.getBoundingClientRect()).width||c.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&c.left>r.left||c.top>r.top?i=o.posBefore:(!s&&c.right<r.left||c.bottom<r.top)&&(i=o.posAfter),s=!0),!o.contentDOM&&i<0&&!o.node.isText))return(o.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?o.posBefore:o.posAfter;a=o.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function tJ(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let s=t.childNodes[a];if(s.nodeType==1){let o=s.getClientRects();for(let c=0;c<o.length;c++){let u=o[c];if(RO(e,u))return tJ(s,e,u)}}if((a=(a+1)%r)==i)break}return t}function sBe(t,e){let n=t.dom.ownerDocument,r,i=0,a=Kze(n,e.left,e.top);a&&({node:r,offset:i}=a);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let u=t.dom.getBoundingClientRect();if(!RO(e,u)||(s=tJ(t.dom,e,u),!s))return null}if(ka)for(let u=s;r&&u;u=Fm(u))u.draggable&&(r=void 0);if(s=rBe(s,e),r){if(so&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;Zb&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(o=aBe(t,r,i,e))}o==null&&(o=iBe(t,s,e));let c=t.docView.nearestDesc(s,!0);return{pos:o,inside:c?c.posAtStart-c.border:-1}}function JV(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(JV(r))return r}return Array.prototype.find.call(n,JV)||t.getBoundingClientRect()}const oBe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function nJ(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),s=Zb||so;if(r.nodeType==3)if(s&&(oBe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Au(oc(r,i,i),n);if(so&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Au(oc(r,i-1,i-1),-1);if(u.top==c.top){let d=Au(oc(r,i,i+1),-1);if(d.top!=c.top)return Nx(d,d.left<u.left)}}return c}else{let c=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(c--,d=1):n<0?c--:u++,Nx(Au(oc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==eo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return zN(c.getBoundingClientRect(),!1)}if(a==null&&i<eo(r)){let c=r.childNodes[i];if(c.nodeType==1)return zN(c.getBoundingClientRect(),!0)}return zN(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==eo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?oc(c,eo(c)-(s?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Nx(Au(u,1),!1)}if(a==null&&i<eo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?oc(c,0,s?0:1):c.nodeType==1?c:null:null;if(u)return Nx(Au(u,-1),!0)}return Nx(Au(r.nodeType==3?oc(r):r,-n),n>=0)}function Nx(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function zN(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function rJ(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 lBe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return rJ(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(a,!0);if(!o)break;if(o.node.isBlock){a=o.contentDOM||o.dom;break}a=o.dom.parentNode}let s=nJ(t,i.pos,1);for(let o=a.firstChild;o;o=o.nextSibling){let c;if(o.nodeType==1)c=o.getClientRects();else if(o.nodeType==3)c=oc(o,0,o.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const cBe=/[\u0590-\u08ac]/;function uBe(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,s=i==r.parent.content.size,o=t.domSelection();return o?!cBe.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?a:s:rJ(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:v}=t.domSelectionRange(),y=x&&!m.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==v;try{o.collapse(d,f),c&&(c!=d||u!=f)&&o.extend&&o.extend(c,u)}catch{}return g!=null&&(o.caretBidiLevel=g),y}):r.pos==r.start()||r.pos==r.end()}let e7=null,t7=null,n7=!1;function dBe(t,e,n){return e7==e&&t7==n?n7:(e7=e,t7=n,n7=n=="up"||n=="down"?lBe(t,e,n):uBe(t,e,n))}const oo=0,r7=1,xh=2,yl=3;class Qb{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=oo,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,s;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(s)+s.size:this.posAtStart}else{let a,s;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>ea(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),s;if(a&&(!n||a.node))if(r&&(s=a.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],a=r+i.size;if(r==e&&a!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let o=i.children[s];if(o.size){i=o;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let s=this.children[r],o=a+s.size;if(o>e||s instanceof aJ){i=e-a;break}a=o}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof iJ&&a.side>=0;r--);if(n<=0){let a,s=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,s=!1);return a&&n&&s&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?ea(a.dom)+1:0}}else{let a,s=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,s=!1);return a&&s&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?ea(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,a=-1;for(let s=r,o=0;;o++){let c=this.children[o],u=s+c.size;if(i==-1&&e<=u){let d=s+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=s;for(let f=o;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=ea(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(u>n||o==this.children.length-1)){n=u;for(let d=o+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=ea(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}s=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),s=Math.max(e,n);for(let m=0,x=0;m<this.children.length;m++){let v=this.children[m],y=x+v.size;if(a>x&&s<y)return v.setSelection(e-x-v.border,n-x-v.border,r,i);x=y}let o=this.domFromPos(e,e?-1:1),c=n==e?o:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((so||ka)&&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 v=m,y;v;v=v.parentNode){if(y=v.nextSibling){y.nodeName=="BR"&&(o=c={node:y.parentNode,offset:ea(y)+1});break}let b=v.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let v=m.childNodes[x-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(so&&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&&ka)&&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&&so)){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 a=this.children[i],s=r+a.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let o=r+a.border,c=s-a.border;if(e>=o&&n<=c){this.dirty=e==r||n==s?xh:r7,e==o&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=yl:a.markDirty(e-o,n-o);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?xh:yl}r=s}this.dirty=xh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?xh:r7;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class iJ extends Qb{constructor(e,n,r,i){let a,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(s.nodeType!=1){let o=document.createElement("span");o.appendChild(s),s=o}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==oo&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class hBe extends Qb{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class lf extends Qb{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],s=a&&a(n,i,r);return(!s||!s.dom)&&(s=xf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new lf(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&yl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=yl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=oo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=oo}}slice(e,n,r){let i=lf.create(this.parent,this.mark,!0,r),a=this.children,s=this.size;n<s&&(a=QP(a,n,s,r)),e>0&&(a=QP(a,0,e,r));for(let o=0;o<a.length;o++)a[o].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class td extends Qb{constructor(e,n,r,i,a,s,o,c,u){super(e,[],a,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(e,n,r,i,a,s){let o=a.nodeViews[n.type.name],c,u=o&&o(n,a,()=>{if(!c)return s;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=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=lJ(d,r,n),u?c=new fBe(e,n,r,i,d,f||null,g,u,a,s+1):n.isText?new QM(e,n,r,i,d,g,a):new td(e,n,r,i,d,f||null,g,a,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>pt.empty)}return e}matchesNode(e,n,r){return this.dirty==oo&&e.eq(this.node)&&Ww(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,a=e.composing?this.localCompositionInfo(e,n):null,s=a&&a.pos>-1?a:null,o=a&&a.pos<0,c=new mBe(this,s&&s.node,e);bBe(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(a.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)&&(s&&this.protectLocalComposition(e,s),sJ(this.contentDOM,this.children,e),Um&&yBe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Kt)||r<n||i>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let s=a.nodeValue,o=vBe(this.node.content,s,r-n,i-n);return o<0?null:{node:a,pos:o,text:s}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let s=new hBe(this,a,n,i);e.input.compositionNodes.push(s),this.children=QP(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==yl||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=oo}updateOuterDeco(e){if(Ww(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=oJ(this.dom,this.nodeDOM,ZP(this.outerDeco,this.node,n),ZP(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 i7(t,e,n,r,i){lJ(r,e,t);let a=new td(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class QM extends td{constructor(e,n,r,i,a,s,o){super(e,n,r,i,a,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==yl||this.dirty!=oo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=oo||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=oo,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new QM(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=yl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class aJ extends Qb{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==oo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class fBe extends td{constructor(e,n,r,i,a,s,o,c,u,d){super(e,n,r,i,a,s,o,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==yl)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function sJ(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let s=e[a],o=s.dom;if(o.parentNode==t){for(;o!=r;)r=a7(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(o,r);if(s instanceof lf){let c=r?r.previousSibling:t.lastChild;sJ(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=a7(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const n0=function(t){t&&(this.nodeName=t)};n0.prototype=Object.create(null);const bh=[new n0];function ZP(t,e,n){if(t.length==0)return bh;let r=n?bh[0]:new n0,i=[r];for(let a=0;a<t.length;a++){let s=t[a].type.attrs;if(s){s.nodeName&&i.push(r=new n0(s.nodeName));for(let o in s){let c=s[o];c!=null&&(n&&i.length==1&&i.push(r=new n0(e.isInline?"span":"div")),o=="class"?r.class=(r.class?r.class+" ":"")+c:o=="style"?r.style=(r.style?r.style+";":"")+c:o!="nodeName"&&(r[o]=c))}}}return i}function oJ(t,e,n,r){if(n==bh&&r==bh)return e;let i=e;for(let a=0;a<r.length;a++){let s=r[a],o=n[a];if(a){let c;o&&o.nodeName==s.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==s.nodeName||(c=document.createElement(s.nodeName),c.pmIsDeco=!0,c.appendChild(i),o=bh[0]),i=c}pBe(i,o||bh[0],s)}return i}function pBe(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.remove(r[a]);for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.add(i[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function lJ(t,e,n){return oJ(t,t,bh,ZP(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 a7(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class mBe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=gBe(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,a=this.stack.length>>1,s=Math.min(a,e.length);for(;i<s&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=oo,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[a])&&!this.isLocked(u.dom)){o=c;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let c=lf.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))a=this.top.children.indexOf(s,this.index);else for(let o=this.index,c=Math.min(this.top.children.length,o+5);o<c;o++){let u=this.top.children[o];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){a=o;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let s=this.top.children[i];return s.dirty==yl&&s.dom==s.contentDOM&&(s.dirty=xh),s.update(e,n,r,a)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,a,s){for(let o=this.index;o<this.top.children.length;o++){let c=this.top.children[o];if(c instanceof td){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,g=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=yl&&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,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=xh,f.updateChildren(i,s+1),f.dirty=oo),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Ww(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=td.create(this.top,n,r,i,a,s);if(o.contentDOM){o.children=e.children,e.children=[];for(let c of o.children)c.parent=o}return e.destroy(),o}addNode(e,n,r,i,a){let s=td.create(this.top,e,n,r,i,a);s.contentDOM&&s.updateChildren(i,a+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let a=new iJ(this.top,e,n,r);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof lf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof QM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ka||fa)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new aJ(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 gBe(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,s=[];e:for(;i>0;){let o;for(;;)if(r){let u=n.children[r-1];if(u instanceof 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,a.set(o,i),s.push(o)}}return{index:i,matched:a,matches:s.reverse()}}function xBe(t,e){return t.type.side-e.type.side}function bBe(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(a,d),u),a+=d.nodeSize}return}let s=0,o=[],c=null;for(let u=0;;){let d,f;for(;s<i.length&&i[s].to==a;){let y=i[s++];y.widget&&(d?(f||(f=[d])).push(y):d=y)}if(d)if(f){f.sort(xBe);for(let y=0;y<f.length;y++)n(f[y],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 y=0;y<o.length;y++)o[y].to<=a&&o.splice(y--,1);for(;s<i.length&&i[s].from<=a&&i[s].to>a;)o.push(i[s++]);let x=a+g.nodeSize;if(g.isText){let y=x;s<i.length&&i[s].from<y&&(y=i[s].from);for(let b=0;b<o.length;b++)o[b].to<y&&(y=o[b].to);y<x&&(c=g.cut(y-a),g=g.cut(0,y-a),x=y,m=-1)}else for(;s<i.length&&i[s].to<x;)s++;let v=g.isInline&&!g.isLeaf?o.filter(y=>!y.inline):o.slice();r(g,v,e.forChild(a,g),m),a=x}}function yBe(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 vBe(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let s=t.child(i++),o=a;if(a+=s.nodeSize,!s.isText)continue;let c=s.text;for(;i<t.childCount;){let u=t.child(i++);if(a+=u.nodeSize,!u.isText)break;c+=u.text}if(a>=n){if(a>=r&&c.slice(r-e.length-o,r-o)==e)return r-e.length;let u=o<r?c.lastIndexOf(e,r-o-1):-1;if(u>=0&&u+e.length+o>=n)return o+u;if(n==r&&c.length>=r+e.length-o&&c.slice(r-o,r-o+e.length)==e)return r}}return-1}function QP(t,e,n,r,i){let a=[];for(let s=0,o=0;s<t.length;s++){let c=t[s],u=o,d=o+=c.size;u>=n||d<=e?a.push(c):(u<e&&a.push(c.slice(0,e-u,r)),i&&(a.push(i),i=void 0),d>n&&a.push(c.slice(n-u,c.size,r)))}return a}function DO(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let o=r.resolve(s),c,u;if(ZM(n)){for(c=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Ht.isSelectable(f)&&i.parent&&!(f.isInline&&Wze(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;u=new Ht(s==g?o:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,g=s;for(let 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,s]=g==t.state.selection.anchor?[g,f]:[f,g],o=r.resolve(s)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let f=e=="pointer"||t.state.selection.head<o.pos&&!a?1:-1;u=jO(t,d,o,f)}return u}function cJ(t){return t.editable?t.hasFocus():dJ(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ac(t,e=!1){let n=t.state.selection;if(uJ(t,n),!!cJ(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&fa){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)wBe(t);else{let{anchor:r,head:i}=n,a,s;s7&&!(n instanceof Kt)&&(n.$from.parent.inlineContent||(a=o7(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=o7(t,n.to))),t.docView.setSelection(r,i,t,e),s7&&(a&&l7(a),s&&l7(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&_Be(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const s7=ka||fa&&ZQ<63;function o7(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(ka&&i&&i.contentEditable=="false")return BN(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return BN(i);if(a)return BN(a)}}function BN(t){return t.contentEditable="true",ka&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function l7(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function _Be(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(()=>{(!cJ(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function wBe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ea(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ya&&ed<=11&&(n.disabled=!0,n.disabled=!1)}function uJ(t,e){if(e instanceof Ht){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(c7(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else c7(t)}function c7(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function jO(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Kt.between(e,n,r)}function u7(t){return t.editable&&!t.hasFocus()?!1:dJ(t)}function dJ(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 SBe(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 JP(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&un.findFrom(a,e)}function Pu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function d7(t,e,n){let r=t.state.selection;if(r instanceof Kt)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return Pu(t,new Kt(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=JP(t.state,e);return i&&i instanceof Ht?Pu(t,i):!1}else if(!(Ks&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!a||a.isText)return!1;let o=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM?Ht.isSelectable(a)?Pu(t,new Ht(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):Zb?Pu(t,new Kt(t.state.doc.resolve(e<0?o:o+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ht&&r.node.isInline)return Pu(t,new Kt(e>0?r.$to:r.$from));{let i=JP(t.state,e);return i?Pu(t,i):!1}}}function qw(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function r0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Op(t,e){return e<0?MBe(t):EBe(t)}function MBe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,s=!1;for(so&&n.nodeType==1&&r<qw(n)&&r0(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(r0(o,-1))i=n,a=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(hJ(n))break;{let o=n.previousSibling;for(;o&&r0(o,-1);)i=n.parentNode,a=ea(o),o=o.previousSibling;if(o)n=o,r=qw(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?eR(t,n,r):i&&eR(t,i,a)}function EBe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=qw(n),a,s;for(;;)if(r<i){if(n.nodeType!=1)break;let o=n.childNodes[r];if(r0(o,1))a=n,s=++r;else break}else{if(hJ(n))break;{let o=n.nextSibling;for(;o&&r0(o,1);)a=o.parentNode,s=ea(o)+1,o=o.nextSibling;if(o)n=o,r=0,i=qw(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&eR(t,a,s)}function hJ(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function ABe(t,e){for(;t&&e==t.childNodes.length&&!Yb(t);)e=ea(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function TBe(t,e){for(;t&&!e&&!Yb(t);)e=ea(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function eR(t,e,n){if(e.nodeType!=3){let a,s;(s=ABe(e,n))?(e=s,n=0):(a=TBe(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(ZM(r)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),r.removeAllRanges(),r.addRange(a)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Ac(t)},50)}function h7(t,e){let n=t.state.doc.resolve(e);if(!(fa||Xze)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),s=(a.top+a.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(a.left-i.left)>1)return a.left<i.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),s=(a.top+a.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function f7(t,e,n){let r=t.state.selection;if(r instanceof Kt&&!r.empty||n.indexOf("s")>-1||Ks&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=JP(t.state,e);if(s&&s instanceof Ht)return Pu(t,s)}if(!i.parent.inlineContent){let s=e<0?i:a,o=r instanceof Ms?un.near(s,e):un.findFrom(s,e);return o?Pu(t,o):!1}return!1}function p7(t,e){if(!(t.state.selection instanceof Kt))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let s=t.state.tr;return e<0?s.delete(n.pos-a.nodeSize,n.pos):s.delete(n.pos,n.pos+a.nodeSize),t.dispatch(s),!0}return!1}function m7(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function CBe(t){if(!ka||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;m7(t,r,"true"),setTimeout(()=>m7(t,r,"false"),20)}return!1}function NBe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function kBe(t,e){let n=e.keyCode,r=NBe(e);if(n==8||Ks&&n==72&&r=="c")return p7(t,-1)||Op(t,-1);if(n==46&&!e.shiftKey||Ks&&n==68&&r=="c")return p7(t,1)||Op(t,1);if(n==13||n==27)return!0;if(n==37||Ks&&n==66&&r=="c"){let i=n==37?h7(t,t.state.selection.from)=="ltr"?-1:1:-1;return d7(t,i,r)||Op(t,i)}else if(n==39||Ks&&n==70&&r=="c"){let i=n==39?h7(t,t.state.selection.from)=="ltr"?1:-1:1;return d7(t,i,r)||Op(t,i)}else{if(n==38||Ks&&n==80&&r=="c")return f7(t,-1,r)||Op(t,-1);if(n==40||Ks&&n==78&&r=="c")return CBe(t)||f7(t,1,r)||Op(t,1);if(r==(Ks?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function OO(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let s=t.someProp("clipboardSerializer")||xf.fromSchema(t.state.schema),o=bJ(),c=o.createElement("div");c.appendChild(s.serializeFragment(r,{document:o}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=xJ[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} ${a}${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 fJ(t,e,n,r,i){let a=i.parent.type.spec.code,s,o;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",g=>{e=g(e,a||r,t)}),a)return o=new kt(pt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",g=>{o=g(o,t,!0)}),o;let f=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(f)o=f;else{let g=i.marks(),{schema:m}=t.state,x=xf.fromSchema(m);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let y=s.appendChild(document.createElement("p"));v&&y.appendChild(x.serializeNode(m.text(v,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=jBe(n),Zb&&OBe(s);let u=s&&s.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let g=s.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;s=g}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||e0.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!PBe.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)o=LBe(g7(o,+d[1],+d[2]),d[4]);else if(o=kt.maxOpen(RBe(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=g7(o,f,g)}return t.someProp("transformPasted",f=>{o=f(o,t,c)}),o}const PBe=/^(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 RBe(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,s=[];if(t.forEach(o=>{if(!s)return;let c=i.findWrapping(o.type),u;if(!c)return s=null;if(u=s.length&&a.length&&mJ(c,a,o,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=gJ(s[s.length-1],a.length));let d=pJ(o,c);s.push(d),i=i.matchType(d.type),a=c}}),s)return pt.from(s)}return t}function pJ(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,pt.from(t));return t}function mJ(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=mJ(t,e,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(pt.from(pJ(n,t,i+1))))}}function gJ(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,gJ(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(pt.empty,!0);return t.copy(n.append(r))}function tR(t,e,n,r,i,a){let s=e<0?t.firstChild:t.lastChild,o=s.content;return t.childCount>1&&(a=0),i<r-1&&(o=tR(o,e,n,r,i+1,a)),i>=n&&(o=e<0?s.contentMatchAt(0).fillBefore(o,a<=i).append(o):o.append(s.contentMatchAt(s.childCount).fillBefore(pt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(o))}function g7(t,e,n){return e<t.openStart&&(t=new kt(tR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new kt(tR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const xJ={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 x7=null;function bJ(){return x7||(x7=document.implementation.createHTMLDocument("title"))}let HN=null;function DBe(t){let e=window.trustedTypes;return e?(HN||(HN=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),HN.createHTML(t)):t}function jBe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=bJ().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&xJ[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=DBe(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function OBe(t){let e=t.querySelectorAll(fa?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function LBe(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:a,openEnd:s}=t;for(let o=r.length-2;o>=0;o-=2){let c=n.nodes[r[o]];if(!c||c.hasRequiredAttrs())break;i=pt.from(c.create(r[o+1],i)),a++,s++}return new kt(i,a,s)}const Pa={},Ra={},IBe={touchstart:!0,touchmove:!0};class FBe{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 UBe(t){for(let e in Pa){let n=Pa[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{BBe(t,r)&&!LO(t,r)&&(t.editable||!(r.type in Ra))&&n(t,r)},IBe[e]?{passive:!0}:void 0)}ka&&t.dom.addEventListener("input",()=>null),nR(t)}function Gu(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function zBe(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 nR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>LO(t,r))})}function LO(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function BBe(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 HBe(t,e){!LO(t,e)&&Pa[e.type]&&(t.editable||!(e.type in Ra))&&Pa[e.type](t,e)}Ra.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!vJ(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(bc&&fa&&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))||kBe(t,n)?n.preventDefault():Gu(t,"key")};Ra.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ra.keypress=(t,e)=>{let n=e;if(vJ(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ks&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Kt)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function JM(t){return{left:t.clientX,top:t.clientY}}function $Be(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function IO(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let s=a.depth+1;s>0;s--)if(t.someProp(e,o=>s>a.depth?o(t,n,a.nodeAfter,a.before(s),i,!0):o(t,n,a.node(s),a.before(s),i,!1)))return!0;return!1}function 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 VBe(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 GBe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ht&&(r=n.node);let a=t.state.doc.resolve(e);for(let s=a.depth+1;s>0;s--){let o=s>a.depth?a.nodeAfter:a.node(s);if(Ht.isSelectable(o)){r&&n.$from.depth>0&&s>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(s);break}}return i!=null?(um(t,Ht.create(t.state.doc,i)),!0):!1}function WBe(t,e,n,r,i){return IO(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?GBe(t,n):VBe(t,n))}function qBe(t,e,n,r){return IO(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function KBe(t,e,n,r){return IO(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||XBe(t,n,r)}function XBe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(um(t,Kt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let s=a>i.depth?i.nodeAfter:i.node(a),o=i.before(a);if(s.inlineContent)um(t,Kt.create(r,o+1,o+1+s.content.size));else if(Ht.isSelectable(s))um(t,Ht.create(r,o));else continue;return!0}}function FO(t){return Kw(t)}const yJ=Ks?"metaKey":"ctrlKey";Pa.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=FO(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&$Be(n,t.input.lastClick)&&!n[yJ]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let s=t.posAtCoords(JM(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new YBe(t,s,n,!!r)):(a=="doubleClick"?qBe:KBe)(t,s.pos,s.inside,n)?n.preventDefault():Gu(t,"pointer"))};class YBe{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[yJ],this.allowDefault=r.shiftKey;let a,s;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);a=d.parent,s=d.depth?d.before():0}const o=i?null:r.target,c=o?e.docView.nearestDesc(o,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||u instanceof Ht&&u.from<=s&&u.to>s)&&(this.mightDrag={node:a,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&so&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Gu(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ac(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(JM(e))),this.updateAllowDefault(e),this.allowDefault||!n?Gu(this.view,"pointer"):WBe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ka&&this.mightDrag&&!this.mightDrag.node.isAtom||fa&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(um(this.view,un.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Gu(this.view,"pointer")}move(e){this.updateAllowDefault(e),Gu(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Pa.touchstart=t=>{t.input.lastTouch=Date.now(),FO(t),Gu(t,"pointer")};Pa.touchmove=t=>{t.input.lastTouch=Date.now(),Gu(t,"pointer")};Pa.contextmenu=t=>FO(t);function vJ(t,e){return t.composing?!0:ka&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const ZBe=bc?5e3:-1;Ra.compositionstart=Ra.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Kt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Kw(t,!0),t.markCursor=null;else if(Kw(t,!e.selection.empty),so&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let s=a<0?i.lastChild:i.childNodes[a-1];if(!s)break;if(s.nodeType==3){let o=t.domSelection();o&&o.collapse(s,s.nodeValue.length);break}else i=s,a=-1}}t.input.composing=!0}_J(t,ZBe)};Ra.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++,_J(t,20))};function _J(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Kw(t),e))}function wJ(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=JBe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function QBe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Vze(e.focusNode,e.focusOffset),r=Gze(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function JBe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Kw(t,e=!1){if(!(bc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),wJ(t),e||t.docView&&t.docView.dirty){let n=DO(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 e8e(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const rb=Ya&&ed<15||Um&&Yze<604;Pa.copy=Ra.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=rb?null:n.clipboardData,s=r.content(),{dom:o,text:c}=OO(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",o.innerHTML),a.setData("text/plain",c)):e8e(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function t8e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function n8e(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ib(t,r.value,null,i,e):ib(t,r.textContent,r.innerHTML,i,e)},50)}function ib(t,e,n,r,i){let a=fJ(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||kt.empty)))return!0;if(!a)return!1;let s=t8e(a),o=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(a);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function SJ(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," "):""}Ra.paste=(t,e)=>{let n=e;if(t.composing&&!bc)return;let r=rb?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ib(t,SJ(r),r.getData("text/html"),i,n)?n.preventDefault():n8e(t,n)};class MJ{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const r8e=Ks?"altKey":"ctrlKey";function EJ(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[r8e]}Pa.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(JM(n)),s;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Ht?i.to-1:i.to))){if(r&&r.mightDrag)s=Ht.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(s=Ht.create(t.state.doc,f.posBefore))}}let o=(s||t.state.selection).content(),{dom:c,text:u,slice:d}=OO(t,o);(!n.dataTransfer.files.length||!fa||ZQ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(rb?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",rb||n.dataTransfer.setData("text/plain",u),t.dragging=new MJ(d,EJ(t,n),s)};Pa.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ra.dragover=Ra.dragenter=(t,e)=>e.preventDefault();Ra.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(JM(n));if(!i)return;let a=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",x=>{s=x(s,t,!1)}):s=fJ(t,SJ(n.dataTransfer),rb?null:n.dataTransfer.getData("text/html"),!1,a);let o=!!(r&&EJ(t,n));if(t.someProp("handleDrop",x=>x(t,n,s||kt.empty,o))){n.preventDefault();return}if(!s)return;n.preventDefault();let c=s?kQ(t.state.doc,a.pos,s):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,g=u.doc;if(f?u.replaceRangeWith(d,d,s.content.firstChild):u.replaceRange(d,d,s),u.doc.eq(g))return;let m=u.doc.resolve(d);if(f&&Ht.isSelectable(s.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new Ht(m));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,y,b,M)=>x=M),u.setSelection(jO(t,m,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Pa.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Ac(t)},20))};Pa.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)};Pa.beforeinput=(t,e)=>{if(fa&&bc&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(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 Ra)Pa[t]=Ra[t];function ab(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||jh,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new Ea(a-r,a-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&&ab(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class nd{constructor(e,n){this.attrs=e,this.spec=n||jh}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=s?null:new Ea(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof nd&&ab(this.attrs,e.attrs)&&ab(this.spec,e.spec)}static is(e){return e.type instanceof nd}destroy(){}}class UO{constructor(e,n){this.attrs=e,this.spec=n||jh}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=a.pos?null:new Ea(a.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof UO&&ab(this.attrs,e.attrs)&&ab(this.spec,e.spec)}destroy(){}}class Ea{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ea(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 Ea(e,e,new Xw(n,r))}static inline(e,n,r,i){return new Ea(e,n,new nd(r,i))}static node(e,n,r,i){return new Ea(e,n,new UO(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof nd}get widget(){return this.type instanceof Xw}}const Bp=[],jh={};class yr{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,jh):da}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=n&&o.to>=e&&(!a||a(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,n-o,r,i+o,a)}}map(e,n,r){return this==da||e.maps.length==0?this:this.mapInner(e,n,0,0,r||jh)}mapInner(e,n,r,i,a){let s;for(let o=0;o<this.local.length;o++){let c=this.local[o].map(e,r,i);c&&c.type.valid(n,c)?(s||(s=[])).push(c):a.onRemove&&a.onRemove(this.local[o].spec)}return this.children.length?i8e(this.children,s||[],e,n,r,i,a):s?new yr(s.sort(Oh),Bp):da}add(e,n){return n.length?this==da?yr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((o,c)=>{let u=c+r,d;if(d=TJ(n,o,u)){for(i||(i=this.children.slice());a<i.length&&i[a]<c;)a+=3;i[a]==c?i[a+2]=i[a+2].addInner(o,d,u+1):i.splice(a,0,c,c+o.nodeSize,Yw(d,o,u+1,jh)),a+=3}});let s=AJ(a?CJ(n):n,-r);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||s.splice(o--,1);return new yr(s.length?this.local.concat(s).sort(Oh):this.local,i||this.children)}remove(e){return e.length==0||this==da?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let s,o=r[a]+n,c=r[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>o&&f.to<c&&(e[d]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(s,o+1);u!=da?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,s;a<e.length;a++)if(s=e[a])for(let o=0;o<i.length;o++)i[o].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(o--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new yr(i,r):da}forChild(e,n){if(this==da)return this;if(n.isLeaf)return yr.empty;let r,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(r=this.children[o+2]);break}let a=e+1,s=a+n.content.size;for(let o=0;o<this.local.length;o++){let c=this.local[o];if(c.from<s&&c.to>a&&c.type instanceof nd){let u=Math.max(a,c.from)-a,d=Math.min(s,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let o=new yr(i.sort(Oh),Bp);return r?new Iu([o,r]):o}return r||da}eq(e){if(this==e)return!0;if(!(e instanceof yr)||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 zO(this.localsInner(e))}localsInner(e){if(this==da)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)}}yr.empty=new yr([],[]);yr.removeOverlap=zO;const da=yr.empty;class Iu{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,jh));return Iu.from(r)}forChild(e,n){if(n.isLeaf)return yr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=da&&(a instanceof Iu?r=r.concat(a.members):r.push(a))}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 a=this.members[i].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let s=0;s<a.length;s++)n.push(a[s])}}return n?zO(r?n:n.sort(Oh)):Bp}static from(e){switch(e.length){case 0:return da;case 1:return e[0];default:return new Iu(e.every(n=>n instanceof yr)?e:e.reduce((n,r)=>n.concat(r instanceof yr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function i8e(t,e,n,r,i,a,s){let o=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((g,m,x,v)=>{let y=v-x-(m-g);for(let b=0;b<o.length;b+=3){let M=o[b+1];if(M<0||g>M+d-f)continue;let S=o[b]+d-f;m>=S?o[b+1]=g<=S?-2:-1:g>=d&&y&&(o[b]+=y,o[b+1]+=y)}f+=y}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<o.length;u+=3)if(o[u+1]<0){if(o[u+1]==-2){c=!0,o[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let g=n.map(t[u+1]+a,-1),m=g-i,{index:x,offset:v}=r.content.findIndex(f),y=r.maybeChild(x);if(y&&v==f&&v+y.nodeSize==m){let b=o[u+2].mapInner(n,y,d+1,t[u]+a+1,s);b!=da?(o[u]=f,o[u+1]=m,o[u+2]=b):(o[u+1]=-2,c=!0)}else c=!0}if(c){let u=a8e(o,t,e,n,i,a,s),d=Yw(u,r,0,s);e=d.local;for(let f=0;f<o.length;f+=3)o[f+1]<0&&(o.splice(f,3),f-=3);for(let f=0,g=0;f<d.children.length;f+=3){let 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 yr(e.sort(Oh),o)}function AJ(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 Ea(i.from+e,i.to+e,i.type))}return n}function a8e(t,e,n,r,i,a,s){function o(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):s.onRemove&&s.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)o(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&o(t[c+2],e[c]+a+1);return n}function TJ(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,s;a<t.length;a++)(s=t[a])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[a]=null);return i}function CJ(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=[],a=!1;e.forEach((o,c)=>{let u=TJ(t,o,c+n);if(u){a=!0;let d=Yw(u,o,n+c+1,r);d!=da&&i.push(c,c+o.nodeSize,d)}});let s=AJ(a?CJ(t):t,-n).sort(Oh);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||(r.onRemove&&r.onRemove(s[o].spec),s.splice(o--,1));return s.length||i.length?new yr(s,i):da}function Oh(t,e){return t.from-e.from||t.to-e.to}function zO(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),b7(e,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),b7(e,i,r.copy(a.from,r.to)));break}}}return e}function b7(t,e,n){for(;e<t.length&&Oh(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!=da&&e.push(r)}),t.cursorWrapper&&e.push(yr.create(t.state.doc,[t.cursorWrapper.deco])),Iu.from(e)}const s8e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},o8e=Ya&&ed<=11;class l8e{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 c8e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new l8e,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]);Ya&&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()}),o8e&&(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,s8e)),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(u7(this.view)){if(this.suppressingSelectionUpdates)return Ac(this.view);if(Ya&&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 a=e.focusNode;a;a=Fm(a))n.add(a);for(let a=e.anchorNode;a;a=Fm(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&u7(e)&&!this.ignoreSelectionChange(r),a=-1,s=-1,o=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(a=a<0?f.from:Math.min(f.from,a),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(o=!0))}if(so&&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||h8e(e,f)!=m)&&g.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ZM(r)&&(u=DO(e))&&u.eq(un.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ac(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,s),u8e(e)),this.handleDOMChange(a,s,o,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ac(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(Ya&&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)&&(a=g)}let s=i&&i.parentNode==e.target?ea(i)+1:0,o=r.localPosFromDOM(e.target,s,-1),c=a&&a.parentNode==e.target?ea(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:o,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let y7=new WeakMap,v7=!1;function u8e(t){if(!y7.has(t)&&(y7.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=so,v7)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."),v7=!0}}function _7(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return of(s.node,s.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function d8e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return _7(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?_7(t,n):null}function h8e(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 f8e(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:s,to:o}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],ZM(c)||u.push({node:c.focusNode,offset:c.focusOffset})),fa&&t.input.lastKeyCode===8)for(let y=a;y>i;y--){let b=r.childNodes[y-1],M=b.pmViewDesc;if(b.nodeName=="BR"&&!M){a=y;break}if(!M||M.size)break}let f=t.state.doc,g=t.someProp("domParser")||e0.fromSchema(t.state.schema),m=f.resolve(s),x=null,v=g.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:a,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:p8e,context:m});if(u&&u[0].pos!=null){let y=u[0].pos,b=u[1]&&u[1].pos;b==null&&(b=y),x={anchor:y+s,head:b+s}}return{doc:v,sel:x,from:s,to:o}}function p8e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ka&&/^(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||ka&&/^(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 m8e=/^(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 g8e(t,e,n,r,i){let a=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=DO(t,N);if(I&&!t.state.selection.eq(I)){if(fa&&bc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,dh(13,"Enter"))))return;let C=t.state.tr.setSelection(I);N=="pointer"?C.setMeta("pointer",!0):N=="key"&&C.scrollIntoView(),a&&C.setMeta("composition",a),t.dispatch(C)}return}let s=t.state.doc.resolve(e),o=s.sharedDepth(n);e=s.before(o+1),n=t.state.doc.resolve(n).after(o+1);let c=t.state.selection,u=f8e(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=y8e(f.content,u.doc.content,u.from,g,m);if(x&&t.input.domChangeCount++,(Um&&t.input.lastIOSEnter>Date.now()-225||bc)&&i.some(N=>N.nodeType==1&&!m8e.test(N.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",N=>N(t,dh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof Kt&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let N=w7(t,t.state.doc,u.sel);if(N&&!N.eq(t.state.selection)){let I=t.state.tr.setSelection(N);a&&I.setMeta("composition",a),t.dispatch(I)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof Kt&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),Ya&&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 v=u.doc.resolveNoCache(x.start-u.from),y=u.doc.resolveNoCache(x.endB-u.from),b=d.resolve(x.start),M=v.sameParent(y)&&v.parent.inlineContent&&b.end()>=x.endA;if((Um&&t.input.lastIOSEnter>Date.now()-225&&(!M||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!M&&v.pos<u.doc.content.size&&(!v.sameParent(y)||!v.parent.inlineContent)&&v.pos<y.pos&&!/\S/.test(u.doc.textBetween(v.pos,y.pos,"","")))&&t.someProp("handleKeyDown",N=>N(t,dh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&b8e(d,x.start,x.endA,v,y)&&t.someProp("handleKeyDown",N=>N(t,dh(8,"Backspace")))){bc&&fa&&t.domObserver.suppressSelectionUpdates();return}fa&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),bc&&!M&&v.start()!=y.start()&&y.parentOffset==0&&v.depth==y.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,y=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,dh(13,"Enter"))})},20));let S=x.start,A=x.endA,T=N=>{let I=N||t.state.tr.replace(S,A,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let C=w7(t,I.doc,u.sel);C&&!(fa&&t.composing&&C.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==S||C.head==I.mapping.map(A)-1)||Ya&&C.empty&&C.head==S)&&I.setSelection(C)}return a&&I.setMeta("composition",a),I.scrollIntoView()},k;if(M)if(v.pos==y.pos){Ya&&ed<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ac(t),20));let N=T(t.state.tr.delete(S,A)),I=d.resolve(x.start).marksAcross(d.resolve(x.endA));I&&N.ensureMarks(I),t.dispatch(N)}else if(x.endA==x.endB&&(k=x8e(v.parent.content.cut(v.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,x.endA-b.start())))){let N=T(t.state.tr);k.type=="add"?N.addMark(S,A,k.mark):N.removeMark(S,A,k.mark),t.dispatch(N)}else if(v.parent.child(v.index()).isText&&v.index()==y.index()-(y.textOffset?0:1)){let N=v.parent.textBetween(v.parentOffset,y.parentOffset),I=()=>T(t.state.tr.insertText(N,S,A));t.someProp("handleTextInput",C=>C(t,S,A,N,I))||t.dispatch(I())}else t.dispatch(T());else t.dispatch(T())}function w7(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:jO(t,e.resolve(n.anchor),e.resolve(n.head))}function x8e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,s,o,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)a=n[d].removeFromSet(a);if(i.length==1&&a.length==0)o=i[0],s="add",c=d=>d.mark(o.addToSet(d.marks));else if(i.length==0&&a.length==1)o=a[0],s="remove",c=d=>d.mark(o.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(pt.from(u).eq(t))return{mark:o,type:s}}function b8e(t,e,n,r,i){if(n-e<=i.pos-r.pos||VN(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let o=a.nodeAfter;return o!=null&&n==e+o.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let s=t.resolve(VN(a,!0,!0));return!s.parent.isTextblock||s.pos>n||VN(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.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 a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function y8e(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:s,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,a-Math.min(s,o));r-=s+c-a}if(s<a&&t.size<e.size){let c=r<=a&&r>=s?a-r:0;a-=c,a&&a<e.size&&S7(e.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-s),s=a}else if(o<a){let c=r<=a&&r>=o?a-r:0;a-=c,a&&a<t.size&&S7(t.textBetween(a-1,a+1))&&(a+=c?1:-1),s=a+(s-o),o=a}return{start:a,endA:s,endB:o}}function S7(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 NJ{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 FBe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(C7),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=A7(this),E7(this),this.nodeViews=T7(this),this.docView=i7(this.state.doc,M7(this),$N(this),this.dom,this),this.domObserver=new c8e(this,(r,i,a,s)=>g8e(this,r,i,a,s)),this.domObserver.start(),UBe(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&&nR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(C7),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,s=!1;e.storedMarks&&this.composing&&(wJ(this),s=!0),this.state=e;let o=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(o||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let m=T7(this);_8e(m,this.nodeViews)&&(this.nodeViews=m,a=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&nR(this),this.editable=A7(this),E7(this);let c=$N(this),u=M7(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(s=!0);let g=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Jze(this);if(s){this.domObserver.stop();let m=f&&(Ya||fa)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&v8e(i.selection,e.selection);if(f){let x=fa?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=QBe(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=i7(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&SBe(this))?Ac(this,m):(uJ(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&&eBe(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&&QV(this,n.getBoundingClientRect(),e)}else QV(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new MJ(e.slice,e.move,i<0?void 0:Ht.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let o=this.directPlugins[s].props[e];if(o!=null&&(i=n?n(o):o))return i}let a=this.state.plugins;if(a)for(let s=0;s<a.length;s++){let o=a[s].props[e];if(o!=null&&(i=n?n(o):o))return i}}hasFocus(){if(Ya){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&&tBe(this.dom),Ac(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return sBe(this,e)}coordsAtPos(e,n=1){return nJ(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 dBe(this,n||this.state,e)}pasteHTML(e,n){return ib(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ib(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return OO(this,e)}destroy(){this.docView&&(zBe(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,Hze())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return HBe(this,e)}domSelectionRange(){let e=this.domSelection();return e?ka&&this.root.nodeType===11&&qze(this.dom.ownerDocument)==this.dom&&d8e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}NJ.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function M7(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"),[Ea.node(0,t.state.doc.content.size,e)]}function E7(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:Ea.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function A7(t){return!t.someProp("editable",e=>e(t.state)===!1)}function v8e(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 T7(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 _8e(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 C7(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:'"'},w8e=typeof navigator<"u"&&/Mac/.test(navigator.platform),S8e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ta=0;ta<10;ta++)md[48+ta]=md[96+ta]=String(ta);for(var ta=1;ta<=24;ta++)md[ta+111]="F"+ta;for(var ta=65;ta<=90;ta++)md[ta]=String.fromCharCode(ta+32),Zw[ta]=String.fromCharCode(ta);for(var GN in md)Zw.hasOwnProperty(GN)||(Zw[GN]=md[GN]);function M8e(t){var e=w8e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||S8e&&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 E8e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),A8e=typeof navigator<"u"&&/Win/.test(navigator.platform);function T8e(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o++){let c=e[o];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))E8e?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function C8e(t){let e=Object.create(null);for(let n in t)e[T8e(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 N8e(t){return new Er({props:{handleKeyDown:kJ(t)}})}function kJ(t){let e=C8e(t);return function(n,r){let i=M8e(r),a,s=e[WN(i,r)];if(s&&s(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)&&!(A8e&&r.ctrlKey&&r.altKey)&&(a=md[r.keyCode])&&a!=i){let o=e[WN(a,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var k8e=Object.defineProperty,BO=(t,e)=>{for(var n in e)k8e(t,n,{get:e[n],enumerable:!0})};function eE(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var tE=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([s,o])=>[s,(...u)=>{const d=o(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s=[],o=!!t,c=t||i.tr,u=()=>(!o&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),s.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...x)=>{const v=this.buildProps(c,e),y=g(...x)(v);return s.push(y),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([o,c])=>[o,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s={tr:t,editor:r,view:a,state:eE({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([o,c])=>[o,(...u)=>c(...u)(s)]))}};return s}},PJ={};BO(PJ,{blur:()=>P8e,clearContent:()=>R8e,clearNodes:()=>D8e,command:()=>j8e,createParagraphNear:()=>O8e,cut:()=>L8e,deleteCurrentNode:()=>I8e,deleteNode:()=>F8e,deleteRange:()=>U8e,deleteSelection:()=>z8e,enter:()=>B8e,exitCode:()=>H8e,extendMarkRange:()=>$8e,first:()=>V8e,focus:()=>W8e,forEach:()=>q8e,insertContent:()=>K8e,insertContentAt:()=>Z8e,joinBackward:()=>e6e,joinDown:()=>J8e,joinForward:()=>t6e,joinItemBackward:()=>n6e,joinItemForward:()=>r6e,joinTextblockBackward:()=>i6e,joinTextblockForward:()=>a6e,joinUp:()=>Q8e,keyboardShortcut:()=>o6e,lift:()=>l6e,liftEmptyBlock:()=>c6e,liftListItem:()=>u6e,newlineInCode:()=>d6e,resetAttributes:()=>h6e,scrollIntoView:()=>f6e,selectAll:()=>p6e,selectNodeBackward:()=>m6e,selectNodeForward:()=>g6e,selectParentNode:()=>x6e,selectTextblockEnd:()=>b6e,selectTextblockStart:()=>y6e,setContent:()=>v6e,setMark:()=>F6e,setMeta:()=>U6e,setNode:()=>z6e,setNodeSelection:()=>B6e,setTextDirection:()=>H6e,setTextSelection:()=>$6e,sinkListItem:()=>V6e,splitBlock:()=>G6e,splitListItem:()=>W6e,toggleList:()=>q6e,toggleMark:()=>K6e,toggleNode:()=>X6e,toggleWrap:()=>Y6e,undoInputRule:()=>Z6e,unsetAllMarks:()=>Q6e,unsetMark:()=>J6e,unsetTextDirection:()=>eHe,updateAttributes:()=>tHe,wrapIn:()=>nHe,wrapInList:()=>rHe});var P8e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),R8e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),D8e=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:s})=>{t.doc.nodesBetween(a.pos,s.pos,(o,c)=>{if(o.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),g=u.resolve(d.map(c+o.nodeSize)),m=f.blockRange(g);if(!m)return;const x=hg(m);if(o.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(m.start,v)}(x||x===0)&&e.lift(m,x)})}),!0},j8e=t=>e=>t(e),O8e=()=>({state:t,dispatch:e})=>WQ(t,e),L8e=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,a.content),r.setSelection(new Kt(r.doc.resolve(Math.max(s-1,0)))),!0},I8e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const o=i.before(a),c=i.after(a);t.delete(o,c).scrollIntoView()}return!0}return!1};function 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 F8e=t=>({tr:e,state:n,dispatch:r})=>{const i=ii(t,n.schema),a=e.selection.$anchor;for(let s=a.depth;s>0;s-=1)if(a.node(s).type===i){if(r){const c=a.before(s),u=a.after(s);e.delete(c,u).scrollIntoView()}return!0}return!1},U8e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},z8e=()=>({state:t,dispatch:e})=>TO(t,e),B8e=()=>({commands:t})=>t.keyboardShortcut("Enter"),H8e=()=>({state:t,dispatch:e})=>Tze(t,e);function HO(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]:HO(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function RJ(t,e,n={}){return t.find(r=>r.type===e&&Qw(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function N7(t,e,n={}){return!!RJ(t,e,n)}function $O(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),!RJ([...i.node.marks],e,n)))return;let s=i.index,o=t.start()+i.offset,c=s+1,u=o+i.node.nodeSize;for(;s>0&&N7([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;c<t.parent.childCount&&N7([...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 $8e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Bc(t,r.schema),{doc:s,selection:o}=n,{$from:c,from:u,to:d}=o;if(i){const f=$O(c,a,e);if(f&&f.from<=u&&f.to>=d){const g=Kt.create(s,f.from,f.to);n.setSelection(g)}}return!0},V8e=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 DJ(t){return t instanceof Kt}function yh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function jJ(t,e=null){if(!e)return null;const n=un.atStart(t),r=un.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?Kt.create(t,yh(0,i,a),yh(t.content.size,i,a)):Kt.create(t,yh(e,i,a),yh(e,i,a))}function G8e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function VO(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var W8e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(VO()||G8e())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!DJ(n.state.selection))return s(),!0;const o=jJ(i.doc,t)||n.state.selection,c=n.state.selection.eq(o);return a&&(c||i.setSelection(o),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},q8e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),K8e=(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 F_(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 s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),sb("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,o="";const c=new yQ({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(s=!0,o=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?e0.fromSchema(c).parseSlice(F_(t),n.parseOptions):e0.fromSchema(c).parse(F_(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const a=e0.fromSchema(e);return n.slice?a.parseSlice(F_(t),n.parseOptions).content:a.parse(F_(t),n.parseOptions)}return sb("",e,n)}function X8e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Oi||i instanceof Ii))return;const a=t.mapping.maps[r];let s=0;a.forEach((o,c,u,d)=>{s===0&&(s=d)}),t.setSelection(un.near(t.doc.resolve(s),n))}var Y8e=t=>!("type"in t),Z8e=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var s;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const c=y=>{a.emit("contentError",{editor:a,error:y,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{sb(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(y){c(y)}try{o=sb(e,a.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(y){return c(y),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,m=!0;if((Y8e(o)?o:[o]).forEach(y=>{y.check(),g=g?y.isText&&y.marks.length===0:!1,m=m?y.isBlock:!1}),d===f&&m){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,f+=1)}let v;if(g){if(Array.isArray(e))v=e.map(y=>y.text||"").join("");else if(e instanceof pt){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),v=y}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,f)}else{v=o;const y=r.doc.resolve(d),b=y.node(),M=y.parentOffset===0,S=b.isText||b.isTextblock,A=b.content.size>0;M&&S&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,v)}n.updateSelection&&X8e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},Q8e=()=>({state:t,dispatch:e})=>Mze(t,e),J8e=()=>({state:t,dispatch:e})=>Eze(t,e),e6e=()=>({state:t,dispatch:e})=>UQ(t,e),t6e=()=>({state:t,dispatch:e})=>$Q(t,e),n6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=KM(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},r6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=KM(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},i6e=()=>({state:t,dispatch:e})=>wze(t,e),a6e=()=>({state:t,dispatch:e})=>Sze(t,e);function LJ(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function s6e(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o+=1){const c=e[o];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))VO()||LJ()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var o6e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=s6e(t).split(/-(?!$)/),s=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),o=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,o))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function gd(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,s=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=>s?s.name===f.node.type.name:!0).filter(f=>Qw(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}var l6e=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return gd(n,i,e)?Aze(n,r):!1},c6e=()=>({state:t,dispatch:e})=>qQ(t,e),u6e=t=>({state:e,dispatch:n})=>{const r=ii(t,e.schema);return Fze(r)(e,n)},d6e=()=>({state:t,dispatch:e})=>GQ(t,e);function nE(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function k7(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 h6e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=nE(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=ii(t,r.schema)),o==="mark"&&(s=Bc(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{a&&a===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,k7(d.attrs,e))),s&&d.marks.length&&d.marks.forEach(g=>{s===g.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,s.create(k7(g.attrs,e))))})})}),c},f6e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),p6e=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ms(t.doc);t.setSelection(n)}return!0},m6e=()=>({state:t,dispatch:e})=>BQ(t,e),g6e=()=>({state:t,dispatch:e})=>VQ(t,e),x6e=()=>({state:t,dispatch:e})=>kze(t,e),b6e=()=>({state:t,dispatch:e})=>Dze(t,e),y6e=()=>({state:t,dispatch:e})=>Rze(t,e);function rR(t,e,n={},r={}){return sb(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var v6e=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:s,commands:o})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=rR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return s&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return s&&a.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function IJ(t,e){const n=Bc(e,t.schema),{from:r,to:i,empty:a}=t.selection,s=[];a?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{s.push(...c.marks)});const o=s.find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function FJ(t,e){const n=new OQ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function _6e(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 w6e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function S6e(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 rE(t){return e=>S6e(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 GO(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Bt(e,"addExtensions",n);return r?[e,...GO(r())]:e}).flat(10)}function WO(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 Un(t,e=void 0,...n){return UJ(t)?e?t.bind(e)(...n):t(...n):t}function M6e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function zm(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function zJ(t){const e=[],{nodeExtensions:n,markExtensions:r}=zm(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage,extensions:i},c=Bt(s,"addGlobalAttributes",o);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([g,m])=>{e.push({type:f,name:g,attribute:{...a,...m}})})})})}),i.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage},c=Bt(s,"addAttributes",o);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const g={...a,...f};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:s.name,name:d,attribute:g})})}),e}function Dr(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const o=a?String(a).split(" "):[],c=r[i]?r[i].split(" "):[],u=o.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const o=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,g]=d.split(":").map(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]=a}),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 E6e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function P7(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,s)=>{const o=s.attribute.parseHTML?s.attribute.parseHTML(n):E6e(n.getAttribute(s.name));return o==null?a:{...a,[s.name]:o}},{});return{...r,...i}}}}function R7(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&M6e(n)?!1:n!=null))}function D7(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 A6e(t,e){var n;const r=zJ(t),{nodeExtensions:i,markExtensions:a}=zm(t),s=(n=i.find(u=>Bt(u,"topNode")))==null?void 0:n.name,o=Object.fromEntries(i.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((b,M)=>{const S=Bt(M,"extendNodeSchema",f);return{...b,...S?S(u):{}}},{}),m=R7({...g,content:Un(Bt(u,"content",f)),marks:Un(Bt(u,"marks",f)),group:Un(Bt(u,"group",f)),inline:Un(Bt(u,"inline",f)),atom:Un(Bt(u,"atom",f)),selectable:Un(Bt(u,"selectable",f)),draggable:Un(Bt(u,"draggable",f)),code:Un(Bt(u,"code",f)),whitespace:Un(Bt(u,"whitespace",f)),linebreakReplacement:Un(Bt(u,"linebreakReplacement",f)),defining:Un(Bt(u,"defining",f)),isolating:Un(Bt(u,"isolating",f)),attrs:Object.fromEntries(d.map(D7))}),x=Un(Bt(u,"parseHTML",f));x&&(m.parseDOM=x.map(b=>P7(b,d)));const v=Bt(u,"renderHTML",f);v&&(m.toDOM=b=>v({node:b,HTMLAttributes:Jw(b,d)}));const y=Bt(u,"renderText",f);return y&&(m.toText=y),[u.name,m]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((y,b)=>{const M=Bt(b,"extendMarkSchema",f);return{...y,...M?M(u):{}}},{}),m=R7({...g,inclusive:Un(Bt(u,"inclusive",f)),excludes:Un(Bt(u,"excludes",f)),group:Un(Bt(u,"group",f)),spanning:Un(Bt(u,"spanning",f)),code:Un(Bt(u,"code",f)),attrs:Object.fromEntries(d.map(D7))}),x=Un(Bt(u,"parseHTML",f));x&&(m.parseDOM=x.map(y=>P7(y,d)));const v=Bt(u,"renderHTML",f);return v&&(m.toDOM=y=>v({mark:y,HTMLAttributes:Jw(y,d)})),[u.name,m]}));return new yQ({topNode:s,nodes:o,marks:c})}function T6e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function qO(t){return t.sort((n,r)=>{const i=Bt(n,"priority")||100,a=Bt(r,"priority")||100;return i>a?-1:i<a?1:0})}function BJ(t){const e=qO(GO(t)),n=T6e(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 HJ(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
- `,textSerializers:s={}}=n||{};let o="";return t.nodesBetween(r,i,(c,u,d,f)=>{var g;c.isBlock&&u>r&&(o+=a);const m=s?.[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 C6e(t,e){const n={from:0,to:t.content.size};return HJ(t,n,e)}function $J(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function N6e(t,e){const n=ii(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,o=>{a.push(o)});const s=a.reverse().find(o=>o.type.name===n.name);return s?{...s.attrs}:{}}function VJ(t,e){const n=nE(typeof e=="string"?e:e.name,t.schema);return n==="node"?N6e(t,e):n==="mark"?IJ(t,e):{}}function k6e(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 P6e(t){const e=k6e(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,s)=>s!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function GJ(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const s=[];if(i.ranges.length)i.forEach((o,c)=>{s.push({from:o,to:c})});else{const{from:o,to:c}=n[a];if(o===void 0||c===void 0)return;s.push({from:o,to:c})}s.forEach(({from:o,to:c})=>{const u=e.slice(a).map(o,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),g=e.invert().map(d);r.push({oldRange:{from:f,to:g},newRange:{from:u,to:d}})})}),P6e(r)}function KO(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),s=$O(a,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:a,to:a+i.nodeSize,mark:s})))}),r}var R6e=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,s=null;for(;a>0&&s===null;){const o=i.node(a);o?.type.name===e?s=o:a-=1}return[s,a]};function qN(t,e){return e.nodes[t]||e.marks[t]||null}function x1(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var D6e=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,s,o)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:s,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function iR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Bc(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>Qw(f.attrs,n,{strict:!1}));let s=0;const o=[];if(i.forEach(({$from:f,$to:g})=>{const m=f.pos,x=g.pos;t.doc.nodesBetween(m,x,(v,y)=>{if(!v.isText&&!v.marks.length)return;const b=Math.max(m,y),M=Math.min(x,y+v.nodeSize),S=M-b;s+=S,o.push(...v.marks.map(A=>({mark:A,from:b,to:M})))})}),s===0)return!1;const c=o.filter(f=>a?a.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=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,g)=>f+g.to-g.from,0);return(c>0?c+u:c)>=s}function j6e(t,e,n={}){if(!e)return gd(t,null,n)||iR(t,null,n);const r=nE(e,t.schema);return r==="node"?gd(t,e,n):r==="mark"?iR(t,e,n):!1}var O6e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=rE(o=>o.type.name===e)(t.selection);if(!a)return!1;const s=t.doc.resolve(a.pos+1);return i.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},L6e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function j7(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function O7(t,e){const{nodeExtensions:n}=zm(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Un(Bt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function iE(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(iE(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function WJ(t){return t instanceof Ht}function I6e(t,e,n){var r;const{selection:i}=e;let a=null;if(DJ(i)&&(a=i.$cursor),a){const o=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(u=>u.type.excludes(n)))}const{ranges:s}=i;return s.some(({$from:o,$to:c})=>{let u=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,c.pos,(d,f,g)=>{if(u)return!1;if(d.isInline){const m=!g||g.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));u=m&&x}return!u}),u})}var F6e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:s,ranges:o}=a,c=Bc(t,r.schema);if(i)if(s){const u=IJ(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),v=Math.min(m+g.nodeSize,f);g.marks.find(b=>b.type===c)?g.marks.forEach(b=>{c===b.type&&n.addMark(x,v,c.create({...b.attrs,...e}))}):n.addMark(x,v,c.create(e))})});return I6e(r,n,c)},U6e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),z6e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=ii(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:o})=>XV(a,{...s,...e})(n)?!0:o.clearNodes()).command(({state:o})=>XV(a,{...s,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},B6e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=yh(t,0,r.content.size),a=Ht.create(r,i);e.setSelection(a)}return!0},H6e=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let s,o;return typeof e=="number"?(s=e,o=e):e&&"from"in e&&"to"in e?(s=e.from,o=e.to):(s=a.from,o=a.to),i&&n.doc.nodesBetween(s,o,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},$6e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,s=Kt.atStart(r).from,o=Kt.atEnd(r).to,c=yh(i,s,o),u=yh(a,s,o),d=Kt.create(r,c,u);e.setSelection(d)}return!0},V6e=t=>({state:e,dispatch:n})=>{const r=ii(t,e.schema);return Bze(r)(e,n)};function L7(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 G6e=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:s}=e,{$from:o,$to:c}=a,u=i.extensionManager.attributes,d=x1(u,o.node().type.name,o.node().attrs);if(a instanceof Ht&&a.node.isBlock)return!o.parentOffset||!Ec(s,o.pos)?!1:(r&&(t&&L7(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:_6e(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&&(a instanceof Kt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,m),g&&!f&&!o.parentOffset&&o.parent.type!==g)){const v=e.mapping.map(o.before()),y=e.doc.resolve(v);o.node(-1).canReplaceWith(y.index(),y.index()+1,g)&&e.setNodeMarkup(e.mapping.map(o.before()),g)}t&&L7(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},W6e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var s;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=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==o||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let b=pt.empty;const M=c.index(-1)?1:c.index(-2)?2:3;for(let I=c.depth-M;I>=c.depth-3;I-=1)b=pt.from(c.node(I).copy(b));const S=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...x1(g,c.node().type.name,c.node().attrs),...e},T=((s=o.contentMatch.defaultType)==null?void 0:s.createAndFill(A))||void 0;b=b.append(pt.from(o.createAndFill(null,T)||void 0));const k=c.before(c.depth-(M-1));n.replace(k,c.after(-S),new kt(b,4-M,0));let N=-1;n.doc.nodesBetween(k,n.doc.content.size,(I,C)=>{if(N>-1)return!1;I.isTextblock&&I.content.size===0&&(N=C+1)}),N>-1&&n.setSelection(Kt.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const m=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...x1(g,f.type.name,f.attrs),...e},v={...x1(g,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const y=m?[{type:o,attrs:x},{type:m,attrs:v}]:[{type:o,attrs:x}];if(!Ec(n.doc,c.pos,2))return!1;if(i){const{selection:b,storedMarks:M}=r,{splittableMarks:S}=a.extensionManager,A=M||b.$to.parentOffset&&b.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!A||!i)return!0;const T=A.filter(k=>S.includes(k.type.name));n.ensureMarks(T)}return!0},KN=(t,e)=>{const n=rE(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&Sd(t.doc,n.pos)&&t.join(n.pos),!0},XN=(t,e)=>{const n=rE(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&Sd(t.doc,r)&&t.join(r),!0},q6e=(t,e,n,r={})=>({editor:i,tr:a,state:s,dispatch:o,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,m=ii(t,s.schema),x=ii(e,s.schema),{selection:v,storedMarks:y}=s,{$from:b,$to:M}=v,S=b.blockRange(M),A=y||v.$to.parentOffset&&v.$from.marks();if(!S)return!1;const T=rE(k=>O7(k.type.name,f))(v);if(S.depth>=1&&T&&S.depth-T.depth<=1){if(T.node.type===m)return u.liftListItem(x);if(O7(T.node.type.name,f)&&m.validContent(T.node.content)&&o)return c().command(()=>(a.setNodeMarkup(T.pos,m),!0)).command(()=>KN(a,m)).command(()=>XN(a,m)).run()}return!n||!A||!o?c().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>KN(a,m)).command(()=>XN(a,m)).run():c().command(()=>{const k=d().wrapInList(m,r),N=A.filter(I=>g.includes(I.type.name));return a.ensureMarks(N),k?!0:u.clearNodes()}).wrapInList(m,r).command(()=>KN(a,m)).command(()=>XN(a,m)).run()},K6e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,s=Bc(t,r.schema);return iR(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:a}):i.setMark(s,e)},X6e=(t,e,n={})=>({state:r,commands:i})=>{const a=ii(t,r.schema),s=ii(e,r.schema),o=gd(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),o?i.setNode(s,c):i.setNode(a,{...c,...n})},Y6e=(t,e={})=>({state:n,commands:r})=>{const i=ii(t,n.schema);return gd(n,i,e)?r.lift(i):r.wrapIn(i,e)},Z6e=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const s=t.tr,o=a.transform;for(let c=o.steps.length-1;c>=0;c-=1)s.step(o.steps[c].invert(o.docs[c]));if(a.text){const c=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else s.delete(a.from,a.to)}return!0}}return!1},Q6e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},J6e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:o}=n,c=Bc(t,r.schema),{$from:u,empty:d,ranges:f}=o;if(!i)return!0;if(d&&s){let{from:g,to:m}=o;const x=(a=u.marks().find(y=>y.type===c))==null?void 0:a.attrs,v=$O(u,c,x);v&&(g=v.from,m=v.to),n.removeMark(g,m,c)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,c)});return n.removeStoredMark(c),!0},eHe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,s;return typeof t=="number"?(a=t,s=t):t&&"from"in t&&"to"in t?(a=t.from,s=t.to):(a=i.from,s=i.to),r&&e.doc.nodesBetween(a,s,(o,c)=>{if(o.isText)return;const u={...o.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},tHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=nE(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=ii(t,r.schema)),o==="mark"&&(s=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,v;n.selection.empty?r.doc.nodesBetween(d,f,(y,b)=>{a&&a===y.type&&(c=!0,x=Math.max(b,d),v=Math.min(b+y.nodeSize,f),g=b,m=y)}):r.doc.nodesBetween(d,f,(y,b)=>{b<d&&a&&a===y.type&&(c=!0,x=Math.max(b,d),v=Math.min(b+y.nodeSize,f),g=b,m=y),b>=d&&b<=f&&(a&&a===y.type&&(c=!0,i&&n.setNodeMarkup(b,void 0,{...y.attrs,...e})),s&&y.marks.length&&y.marks.forEach(M=>{if(s===M.type&&(c=!0,i)){const S=Math.max(b,d),A=Math.min(b+y.nodeSize,f);n.addMark(S,A,s.create({...M.attrs,...e}))}}))}),m&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(y=>{s===y.type&&i&&n.addMark(x,v,s.create({...y.attrs,...e}))}))}),c},nHe=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return jze(i,e)(n,r)},rHe=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return Oze(i,e)(n,r)},iHe=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={}}},aE=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},aHe=(t,e)=>{if(HO(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:a,rules:s,plugin:o}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let d=!1;const f=D6e(u)+a;return s.forEach(g=>{if(d)return;const m=aHe(f,g.find);if(!m)return;const x=c.state.tr,v=eE({state:c.state,transaction:x}),y={from:r-(m[0].length-a.length),to:i},{commands:b,chain:M,can:S}=new tE({editor:n,state:v});g.handler({state:v,range:y,match:m,commands:b,chain:M,can:S})===null||!x.steps.length||(g.undoable&&x.setMeta(o,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function sHe(t){const{editor:e,rules:n}=t,r=new Er({state:{init(){return null},apply(i,a,s){const o=i.getMeta(r);if(o)return o;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=WO(pt.from(d),s.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:a}},props:{handleTextInput(i,a,s,o){return U_({editor:e,from:a,to:s,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&U_({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?U_({editor:e,from:s.pos,to:s.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function oHe(t){return Object.prototype.toString.call(t).slice(8,-1)}function z_(t){return oHe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function qJ(t,e){const n={...t};return z_(t)&&z_(e)&&Object.keys(e).forEach(r=>{z_(e[r])&&z_(t[r])?n[r]=qJ(t[r],e[r]):n[r]=e[r]}),n}var XO=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{...Un(Bt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Un(Bt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>qJ(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}},Ed=class KJ extends XO{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new KJ(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(u=>u?.type.name===n.name))return!1;const c=s.find(u=>u?.type.name===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function lHe(t){return typeof t=="number"}var cHe=class{constructor(t){this.find=t.find,this.handler=t.handler}},uHe=(t,e,n)=>{if(HO(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function dHe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:s,dropEvent:o}=t,{commands:c,chain:u,can:d}=new tE({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(m,x)=>{var v,y,b,M,S;if((y=(v=m.type)==null?void 0:v.spec)!=null&&y.code||!(m.isText||m.isTextblock||m.isInline))return;const A=(S=(M=(b=m.content)==null?void 0:b.size)!=null?M:m.nodeSize)!=null?S:0,T=Math.max(r,x),k=Math.min(i,x+A);if(T>=k)return;const N=m.isText?m.text||"":m.textBetween(T-x,k-x,void 0,"");uHe(N,a.find,s).forEach(C=>{if(C.index===void 0)return;const D=T+C.index+1,F=D+C[0].length,O={from:n.tr.mapping.map(D),to:n.tr.mapping.map(F)},q=a.handler({state:n,range:O,match:C,commands:c,chain:u,can:d,pasteEvent:s,dropEvent:o});f.push(q)})}),f.every(m=>m!==null)}var B_=null,hHe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function fHe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const c=({state:d,from:f,to:g,rule:m,pasteEvt:x})=>{const v=d.tr,y=eE({state:d,transaction:v});if(!(!dHe({editor:e,state:y,from:Math.max(f-1,0),to:g.b-1,rule:m,pasteEvent:x,dropEvent:o})||!v.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(d=>new Er({view(f){const g=x=>{var v;r=(v=f.dom.parentElement)!=null&&v.contains(x.target)?f.dom.parentElement:null,r&&(B_=e)},m=()=>{B_&&(B_=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(a=r===f.dom.parentElement,o=g,!a){const m=B_;m?.isEditable&&setTimeout(()=>{const x=m.state.selection;x&&m.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,g)=>{var m;const x=(m=g.clipboardData)==null?void 0:m.getData("text/html");return s=g,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,m)=>{const x=f[0],v=x.getMeta("uiEvent")==="paste"&&!i,y=x.getMeta("uiEvent")==="drop"&&!a,b=x.getMeta("applyPasteRules"),M=!!b;if(!v&&!y&&!M)return;if(M){let{text:T}=b;typeof T=="string"?T=T:T=WO(pt.from(T),m.schema);const{from:k}=b,N=k+T.length,I=hHe(T);return c({rule:d,state:m,from:k,to:{b:N},pasteEvt:I})}const S=g.doc.content.findDiffStart(m.doc.content),A=g.doc.content.findDiffEnd(m.doc.content);if(!(!lHe(S)||!A||S===A.b))return c({rule:d,state:m,from:S,to:A,pasteEvt:s})}}))}var sE=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=BJ(t),this.schema=A6e(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 qO([...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)},a=[],s=Bt(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&Bt(r,"exitable",i)&&(o.ArrowRight=()=>Ed.handleExit({editor:t,mark:r})),s){const g=Object.fromEntries(Object.entries(s()).map(([m,x])=>[m,()=>x({editor:t})]));o={...o,...g}}const c=N8e(o);a.push(c);const u=Bt(r,"addInputRules",i);if(j7(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const m=sHe({editor:t,rules:g}),x=Array.isArray(m)?m:[m];a.push(...x)}}const d=Bt(r,"addPasteRules",i);if(j7(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const m=fHe({editor:t,rules:g});a.push(...m)}}const f=Bt(r,"addProseMirrorPlugins",i);if(f){const g=f();a.push(...g)}return a})}get attributes(){return zJ(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=zm(this.extensions);return Object.fromEntries(e.filter(n=>!!Bt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ii(n.name,this.schema)},a=Bt(n,"addNodeView",i);if(!a)return[];const s=a();if(!s)return[];const o=(c,u,d,f,g)=>{const m=Jw(c,r);return s({node:c,view:u,getPos:d,decorations:f,innerDecorations:g,editor:t,extension:n,HTMLAttributes:m})};return[n.name,o]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=zm(this.extensions);return Object.fromEntries(e.filter(n=>!!Bt(n,"addMarkView")).map(n=>{const r=this.attributes.filter(o=>o.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Bc(n.name,this.schema)},a=Bt(n,"addMarkView",i);if(!a)return[];const s=(o,c,u)=>{const d=Jw(o,r);return a()({mark:o,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{CHe(o,t,f)}})};return[n.name,s]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:qN(e.name,this.schema)};e.type==="mark"&&((n=Un(Bt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Bt(e,"onBeforeCreate",r),a=Bt(e,"onCreate",r),s=Bt(e,"onUpdate",r),o=Bt(e,"onSelectionUpdate",r),c=Bt(e,"onTransaction",r),u=Bt(e,"onFocus",r),d=Bt(e,"onBlur",r),f=Bt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),s&&this.editor.on("update",s),o&&this.editor.on("selectionUpdate",o),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};sE.resolve=BJ;sE.sort=qO;sE.flatten=GO;var pHe={};BO(pHe,{ClipboardTextSerializer:()=>YJ,Commands:()=>ZJ,Delete:()=>QJ,Drop:()=>JJ,Editable:()=>eee,FocusEvents:()=>nee,Keymap:()=>ree,Paste:()=>iee,Tabindex:()=>aee,TextDirection:()=>see,focusEventsPluginKey:()=>tee});var Qn=class XJ extends XO{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new XJ(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},YJ=Qn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Er({key:new Si("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,s=Math.min(...a.map(d=>d.$from.pos)),o=Math.max(...a.map(d=>d.$to.pos)),c=$J(n);return HJ(r,{from:s,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),ZJ=Qn.create({name:"commands",addCommands(){return{...PJ}}}),QJ=Qn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var s,o,c,u;if((u=(c=(o=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:o.filterTransaction)==null?void 0:c.call(o,t))!=null?u:t.getMeta("y-sync$"))return;const d=FJ(t.before,[t,...e]);GJ(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,v)=>{const y=v+x.nodeSize-2,b=m.oldRange.from<=v&&y<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:v,to:y,newFrom:d.mapping.map(v),newTo:d.mapping.map(y),deletedRange:m.oldRange,newRange:m.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((m,x)=>{var v,y;if(m instanceof Oo){const b=g.slice(x).map(m.from,-1),M=g.slice(x).map(m.to),S=g.invert().map(b,-1),A=g.invert().map(M),T=(v=d.doc.nodeAt(b-1))==null?void 0:v.marks.some(N=>N.eq(m.mark)),k=(y=d.doc.nodeAt(M))==null?void 0:y.marks.some(N=>N.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:S,to:A},newRange:{from:b,to:M},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(a,0):a()}}),JJ=Qn.create({name:"drop",addProseMirrorPlugins(){return[new Er({key:new Si("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),eee=Qn.create({name:"editable",addProseMirrorPlugins(){return[new Er({key:new Si("editable"),props:{editable:()=>this.editor.options.editable}})]}}),tee=new Si("focusEvents"),nee=Qn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Er({key:tee,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}}}})]}}),ree=Qn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:o})=>{const{selection:c,doc:u}=o,{empty:d,$anchor:f}=c,{pos:g,parent:m}=f,x=f.parent.isTextblock&&g>0?o.doc.resolve(g-1):f,v=x.parent.type.spec.isolating,y=f.pos-f.parentOffset,b=v&&x.parent.childCount===1?y===f.pos:un.atStart(u).from===g;return!d||!m.type.isTextblock||m.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return VO()||LJ()?a:i},addProseMirrorPlugins(){return[new Er({key:new Si("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:s,to:o}=e.selection,c=un.atStart(e.doc).from,u=un.atEnd(e.doc).to;if(a||!(s===c&&o===u)||!iE(n.doc))return;const g=n.tr,m=eE({state:n,transaction:g}),{commands:x}=new tE({editor:this.editor,state:m});if(x.clearNodes(),!!g.steps.length)return g}})]}}),iee=Qn.create({name:"paste",addProseMirrorPlugins(){return[new Er({key:new Si("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),aee=Qn.create({name:"tabindex",addProseMirrorPlugins(){return[new Er({key:new Si("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),see=Qn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=zm(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Er({key:new Si("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),mHe=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,a=n.isAtom&&!n.isText,s=this.pos+r+(a?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const o=this.resolvedPos.doc.resolve(s);if(!i&&o.depth<=this.depth)return;const c=new 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 a=i.node.attrs,s=Object.keys(n);for(let o=0;o<s.length;o+=1){const c=s[o];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&a.every(c=>n[c]===s.node.attrs[c])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},gHe=`.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 xHe(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 bHe=class extends iHe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=jJ(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=xHe(gHe,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 a=typeof i=="string"?`${i}$`:i.key;n=n.filter(s=>!s.key.startsWith(a))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[eee,YJ.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),ZJ,nee,ree,aee,JJ,iee,QJ,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 sE(r,this)}createCommandManager(){this.commandManager=new tE({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=rR(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=rR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new NJ(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),o=s?.getMeta("focus"),c=s?.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:s}),c&&this.emit("blur",{editor:this,event:c.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return VJ(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return j6e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return WO(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return C6e(this.state.doc,{blockSeparator:e,textSerializers:{...$J(this.schema),...n}})}get isEmpty(){return iE(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 mHe(e,this)}get $doc(){return this.$pos(0)}};function Bm(t){return new aE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Un(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,s=r[r.length-1],o=r[0];if(s){const c=o.search(/\S/),u=n.from+o.indexOf(s),d=u+s.length;if(KO(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(v=>v===t.type&&v!==m.mark.type)).filter(m=>m.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const g=n.from+c+s.length;a.addMark(n.from+c,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function oee(t){return new aE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Un(t.getAttributes,void 0,r)||{},{tr:a}=e,s=n.from;let o=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=s+u;d>o?d=o:o=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,s+r[0].length-1),a.replaceWith(d,o,c)}else if(r[0]){const u=t.type.isInline?s:s-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(s),a.mapping.map(o))}a.scrollIntoView()},undoable:t.undoable})}function aR(t){return new aE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=Un(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function Hm(t){return new aE({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=Un(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),c=s.doc.resolve(n.from).blockRange(),u=c&&EO(c,t.type,a);if(!u)return null;if(s.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 v=x.filter(y=>m.includes(y.type.name));s.ensureMarks(v)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=s.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&Sd(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)},undoable:t.undoable})}var yHe=t=>"touches"in t,vHe=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.clientX-this.startX,c=s.clientY-this.startY;this.handleResize(o,c)},this.handleTouchMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.touches[0];if(!o)return;const c=o.clientX-this.startX,u=o.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const s=this.element.offsetWidth,o=this.element.offsetHeight;this.onCommit(s,o),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,yHe(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),s=t.includes("left"),o=t.includes("bottom"),c=t.includes("top");return a?r=this.startWidth+e:s&&(r=this.startWidth-e),o?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(o?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,s;if(!n){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let o=t,c=e;return o<this.minSize.width&&(o=this.minSize.width,c=o/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,o=c*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&o>this.maxSize.width&&(o=this.maxSize.width,c=o/this.aspectRatio),(s=this.maxSize)!=null&&s.height&&c>this.maxSize.height&&(c=this.maxSize.height,o=c*this.aspectRatio),{width:o,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function _He(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ht){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}var wHe={};BO(wHe,{createAtomBlockMarkdownSpec:()=>SHe,createBlockMarkdownSpec:()=>MHe,createInlineMarkdownSpec:()=>THe,parseAttributes:()=>YO,parseIndentedBlocks:()=>sR,renderNestedMarkdownContent:()=>QO,serializeAttributes:()=>ZO});function YO(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const s=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(s)).forEach(([,u,d])=>{var f;const g=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),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 ZO(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 SHe(t){const{nodeName:e,name:n,parseAttributes:r=YO,serializeAttributes:i=ZO,defaultAttributes:a={},requiredAttributes:s=[],allowedAttributes:o}=t,c=n||e,u=d=>{if(!o)return d;const f={};return o.forEach(g=>{g in d&&(f[g]=d[g])}),f};return{parseMarkdown:(d,f)=>{const g={...a,...d.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const g=new RegExp(`^:::${c}(?:\\s|$)`,"m"),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 v=x[1]||"",y=r(v);if(!s.find(M=>!(M in y)))return{type:e,raw:x[0],attributes:y}}},renderMarkdown:d=>{const f=u(d.attrs||{}),g=i(f),m=g?` {${g}}`:"";return`:::${c}${m} :::`}}}function MHe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=YO,serializeAttributes:a=ZO,defaultAttributes:s={},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 v=r(f);m=typeof v=="string"?[{type:"text",text:v}]:v}else o==="block"?m=g.parseChildren(f.tokens||[]):m=g.parseInline(f.tokens||[]);const x={...s,...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 v=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=f.match(v);if(!y)return;const[b,M=""]=y,S=i(M);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 O=I.slice(0,D);k=O.trim();const q=f.slice(0,T+D+C[0].length);let R=[];if(k)if(o==="block")for(R=m.blockTokens(O),R.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=m.inlineTokens(W.text))});R.length>0;){const W=R[R.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))R.pop();else break}else R=m.inlineTokens(k);return{type:e,raw:q,attributes:S,content:k,tokens:R}}}}}},renderMarkdown:(f,g)=>{const m=d(f.attrs||{}),x=a(m),v=x?` {${x}}`:"",y=g.renderChildren(f.content||[],`
- `);return`:::${u}${v}
- ${y}
- :::`}}}function EHe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,s]=r;e[i]=a||s,r=n.exec(t)}return e}function AHe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function THe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=EHe,serializeAttributes:a=AHe,defaultAttributes:s={},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={...s,...g.attributes};if(o)return m.createNode(e,x);const v=r?r(g):g.content||"";return v?m.createNode(e,x,[m.createTextNode(v)]):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),v=x?.index;return v!==void 0?v:-1},tokenize(g,m,x){const v=o?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),y=g.match(v);if(!y)return;let b="",M="";if(o){const[,A]=y;M=A}else{const[,A,T]=y;M=A,b=T||""}const S=i(M.trim());return{type:e,raw:y[0],content:b.trim(),attributes:S}}},renderMarkdown:g=>{let m="";r?m=r(g):g.content&&g.content.length>0&&(m=g.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const x=d(g.attrs||{}),v=a(x),y=v?` ${v}`:"";return o?`[${u}${y}]`:`[${u}${y}]${m}[/${u}]`}}}function sR(t,e,n){var r,i,a,s;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:v,mainContent:y}=x;u=`${u}${g}
- `;const b=[y];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)>v){b.push(T),u=`${u}${T}
- `,d+=1;continue}else break}if((((s=(a=T.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:s.length)||0)>v)b.push(T),u=`${u}${T}
- `,d+=1;else break}let M;const S=b.slice(1);if(S.length>0){const T=S.map(k=>k.slice(v+f)).join(`
- `);T.trim()&&(e.customNestedParser?M=e.customNestedParser(T):M=n.blockTokens(T))}const A=e.createToken(x,M);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function QO(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...s]=t.content,o=e.renderChildren([a]),c=[`${i}${o}`];return s&&s.length>0&&s.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(g=>g?e.indent(g):"").join(`
- `);c.push(f)}}),c.join(`
- `)}function CHe(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,s=t;i.descendants((o,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+o.nodeSize;let f=null;if(o.marks.forEach(m=>{if(m!==s)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});a.removeMark(u,d,t.type),a.addMark(u,d,m)}}),a.docChanged&&e.view.dispatch(a)}var Ja=class lee extends XO{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new lee(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 cHe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Un(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:s}=e,o=r[r.length-1],c=r[0];let u=n.to;if(o){const d=c.search(/\S/),f=n.from+c.indexOf(o),g=f+o.length;if(KO(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(y=>y===t.type&&y!==x.mark.type)).filter(x=>x.to>f).length)return null;g<n.to&&s.delete(g,n.to),f>n.from&&s.delete(n.from+d,f),u=n.from+d+o.length,s.addMark(n.from+d,u,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}var YN,I7;function NHe(){return I7||(I7=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,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var s=a[i];if(!(s==="_owner"&&e.$$typeof)&&!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}),YN}var kHe=NHe();const PHe=fo(kHe);var RHe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},DHe=({contentComponent:t})=>{const e=AR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return l.jsx(l.Fragment,{children:Object.values(e)})};function jHe(){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]:sse.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 OHe=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=jHe(),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:RHe(e,this.editorContentRef),...n}),t?.contentComponent&&l.jsx(DHe,{contentComponent:t.contentComponent})]})}},LHe=E.forwardRef((t,e)=>{const n=mr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return mr.createElement(OHe,{key:n,innerRef:e,...t})}),IHe=mr.memo(LHe),FHe=typeof window<"u"?E.useLayoutEffect:E.useEffect,UHe=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 zHe(t){var e;const[n]=E.useState(()=>new UHe(t.editor)),r=sW.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:PHe);return FHe(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var BHe=!1,oR=typeof window>"u",HHe=oR||!!(typeof window<"u"&&window.next),$He=class cee{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?oR||HHe?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new bHe(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var s;return i===((s=n.extensions)==null?void 0:s[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?cee.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 VHe(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new $He(n)),i=AR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(i),E.useEffect(r.onRender(e)),zHe({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var GHe=E.createContext({editor:null});GHe.Consumer;var WHe=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),qHe=()=>E.useContext(WHe);mr.forwardRef((t,e)=>{const{onDragStart:n}=qHe(),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]},KHe=/^\s*>\s$/,XHe=Ja.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return eS("blockquote",{...Dr(this.options.HTMLAttributes,t),children:eS("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const o=e.renderChildren([i]).split(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(o.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Hm({find:KHe,type:this.type})]}}),YHe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,ZHe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,QHe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,JHe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,e$e=Ed.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return eS("strong",{...Dr(this.options.HTMLAttributes,t),children:eS("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Bm({find:YHe,type:this.type}),Bm({find:QHe,type:this.type})]},addPasteRules(){return[cf({find:ZHe,type:this.type}),cf({find:JHe,type:this.type})]}}),t$e=/(^|[^`])`([^`]+)`(?!`)$/,n$e=/(^|[^`])`([^`]+)`(?!`)/g,r$e=Ed.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Dr(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Bm({find:t$e,type:this.type})]},addPasteRules(){return[cf({find:n$e,type:this.type})]}}),ZN=4,i$e=/^```([a-z]+)?[\s\n]$/,a$e=/^~~~([a-z]+)?[\s\n]$/,s$e=Ja.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 a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",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:a,empty:s}=i;if(a.parent.type!==this.type)return!1;const o=" ".repeat(n);return s?t.commands.insertContent(o):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,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:a,empty:s}=i;return a.parent.type!==this.type?!1:s?t.commands.command(({tr:o})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),m=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let x=0,v=0;const y=u-d;for(let k=0;k<m.length;k+=1){if(v+m[k].length>=y){x=k;break}v+=m[k].length+1}const M=((c=m[x].match(/^ */))==null?void 0:c[0])||"",S=Math.min(M.length,n);if(S===0)return!0;let A=d;for(let k=0;k<x;k+=1)A+=m[k].length+1;return o.delete(A,A+S),u-A<=S&&o.setSelection(Kt.create(o.doc,A)),!0}):t.commands.command(({tr:o})=>{const{from:c,to:u}=i,g=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(m=>{var x;const v=((x=m.match(/^ */))==null?void 0:x[0])||"",y=Math.min(v.length,n);return m.slice(y)}).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 a=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
- `);return!a||!s?!1:t.chain().command(({tr:o})=>(o.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const o=i.after();return o===void 0?!1:r.nodeAt(o)?t.commands.command(({tr:u})=>(u.setSelection(un.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[aR({find:i$e,type:this.type,getAttributes:t=>({language:t[1]})}),aR({find:a$e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Er({key:new Si("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:s,schema:o}=t.state,c=o.text(n.replace(/\r\n?/g,`
- `));return s.replaceSelectionWith(this.type.create({language:a},c)),s.selection.$from.parent.type!==this.type&&s.setSelection(Kt.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),o$e=Ja.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),l$e=Ja.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:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:o}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&s){const f=c.filter(g=>o.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),c$e=Ja.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=>aR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),u$e=Ja.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(!_He(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return WJ(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:s,dispatch:o})=>{if(o){const{$to:c}=s.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(Kt.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(Ht.create(s.doc,c.pos)):s.setSelection(Kt.create(s.doc,c.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(s.insert(u,f),s.setSelection(Kt.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[oee({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),d$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,h$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,f$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,p$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,m$e=Ed.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Dr(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Bm({find:d$e,type:this.type}),Bm({find:f$e,type:this.type})]},addPasteRules(){return[cf({find:h$e,type:this.type}),cf({find:p$e,type:this.type})]}});const g$e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",x$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",lR="numeric",cR="ascii",uR="alpha",i0="asciinumeric",$x="alphanumeric",dR="domain",uee="emoji",b$e="scheme",y$e="slashscheme",QN="whitespace";function v$e(t,e){return t in e||(e[t]=[]),e[t]}function vh(t,e,n){e[lR]&&(e[i0]=!0,e[$x]=!0),e[cR]&&(e[i0]=!0,e[uR]=!0),e[i0]&&(e[$x]=!0),e[uR]&&(e[$x]=!0),e[$x]&&(e[dR]=!0),e[uee]&&(e[dR]=!0);for(const r in e){const i=v$e(r,n);i.indexOf(t)<0&&i.push(t)}}function _$e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ga(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ga.groups={};Ga.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],a=e.jr[r][1];if(a&&i.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Ga.groups;let i;return e&&e.j?i=e:(i=new Ga(e),n&&r&&vh(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const a=t.length;if(!a)return i;for(let s=0;s<a-1;s++)i=i.tt(t[s]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||Ga.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let s,o=i.go(t);if(o?(s=new Ga,Object.assign(s.j,o.j),s.jr.push.apply(s.jr,o.jr),s.jd=o.jd,s.t=o.t):s=new Ga,a){if(r)if(s.t&&typeof s.t=="string"){const c=Object.assign(_$e(s.t,r),n);vh(a,c,r)}else n&&vh(a,n,r);s.t=a}return i.j[t]=s,s}};const sn=(t,e,n,r,i)=>t.ta(e,n,r,i),Nr=(t,e,n,r,i)=>t.tr(e,n,r,i),F7=(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",hR="UWORD",dee="ASCIINUMERICAL",hee="ALPHANUMERICAL",ob="LOCALHOST",fR="TLD",pR="UTLD",b1="SCHEME",$p="SLASH_SCHEME",JO="NUM",mR="WS",eL="NL",a0="OPENBRACE",s0="CLOSEBRACE",tS="OPENBRACKET",nS="CLOSEBRACKET",rS="OPENPAREN",iS="CLOSEPAREN",aS="OPENANGLEBRACKET",sS="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",yS="BACKTICK",vS="CARET",Fu="COLON",tL="COMMA",_S="DOLLAR",Qo="DOT",wS="EQUALS",nL="EXCLAMATION",Gs="HYPHEN",o0="PERCENT",SS="PIPE",MS="PLUS",ES="POUND",l0="QUERY",rL="QUOTE",fee="FULLWIDTHMIDDLEDOT",iL="SEMI",Jo="SLASH",c0="TILDE",AS="UNDERSCORE",pee="EMOJI",TS="SYM";var mee=Object.freeze({__proto__:null,ALPHANUMERICAL:hee,AMPERSAND:mS,APOSTROPHE:gS,ASCIINUMERICAL:dee,ASTERISK:xS,AT:Ru,BACKSLASH:bS,BACKTICK:yS,CARET:vS,CLOSEANGLEBRACKET:sS,CLOSEBRACE:s0,CLOSEBRACKET:nS,CLOSEPAREN:iS,COLON:Fu,COMMA:tL,DOLLAR:_S,DOT:Qo,EMOJI:pee,EQUALS:wS,EXCLAMATION:nL,FULLWIDTHGREATERTHAN:pS,FULLWIDTHLEFTPAREN:oS,FULLWIDTHLESSTHAN:fS,FULLWIDTHMIDDLEDOT:fee,FULLWIDTHRIGHTPAREN:lS,HYPHEN:Gs,LEFTCORNERBRACKET:cS,LEFTWHITECORNERBRACKET:dS,LOCALHOST:ob,NL:eL,NUM:JO,OPENANGLEBRACKET:aS,OPENBRACE:a0,OPENBRACKET:tS,OPENPAREN:rS,PERCENT:o0,PIPE:SS,PLUS:MS,POUND:ES,QUERY:l0,QUOTE:rL,RIGHTCORNERBRACKET:uS,RIGHTWHITECORNERBRACKET:hS,SCHEME:b1,SEMI:iL,SLASH:Jo,SLASH_SCHEME:$p,SYM:TS,TILDE:c0,TLD:fR,UNDERSCORE:AS,UTLD:pR,UWORD:hR,WORD:sc,WS:mR});const nc=/[a-z]/,kx=new RegExp("\\p{L}","u"),JN=new RegExp("\\p{Emoji}","u"),rc=/\d/,ek=/\s/,U7="\r",tk=`
- `,w$e="️",S$e="",nk="";let H_=null,$_=null;function M$e(t=[]){const e={};Ga.groups=e;const n=new Ga;H_==null&&(H_=z7(g$e)),$_==null&&($_=z7(x$e)),gt(n,"'",gS),gt(n,"{",a0),gt(n,"}",s0),gt(n,"[",tS),gt(n,"]",nS),gt(n,"(",rS),gt(n,")",iS),gt(n,"<",aS),gt(n,">",sS),gt(n,"(",oS),gt(n,")",lS),gt(n,"「",cS),gt(n,"」",uS),gt(n,"『",dS),gt(n,"』",hS),gt(n,"<",fS),gt(n,">",pS),gt(n,"&",mS),gt(n,"*",xS),gt(n,"@",Ru),gt(n,"`",yS),gt(n,"^",vS),gt(n,":",Fu),gt(n,",",tL),gt(n,"$",_S),gt(n,".",Qo),gt(n,"=",wS),gt(n,"!",nL),gt(n,"-",Gs),gt(n,"%",o0),gt(n,"|",SS),gt(n,"+",MS),gt(n,"#",ES),gt(n,"?",l0),gt(n,'"',rL),gt(n,"/",Jo),gt(n,";",iL),gt(n,"~",c0),gt(n,"_",AS),gt(n,"\\",bS),gt(n,"・",fee);const r=Nr(n,rc,JO,{[lR]:!0});Nr(r,rc,r);const i=Nr(r,nc,dee,{[i0]:!0}),a=Nr(r,kx,hee,{[$x]:!0}),s=Nr(n,nc,sc,{[cR]:!0});Nr(s,rc,i),Nr(s,nc,s),Nr(i,rc,i),Nr(i,nc,i);const o=Nr(n,kx,hR,{[uR]:!0});Nr(o,nc),Nr(o,rc,a),Nr(o,kx,o),Nr(a,rc,a),Nr(a,nc),Nr(a,kx,a);const c=gt(n,tk,eL,{[QN]:!0}),u=gt(n,U7,mR,{[QN]:!0}),d=Nr(n,ek,mR,{[QN]:!0});gt(n,nk,d),gt(u,tk,c),gt(u,nk,d),Nr(u,ek,d),gt(d,U7),gt(d,tk),Nr(d,ek,d),gt(d,nk,d);const f=Nr(n,JN,pee,{[uee]:!0});gt(f,"#"),Nr(f,JN,f),gt(f,w$e,f);const g=gt(f,S$e);gt(g,"#"),Nr(g,JN,f);const m=[[nc,s],[rc,i]],x=[[nc,null],[kx,o],[rc,a]];for(let v=0;v<H_.length;v++)Eu(n,H_[v],fR,sc,m);for(let v=0;v<$_.length;v++)Eu(n,$_[v],pR,hR,x);vh(fR,{tld:!0,ascii:!0},e),vh(pR,{utld:!0,alpha:!0},e),Eu(n,"file",b1,sc,m),Eu(n,"mailto",b1,sc,m),Eu(n,"http",$p,sc,m),Eu(n,"https",$p,sc,m),Eu(n,"ftp",$p,sc,m),Eu(n,"ftps",$p,sc,m),vh(b1,{scheme:!0,ascii:!0},e),vh($p,{slashscheme:!0,ascii:!0},e),t=t.sort((v,y)=>v[0]>y[0]?1:-1);for(let v=0;v<t.length;v++){const y=t[v][0],M=t[v][1]?{[b$e]:!0}:{[y$e]:!0};y.indexOf("-")>=0?M[dR]=!0:nc.test(y)?rc.test(y)?M[i0]=!0:M[cR]=!0:M[lR]=!0,F7(n,y,y,M)}return F7(n,"localhost",ob,{ascii:!0}),n.jd=new Ga(TS),{start:n,tokens:Object.assign({groups:e},mee)}}function gee(t,e){const n=E$e(e.replace(/[A-Z]/g,o=>o.toLowerCase())),r=n.length,i=[];let a=0,s=0;for(;s<r;){let o=t,c=null,u=0,d=null,f=-1,g=-1;for(;s<r&&(c=o.go(n[s]));)o=c,o.accepts()?(f=0,g=0,d=o):f>=0&&(f+=n[s].length,g++),u+=n[s].length,a+=n[s].length,s++;a-=f,s-=g,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function E$e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,s=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function Eu(t,e,n,r,i){let a;const s=e.length;for(let o=0;o<s-1;o++){const c=e[o];t.j[c]?a=t.j[c]:(a=new Ga(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new Ga(n),a.jr=i.slice(),t.j[e[s-1]]=a,a}function z7(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let a=0;for(;i.indexOf(t[r+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+a),10);s>0;s--)n.pop();r+=a}else n.push(t[r]),r++}return e}const lb={defaultProtocol:"http",events:null,format:B7,formatHref:B7,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function aL(t,e=null){let n=Object.assign({},lb);t&&(n=Object.assign(n,t instanceof aL?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;a<r.length;a++)i.push(r[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}aL.prototype={o:lb,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:lb[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function B7(t){return t}function xee(t,e){this.t="token",this.v=t,this.tk=e}xee.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=lb.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=this.toFormattedString(t),s={},o=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return s.href=r,o&&(s.class=o),c&&(s.target=c),u&&(s.rel=u),d&&Object.assign(s,d),{tagName:i,attributes:s,content:a,eventListeners:f}}};function oE(t,e){class n extends xee{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const H7=oE("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),$7=oE("text"),A$e=oE("nl"),V_=oE("url",{isLink:!0,toHref(t=lb.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==ob&&t[1].t===Fu}}),Hs=t=>new Ga(t);function T$e({groups:t}){const e=t.domain.concat([mS,xS,Ru,bS,yS,vS,_S,wS,Gs,JO,o0,SS,MS,ES,Jo,TS,c0,AS]),n=[gS,Fu,tL,Qo,nL,o0,l0,rL,iL,aS,sS,a0,s0,nS,tS,rS,iS,oS,lS,cS,uS,dS,hS,fS,pS],r=[mS,gS,xS,bS,yS,vS,_S,wS,Gs,a0,s0,o0,SS,MS,ES,l0,Jo,TS,c0,AS],i=Hs(),a=gt(i,c0);sn(a,r,a),sn(a,t.domain,a);const s=Hs(),o=Hs(),c=Hs();sn(i,t.domain,s),sn(i,t.scheme,o),sn(i,t.slashscheme,c),sn(s,r,a),sn(s,t.domain,s);const u=gt(s,Ru);gt(a,Ru,u),gt(o,Ru,u),gt(c,Ru,u);const d=gt(a,Qo);sn(d,r,a),sn(d,t.domain,a);const f=Hs();sn(u,t.domain,f),sn(f,t.domain,f);const g=gt(f,Qo);sn(g,t.domain,f);const m=Hs(H7);sn(g,t.tld,m),sn(g,t.utld,m),gt(u,ob,m);const x=gt(f,Gs);gt(x,Gs,x),sn(x,t.domain,f),sn(m,t.domain,f),gt(m,Qo,g),gt(m,Gs,x);const v=gt(m,Fu);sn(v,t.numeric,H7);const y=gt(s,Gs),b=gt(s,Qo);gt(y,Gs,y),sn(y,t.domain,s),sn(b,r,a),sn(b,t.domain,s);const M=Hs(V_);sn(b,t.tld,M),sn(b,t.utld,M),sn(M,t.domain,s),sn(M,r,a),gt(M,Qo,b),gt(M,Gs,y),gt(M,Ru,u);const S=gt(M,Fu),A=Hs(V_);sn(S,t.numeric,A);const T=Hs(V_),k=Hs();sn(T,e,T),sn(T,n,k),sn(k,e,T),sn(k,n,k),gt(M,Jo,T),gt(A,Jo,T);const N=gt(o,Fu),I=gt(c,Fu),C=gt(I,Jo),D=gt(C,Jo);sn(o,t.domain,s),gt(o,Qo,b),gt(o,Gs,y),sn(c,t.domain,s),gt(c,Qo,b),gt(c,Gs,y),sn(N,t.domain,T),gt(N,Jo,T),gt(N,l0,T),sn(D,t.domain,T),sn(D,e,T),gt(D,Jo,T);const F=[[a0,s0],[tS,nS],[rS,iS],[aS,sS],[oS,lS],[cS,uS],[dS,hS],[fS,pS]];for(let O=0;O<F.length;O++){const[q,R]=F[O],W=gt(T,q);gt(k,q,W),gt(W,R,T);const K=Hs(V_);sn(W,e,K);const G=Hs();sn(W,n),sn(K,e,K),sn(K,n,G),sn(G,e,K),sn(G,n,G),gt(K,R,T),gt(G,R,T)}return gt(i,ob,M),gt(i,eL,A$e),{start:i,tokens:mee}}function C$e(t,e,n){let r=n.length,i=0,a=[],s=[];for(;i<r;){let o=t,c=null,u=null,d=0,f=null,g=-1;for(;i<r&&!(c=o.go(n[i].t));)s.push(n[i++]);for(;i<r&&(u=c||o.go(n[i].t));)c=null,o=u,o.accepts()?(g=0,f=o):g>=0&&g++,i++,d++;if(g<0)i-=d,i<r&&(s.push(n[i]),i++);else{s.length>0&&(a.push(rk($7,e,s)),s=[]),i-=g,d-=g;const m=f.t,x=n.slice(i-d,i);a.push(rk(m,e,x))}}return s.length>0&&a.push(rk($7,e,s)),a}function rk(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const N$e=typeof console<"u"&&console&&console.warn||(()=>{}),k$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 P$e(){return Ga.groups={},cr.scanner=null,cr.parser=null,cr.tokenQueue=[],cr.pluginQueue=[],cr.customSchemes=[],cr.initialized=!1,cr}function V7(t,e=!1){if(cr.initialized&&N$e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${k$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 R$e(){cr.scanner=M$e(cr.customSchemes);for(let t=0;t<cr.tokenQueue.length;t++)cr.tokenQueue[t][1]({scanner:cr.scanner});cr.parser=T$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 sL(t){return cr.initialized||R$e(),C$e(cr.parser.start,t,gee(cr.scanner.start,t))}sL.scan=gee;function bee(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 aL(n),i=sL(t),a=[];for(let s=0;s<i.length;s++){const o=i[s];o.isLink&&(!e||o.t===e)&&r.check(o)&&a.push(o.toFormattedObject(r))}return a}var oL="[\0- -\u2029 ]",D$e=new RegExp(oL),j$e=new RegExp(`${oL}$`),O$e=new RegExp(oL,"g");function L$e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function I$e(t){return new Er({key:new Si("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),a=e.some(u=>u.getMeta("preventAutolink"));if(!i||a)return;const{tr:s}=r,o=FJ(n.doc,[...e]);if(GJ(o).forEach(({newRange:u})=>{const d=w6e(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(!j$e.test(m))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const m=g.split(D$e).filter(Boolean);if(m.length<=0)return!1;const x=m[m.length-1],v=f.pos+g.lastIndexOf(x);if(!x)return!1;const y=sL(x).map(b=>b.toObject(t.defaultProtocol));if(!L$e(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:v+b.start+1,to:v+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{KO(b.from,b.to,r.doc).some(M=>M.mark.type===t.type)||s.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function F$e(t){return new Er({key:new Si("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;s=f.find(g=>g.nodeName==="A")}if(!s)return!1;const o=VJ(e.state,t.type.name),c=(i=s?.href)!=null?i:o.href,u=(a=s?.target)!=null?a:o.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&c?(window.open(c,u),!0):!1}}})}function U$e(t){return new Er({key:new Si("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:s}=a,{empty:o}=s;if(o)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=bee(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(O$e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var yee=Ed.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"){V7(t);return}V7(t.scheme,t.optionalSlashes)})},onDestroy(){P$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=bee(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:s=>!!Jd(s,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(I$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(F$e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(U$e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),z$e=yee,B$e=Object.defineProperty,H$e=(t,e)=>{for(var n in e)B$e(t,n,{get:e[n],enumerable:!0})},$$e="listItem",G7="textStyle",W7=/^\s*([-+*])\s$/,vee=Ja.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($$e,this.editor.getAttributes(G7)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Hm({find:W7,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Hm({find:W7,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(G7),editor:this.editor})),[t]}}),_ee=Ja.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 s=t.tokens.slice(1),o=e.parseChildren(s);n.push(...o)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>QO(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)}}}),V$e={};H$e(V$e,{findListItemPos:()=>Jb,getNextListDepth:()=>lL,handleBackspace:()=>gR,handleDelete:()=>xR,hasListBefore:()=>wee,hasListItemAfter:()=>G$e,hasListItemBefore:()=>See,listItemHasSubList:()=>Mee,nextListIsDeeper:()=>Eee,nextListIsHigher:()=>Aee});var Jb=(t,e)=>{const{$from:n}=e.selection,r=ii(t,e.schema);let i=null,a=n.depth,s=n.pos,o=null;for(;a>0&&o===null;)i=n.node(a),i.type===r?o=a:(a-=1,s-=1);return o===null?null:{$pos:e.doc.resolve(s),depth:o}},lL=(t,e)=>{const n=Jb(t,e);if(!n)return!1;const[,r]=R6e(e,t,n.$pos.pos+4);return r},wee=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},See=(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)},Mee=(t,e,n)=>{if(!n)return!1;const r=ii(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},gR=(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)&&wee(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)||!L6e(t.state))return!1;const r=Jb(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=Mee(e,t.state,a);return See(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Eee=(t,e)=>{const n=lL(t,e),r=Jb(t,e);return!r||!n?!1:n>r.depth},Aee=(t,e)=>{const n=lL(t,e),r=Jb(t,e);return!r||!n?!1:n<r.depth},xR=(t,e)=>{if(!gd(t.state,e)||!O6e(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():Aee(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},G$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)},Tee=Qn.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&xR(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&&xR(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&&gR(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&&gR(t,n,r)&&(e=!0)}),e}}}}),q7=/^(\s*)(\d+)\.\s+(.*)$/,W$e=/^\s/;function q$e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(q7);if(!a)break;const[,s,o,c]=a,u=s.length;let d=c,f=n+1;const g=[i];for(;f<t.length;){const m=t[f];if(m.match(q7))break;if(m.trim()==="")g.push(m),d+=`
- `,f+=1;else if(m.match(W$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 Cee(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const s=t[a];if(s.indent===e){const o=s.content.split(`
- `),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=a+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(v=>v.indent)),x=Cee(g,m,n);u.push({type:"list",ordered:!0,start:g[0].number,items:x,raw:g.map(v=>v.raw).join(`
- `)})}i.push({type:"list_item",raw:s.raw,tokens:u}),a=f}else a+=1}return i}function K$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 a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var X$e="listItem",K7="textStyle",X7=/^(\d+)\.\s$/,Nee=Ja.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?K$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(`
- `),[a,s]=q$e(i);if(a.length===0)return;const o=Cee(a,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:o,raw:i.slice(0,s).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(X$e,this.editor.getAttributes(K7)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Hm({find:X7,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Hm({find:X7,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(K7)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Y$e=/^\s*(\[([( |x])?\])\s$/,Z$e=Ja.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 QO(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),s=document.createElement("span"),o=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,g;o.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,d,o.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",d=>d.preventDefault()),o.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const 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,a.append(o,s),i.append(a,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,o.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[Hm({find:Y$e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Q$e=Ja.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=a=>{const s=sR(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,c)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:c}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=sR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Qn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(vee.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(_ee.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Tee.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Nee.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Z$e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Q$e.configure(this.options.taskList)),t}});var J$e=Ja.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()}}}),eVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,tVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,nVe=Ed.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Dr(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Bm({find:eVe,type:this.type})]},addPasteRules(){return[cf({find:tVe,type:this.type})]}}),rVe=Ja.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),kee=Ed.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 a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),iVe=kee;function aVe(t={}){return new Er({view(e){return new sVe(e,t)}})}class sVe{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=s=>{this[i](s)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),s=a.width/i.offsetWidth,o=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,g=e.nodeAfter;if(f||g){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let x=m.getBoundingClientRect(),v=f?x.bottom:x.top;f&&g&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*o;r={left:x.left,right:x.right,top:v-y,bottom:v+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*s;r={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),g=f.width/c.offsetWidth,m=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,d=f.top-c.scrollTop*m}this.element.style.left=(r.left-u)/s+"px",this.element.style.top=(r.top-d)/o+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=kQ(this.editorView.state.doc,s,this.editorView.dragging.slice);o!=null&&(s=o)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Pr extends un{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Pr.valid(r)?new Pr(r):un.near(r)}content(){return kt.empty}eq(e){return e instanceof Pr&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Pr(e.resolve(n.pos))}getBookmark(){return new cL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!oVe(e)||!lVe(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,a=null;for(let s=e.depth;;s--){let o=e.node(s);if(n>0?e.indexAfter(s)<o.childCount:e.index(s)>0){a=o.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let c=e.doc.resolve(i);if(Pr.valid(c))return c}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!Ht.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=s,i+=n;let o=e.doc.resolve(i);if(Pr.valid(o))return o}return null}}}Pr.prototype.visible=!1;Pr.findFrom=Pr.findGapCursorFrom;un.jsonID("gapcursor",Pr);class cL{constructor(e){this.pos=e}map(e){return new cL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Pr.valid(n)?new Pr(n):un.near(n)}}function Pee(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function oVe(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||Pee(i.type))return!0;if(i.inlineContent)return!1}}return!0}function lVe(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||Pee(i.type))return!0;if(i.inlineContent)return!1}}return!0}function cVe(){return new Er({props:{decorations:fVe,createSelectionBetween(t,e,n){return e.pos==n.pos&&Pr.valid(n)?new Pr(n):null},handleClick:dVe,handleKeyDown:uVe,handleDOMEvents:{beforeinput:hVe}}})}const uVe=kJ({ArrowLeft:G_("horiz",-1),ArrowRight:G_("horiz",1),ArrowUp:G_("vert",-1),ArrowDown:G_("vert",1)});function G_(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let s=r.selection,o=e>0?s.$to:s.$from,c=s.empty;if(s instanceof Kt){if(!a.endOfTextblock(n)||o.depth==0)return!1;c=!1,o=r.doc.resolve(e>0?o.after():o.before())}let u=Pr.findGapCursorFrom(o,e,c);return u?(i&&i(r.tr.setSelection(new Pr(u))),!0):!1}}function dVe(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 hVe(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 s=r.length-1;s>=0;s--)i=pt.from(r[s].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new kt(i,0,0));return a.setSelection(Kt.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function fVe(t){if(!(t.selection instanceof Pr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",yr.create(t.doc,[Ea.widget(t.selection.head,e,{key:"gapcursor"})])}var CS=200,Fi=function(){};Fi.prototype.append=function(e){return e.length?(e=Fi.from(e),!this.length&&e||e.length<CS&&this.leafAppend(e)||this.length<CS&&e.leafPrepend(this)||this.appendInner(e)):this};Fi.prototype.prepend=function(e){return e.length?Fi.from(e).append(this):this};Fi.prototype.appendInner=function(e){return new pVe(this,e)};Fi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Fi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Fi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Fi.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Fi.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,s){return i.push(e(a,s))},n,r),i};Fi.from=function(e){return e instanceof Fi?e:e&&e.length?new Ree(e):Fi.empty};var Ree=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,s,o){for(var c=a;c<s;c++)if(i(this.values[c],o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,s,o){for(var c=a-1;c>=s;c--)if(i(this.values[c],o+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=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})(Fi);Fi.empty=new Ree([]);var pVe=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,s){var o=this.left.length;if(i<o&&this.left.forEachInner(r,i,Math.min(a,o),s)===!1||a>o&&this.right.forEachInner(r,Math.max(i-o,0),Math.min(this.length,a)-o,s+o)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,s){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(r,i-o,Math.max(a,o)-o,s+o)===!1||a<o&&this.left.forEachInvertedInner(r,Math.min(i,o),a,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Fi);const mVe=500;class Po{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let s=e.tr,o,c,u=[],d=[];return this.items.forEach((f,g)=>{if(!f.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new el(f.map));let m=f.step.map(i.slice(a)),x;m&&s.maybeStep(m).doc&&(x=s.mapping.maps[s.mapping.maps.length-1],u.push(new el(x,void 0,void 0,u.length+d.length))),a--,x&&i.appendMap(x,a)}else s.maybeStep(f.step);if(f.selection)return o=i?f.selection.map(i.slice(a)):f.selection,c=new Po(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:s,selection:o}}addTransform(e,n,r,i){let a=[],s=this.eventCount,o=this.items,c=!i&&o.length?o.get(o.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),g=new el(e.mapping.maps[d],f,n),m;(m=c&&c.merge(g))&&(g=m,d?a.pop():o=o.slice(0,o.length-1)),a.push(g),n&&(s++,n=void 0),i||(c=g)}let u=s-r.depth;return u>xVe&&(o=gVe(o,u),s-=u),new Po(o.append(a),s)}remapping(e,n){let r=new tb;return this.items.forEach((i,a)=>{let s=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new Po(this.items.append(e.map(n=>new el(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach(g=>{g.selection&&o--},i);let c=n;this.items.forEach(g=>{let m=a.getMirror(--c);if(m==null)return;s=Math.min(s,m);let x=a.maps[m];if(g.step){let v=e.steps[m].invert(e.docs[m]),y=g.selection&&g.selection.map(a.slice(c+1,m));y&&o++,r.push(new el(x,v,y))}else r.push(new el(x))},i);let u=[];for(let g=n;g<s;g++)u.push(new el(a.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new Po(d,o);return f.emptyItemCount()>mVe&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((s,o)=>{if(o>=e)i.push(s),s.selection&&a++;else if(s.step){let c=s.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=s.selection&&s.selection.map(n.slice(r));d&&a++;let f=new el(u.invert(),c,d),g,m=i.length-1;(g=i.length&&i[m].merge(f))?i[m]=g:i.push(f)}}else s.map&&r--},this.items.length,0),new Po(Fi.from(i.reverse()),a)}}Po.empty=new Po(Fi.empty,0);function gVe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class el{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new el(n.getMap().invert(),n,this.selection)}}}class Du{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const xVe=20;function bVe(t,e,n,r){let i=n.getMeta(Lh),a;if(i)return i.historyState;n.getMeta(_Ve)&&(t=new Du(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Lh))return s.getMeta(Lh).redo?new Du(t.done.addTransform(n,void 0,r,y1(e)),t.undone,Y7(n.mapping.maps),t.prevTime,t.prevComposition):new Du(t.done,t.undone.addTransform(n,void 0,r,y1(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),c=t.prevTime==0||!s&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!yVe(n,t.prevRanges)),u=s?ik(t.prevRanges,n.mapping):Y7(n.mapping.maps);return new Du(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,y1(e)),Po.empty,u,n.time,o??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Du(t.done.rebased(n,a),t.undone.rebased(n,a),ik(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Du(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ik(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function yVe(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&i>=e[a]&&(n=!0)}),n}function Y7(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,s)=>e.push(a,s));return e}function ik(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function vVe(t,e,n){let r=y1(e),i=Lh.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let s=a.selection.resolve(a.transform.doc),o=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new Du(n?o:a.remaining,n?a.remaining:o,null,0,-1);return a.transform.setSelection(s).setMeta(Lh,{redo:n,historyState:c})}let ak=!1,Z7=null;function y1(t){let e=t.plugins;if(Z7!=e){ak=!1,Z7=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){ak=!0;break}}return ak}const Lh=new Si("history"),_Ve=new Si("closeHistory");function wVe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Er({key:Lh,state:{init(){return new Du(Po.empty,Po.empty,null,0,-1)},apply(e,n,r){return bVe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?jee:r=="historyRedo"?Oee:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Dee(t,e){return(n,r)=>{let i=Lh.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=vVe(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const jee=Dee(!1,!0),Oee=Dee(!0,!0);Qn.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Er({key:new Si("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const s=a-i,o=0,c=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(o,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,c=a-r,u=o-c,d=o;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var SVe=Qn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[aVe(this.options)]}});Qn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Er({key:new Si("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return yr.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;s+=1});let o=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&s-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";a.push(Ea.node(u,u+c.nodeSize,{class:this.options.className}))}),yr.create(t,a)}}})]}});var MVe=Qn.create({name:"gapCursor",addProseMirrorPlugins(){return[cVe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Un(Bt(t,"allowGapCursor",n)))!=null?e:null}}});Qn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Er({key:new Si("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((s,o)=>{const c=r>=o&&r<=o+s.nodeSize,u=!s.isLeaf&&iE(s);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Ea.node(o,o+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:o,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),yr.create(t,i)}}})]}});Qn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Er({key:new Si("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||WJ(n.selection)||t.view.dragging?null:yr.create(n.doc,[Ea.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Q7({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var EVe=Qn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Si(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Er({key:e,appendTransaction:(i,a,s)=>{const{doc:o,tr:c,schema:u}=s,d=e.getState(s),f=o.content.size,g=u.nodes[n];if(d)return c.insert(f,g.create())},state:{init:(i,a)=>{const s=a.tr.doc.lastChild;return!Q7({node:s,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const s=i.doc.lastChild;return!Q7({node:s,types:r})}}})]}}),AVe=Qn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>jee(t,e),redo:()=>({state:t,dispatch:e})=>Oee(t,e)}},addProseMirrorPlugins(){return[wVe(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()}}}),TVe=Qn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(e$e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(XHe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(vee.configure(this.options.bulletList)),this.options.code!==!1&&i.push(r$e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(s$e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(o$e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(SVe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(MVe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(l$e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(c$e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(AVe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(u$e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(m$e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(_ee.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Tee.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(yee.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Nee.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(J$e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(nVe.configure(this.options.strike)),this.options.text!==!1&&i.push(rVe.configure(this.options.text)),this.options.underline!==!1&&i.push(kee.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(EVe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),CVe=TVe,NVe=Qn.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),kVe=NVe,PVe=20,Lee=(t,e=0)=>{const n=[];return!t.children.length||e>PVe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Lee(r,e+1))}),n},RVe=t=>{if(!t.children.length)return;const e=Lee(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),s=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${s};${a}`)})},Iee=Ed.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&RVe(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(a=>!!a))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),DVe=Qn.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="background-color")return o.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Fee=Qn.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="color")return o.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),jVe=Qn.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),OVe=Qn.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),LVe=Qn.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});Qn.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(DVe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Fee.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(jVe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(OVe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(LVe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Iee.configure(this.options.textStyle)),t}});var IVe=Fee,FVe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,UVe=Ja.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,a,s;const o=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(s=(a=t.attrs)==null?void 0:a.title)!=null?s:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:s})=>{const o=document.createElement("img");Object.entries(s).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:o.setAttribute(d,f);break}}),o.src=s.src;const c=new vHe({element:o,node:i,getPos:a,onResize:(d,f)=>{o.style.width=`${d}px`,o.style.height=`${f}px`},onCommit:(d,f)=>{const g=a();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,g)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",o.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[oee({find:FVe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),zVe=UVe;function J7({content:t,onChange:e,placeholder:n}){const r=VHe({extensions:[CVe.configure({heading:!1,codeBlock:!1,code:!1}),iVe,z$e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),kVe.configure({types:["paragraph"]}),Iee,IVe,zVe.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:s})=>{e(s.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!r)return null;const i=({onClick:s,isActive:o=!1,children:c,title:u})=>l.jsx("button",{type:"button",onClick:s,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${o?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:c}),a=()=>{const s=window.prompt("Enter URL:");s&&r.chain().focus().setLink({href:s}).run()};return l.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[l.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[l.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:l.jsx(toe,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:l.jsx(Dle,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:l.jsx(Eue,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:l.jsx(HR,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:l.jsx(uG,{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(xue,{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(fue,{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(mue,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:l.jsx(zS,{className:"w-4 h-4"})}),r.isActive("link")&&l.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:l.jsx(xG,{className:"w-4 h-4"})})]}),l.jsx(IHe,{editor:r})]})}function BVe({archiveId:t,archiveName:e,onClose:n}){const r=En(),[i,a]=E.useState(!1),[s,o]=E.useState(null),[c,u]=E.useState({}),{data:d,isLoading:f,error:g}=vt({queryKey:["archive-project-page",t],queryFn:()=>ke.getArchiveProjectPage(t)}),m=wt({mutationFn:T=>ke.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});E.useEffect(()=>{const T=k=>{k.key==="Escape"&&(s!==null?o(null):i?b():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[s,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],v=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},y=()=>{m.mutate(c)},b=()=>{a(!1),u({})},M=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 O="";if(F==="a"&&D.getAttribute("href")){const R=D.getAttribute("href");R?.toLowerCase().startsWith("http")&&(O=` href="${R}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const R=D.getAttribute("src");if(!R?.toLowerCase().startsWith("http"))return"";O=` src="${R}" style="max-width: 100%; height: auto;"`}const q=Array.from(D.childNodes).map(I).join("");return["br","img"].includes(F)?`<${F}${O} />`:`<${F}${O}>${q}</${F}>`}return""};return Array.from(N.body.childNodes).map(I).join("")},S=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),A=T=>{T.target===T.currentTarget&&n()};return l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(to,{className:"w-5 h-5 text-bambu-green"}),l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&l.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[!i&&S&&l.jsxs(Le,{variant:"ghost",size:"sm",onClick:v,children:[l.jsx(S0,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:b,children:"Cancel"}),l.jsxs(Le,{variant:"primary",size:"sm",onClick:y,disabled:m.isPending,children:[l.jsx(Ro,{className:"w-4 h-4 mr-1"}),"Save"]})]}),l.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&l.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!S&&l.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[l.jsx(to,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"No project page data found in this 3MF file."}),l.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&S&&l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"space-y-4",children:[i?l.jsx("input",{type:"text",value:c.title||"",onChange:T=>u({...c,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&l.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),l.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Dk,{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(Dk,{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(As,{className:"w-3 h-3"})})]}),d.creation_date&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx(Zr,{className:"w-4 h-4"}),l.jsx("span",{children:d.creation_date})]}),i?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(to,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:c.license||"",onChange:T=>u({...c,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx(to,{className:"w-4 h-4"}),l.jsx("span",{children:d.license})]}),d.origin&&l.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?l.jsx(J7,{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:M(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(J7,{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:M(d.profile_description)}}),d.profile_user_name&&l.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[l.jsx(gb,{className:"w-4 h-4"}),"Images (",x.length,")"]}),l.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((T,k)=>l.jsx("button",{onClick:()=>o(k),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:l.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),d.design_model_id&&l.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[l.jsx(As,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),s!==null&&x[s]&&l.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[l.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.max(0,s-1))},disabled:s===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:l.jsx(Bh,{className:"w-6 h-6 text-white"})}),l.jsx("img",{src:x[s].url,alt:x[s].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),l.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(x.length-1,s+1))},disabled:s===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:l.jsx(df,{className:"w-6 h-6 text-white"})}),l.jsx("button",{onClick:()=>o(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:l.jsx(Wt,{className:"w-6 h-6 text-white"})}),l.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[s+1," / ",x.length]})]})]})}const HVe=[.25,.5,.75,1,1.5,2,3,4];function $Ve({src:t,title:e,downloadFilename:n,onClose:r}){const i=E.useRef(null),[a,s]=E.useState(!0),[o,c]=E.useState(2),[u,d]=E.useState(0),[f,g]=E.useState(0);E.useEffect(()=>{const S=i.current;S&&(S.playbackRate=o)},[o]),E.useEffect(()=>{const S=A=>{A.key==="Escape"&&r()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[r]),E.useEffect(()=>{const S=i.current;if(!S)return;const A=()=>d(S.currentTime),T=()=>g(S.duration),k=()=>s(!0),N=()=>s(!1);return S.addEventListener("timeupdate",A),S.addEventListener("durationchange",T),S.addEventListener("play",k),S.addEventListener("pause",N),()=>{S.removeEventListener("timeupdate",A),S.removeEventListener("durationchange",T),S.removeEventListener("play",k),S.removeEventListener("pause",N)}},[]);const m=()=>{const S=i.current;S&&(a?S.pause():S.play())},x=S=>{const A=i.current;A&&(A.currentTime=parseFloat(S.target.value))},v=()=>{const S=i.current;S&&(S.currentTime=Math.max(0,S.currentTime-5))},y=()=>{const S=i.current;S&&(S.currentTime=Math.min(f,S.currentTime+5))},b=S=>{const A=Math.floor(S/60),T=Math.floor(S%60);return`${A}:${T.toString().padStart(2,"0")}`},M=()=>{const S=document.createElement("a");S.href=t,S.download=n,S.click()};return l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:l.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Zp,{className:"w-5 h-5 text-bambu-green"}),e]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:M,children:[l.jsx(Es,{className:"w-4 h-4"}),"Download"]}),l.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),l.jsxs("div",{className:"p-4",children:[l.jsx("video",{ref:i,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:m}),l.jsxs("div",{className:"mt-4 space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:b(u)}),l.jsx("input",{type:"range",min:0,max:f||100,value:u,onChange:x,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),l.jsx("span",{className:"text-xs text-bambu-gray w-12",children:b(f)})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:l.jsx(eue,{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:a?l.jsx(_ce,{className:"w-5 h-5 text-white"}):l.jsx(BS,{className:"w-5 h-5 text-white"})}),l.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:l.jsx(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:HVe.map(S=>l.jsxs("button",{onClick:()=>c(S),className:`px-2 py-1 text-xs rounded transition-colors ${o===S?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[S,"x"]},S))})]})]})]})]})]})})}function VVe({archiveId:t,archiveName:e,onClose:n}){const r=En(),{showToast:i}=ai(),[a,s]=E.useState(null),[o,c]=E.useState("asap"),[u,d]=E.useState(""),[f,g]=E.useState(!1),[m,x]=E.useState(!1),{data:v}=vt({queryKey:["printers"],queryFn:()=>ke.getPrinters()});E.useEffect(()=>{v?.length===1&&!a&&s(v[0].id)},[v,a]),E.useEffect(()=>{const S=A=>{A.key==="Escape"&&n()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[n]);const y=wt({mutationFn:S=>ke.addToQueue(S),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:S=>{i(S.message||"Failed to add to queue","error")}}),b=S=>{if(S.preventDefault(),!a){i("Please select a printer","error");return}const A={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:m};o==="scheduled"&&u&&(A.scheduled_time=new Date(u).toISOString()),y.mutate(A)},M=()=>{const S=new Date;return S.setMinutes(S.getMinutes()+1),S.toISOString().slice(0,16)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Zr,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),l.jsx("p",{className:"text-white font-medium truncate",children:e})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),v?.length===0?l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(lo,{className:"w-4 h-4"}),"No printers configured"]}):l.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:S=>s(S.target.value?Number(S.target.value):null),required:!0,children:[l.jsx("option",{value:"",children:"Select printer..."}),v?.map(S=>l.jsx("option",{value:S.id,children:S.name},S.id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[l.jsx(_r,{className:"w-4 h-4"}),"ASAP (when idle)"]}),l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[l.jsx(Zr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),l.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:S=>d(S.target.value),min:M(),required:!0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:S=>g(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:S=>x(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[l.jsx(bd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",disabled:y.isPending||!a||v?.length===0,children:y.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function GVe({archiveIds:t,onClose:e}){E.useEffect(()=>{const a=s=>{s.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=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:a=>a.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(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(WVe,{comparison:n}):null}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsx(Le,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function WVe({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 bR(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Px(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function e9(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function qVe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a}){const s=En(),{showToast:o}=ai(),c=wG(),[u,d]=E.useState(!1),[f,g]=E.useState(!1),[m,x]=E.useState(!1),[v,y]=E.useState(!1),[b,M]=E.useState(!1),[S,A]=E.useState(!1),[T,k]=E.useState([]),[N,I]=E.useState(!1),[C,D]=E.useState(!1),[F,O]=E.useState(!1),[q,R]=E.useState(!1),[W,K]=E.useState(!1),[G,ee]=E.useState(null),Z=E.useRef(null),Q=wt({mutationFn:ie=>ke.uploadSource3mf(t.id,ie),onSuccess:ie=>{s.invalidateQueries({queryKey:["archives"]}),o(`Source 3MF attached: ${ie.filename}`)},onError:ie=>{o(ie.message||"Failed to upload source 3MF","error")}}),U=wt({mutationFn:()=>ke.deleteSource3mf(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),o("Source 3MF removed")},onError:ie=>{o(ie.message||"Failed to remove source 3MF","error")}}),$=wt({mutationFn:()=>ke.scanArchiveTimelapse(t.id),onSuccess:ie=>{ie.status==="attached"?(s.invalidateQueries({queryKey:["archives"]}),o(`Timelapse attached: ${ie.filename}`)):ie.status==="exists"?o("Timelapse already attached"):ie.status==="not_found"&&ie.available_files&&ie.available_files.length>0?(k(ie.available_files),A(!0)):o(ie.message||"No matching timelapse found","warning")},onError:ie=>{o(ie.message||"Failed to scan for timelapse","error")}}),X=wt({mutationFn:ie=>ke.selectArchiveTimelapse(t.id,ie),onSuccess:ie=>{s.invalidateQueries({queryKey:["archives"]}),o(`Timelapse attached: ${ie.filename}`),A(!1),k([])},onError:ie=>{o(ie.message||"Failed to attach timelapse","error")}}),te=wt({mutationFn:()=>ke.deleteArchive(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),o("Archive deleted")},onError:()=>{o("Failed to delete archive","error")}}),fe=wt({mutationFn:()=>ke.toggleFavorite(t.id),onSuccess:ie=>{s.invalidateQueries({queryKey:["archives"]}),o(ie.is_favorite?"Added to favorites":"Removed from favorites")}}),pe=wt({mutationFn:ie=>ke.updateArchive(t.id,{project_id:ie}),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),s.invalidateQueries({queryKey:["projects"]}),o("Project updated")},onError:()=>{o("Failed to update project","error")}}),xe=ie=>{ie.preventDefault(),ee({x:ie.clientX,y:ie.clientY})},Ne=[{label:"Print",icon:l.jsx(Ts,{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(As,{className:"w-4 h-4"}),onClick:()=>{const ie=t.print_name||t.filename||"model",be=`${window.location.origin}${ke.getArchiveForSlicer(t.id,ie)}`;window.location.href=`bambustudioopen://${encodeURIComponent(be)}`}},{label:"View on MakerWorld",icon:l.jsx(y0,{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:()=>M(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:l.jsx(Bce,{className:"w-4 h-4"}),onClick:()=>$.mutate(),disabled:!t.printer_id||!!t.timelapse_path||$.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:l.jsx(KF,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const ie=document.createElement("a");ie.href=ke.getSource3mfDownloadUrl(t.id),ie.download=`${t.print_name||t.filename}_source.3mf`,ie.click()}else Z.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:l.jsx(vs,{className:"w-4 h-4"}),onClick:()=>Z.current?.click()},{label:"Remove Source 3MF",icon:l.jsx(Rn,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:l.jsx(Es,{className:"w-4 h-4"}),onClick:()=>{const ie=document.createElement("a");ie.href=ke.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()}},{label:"Copy Download Link",icon:l.jsx(Hh,{className:"w-4 h-4"}),onClick:()=>{const ie=`${window.location.origin}${ke.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ie).then(()=>{o("Link copied to clipboard")}).catch(()=>{o("Failed to copy link","error")})}},{label:"QR Code",icon:l.jsx(jce,{className:"w-4 h-4"}),onClick:()=>I(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:l.jsx(b0,{className:"w-4 h-4"}),onClick:()=>D(!0),disabled:!t.photos?.length},{label:"Project Page",icon:l.jsx(to,{className:"w-4 h-4"}),onClick:()=>O(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:l.jsx(xm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>fe.mutate()},{label:"Edit",icon:l.jsx(rd,{className:"w-4 h-4"}),onClick:()=>y(!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 ie=[];if(t.project_id&&ie.push({label:"Remove from Project",icon:l.jsx(Wt,{className:"w-4 h-4"}),onClick:()=>pe.mutate(null)}),!a)ie.push({label:"Loading...",icon:l.jsx(At,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const be=a.filter(je=>je.status==="active");be.length===0?ie.push({label:"No projects available",icon:l.jsx(qu,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):be.forEach(je=>{ie.push({label:je.name,icon:l.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:je.color||"#888"}}),onClick:()=>pe.mutate(je.id),disabled:t.project_id===je.id})})}return ie})()},{label:n?"Deselect":"Select",icon:n?l.jsx(Vh,{className:"w-4 h-4"}):l.jsx(gm,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:l.jsx(Rn,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return l.jsxs(Nt,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:xe,onClick:i?()=>r(t.id):void 0,children:[i&&l.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation(),r(t.id)},children:n?l.jsx(Vh,{className:"w-5 h-5 text-bambu-green"}):l.jsx(gm,{className:"w-5 h-5 text-white"})}),l.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?l.jsx("img",{src:ke.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center",children:l.jsx(gb,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),c&&l.jsx("button",{className:"absolute top-2 right-10 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation();const be=ie.currentTarget.getBoundingClientRect();ee({x:be.left,y:be.bottom+4})},title:"Menu",children:l.jsx(sG,{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:ie=>{ie.stopPropagation(),fe.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:l.jsx(xm,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&l.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:t.status==="aborted"?"cancelled":"failed"}),t.duplicate_count>0&&l.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:"This model has been printed before",children:[l.jsx(Hh,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&l.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation();const be=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",je=`${window.location.origin}${ke.getSource3mfForSlicer(t.id,be)}`;window.location.href=`bambustudioopen://${encodeURIComponent(je)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:l.jsx(KF,{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:ie=>{ie.stopPropagation(),M(!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:ie=>{ie.stopPropagation(),D(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[l.jsx(b0,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&l.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]})]}),l.jsxs(Rt,{className:"p-4 flex-1 flex flex-col",children:[l.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:e}),t.project_name&&l.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(ie=>ie.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(ie=>ie.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Px(t.print_time_seconds||0)}
- Actual: ${Px(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Px(t.actual_time_seconds)}`:`Estimated: ${Px(t.print_time_seconds||0)}`,children:[l.jsx(_r,{className:"w-3 h-3"}),Px(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&l.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[l.jsx(w0,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[l.jsx($h,{className:"w-3 h-3"}),t.total_layers&&l.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&l.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&l.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&l.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[l.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&l.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((ie,be)=>l.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ie},title:ie},be))})]})]}),(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(hG,{className:"w-3 h-3"})}),t.tags?.split(",").map((ie,be)=>l.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ie.trim()},be))]}),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:e9(t.created_at)}),l.jsx("span",{children:bR(t.file_size)})]}),l.jsxs("div",{className:"flex gap-1 mt-3",children:[l.jsxs(Le,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>g(!0),children:[l.jsx(Ts,{className:"w-3 h-3 flex-shrink-0"}),l.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=t.print_name||t.filename||"model",be=`${window.location.origin}${ke.getArchiveForSlicer(t.id,ie)}`;window.location.href=`bambustudioopen://${encodeURIComponent(be)}`},title:"Open in Bambu Studio",children:l.jsx(As,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url,title:t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"Not from MakerWorld",children:l.jsx(y0,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>d(!0),title:"3D Preview",children:l.jsx(fm,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=document.createElement("a");ie.href=ke.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()},title:"Download",children:l.jsx(Es,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>y(!0),title:"Edit",children:l.jsx(rd,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:l.jsx(Rn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&l.jsx(xUe,{archive:t,onClose:()=>y(!1)}),u&&l.jsx(hUe,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>d(!1)}),f&&l.jsx(fUe,{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:()=>{te.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)}),G&&l.jsx(bUe,{x:G.x,y:G.y,items:Ne,onClose:()=>ee(null)}),b&&t.timelapse_path&&l.jsx($Ve,{src:ke.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,onClose:()=>M(!1)}),S&&T.length>0&&l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),l.jsx("button",{onClick:()=>{A(!1),k([])},className:"text-gray-400 hover:text-white p-1",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(ie=>l.jsxs("button",{onClick:()=>X.mutate(ie.name),disabled:X.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:ie.name}),l.jsxs("p",{className:"text-sm text-gray-400",children:[bR(ie.size),ie.mtime&&` • ${e9(ie.mtime)}`]})]})]},ie.name))}),l.jsx("div",{className:"p-4 border-t border-gray-700",children:l.jsx(Le,{variant:"secondary",onClick:()=>{A(!1),k([])},className:"w-full",children:"Cancel"})})]})}),N&&l.jsx(EUe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),C&&t.photos&&t.photos.length>0&&l.jsx(AUe,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>D(!1),onDelete:async ie=>{try{await ke.deleteArchivePhoto(t.id,ie),s.invalidateQueries({queryKey:["archives"]}),o("Photo deleted")}catch{o("Failed to delete photo","error")}}}),F&&l.jsx(BVe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>O(!1)}),q&&l.jsx(VVe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),l.jsx("input",{ref:Z,type:"file",accept:".3mf",className:"hidden",onChange:ie=>{const be=ie.target.files?.[0];be&&Q.mutate(be),ie.target.value=""}})]})}const KVe=[{id:"all",label:"All Archives",icon:l.jsx(ple,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:l.jsx(_r,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:l.jsx(Zr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:l.jsx(Zr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:l.jsx(xm,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:l.jsx(lo,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:l.jsx(Hh,{className:"w-4 h-4"})}];function XVe(){const t=En(),{showToast:e}=ai(),n=E.useRef(null),[r,i]=E.useState(""),[a,s]=E.useState(null),[o,c]=E.useState(null),[u,d]=E.useState(new Set),[f,g]=E.useState("or"),[m,x]=E.useState(!1),[v,y]=E.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[b,M]=E.useState(null),[S,A]=E.useState(!1),[T,k]=E.useState([]),[N,I]=E.useState(!1),[C,D]=E.useState(new Set),[F,O]=E.useState(!1),[q,R]=E.useState(!1),[W,K]=E.useState(!1),[G,ee]=E.useState("grid"),[Z,Q]=E.useState("date-desc"),[U,$]=E.useState("all"),[X,te]=E.useState(!1),[fe,pe]=E.useState(!1),[xe,Ne]=E.useState(!1),{data:ie,isLoading:be}=vt({queryKey:["archives",a],queryFn:()=>ke.getArchives(a||void 0)}),{data:je}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:he}=vt({queryKey:["projects"],queryFn:()=>ke.getProjects()}),ht=wt({mutationFn:async ue=>(await Promise.all(ue.map(Ve=>ke.deleteArchive(Ve))),ue.length),onSuccess:ue=>{t.invalidateQueries({queryKey:["archives"]}),D(new Set),e(`${ue} archive${ue!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});E.useEffect(()=>{localStorage.setItem("archiveHideFailed",v.toString())},[v]);const H=new Map(je?.map(ue=>[ue.id,ue.name])||[]),B=[...new Set(ie?.flatMap(ue=>ue.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),re=[...new Set(ie?.flatMap(ue=>ue.filament_color?.split(",")||[]).filter(Boolean)||[])],V=[...new Set(ie?.flatMap(ue=>ue.tags?.split(",").map(Ve=>Ve.trim())||[]).filter(Boolean)||[])].sort(),J=ie?.filter(ue=>{const Ve=new Date,Fe=new Date(ue.created_at);let oe=!0;switch(U){case"recent":oe=Ve.getTime()-Fe.getTime()<1440*60*1e3;break;case"this-week":oe=Ve.getTime()-Fe.getTime()<10080*60*1e3;break;case"this-month":oe=Fe.getMonth()===Ve.getMonth()&&Fe.getFullYear()===Ve.getFullYear();break;case"favorites":oe=ue.is_favorite===!0;break;case"failed":oe=ue.status==="failed"||ue.status==="aborted";break;case"duplicates":oe=ue.duplicate_count>0;break}const Je=(ue.print_name||ue.filename).toLowerCase().includes(r.toLowerCase()),He=!o||ue.filament_type?.split(", ").includes(o),Ke=ue.filament_color?.split(",")||[],ct=u.size===0||(f==="or"?Ke.some(Ce=>u.has(Ce)):[...u].every(Ce=>Ke.includes(Ce))),de=U==="favorites"||!m||ue.is_favorite,Ye=U==="failed"||!v||ue.status!=="failed"&&ue.status!=="aborted",ge=ue.tags?.split(",").map(Ce=>Ce.trim())||[],Ue=!b||ge.includes(b);return oe&&Je&&He&&ct&&de&&Ye&&Ue}).sort((ue,Ve)=>{switch(Z){case"date-desc":return new Date(Ve.created_at).getTime()-new Date(ue.created_at).getTime();case"date-asc":return new Date(ue.created_at).getTime()-new Date(Ve.created_at).getTime();case"name-asc":return(ue.print_name||ue.filename).localeCompare(Ve.print_name||Ve.filename);case"name-desc":return(Ve.print_name||Ve.filename).localeCompare(ue.print_name||ue.filename);case"size-desc":return Ve.file_size-ue.file_size;case"size-asc":return ue.file_size-Ve.file_size;default:return 0}}),se=F||C.size>0,Ae=ue=>{D(Ve=>{const Fe=new Set(Ve);return Fe.has(ue)?Fe.delete(ue):Fe.add(ue),Fe})},Pe=()=>{J&&D(new Set(J.map(ue=>ue.id)))},Se=()=>{D(new Set),O(!1)},z=ue=>{d(Ve=>{const Fe=new Set(Ve);return Fe.has(ue)?Fe.delete(ue):Fe.add(ue),Fe})},L=()=>{d(new Set)},ne=()=>{i(""),s(null),c(null),x(!1),y(!1),M(null)},ve=r||a||o||m||v||b,we=E.useCallback(ue=>{ue.preventDefault(),ue.dataTransfer.types.includes("Files")&&I(!0)},[]),ye=E.useCallback(ue=>{ue.preventDefault(),ue.currentTarget===ue.target&&I(!1)},[]),nt=E.useCallback(ue=>{ue.preventDefault(),I(!1);const Ve=Array.from(ue.dataTransfer.files).filter(Fe=>Fe.name.endsWith(".3mf"));Ve.length>0?(k(Ve),A(!0)):ue.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),Be=E.useCallback(ue=>{const Ve=ue.target;if(Ve.tagName==="INPUT"||Ve.tagName==="TEXTAREA"||Ve.isContentEditable){ue.key==="Escape"&&Ve.blur();return}switch(ue.key){case"/":ue.preventDefault(),n.current?.focus();break;case"u":case"U":!ue.metaKey&&!ue.ctrlKey&&(ue.preventDefault(),A(!0));break;case"Escape":se&&Se();break}},[se]);return E.useEffect(()=>(document.addEventListener("keydown",Be),()=>document.removeEventListener("keydown",Be)),[Be]),l.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:we,onDragLeave:ye,onDrop:nt,children:[N&&l.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:l.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[l.jsx(vs,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),l.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),l.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),se&&l.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:Se,children:[l.jsx(Wt,{className:"w-4 h-4"}),"Close"]}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs("span",{className:"text-white font-medium",children:[C.size," selected"]}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:Pe,children:"Select All"}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>K(!0),children:[l.jsx(E0,{className:"w-4 h-4"}),"Tags"]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>{const ue=Array.from(C);Promise.all(ue.map(Ve=>ke.toggleFavorite(Ve))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ue.length} archive${ue.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[l.jsx(xm,{className:"w-4 h-4"}),"Favorite"]}),l.jsxs(Le,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>R(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]}),l.jsxs("div",{className:"flex items-center justify-between mb-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),l.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:U,onChange:ue=>$(ue.target.value),children:KVe.map(ue=>l.jsx("option",{value:ue.id,children:ue.label},ue.id))})]}),l.jsxs("p",{className:"text-bambu-gray",children:[J?.length||0," of ",ie?.length||0," prints"]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"relative",children:[l.jsxs(Le,{variant:"secondary",onClick:()=>te(!X),disabled:fe,children:[fe?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(T1,{className:"w-4 h-4"}),"Export"]}),X&&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()=>{te(!1),pe(!0);try{const{blob:ue,filename:Ve}=await ke.exportArchives({format:"csv",printerId:a||void 0,status:U==="failed"?"failed":void 0,search:r||void 0}),Fe=URL.createObjectURL(ue),oe=document.createElement("a");oe.href=Fe,oe.download=Ve,oe.click(),URL.revokeObjectURL(Fe),e("Export downloaded")}catch{e("Export failed","error")}finally{pe(!1)}},children:[l.jsx(to,{className:"w-4 h-4"}),"Export as CSV"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{te(!1),pe(!0);try{const{blob:ue,filename:Ve}=await ke.exportArchives({format:"xlsx",printerId:a||void 0,status:U==="failed"?"failed":void 0,search:r||void 0}),Fe=URL.createObjectURL(ue),oe=document.createElement("a");oe.href=Fe,oe.download=Ve,oe.click(),URL.revokeObjectURL(Fe),e("Export downloaded")}catch{e("Export failed","error")}finally{pe(!1)}},children:[l.jsx(T1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),C.size>=2&&C.size<=5&&l.jsxs(Le,{variant:"secondary",onClick:()=>Ne(!0),children:[l.jsx(Qp,{className:"w-4 h-4"}),"Compare (",C.size,")"]}),!se&&l.jsxs(Le,{variant:"secondary",onClick:()=>O(!0),children:[l.jsx(Vh,{className:"w-4 h-4"}),"Select"]}),l.jsxs(Le,{onClick:()=>A(!0),children:[l.jsx(vs,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),l.jsx(Nt,{className:"mb-6",children:l.jsxs(Rt,{className:"py-4",children:[l.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[l.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[l.jsx(id,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:ue=>i(ue.target.value)})]}),l.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(UR,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:ue=>s(ue.target.value?Number(ue.target.value):null),children:[l.jsx("option",{value:"",children:"All Printers"}),je?.map(ue=>l.jsx("option",{value:ue.id,children:ue.name},ue.id))]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(w0,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o||"",onChange:ue=>c(ue.target.value||null),children:[l.jsx("option",{value:"",children:"All Materials"}),B.map(ue=>l.jsx("option",{value:ue,children:ue},ue))]})]}),l.jsxs("button",{onClick:()=>x(!m),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${m?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:m?"Show all":"Show favorites only",children:[l.jsx(xm,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),l.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),l.jsxs("button",{onClick:()=>y(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:v?"Show failed prints":"Hide failed prints",children:[l.jsx(lo,{className:"w-4 h-4 "}),l.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),V.length>0&&l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(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:b||"",onChange:ue=>M(ue.target.value||null),children:[l.jsx("option",{value:"",children:"All Tags"}),V.map(ue=>l.jsx("option",{value:ue,children:ue},ue))]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(Zse,{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:Z,onChange:ue=>Q(ue.target.value),children:[l.jsx("option",{value:"date-desc",children:"Newest first"}),l.jsx("option",{value:"date-asc",children:"Oldest first"}),l.jsx("option",{value:"name-asc",children:"Name A-Z"}),l.jsx("option",{value:"name-desc",children:"Name Z-A"}),l.jsx("option",{value:"size-desc",children:"Largest first"}),l.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),l.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[l.jsx("button",{className:`p-2 ${G==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ee("grid"),title:"Grid view",children:l.jsx(cG,{className:"w-4 h-4"})}),l.jsx("button",{className:`p-2 ${G==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ee("list"),title:"List view",children:l.jsx(HR,{className:"w-4 h-4"})}),l.jsx("button",{className:`p-2 ${G==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ee("calendar"),title:"Calendar view",children:l.jsx(uoe,{className:"w-4 h-4"})})]})]}),ve&&l.jsxs(Le,{variant:"ghost",size:"sm",onClick:ne,className:"text-bambu-gray hover:text-white",children:[l.jsx(Wt,{className:"w-4 h-4"}),"Reset"]})]}),re.length>0&&l.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&l.jsx("button",{onClick:()=>g(ue=>ue==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),l.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:re.map(ue=>l.jsx("button",{onClick:()=>z(ue),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(ue)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ue},title:ue},ue))}),u.size>0&&l.jsxs("button",{onClick:L,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[l.jsx(Wt,{className:"w-3 h-3"}),"Clear"]})]})]})}),be?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):J?.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-12",children:[l.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):G==="calendar"?l.jsx(Nt,{className:"p-6",children:l.jsx(MUe,{archives:J||[],onArchiveClick:ue=>{i(ue.print_name||ue.filename),ee("grid")}})}):G==="grid"?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:J?.map(ue=>l.jsx(qVe,{archive:ue,printerName:ue.printer_id?H.get(ue.printer_id)||"Unknown":"No Printer",isSelected:C.has(ue.id),onSelect:Ae,selectionMode:se,projects:he},ue.id))}):G==="list"?l.jsx(Nt,{children:l.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[l.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[l.jsx("div",{className:"col-span-1"}),l.jsx("div",{className:"col-span-4",children:"Name"}),l.jsx("div",{className:"col-span-2",children:"Printer"}),l.jsx("div",{className:"col-span-2",children:"Date"}),l.jsx("div",{className:"col-span-1",children:"Size"}),l.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),J?.map(ue=>l.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${C.has(ue.id)?"bg-bambu-green/10":""}`,children:[l.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[se&&l.jsx("button",{onClick:()=>Ae(ue.id),children:C.has(ue.id)?l.jsx(Vh,{className:"w-4 h-4 text-bambu-green"}):l.jsx(gm,{className:"w-4 h-4 text-bambu-gray"})}),ue.thumbnail_path?l.jsx("img",{src:ke.getArchiveThumbnail(ue.id),alt:"",className:"w-10 h-10 object-cover rounded"}):l.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:l.jsx(gb,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),l.jsxs("div",{className:"col-span-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-white text-sm truncate",children:ue.print_name||ue.filename}),ue.timelapse_path&&l.jsx("span",{title:"Has timelapse",children:l.jsx(Zp,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),ue.filament_type&&l.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:ue.filament_type}),ue.filament_color&&l.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:ue.filament_color.split(",").map((Ve,Fe)=>l.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:Ve},title:Ve},Fe))})]})]}),l.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:ue.printer_id?H.get(ue.printer_id)||"Unknown":"No Printer"}),l.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(ue.created_at).toLocaleDateString()}),l.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:bR(ue.file_size)}),l.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{const Ve=ue.print_name||ue.filename||"model",Fe=`${window.location.origin}${ke.getArchiveForSlicer(ue.id,Ve)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Fe)}`},title:"Open in Slicer",children:l.jsx(As,{className:"w-4 h-4"})}),ue.makerworld_url&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>window.open(ue.makerworld_url,"_blank"),title:"MakerWorld",children:l.jsx(y0,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{const Ve=document.createElement("a");Ve.href=ke.getArchiveDownload(ue.id),Ve.download=`${ue.print_name||ue.filename}.3mf`,Ve.click()},title:"Download",children:l.jsx(Es,{className:"w-4 h-4"})})]})]},ue.id))]})}):null,S&&l.jsx(pUe,{onClose:()=>{A(!1),k([])},initialFiles:T}),q&&l.jsx(Qr,{title:"Delete Archives",message:`Are you sure you want to delete ${C.size} archive${C.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${C.size}`,variant:"danger",onConfirm:()=>{ht.mutate(Array.from(C)),R(!1)},onCancel:()=>R(!1)}),W&&l.jsx(yUe,{selectedIds:Array.from(C),existingTags:V,onClose:()=>K(!1)}),xe&&C.size>=2&&C.size<=5&&l.jsx(GVe,{archiveIds:Array.from(C),onClose:()=>{Ne(!1),D(new Set),O(!1)}})]})}function YVe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const lE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function uL(t){return"nodeType"in t}function es(t){var e,n;return t?fg(t)?t:uL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function dL(t){const{Document:e}=es(t);return t instanceof e}function ey(t){return fg(t)?!1:t instanceof es(t).HTMLElement}function Uee(t){return t instanceof es(t).SVGElement}function pg(t){return t?fg(t)?t.document:uL(t)?dL(t)?t:ey(t)||Uee(t)?t.ownerDocument:document:document:document}const vl=lE?E.useLayoutEffect:E.useEffect;function hL(t){const e=E.useRef(t);return vl(()=>{e.current=t}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function ZVe(){const t=E.useRef(null),e=E.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=E.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function cb(t,e){e===void 0&&(e=[t]);const n=E.useRef(t);return vl(()=>{n.current!==t&&(n.current=t)},e),n}function ty(t,e){const n=E.useRef();return E.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function NS(t){const e=hL(t),n=E.useRef(null),r=E.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function yR(t){const e=E.useRef();return E.useEffect(()=>{e.current=t},[t]),e.current}let sk={};function ny(t,e){return E.useMemo(()=>{if(e)return e;const n=sk[t]==null?0:sk[t]+1;return sk[t]=n,t+"-"+n},[t,e])}function zee(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((a,s)=>{const o=Object.entries(s);for(const[c,u]of o){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const dm=zee(1),ub=zee(-1);function QVe(t){return"clientX"in t&&"clientY"in t}function fL(t){if(!t)return!1;const{KeyboardEvent:e}=es(t.target);return e&&t instanceof e}function JVe(t){if(!t)return!1;const{TouchEvent:e}=es(t.target);return e&&t instanceof e}function vR(t){if(JVe(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 QVe(t)?{x:t.clientX,y:t.clientY}:null}const $m=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[$m.Translate.toString(t),$m.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),t9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function e7e(t){return t.matches(t9)?t:t.querySelector(t9)}const t7e={display:"none"};function n7e(t){let{id:e,value:n}=t;return mr.createElement("div",{id:e,style:t7e},n)}function r7e(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 i7e(){const[t,e]=E.useState("");return{announce:E.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Bee=E.createContext(null);function a7e(t){const e=E.useContext(Bee);E.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function s7e(){const[t]=E.useState(()=>new Set),e=E.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[E.useCallback(r=>{let{type:i,event:a}=r;t.forEach(s=>{var o;return(o=s[i])==null?void 0:o.call(s,a)})},[t]),e]}const o7e={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.
- `},l7e={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 c7e(t){let{announcements:e=l7e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=o7e}=t;const{announce:a,announcement:s}=i7e(),o=ny("DndLiveRegion"),[c,u]=E.useState(!1);if(E.useEffect(()=>{u(!0)},[]),a7e(E.useMemo(()=>({onDragStart(f){let{active:g}=f;a(e.onDragStart({active:g}))},onDragMove(f){let{active:g,over:m}=f;e.onDragMove&&a(e.onDragMove({active:g,over:m}))},onDragOver(f){let{active:g,over:m}=f;a(e.onDragOver({active:g,over:m}))},onDragEnd(f){let{active:g,over:m}=f;a(e.onDragEnd({active:g,over:m}))},onDragCancel(f){let{active:g,over:m}=f;a(e.onDragCancel({active:g,over:m}))}}),[a,e])),!c)return null;const d=mr.createElement(mr.Fragment,null,mr.createElement(n7e,{id:r,value:i.draggable}),mr.createElement(r7e,{id:o,announcement:s}));return n?hc.createPortal(d,n):d}var di;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(di||(di={}));function kS(){}function PS(t,e){return E.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Hee(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const zo=Object.freeze({x:0,y:0});function $ee(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Vee(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function u7e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function n9(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 Gee(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function r9(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 Wee=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=r9(e,e.left,e.top),a=[];for(const s of r){const{id:o}=s,c=n.get(o);if(c){const u=$ee(r9(c),i);a.push({id:o,data:{droppableContainer:s,value:u}})}}return a.sort(Vee)},d7e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=n9(e),a=[];for(const s of r){const{id:o}=s,c=n.get(o);if(c){const u=n9(c),d=i.reduce((g,m,x)=>g+$ee(u[x],m),0),f=Number((d/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:f}})}}return a.sort(Vee)};function h7e(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),s=i-r,o=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,d=s*o,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const f7e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:s}=a,o=n.get(s);if(o){const c=h7e(o,e);c>0&&i.push({id:s,data:{droppableContainer:a,value:c}})}}return i.sort(u7e)};function p7e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function qee(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:zo}function m7e(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.reduce((s,o)=>({...s,top:s.top+t*o.y,bottom:s.bottom+t*o.y,left:s.left+t*o.x,right:s.right+t*o.x}),{...n})}}const g7e=m7e(1);function x7e(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 b7e(t,e,n){const r=x7e(e);if(!r)return t;const{scaleX:i,scaleY:a,x:s,y:o}=r,c=t.left-s-(1-i)*parseFloat(n),u=t.top-o-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=a?t.height/a:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const y7e={ignoreTransform:!1};function mg(t,e){e===void 0&&(e=y7e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=es(t).getComputedStyle(t);u&&(n=b7e(n,u,d))}const{top:r,left:i,width:a,height:s,bottom:o,right:c}=n;return{top:r,left:i,width:a,height:s,bottom:o,right:c}}function i9(t){return mg(t,{ignoreTransform:!0})}function v7e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function _7e(t,e){return e===void 0&&(e=es(t).getComputedStyle(t)),e.position==="fixed"}function w7e(t,e){e===void 0&&(e=es(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=e[i];return typeof a=="string"?n.test(a):!1})}function cE(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(dL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!ey(i)||Uee(i)||n.includes(i))return n;const a=es(t).getComputedStyle(i);return i!==t&&w7e(i,a)&&n.push(i),_7e(i,a)?n:r(i.parentNode)}return t?r(t):n}function Kee(t){const[e]=cE(t,1);return e??null}function ok(t){return!lE||!t?null:fg(t)?t:uL(t)?dL(t)||t===pg(t).scrollingElement?window:ey(t)?t:null:null}function Xee(t){return fg(t)?t.scrollX:t.scrollLeft}function Yee(t){return fg(t)?t.scrollY:t.scrollTop}function _R(t){return{x:Xee(t),y:Yee(t)}}var ji;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ji||(ji={}));function Zee(t){return!lE||!t?!1:t===document.scrollingElement}function Qee(t){const e={x:0,y:0},n=Zee(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,s=t.scrollTop>=r.y,o=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:s,isRight:o,maxScroll:r,minScroll:e}}const S7e={x:.2,y:.2};function M7e(t,e,n,r,i){let{top:a,left:s,right:o,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=S7e);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=Qee(t),m={x:0,y:0},x={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+v.height?(m.y=ji.Backward,x.y=r*Math.abs((e.top+v.height-a)/v.height)):!d&&c>=e.bottom-v.height&&(m.y=ji.Forward,x.y=r*Math.abs((e.bottom-v.height-c)/v.height)),!g&&o>=e.right-v.width?(m.x=ji.Forward,x.x=r*Math.abs((e.right-v.width-o)/v.width)):!f&&s<=e.left+v.width&&(m.x=ji.Backward,x.x=r*Math.abs((e.left+v.width-s)/v.width)),{direction:m,speed:x}}function E7e(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function Jee(t){return t.reduce((e,n)=>dm(e,_R(n)),zo)}function A7e(t){return t.reduce((e,n)=>e+Xee(n),0)}function T7e(t){return t.reduce((e,n)=>e+Yee(n),0)}function C7e(t,e){if(e===void 0&&(e=mg),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);Kee(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const N7e=[["x",["left","right"],A7e],["y",["top","bottom"],T7e]];class pL{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=cE(n),i=Jee(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of N7e)for(const c of s)Object.defineProperty(this,c,{get:()=>{const u=o(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class u0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function k7e(t){const{EventTarget:e}=es(t);return t instanceof e?t:pg(t)}function lk(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 Xs;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Xs||(Xs={}));function a9(t){t.preventDefault()}function P7e(t){t.stopPropagation()}var Sn;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Sn||(Sn={}));const ete={start:[Sn.Space,Sn.Enter],cancel:[Sn.Esc],end:[Sn.Space,Sn.Enter,Sn.Tab]},R7e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Sn.Right:return{...n,x:n.x+25};case Sn.Left:return{...n,x:n.x-25};case Sn.Down:return{...n,y:n.y+25};case Sn.Up:return{...n,y:n.y-25}}};class uE{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new u0(pg(n)),this.windowListeners=new u0(es(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Xs.Resize,this.handleCancel),this.windowListeners.add(Xs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Xs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&C7e(r),n(zo)}handleKeyDown(e){if(fL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=ete,coordinateGetter:s=R7e,scrollBehavior:o="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:zo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=s(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=ub(f,d),m={x:0,y:0},{scrollableAncestors:x}=r.current;for(const v of x){const y=e.code,{isTop:b,isRight:M,isLeft:S,isBottom:A,maxScroll:T,minScroll:k}=Qee(v),N=E7e(v),I={x:Math.min(y===Sn.Right?N.right-N.width/2:N.right,Math.max(y===Sn.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(y===Sn.Down?N.bottom-N.height/2:N.bottom,Math.max(y===Sn.Down?N.top:N.top+N.height/2,f.y))},C=y===Sn.Right&&!M||y===Sn.Left&&!S,D=y===Sn.Down&&!A||y===Sn.Up&&!b;if(C&&I.x!==f.x){const F=v.scrollLeft+g.x,O=y===Sn.Right&&F<=T.x||y===Sn.Left&&F>=k.x;if(O&&!g.y){v.scrollTo({left:F,behavior:o});return}O?m.x=v.scrollLeft-F:m.x=y===Sn.Right?v.scrollLeft-T.x:v.scrollLeft-k.x,m.x&&v.scrollBy({left:-m.x,behavior:o});break}else if(D&&I.y!==f.y){const F=v.scrollTop+g.y,O=y===Sn.Down&&F<=T.y||y===Sn.Up&&F>=k.y;if(O&&!g.x){v.scrollTo({top:F,behavior:o});return}O?m.y=v.scrollTop-F:m.y=y===Sn.Down?v.scrollTop-T.y:v.scrollTop-k.y,m.y&&v.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,dm(ub(f,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}uE.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=ete,onActivation:i}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const o=a.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function s9(t){return!!(t&&"distance"in t)}function o9(t){return!!(t&&"delay"in t)}class mL{constructor(e,n,r){var i;r===void 0&&(r=k7e(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:s}=a;this.props=e,this.events=n,this.document=pg(s),this.documentListeners=new u0(this.document),this.listeners=new u0(r),this.windowListeners=new u0(es(s)),this.initialCoordinates=(i=vR(a))!=null?i:zo,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Xs.Resize,this.handleCancel),this.windowListeners.add(Xs.DragStart,a9),this.windowListeners.add(Xs.VisibilityChange,this.handleCancel),this.windowListeners.add(Xs.ContextMenu,a9),this.documentListeners.add(Xs.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(o9(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(s9(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(Xs.Click,P7e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Xs.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:s,options:{activationConstraint:o}}=a;if(!i)return;const c=(n=vR(e))!=null?n:zo,u=ub(i,c);if(!r&&o){if(s9(o)){if(o.tolerance!=null&&lk(u,o.tolerance))return this.handleCancel();if(lk(u,o.distance))return this.handleStart()}if(o9(o)&&lk(u,o.tolerance))return this.handleCancel();this.handlePending(o,u);return}e.cancelable&&e.preventDefault(),s(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Sn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const D7e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class dE extends mL{constructor(e){const{event:n}=e,r=pg(n.target);super(e,D7e,r)}}dE.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 j7e={move:{name:"mousemove"},end:{name:"mouseup"}};var wR;(function(t){t[t.RightClick=2]="RightClick"})(wR||(wR={}));class O7e extends mL{constructor(e){super(e,j7e,pg(e.event.target))}}O7e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===wR.RightClick?!1:(r?.({event:n}),!0)}}];const ck={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class L7e extends mL{constructor(e){super(e,ck)}static setup(){return window.addEventListener(ck.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(ck.move.name,e)};function e(){}}}L7e.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var d0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(d0||(d0={}));var RS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(RS||(RS={}));function I7e(t){let{acceleration:e,activator:n=d0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:s=5,order:o=RS.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const m=U7e({delta:f,disabled:!a}),[x,v]=ZVe(),y=E.useRef({x:0,y:0}),b=E.useRef({x:0,y:0}),M=E.useMemo(()=>{switch(n){case d0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case d0.DraggableRect:return i}},[n,i,c]),S=E.useRef(null),A=E.useCallback(()=>{const k=S.current;if(!k)return;const N=y.current.x*b.current.x,I=y.current.y*b.current.y;k.scrollBy(N,I)},[]),T=E.useMemo(()=>o===RS.TreeOrder?[...u].reverse():u,[o,u]);E.useEffect(()=>{if(!a||!u.length||!M){v();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}=M7e(k,I,M,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){v(),S.current=k,x(A,s),y.current=D,b.current=C;return}}y.current={x:0,y:0},b.current={x:0,y:0},v()},[e,A,r,v,a,s,JSON.stringify(M),JSON.stringify(m),x,u,T,d,JSON.stringify(g)])}const F7e={x:{[ji.Backward]:!1,[ji.Forward]:!1},y:{[ji.Backward]:!1,[ji.Forward]:!1}};function U7e(t){let{delta:e,disabled:n}=t;const r=yR(e);return ty(i=>{if(n||!r||!i)return F7e;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[ji.Backward]:i.x[ji.Backward]||a.x===-1,[ji.Forward]:i.x[ji.Forward]||a.x===1},y:{[ji.Backward]:i.y[ji.Backward]||a.y===-1,[ji.Forward]:i.y[ji.Forward]||a.y===1}}},[n,e,r])}function z7e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return ty(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function B7e(t,e){return E.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...a]},[]),[t,e])}var db;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(db||(db={}));var SR;(function(t){t.Optimized="optimized"})(SR||(SR={}));const l9=new Map;function H7e(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,s]=E.useState(null),{frequency:o,measure:c,strategy:u}=i,d=E.useRef(t),f=y(),g=cb(f),m=E.useCallback(function(b){b===void 0&&(b=[]),!g.current&&s(M=>M===null?b:M.concat(b.filter(S=>!M.includes(S))))},[g]),x=E.useRef(null),v=ty(b=>{if(f&&!n)return l9;if(!b||b===l9||d.current!==t||a!=null){const M=new Map;for(let S of t){if(!S)continue;if(a&&a.length>0&&!a.includes(S.id)&&S.rect.current){M.set(S.id,S.rect.current);continue}const A=S.node.current,T=A?new pL(c(A),A):null;S.rect.current=T,T&&M.set(S.id,T)}return M}return b},[t,a,n,f,c]);return E.useEffect(()=>{d.current=t},[t]),E.useEffect(()=>{f||m()},[n,f]),E.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),E.useEffect(()=>{f||typeof o!="number"||x.current!==null||(x.current=setTimeout(()=>{m(),x.current=null},o))},[o,f,m,...r]),{droppableRects:v,measureDroppableContainers:m,measuringScheduled:a!=null};function y(){switch(u){case db.Always:return!1;case db.BeforeDragging:return n;default:return!n}}}function tte(t,e){return ty(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function $7e(t,e){return tte(t,e)}function V7e(t){let{callback:e,disabled:n}=t;const r=hL(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function hE(t){let{callback:e,disabled:n}=t;const r=hL(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function G7e(t){return new pL(mg(t),t)}function c9(t,e,n){e===void 0&&(e=G7e);const[r,i]=E.useState(null);function a(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const s=V7e({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),o=hE({callback:a});return vl(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),r}function W7e(t){const e=tte(t);return qee(t,e)}const u9=[];function q7e(t){const e=E.useRef(t),n=ty(r=>t?r&&r!==u9&&t&&e.current&&t.parentNode===e.current.parentNode?r:cE(t):u9,[t]);return E.useEffect(()=>{e.current=t},[t]),n}function K7e(t){const[e,n]=E.useState(null),r=E.useRef(t),i=E.useCallback(a=>{const s=ok(a.target);s&&n(o=>o?(o.set(s,_R(s)),new Map(o)):null)},[]);return E.useEffect(()=>{const a=r.current;if(t!==a){s(a);const o=t.map(c=>{const u=ok(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,_R(u)]):null}).filter(c=>c!=null);n(o.length?new Map(o):null),r.current=t}return()=>{s(t),s(a)};function s(o){o.forEach(c=>{const u=ok(c);u?.removeEventListener("scroll",i)})}},[i,t]),E.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>dm(a,s),zo):Jee(t):zo,[t,e])}function d9(t,e){e===void 0&&(e=[]);const n=E.useRef(null);return E.useEffect(()=>{n.current=null},e),E.useEffect(()=>{const r=t!==zo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?ub(t,n.current):zo}function X7e(t){E.useEffect(()=>{if(!lE)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 Y7e(t,e){return E.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=s=>{a(s,e)},n},{}),[t,e])}function nte(t){return E.useMemo(()=>t?v7e(t):null,[t])}const h9=[];function Z7e(t,e){e===void 0&&(e=mg);const[n]=t,r=nte(n?es(n):null),[i,a]=E.useState(h9);function s(){a(()=>t.length?t.map(c=>Zee(c)?r:new pL(e(c),c)):h9)}const o=hE({callback:s});return vl(()=>{o?.disconnect(),s(),t.forEach(c=>o?.observe(c))},[t]),i}function Q7e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return ey(e)?e:t}function J7e(t){let{measure:e}=t;const[n,r]=E.useState(null),i=E.useCallback(u=>{for(const{target:d}of u)if(ey(d)){r(f=>{const g=e(d);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),a=hE({callback:i}),s=E.useCallback(u=>{const d=Q7e(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[o,c]=NS(s);return E.useMemo(()=>({nodeRef:o,rect:n,setRef:c}),[n,o,c])}const e9e=[{sensor:dE,options:{}},{sensor:uE,options:{}}],t9e={current:{}},v1={draggable:{measure:i9},droppable:{measure:i9,strategy:db.WhileDragging,frequency:SR.Optimized},dragOverlay:{measure:mg}};class h0 extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const n9e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new h0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:kS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:v1,measureDroppableContainers:kS,windowRect:null,measuringScheduled:!1},r9e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:kS,draggableNodes:new Map,over:null,measureDroppableContainers:kS},fE=E.createContext(r9e),rte=E.createContext(n9e);function i9e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new h0}}}function a9e(t,e){switch(e.type){case di.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case di.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case di.DragEnd:case di.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case di.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new h0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case di.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const s=new h0(t.droppable.containers);return s.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:s}}}case di.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new h0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function s9e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=E.useContext(fE),a=yR(r),s=yR(n?.id);return E.useEffect(()=>{if(!e&&!r&&a&&s!=null){if(!fL(a)||document.activeElement===a.target)return;const o=i.get(s);if(!o)return;const{activatorNode:c,node:u}=o;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=e7e(d);if(f){f.focus();break}}})}},[r,e,i,s,a]),null}function o9e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function l9e(t){return E.useMemo(()=>({draggable:{...v1.draggable,...t?.draggable},droppable:{...v1.droppable,...t?.droppable},dragOverlay:{...v1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function c9e(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=E.useRef(!1),{x:s,y:o}=typeof i=="boolean"?{x:i,y:i}:i;vl(()=>{if(!s&&!o||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=qee(d,r);if(s||(f.x=0),o||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=Kee(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,s,o,r,n])}const ite=E.createContext({...zo,scaleX:1,scaleY:1});var ju;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(ju||(ju={}));const ate=E.memo(function(e){var n,r,i,a;let{id:s,accessibility:o,autoScroll:c=!0,children:u,sensors:d=e9e,collisionDetection:f=f7e,measuring:g,modifiers:m,...x}=e;const v=E.useReducer(a9e,void 0,i9e),[y,b]=v,[M,S]=s7e(),[A,T]=E.useState(ju.Uninitialized),k=A===ju.Initialized,{draggable:{active:N,nodes:I,translate:C},droppable:{containers:D}}=y,F=N!=null?I.get(N):null,O=E.useRef({initial:null,translated:null}),q=E.useMemo(()=>{var Ue;return N!=null?{id:N,data:(Ue=F?.data)!=null?Ue:t9e,rect:O}:null},[N,F]),R=E.useRef(null),[W,K]=E.useState(null),[G,ee]=E.useState(null),Z=cb(x,Object.values(x)),Q=ny("DndDescribedBy",s),U=E.useMemo(()=>D.getEnabled(),[D]),$=l9e(g),{droppableRects:X,measureDroppableContainers:te,measuringScheduled:fe}=H7e(U,{dragging:k,dependencies:[C.x,C.y],config:$.droppable}),pe=z7e(I,N),xe=E.useMemo(()=>G?vR(G):null,[G]),Ne=ge(),ie=$7e(pe,$.draggable.measure);c9e({activeNode:N!=null?I.get(N):null,config:Ne.layoutShiftCompensation,initialRect:ie,measure:$.draggable.measure});const be=c9(pe,$.draggable.measure,ie),je=c9(pe?pe.parentElement:null),he=E.useRef({activatorEvent:null,active:null,activeNode:pe,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:I,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ht=D.getNodeFor((n=he.current.over)==null?void 0:n.id),H=J7e({measure:$.dragOverlay.measure}),B=(r=H.nodeRef.current)!=null?r:pe,re=k?(i=H.rect)!=null?i:be:null,V=!!(H.nodeRef.current&&H.rect),J=W7e(V?null:be),se=nte(B?es(B):null),Ae=q7e(k?ht??pe:null),Pe=Z7e(Ae),Se=o9e(m,{transform:{x:C.x-J.x,y:C.y-J.y,scaleX:1,scaleY:1},activatorEvent:G,active:q,activeNodeRect:be,containerNodeRect:je,draggingNodeRect:re,over:he.current.over,overlayNodeRect:H.rect,scrollableAncestors:Ae,scrollableAncestorRects:Pe,windowRect:se}),z=xe?dm(xe,C):null,L=K7e(Ae),ne=d9(L),ve=d9(L,[be]),we=dm(Se,ne),ye=re?g7e(re,Se):null,nt=q&&ye?f({active:q,collisionRect:ye,droppableRects:X,droppableContainers:U,pointerCoordinates:z}):null,Be=Gee(nt,"id"),[ue,Ve]=E.useState(null),Fe=V?Se:dm(Se,ve),oe=p7e(Fe,(a=ue?.rect)!=null?a:null,be),Je=E.useRef(null),He=E.useCallback((Ue,Ce)=>{let{sensor:_e,options:ce}=Ce;if(R.current==null)return;const st=I.get(R.current);if(!st)return;const xt=Ue.nativeEvent,St=new _e({active:R.current,activeNode:st,event:xt,options:ce,context:he,onAbort(Ot){if(!I.get(Ot))return;const{onDragAbort:On}=Z.current,Mi={id:Ot};On?.(Mi),M({type:"onDragAbort",event:Mi})},onPending(Ot,Vt,On,Mi){if(!I.get(Ot))return;const{onDragPending:Ei}=Z.current,zi={id:Ot,constraint:Vt,initialCoordinates:On,offset:Mi};Ei?.(zi),M({type:"onDragPending",event:zi})},onStart(Ot){const Vt=R.current;if(Vt==null)return;const On=I.get(Vt);if(!On)return;const{onDragStart:Mi}=Z.current,si={activatorEvent:xt,active:{id:Vt,data:On.data,rect:O}};hc.unstable_batchedUpdates(()=>{Mi?.(si),T(ju.Initializing),b({type:di.DragStart,initialCoordinates:Ot,active:Vt}),M({type:"onDragStart",event:si}),K(Je.current),ee(xt)})},onMove(Ot){b({type:di.DragMove,coordinates:Ot})},onEnd:Qt(di.DragEnd),onCancel:Qt(di.DragCancel)});Je.current=St;function Qt(Ot){return async function(){const{active:On,collisions:Mi,over:si,scrollAdjustedTranslate:Ei}=he.current;let zi=null;if(On&&Ei){const{cancelDrop:ra}=Z.current;zi={activatorEvent:xt,active:On,collisions:Mi,delta:Ei,over:si},Ot===di.DragEnd&&typeof ra=="function"&&await Promise.resolve(ra(zi))&&(Ot=di.DragCancel)}R.current=null,hc.unstable_batchedUpdates(()=>{b({type:Ot}),T(ju.Uninitialized),Ve(null),K(null),ee(null),Je.current=null;const ra=Ot===di.DragEnd?"onDragEnd":"onDragCancel";if(zi){const Hr=Z.current[ra];Hr?.(zi),M({type:ra,event:zi})}})}}},[I]),Ke=E.useCallback((Ue,Ce)=>(_e,ce)=>{const st=_e.nativeEvent,xt=I.get(ce);if(R.current!==null||!xt||st.dndKit||st.defaultPrevented)return;const St={active:xt};Ue(_e,Ce.options,St)===!0&&(st.dndKit={capturedBy:Ce.sensor},R.current=ce,He(_e,Ce))},[I,He]),ct=B7e(d,Ke);X7e(d),vl(()=>{be&&A===ju.Initializing&&T(ju.Initialized)},[be,A]),E.useEffect(()=>{const{onDragMove:Ue}=Z.current,{active:Ce,activatorEvent:_e,collisions:ce,over:st}=he.current;if(!Ce||!_e)return;const xt={active:Ce,activatorEvent:_e,collisions:ce,delta:{x:we.x,y:we.y},over:st};hc.unstable_batchedUpdates(()=>{Ue?.(xt),M({type:"onDragMove",event:xt})})},[we.x,we.y]),E.useEffect(()=>{const{active:Ue,activatorEvent:Ce,collisions:_e,droppableContainers:ce,scrollAdjustedTranslate:st}=he.current;if(!Ue||R.current==null||!Ce||!st)return;const{onDragOver:xt}=Z.current,St=ce.get(Be),Qt=St&&St.rect.current?{id:St.id,rect:St.rect.current,data:St.data,disabled:St.disabled}:null,Ot={active:Ue,activatorEvent:Ce,collisions:_e,delta:{x:st.x,y:st.y},over:Qt};hc.unstable_batchedUpdates(()=>{Ve(Qt),xt?.(Ot),M({type:"onDragOver",event:Ot})})},[Be]),vl(()=>{he.current={activatorEvent:G,active:q,activeNode:pe,collisionRect:ye,collisions:nt,droppableRects:X,draggableNodes:I,draggingNode:B,draggingNodeRect:re,droppableContainers:D,over:ue,scrollableAncestors:Ae,scrollAdjustedTranslate:we},O.current={initial:re,translated:ye}},[q,pe,nt,ye,I,B,re,X,D,ue,Ae,we]),I7e({...Ne,delta:C,draggingRect:ye,pointerCoordinates:z,scrollableAncestors:Ae,scrollableAncestorRects:Pe});const de=E.useMemo(()=>({active:q,activeNode:pe,activeNodeRect:be,activatorEvent:G,collisions:nt,containerNodeRect:je,dragOverlay:H,draggableNodes:I,droppableContainers:D,droppableRects:X,over:ue,measureDroppableContainers:te,scrollableAncestors:Ae,scrollableAncestorRects:Pe,measuringConfiguration:$,measuringScheduled:fe,windowRect:se}),[q,pe,be,G,nt,je,H,I,D,X,ue,te,Ae,Pe,$,fe,se]),Ye=E.useMemo(()=>({activatorEvent:G,activators:ct,active:q,activeNodeRect:be,ariaDescribedById:{draggable:Q},dispatch:b,draggableNodes:I,over:ue,measureDroppableContainers:te}),[G,ct,q,be,b,Q,I,ue,te]);return mr.createElement(Bee.Provider,{value:S},mr.createElement(fE.Provider,{value:Ye},mr.createElement(rte.Provider,{value:de},mr.createElement(ite.Provider,{value:oe},u)),mr.createElement(s9e,{disabled:o?.restoreFocus===!1})),mr.createElement(c7e,{...o,hiddenTextDescribedById:Q}));function ge(){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}}}),u9e=E.createContext(null),f9="button",d9e="Draggable";function h9e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=ny(d9e),{activators:s,activatorEvent:o,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=E.useContext(fE),{role:m=f9,roleDescription:x="draggable",tabIndex:v=0}=i??{},y=c?.id===e,b=E.useContext(y?ite:u9e),[M,S]=NS(),[A,T]=NS(),k=Y7e(s,e),N=cb(n);vl(()=>(f.set(e,{id:e,key:a,node:M,activatorNode:A,data:N}),()=>{const C=f.get(e);C&&C.key===a&&f.delete(e)}),[f,e]);const I=E.useMemo(()=>({role:m,tabIndex:v,"aria-disabled":r,"aria-pressed":y&&m===f9?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,m,v,y,x,d.draggable]);return{active:c,activatorEvent:o,activeNodeRect:u,attributes:I,isDragging:y,listeners:r?void 0:k,node:M,over:g,setNodeRef:S,setActivatorNodeRef:T,transform:b}}function f9e(){return E.useContext(rte)}const p9e="Droppable",m9e={timeout:25};function g9e(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=ny(p9e),{active:s,dispatch:o,over:c,measureDroppableContainers:u}=E.useContext(fE),d=E.useRef({disabled:n}),f=E.useRef(!1),g=E.useRef(null),m=E.useRef(null),{disabled:x,updateMeasurementsFor:v,timeout:y}={...m9e,...i},b=cb(v??r),M=E.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},y)},[y]),S=hE({callback:M,disabled:x||!s}),A=E.useCallback((I,C)=>{S&&(C&&(S.unobserve(C),f.current=!1),I&&S.observe(I))},[S]),[T,k]=NS(A),N=cb(e);return E.useEffect(()=>{!S||!T.current||(S.disconnect(),f.current=!1,S.observe(T.current))},[T,S]),E.useEffect(()=>(o({type:di.RegisterDroppable,element:{id:r,key:a,disabled:n,node:T,rect:g,data:N}}),()=>o({type:di.UnregisterDroppable,key:a,id:r})),[r]),E.useEffect(()=>{n!==d.current.disabled&&(o({type:di.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,o]),{active:s,rect:g,isOver:c?.id===r,node:T,over:c,setNodeRef:k}}function pE(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function x9e(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function W_(t){return t!==null&&t>=0}function b9e(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 y9e(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const gL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=pE(e,r,n),s=e[i],o=a[i];return!o||!s?null:{x:o.left-s.left,y:o.top-s.top,scaleX:o.width/s.width,scaleY:o.height/s.height}},q_={scaleX:1,scaleY:1},v9e=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:s}=t;const o=(e=a[n])!=null?e:r;if(!o)return null;if(i===n){const u=a[s];return u?{x:0,y:n<s?u.top+u.height-(o.top+o.height):u.top-o.top,...q_}:null}const c=_9e(a,i,n);return i>n&&i<=s?{x:0,y:-o.height-c,...q_}:i<n&&i>=s?{x:0,y:o.height+c,...q_}:{x:0,y:0,...q_}};function _9e(t,e,n){const r=t[e],i=t[e-1],a=t[e+1];return r?n<e?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const ste="Sortable",ote=mr.createContext({activeIndex:-1,containerId:ste,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:gL,disabled:{draggable:!1,droppable:!1}});function lte(t){let{children:e,id:n,items:r,strategy:i=gL,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:c,over:u,measureDroppableContainers:d}=f9e(),f=ny(ste,n),g=o.rect!==null,m=E.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),x=s!=null,v=s?m.indexOf(s.id):-1,y=u?m.indexOf(u.id):-1,b=E.useRef(m),M=!b9e(m,b.current),S=y!==-1&&v===-1||M,A=y9e(a);vl(()=>{M&&x&&d(m)},[M,m,x,d]),E.useEffect(()=>{b.current=m},[m]);const T=E.useMemo(()=>({activeIndex:v,containerId:f,disabled:A,disableTransforms:S,items:m,overIndex:y,useDragOverlay:g,sortedRects:x9e(m,c),strategy:i}),[v,f,A.draggable,A.droppable,S,m,y,c,g,i]);return mr.createElement(ote.Provider,{value:T},e)}const w9e=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return pE(n,r,i).indexOf(e)},S9e=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:s,previousItems:o,previousContainerId:c,transition:u}=t;return!u||!r||o!==a&&i===s?!1:n?!0:s!==i&&e===c},M9e={duration:200,easing:"ease"},cte="transform",E9e=$m.Transition.toString({property:cte,duration:0,easing:"linear"}),A9e={roleDescription:"sortable"};function T9e(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,s]=E.useState(null),o=E.useRef(n);return vl(()=>{if(!e&&n!==o.current&&r.current){const c=i.current;if(c){const u=mg(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&s(d)}}n!==o.current&&(o.current=n)},[e,n,r,i]),E.useEffect(()=>{a&&s(null)},[a]),a}function ute(t){let{animateLayoutChanges:e=S9e,attributes:n,disabled:r,data:i,getNewIndex:a=w9e,id:s,strategy:o,resizeObserverConfig:c,transition:u=M9e}=t;const{items:d,containerId:f,activeIndex:g,disabled:m,disableTransforms:x,sortedRects:v,overIndex:y,useDragOverlay:b,strategy:M}=E.useContext(ote),S=C9e(r,m),A=d.indexOf(s),T=E.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),k=E.useMemo(()=>d.slice(d.indexOf(s)),[d,s]),{rect:N,node:I,isOver:C,setNodeRef:D}=g9e({id:s,data:T,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:F,activatorEvent:O,activeNodeRect:q,attributes:R,setNodeRef:W,listeners:K,isDragging:G,over:ee,setActivatorNodeRef:Z,transform:Q}=h9e({id:s,data:T,attributes:{...A9e,...n},disabled:S.draggable}),U=YVe(D,W),$=!!F,X=$&&!x&&W_(g)&&W_(y),te=!b&&G,fe=te&&X?Q:null,xe=X?fe??(o??M)({rects:v,activeNodeRect:q,activeIndex:g,overIndex:y,index:A}):null,Ne=W_(g)&&W_(y)?a({id:s,items:d,activeIndex:g,overIndex:y}):A,ie=F?.id,be=E.useRef({activeId:ie,items:d,newIndex:Ne,containerId:f}),je=d!==be.current.items,he=e({active:F,containerId:f,isDragging:G,isSorting:$,id:s,index:A,items:d,newIndex:be.current.newIndex,previousItems:be.current.items,previousContainerId:be.current.containerId,transition:u,wasDragging:be.current.activeId!=null}),ht=T9e({disabled:!he,index:A,node:I,rect:N});return E.useEffect(()=>{$&&be.current.newIndex!==Ne&&(be.current.newIndex=Ne),f!==be.current.containerId&&(be.current.containerId=f),d!==be.current.items&&(be.current.items=d)},[$,Ne,f,d]),E.useEffect(()=>{if(ie===be.current.activeId)return;if(ie!=null&&be.current.activeId==null){be.current.activeId=ie;return}const B=setTimeout(()=>{be.current.activeId=ie},50);return()=>clearTimeout(B)},[ie]),{active:F,activeIndex:g,attributes:R,data:T,rect:N,index:A,newIndex:Ne,items:d,isOver:C,isSorting:$,isDragging:G,listeners:K,node:I,overIndex:y,over:ee,setNodeRef:U,setActivatorNodeRef:Z,setDroppableNodeRef:D,setDraggableNodeRef:W,transform:ht??xe,transition:H()};function H(){if(ht||je&&be.current.newIndex===A)return E9e;if(!(te&&!fL(O)||!u)&&($||he))return $m.Transition.toString({...u,property:cte})}}function C9e(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 N9e=[Sn.Down,Sn.Right,Sn.Up,Sn.Left],dte=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if(N9e.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=i.get(f.id);if(g)switch(t.code){case Sn.Down:r.top<g.top&&c.push(f);break;case Sn.Up:r.top>g.top&&c.push(f);break;case Sn.Left:r.left>g.left&&c.push(f);break;case Sn.Right:r.left<g.left&&c.push(f);break}});const u=d7e({collisionRect:r,droppableRects:i,droppableContainers:c});let d=Gee(u,"id");if(d===s?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),g=a.get(d),m=g?i.get(g.id):null,x=g?.node.current;if(x&&m&&f&&g){const y=cE(x).some((k,N)=>o[N]!==k),b=hte(f,g),M=k9e(f,g),S=y||!b?{x:0,y:0}:{x:M?r.width-m.width:0,y:M?r.height-m.height:0},A={x:m.left,y:m.top};return S.x&&S.y?A:ub(A,S)}}}};function hte(t,e){return!DS(t)||!DS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function k9e(t,e){return!DS(t)||!DS(e)||!hte(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function P9e({item:t,onClose:e}){const n=En(),{showToast:r}=ai(),[i,a]=E.useState(t.printer_id),s=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[o,c]=E.useState(t.scheduled_time&&!s?"scheduled":"asap"),[u,d]=E.useState(()=>t.scheduled_time&&!s?new Date(t.scheduled_time).toISOString().slice(0,16):""),[f,g]=E.useState(t.require_previous_success),[m,x]=E.useState(t.auto_off_after),{data:v}=vt({queryKey:["printers"],queryFn:()=>ke.getPrinters()});E.useEffect(()=>{const S=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e]);const y=wt({mutationFn:S=>ke.updateQueueItem(t.id,S),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:S=>{r(S.message||"Failed to update queue item","error")}}),b=S=>{S.preventDefault();const A={printer_id:i,require_previous_success:f,auto_off_after:m};o==="scheduled"&&u?A.scheduled_time=new Date(u).toISOString():A.scheduled_time=null,y.mutate(A)},M=()=>{const S=new Date;return S.setMinutes(S.getMinutes()+1),S.toISOString().slice(0,16)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(rd,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),l.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),v?.length===0?l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(lo,{className:"w-4 h-4"}),"No printers configured"]}):l.jsx("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:S=>a(Number(S.target.value)),required:!0,children:v?.map(S=>l.jsx("option",{value:S.id,children:S.name},S.id))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[l.jsx(_r,{className:"w-4 h-4"}),"ASAP (when idle)"]}),l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[l.jsx(Zr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),l.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:S=>d(S.target.value),min:M(),required:!0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:S=>g(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:S=>x(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[l.jsx(bd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",disabled:y.isPending||v?.length===0,children:y.isPending?"Saving...":"Save Changes"})]})]})]})})})}function fte(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 R9e(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 D9e({status:t}){const e={pending:{icon:_r,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:BS,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:fi,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:gs,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:N1,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Wt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return l.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[l.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function uk({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:s}){const{attributes:o,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=ute({id:t.id,disabled:t.status!=="pending"}),m={transform:$m.Transform.toString(d),transition:f},x=t.status==="printing",v=t.status==="pending",y=["completed","failed","skipped","cancelled"].includes(t.status);return l.jsx("div",{ref:u,style: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:[v?l.jsx("div",{...o,...c,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:l.jsx(v0,{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(As,{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(Ts,{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(Uu,{className:"w-3.5 h-3.5"}),fte(t.print_time_seconds)]}),v&&l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(_r,{className:"w-3.5 h-3.5"}),R9e(t.scheduled_time)]})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&l.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:"Requires previous success"}),t.auto_off_after&&l.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[l.jsx(bd,{className:"w-3 h-3"}),"Auto power off"]})]}),x&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&l.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[l.jsx(lo,{className:"w-3 h-3"}),t.error_message]})]}),l.jsx(D9e,{status:t.status}),l.jsxs("div",{className:"flex items-center gap-1",children:[x&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:l.jsx(Coe,{className:"w-4 h-4"})}),v&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:l.jsx(rd,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),y&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:s,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:l.jsx(Ta,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})]})})}function j9e(){const t=En(),{showToast:e}=ai(),[n,r]=E.useState(null),[i,a]=E.useState(""),[s,o]=E.useState(!1),[c,u]=E.useState(null),[d,f]=E.useState(null),[g,m]=E.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[x,v]=E.useState(()=>{const Z=localStorage.getItem("queue.historySortAsc");return Z!==null?Z==="true":!1}),[y,b]=E.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[M,S]=E.useState(()=>{const Z=localStorage.getItem("queue.pendingSortAsc");return Z!==null?Z==="true":!0});E.useEffect(()=>{localStorage.setItem("queue.historySortBy",g)},[g]),E.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(x))},[x]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",y)},[y]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(M))},[M]);const A=Hee(PS(dE,{activationConstraint:{distance:8}}),PS(uE,{coordinateGetter:dte})),{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=wt({mutationFn:Z=>ke.cancelQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),C=wt({mutationFn:Z=>ke.removeFromQueue(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),D=wt({mutationFn:Z=>ke.stopQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),F=wt({mutationFn:Z=>ke.reorderQueue(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),O=wt({mutationFn:Z=>{const Q=new Date;return Q.setFullYear(Q.getFullYear()+1),ke.addToQueue({printer_id:Z.printer_id,archive_id:Z.archive_id,scheduled_time:Q.toISOString(),require_previous_success:!1,auto_off_after:!1})},onSuccess:Z=>{t.invalidateQueries({queryKey:["queue"]}),e("Added back to queue - please set schedule"),u(Z)},onError:Z=>e(Z.message||"Failed to re-queue item","error")}),q=wt({mutationFn:async()=>{const Z=T?.filter(Q=>["completed","failed","skipped","cancelled"].includes(Q.status))||[];for(const Q of Z)await ke.removeFromQueue(Q.id);return Z.length},onSuccess:Z=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Z} history item${Z!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),R=E.useMemo(()=>{const Z=T?.filter(U=>U.status==="pending")||[],Q=U=>{if(!U.scheduled_time)return 0;const $=new Date(U.scheduled_time).getTime(),X=Date.now()+4320*60*60*1e3;return $>X?0:$};return[...Z].sort((U,$)=>{let X;return y==="name"?X=(U.archive_name||"").localeCompare($.archive_name||""):y==="printer"?X=(U.printer_name||"").localeCompare($.printer_name||""):y==="time"?X=Q(U)-Q($):X=U.position-$.position,M?X:-X})},[T,y,M]),W=T?.filter(Z=>Z.status==="printing")||[],K=E.useMemo(()=>[...T?.filter(Q=>["completed","failed","skipped","cancelled"].includes(Q.status))||[]].sort((Q,U)=>{let $;return g==="name"?$=(Q.archive_name||"").localeCompare(U.archive_name||""):g==="printer"?$=(Q.printer_name||"").localeCompare(U.printer_name||""):$=new Date(U.completed_at||U.created_at).getTime()-new Date(Q.completed_at||Q.created_at).getTime(),x?-$:$}),[T,g,x]),G=E.useMemo(()=>R.reduce((Z,Q)=>Z+(Q.print_time_seconds||0),0),[R]),ee=Z=>{const{active:Q,over:U}=Z;if(!U||Q.id===U.id)return;const $=R.findIndex(te=>te.id===Q.id),X=R.findIndex(te=>te.id===U.id);if($!==-1&&X!==-1){const fe=pE(R,$,X).map((pe,xe)=>({id:pe.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(uG,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),l.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[l.jsx(Nt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:l.jsx(BS,{className:"w-5 h-5 text-blue-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:W.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),l.jsx(Nt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:l.jsx(_r,{className:"w-5 h-5 text-yellow-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:R.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),l.jsx(Nt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:l.jsx(Uu,{className:"w-5 h-5 text-bambu-green"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:fte(G)}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),l.jsx(Nt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:l.jsx(fi,{className:"w-5 h-5 text-gray-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:K.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),l.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:Z=>r(Z.target.value?Number(Z.target.value):null),children:[l.jsx("option",{value:"",children:"All Printers"}),N?.map(Z=>l.jsx("option",{value:Z.id,children:Z.name},Z.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:Z=>a(Z.target.value),children:[l.jsx("option",{value:"",children:"All Status"}),l.jsx("option",{value:"pending",children:"Pending"}),l.jsx("option",{value:"printing",children:"Printing"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"failed",children:"Failed"}),l.jsx("option",{value:"skipped",children:"Skipped"}),l.jsx("option",{value:"cancelled",children:"Cancelled"})]}),l.jsx("div",{className:"flex-1"}),K.length>0&&l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Clear History"]})]}),k?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?l.jsxs(Nt,{className:"p-12 text-center border-dashed",children:[l.jsx(Zr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),l.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),l.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'})]}):l.jsxs("div",{className:"space-y-8",children:[W.length>0&&l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),l.jsx("div",{className:"space-y-3",children:W.map(Z=>l.jsx(uk,{item:Z,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>f({type:"stop",item:Z}),onRequeue:()=>{}},Z.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:y,onChange:Z=>b(Z.target.value),children:[l.jsx("option",{value:"position",children:"Sort by Position"}),l.jsx("option",{value:"name",children:"Sort by Name"}),l.jsx("option",{value:"printer",children:"Sort by Printer"}),l.jsx("option",{value:"time",children:"Sort by Schedule"})]}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>S(!M),title:M?"Ascending":"Descending",className:"px-2",children:M?l.jsx(hm,{className:"w-4 h-4"}):l.jsx(x0,{className:"w-4 h-4"})})]})]}),l.jsx(ate,{sensors:A,collisionDetection:Wee,onDragEnd:ee,children:l.jsx(lte,{items:R.map(Z=>Z.id),strategy:v9e,children:l.jsx("div",{className:"space-y-3",children:R.map((Z,Q)=>l.jsx(uk,{item:Z,position:Q+1,onEdit:()=>u(Z),onCancel:()=>f({type:"cancel",item:Z}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Z.id))})})})]}),K.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(fi,{className:"w-5 h-5 text-bambu-gray"}),"History",l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",K.length," item",K.length!==1?"s":"",")"]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:g,onChange:Z=>m(Z.target.value),children:[l.jsx("option",{value:"date",children:"Sort by Date"}),l.jsx("option",{value:"name",children:"Sort by Name"}),l.jsx("option",{value:"printer",children:"Sort by Printer"})]}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>v(!x),title:x?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:x?l.jsx(hm,{className:"w-4 h-4"}):l.jsx(x0,{className:"w-4 h-4"})})]})]}),l.jsx("div",{className:"space-y-3",children:K.slice(0,20).map((Z,Q)=>l.jsx(uk,{item:Z,position:Q+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>f({type:"remove",item:Z}),onStop:()=>{},onRequeue:()=>O.mutate(Z)},Z.id))})]})]}),c&&l.jsx(P9e,{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)}),s&&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 O9e({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=E.useMemo(()=>{const c={};t.forEach(b=>{const M=b.split("T")[0];c[M]=(c[M]||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 v=new Date(d);let y=0;for(;v<=u;)v.getDay()===0&&m.length>0&&(f.push(m),m=[],y++),v.getMonth()!==x&&(g.push({month:v.toLocaleDateString("en-US",{month:"short"}),weekIndex:y}),x=v.getMonth()),m.push(new Date(v)),v.setDate(v.getDate()+1);return m.length>0&&f.push(m),{weeks:f,monthLabels:g,printCounts:c}},[t,e]),a=Math.max(1,...Object.values(i)),s=c=>{if(c===0)return"bg-bambu-dark";const u=c/a;return u<=.25?"bg-bambu-green/30":u<=.5?"bg-bambu-green/50":u<=.75?"bg-bambu-green/75":"bg-bambu-green"},o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return l.jsxs("div",{className:"overflow-x-auto",children:[l.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:c,weekIndex:u},d)=>l.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:d===0?0:`${(u-(r[d-1]?.weekIndex||0))*14-24}px`},children:c},d))}),l.jsxs("div",{className:"flex gap-0.5",children:[l.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((c,u)=>l.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:u%2===1?"visible":"hidden"},children:c},c))}),n.map((c,u)=>l.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(d=>{const f=c.find(v=>v.getDay()===d);if(!f)return l.jsx("div",{className:"w-3 h-3"},d);const g=f.toISOString().split("T")[0],m=i[g]||0,x=g===new Date().toISOString().split("T")[0];return l.jsx("div",{className:`w-3 h-3 rounded-sm ${s(m)} ${x?"ring-1 ring-white":""}`,title:`${f.toLocaleDateString()}: ${m} print${m!==1?"s":""}`},d)})},u))]}),l.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[l.jsx("span",{children:"Less"}),l.jsxs("div",{className:"flex gap-0.5",children:[l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),l.jsx("span",{children:"More"})]})]})}const K_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function L9e(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 I9e({archives:t,currency:e="$"}){const[n,r]=E.useState("30d"),i=E.useMemo(()=>{const g=L9e(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=g)},[t,n]),a=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const v=new Date(m.completed_at||m.created_at).toISOString().split("T")[0],y=g.get(v)||{date:v,filament:0,cost:0,prints:0};y.filament+=m.filament_used_grams||0,y.cost+=m.cost||0,y.prints+=1,g.set(v,y)}),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]),s=E.useMemo(()=>{if(n==="7d"||n==="30d")return a;const g=new Map;return i.forEach(m=>{const x=new Date(m.completed_at||m.created_at),v=new Date(x);v.setDate(x.getDate()-x.getDay());const y=v.toISOString().split("T")[0],b=g.get(y)||{week:y,filament:0,cost:0,prints:0};b.filament+=m.filament_used_grams||0,b.cost+=m.cost||0,b.prints+=1,g.set(y,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,a,n]),o=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const v=(m.filament_type||"Unknown").split(", ");v.forEach(y=>{const b=(m.filament_used_grams||0)/v.length;g.set(y,(g.get(y)||0)+b)})}),Array.from(g.entries()).map(([m,x])=>({name:m,value:Math.round(x)})).sort((m,x)=>x.value-m.value)},[i]),c=E.useMemo(()=>{const g=new Date,m=[];for(let x=5;x>=0;x--){const v=new Date(g.getFullYear(),g.getMonth()-x,1),y=new Date(g.getFullYear(),g.getMonth()-x+1,0),b=v.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(S=>{const A=new Date(S.completed_at||S.created_at);return A>=v&&A<=y});m.push({month:b,filament:Math.round(M.reduce((S,A)=>S+(A.filament_used_grams||0),0)),cost:M.reduce((S,A)=>S+(A.cost||0),0),prints:M.length})}return m},[t]),u=n==="7d"||n==="30d"?a:s,d=i.reduce((g,m)=>g+(m.filament_used_grams||0),0),f=i.reduce((g,m)=>g+(m.cost||0),0);return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),l.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>l.jsx("button",{onClick:()=>r(g),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===g?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:g==="all"?"All":g.replace("d","D")},g))})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),l.jsx(n1,{width:"100%",height:250,children:l.jsxs(eCe,{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(Mw,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),l.jsx(Ew,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),l.jsx(i1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),l.jsx(_Y,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):l.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx(n1,{width:160,height:160,children:l.jsxs(QTe,{children:[l.jsx(GX,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>l.jsx($b,{fill:K_[m%K_.length]},`cell-${m}`))}),l.jsx(i1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),l.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const x=o.reduce((y,b)=>y+b.value,0),v=x>0?(g.value/x*100).toFixed(0):0;return l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:K_[m%K_.length]}}),l.jsx("span",{className:"text-white truncate flex-1",children:g.name}),l.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[v,"%"]})]},g.name)})})]}):l.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),l.jsx(n1,{width:"100%",height:200,children:l.jsxs(zTe,{data:c,children:[l.jsx(ww,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),l.jsx(Mw,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),l.jsx(Ew,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),l.jsx(i1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,m)=>[m==="filament"?`${g}g`:m==="cost"?`${e}${g.toFixed(2)}`:g,m==="filament"?"Filament":m==="cost"?"Cost":"Prints"]}),l.jsx(vD,{}),l.jsx(ZX,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function F9e({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:s}){const{attributes:o,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=ute({id:t}),m={transform:$m.Transform.toString(d),transition:f,opacity:g?.5:1};return r?null:l.jsxs("div",{ref:u,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{...o,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:l.jsx(v0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),l.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?l.jsx(dce,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):l.jsx(rce,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),l.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:l.jsx(FR,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),l.jsx("div",{className:"p-4",children:n})]})}function U9e({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const s=()=>{const A={};return t.forEach(T=>{A[T.id]=T.defaultSize||4}),A},[o,c]=E.useState(()=>{const A=localStorage.getItem(e);if(A)try{const T=JSON.parse(A);return T.sizes||(T.sizes=s()),T}catch{}return{order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:s()}}),[u,d]=E.useState(!1);E.useEffect(()=>{const A=()=>d(T=>!T);return window.addEventListener("toggle-hidden-panel",A),()=>window.removeEventListener("toggle-hidden-panel",A)},[]),E.useEffect(()=>{localStorage.setItem(e,JSON.stringify(o))},[o,e]),E.useEffect(()=>{const T=t.map(k=>k.id).filter(k=>!o.order.includes(k));T.length>0&&c(k=>({...k,order:[...k.order,...T]}))},[t,o.order]);const f=Hee(PS(dE,{activationConstraint:{distance:8}}),PS(uE,{coordinateGetter:dte})),g=A=>{const{active:T,over:k}=A;k&&T.id!==k.id&&c(N=>{const I=N.order.indexOf(T.id),C=N.order.indexOf(k.id);return{...N,order:pE(N.order,I,C)}})},m=A=>{c(T=>({...T,hidden:T.hidden.includes(A)?T.hidden.filter(k=>k!==A):[...T.hidden,A]}))},x=A=>{c(T=>{const k=T.sizes[A]||4,N=k===1?2:k===2?4:1;return{...T,sizes:{...T.sizes,[A]:N}}})},v=()=>{const A={order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:s()};c(A),i?.()},y=o.order.map(A=>t.find(T=>T.id===A)).filter(Boolean),b=y.filter(A=>!o.hidden.includes(A.id)),M=y.filter(A=>o.hidden.includes(A.id)),S=a?.({hiddenCount:M.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:v});return l.jsxs("div",{className:"space-y-4",children:[S,!r&&!a&&l.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:v,children:[l.jsx(Xm,{className:"w-4 h-4"}),"Reset Layout"]}),M.length>0&&l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[l.jsx(mm,{className:"w-4 h-4"}),M.length," Hidden"]})]}),u&&M.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:M.map(A=>l.jsxs("button",{onClick:()=>m(A.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[l.jsx(mm,{className:"w-3 h-3"}),A.title]},A.id))})]}),l.jsx(ate,{sensors:f,collisionDetection:Wee,onDragEnd:g,children:l.jsx(lte,{items:b.map(A=>A.id),strategy:gL,children:l.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:b.map(A=>l.jsx(F9e,{id:A.id,title:A.title,isHidden:o.hidden.includes(A.id),size:o.sizes[A.id]||2,onToggleVisibility:()=>m(A.id),onToggleSize:()=>x(A.id),children:A.component},A.id))})})}),b.length===0&&l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx("p",{children:"All widgets are hidden."}),l.jsx(Le,{className:"mt-4",onClick:v,children:"Reset Layout"})]})]})}function z9e({stats:t,currency:e}){return l.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:l.jsx(w0,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),l.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:l.jsx(_r,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:l.jsx(w0,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:l.jsx(Ck,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:l.jsx(bm,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:l.jsx(Ck,{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 B9e({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("div",{className:"relative w-28 h-28",children:[l.jsxs("svg",{className:"w-full h-full -rotate-90",children:[l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),l.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(gs,{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 H9e({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const i=(Math.min(150,Math.max(50,n))-50)/100*100,s=(c=>c>=95&&c<=105?"#00ae42":c>105?"#3b82f6":"#f97316")(n),o=n-100;return l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("div",{className:"relative w-28 h-28",children:[l.jsxs("svg",{className:"w-full h-full -rotate-90",children:[l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),l.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[l.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),l.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),l.jsxs("div",{className:"space-y-2 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[l.jsx(fG,{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 $9e({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 V9e({printDates:t}){return l.jsx(O9e,{printDates:t,months:4})}function G9e({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(Ts,{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 W9e({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(I9e,{archives:t,currency:e})}function q9e(){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(mG,{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 K9e(){const{showToast:t}=ai(),[e,n]=E.useState(!1),[r,i]=E.useState(!1),[a,s]=E.useState(0),[o,c]=E.useState(0);E.useEffect(()=>{const S=()=>{try{const T=localStorage.getItem("bambusy-dashboard-layout");if(T){const k=JSON.parse(T);c(k.hidden?.length||0)}}catch{c(0)}};S(),window.addEventListener("storage",S);const A=setInterval(S,500);return()=>{window.removeEventListener("storage",S),clearInterval(A)}},[a]);const{data:u,isLoading:d}=vt({queryKey:["archiveStats"],queryFn:ke.getArchiveStats}),{data:f}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:g}=vt({queryKey:["archives"],queryFn:()=>ke.getArchives(void 0,void 0,1e3,0)}),{data:m}=vt({queryKey:["settings"],queryFn:ke.getSettings}),x=async S=>{i(!1),n(!0);try{const{blob:A,filename:T}=await ke.exportStats({format:S,days:90}),k=URL.createObjectURL(A),N=document.createElement("a");N.href=k,N.download=T,N.click(),URL.revokeObjectURL(k),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},v=m?.currency||"$",y=new Map(f?.map(S=>[String(S.id),S.name])||[]),b=g?.map(S=>S.created_at)||[];if(d)return l.jsx("div",{className:"p-4 md:p-8",children:l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const M=[{id:"quick-stats",title:"Quick Stats",component:l.jsx(z9e,{stats:u,currency:v}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:l.jsx(B9e,{stats:u}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:l.jsx(H9e,{stats:u,printerMap:y}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:l.jsx($9e,{stats:u}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:l.jsx(q9e,{}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:l.jsx(V9e,{printDates:b}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:l.jsx(G9e,{stats:u,printerMap:y}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:l.jsx(W9e,{archives:g||[],currency:v}),defaultSize:4}];return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),l.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&l.jsxs(Le,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[l.jsx(mm,{className:"w-4 h-4"}),o," Hidden"]}),l.jsxs(Le,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),s(S=>S+1),t("Layout reset")},children:[l.jsx(Xm,{className:"w-4 h-4"}),"Reset Layout"]}),l.jsxs("div",{className:"relative",children:[l.jsxs(Le,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(T1,{className:"w-4 h-4"}),"Export Stats"]}),r&&l.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>x("csv"),children:[l.jsx(to,{className:"w-4 h-4"}),"Export as CSV"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>x("xlsx"),children:[l.jsx(T1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),l.jsx(U9e,{widgets:M,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function X9e({plug:t,onEdit:e}){const n=En(),[r,i]=E.useState(!1),[a,s]=E.useState(!1),[o,c]=E.useState(!1),[u,d]=E.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}),v=x?.find(k=>k.id===t.printer_id),y=wt({mutationFn:k=>ke.controlSmartPlug(t.id,k),onSuccess:()=>{m()}}),b=wt({mutationFn:k=>ke.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=wt({mutationFn:()=>ke.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),S=f?.state==="ON",A=f?.reachable??!1,T=y.isPending;return l.jsxs(l.Fragment,{children:[l.jsx(Nt,{className:"relative",children:l.jsxs(Rt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${A?S?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:l.jsx(Jp,{className:`w-5 h-5 ${A?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),l.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),l.jsx("div",{className:"flex items-center gap-2",children:g?l.jsx(At,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?l.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[l.jsx(yG,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:S?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):l.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[l.jsx(qR,{className:"w-4 h-4"}),l.jsx("span",{children:"Offline"})]})})]}),v&&l.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),l.jsx("span",{className:"text-sm text-white",children:v.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&l.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&l.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[l.jsx(wh,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&l.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[l.jsx(Zr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),l.jsxs("div",{className:"flex gap-2 mb-3",children:[l.jsxs(Le,{size:"sm",variant:S?"primary":"secondary",disabled:!A||T,onClick:()=>s(!0),className:"flex-1",children:[T?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(bd,{className:"w-4 h-4"}),"On"]}),l.jsxs(Le,{size:"sm",variant:S?"secondary":"primary",disabled:!A||T,onClick:()=>c(!0),className:"flex-1",children:[T?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(VR,{className:"w-4 h-4"}),"Off"]})]}),l.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(HS,{className:"w-4 h-4"}),"Automation Settings"]}),l.jsx("span",{children:u?"-":"+"})]}),u&&l.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Enabled"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.enabled,onChange:k=>b.mutate({enabled:k.target.checked}),className:"sr-only peer"}),l.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Auto On"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:k=>b.mutate({auto_on:k.target.checked}),className:"sr-only peer"}),l.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:k=>b.mutate({auto_off:k.target.checked}),className:"sr-only peer"}),l.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&l.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[l.jsx(_r,{className:"w-4 h-4"}),"Time"]}),l.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[l.jsx(Sh,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),l.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:k=>b.mutate({off_delay_minutes:parseInt(k.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),l.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:k=>b.mutate({off_temp_threshold:parseInt(k.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),l.jsxs("div",{className:"flex gap-2 pt-2",children:[l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[l.jsx($R,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})]})}),r&&l.jsx(Qr,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),i(!1)},onCancel:()=>i(!1)}),a&&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:()=>{y.mutate("on"),s(!1)},onCancel:()=>s(!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:()=>{y.mutate("off"),c(!1)},onCancel:()=>c(!1)})]})}function Y9e({plug:t,onClose:e}){const n=En(),r=!!t,[i,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.ip_address||""),[c,u]=E.useState(t?.username||""),[d,f]=E.useState(t?.password||""),[g,m]=E.useState(t?.printer_id||null),[x,v]=E.useState(null),[y,b]=E.useState(null),[M,S]=E.useState(t?.power_alert_enabled||!1),[A,T]=E.useState(t?.power_alert_high?.toString()||""),[k,N]=E.useState(t?.power_alert_low?.toString()||""),[I,C]=E.useState(t?.schedule_enabled||!1),[D,F]=E.useState(t?.schedule_on_time||""),[O,q]=E.useState(t?.schedule_off_time||""),{data:R}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:W}=vt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs});E.useEffect(()=>{const $=X=>{X.key==="Escape"&&e()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e]);const K=wt({mutationFn:()=>ke.testSmartPlugConnection(s,c||null,d||null),onSuccess:$=>{v($),b(null),!i&&$.device_name&&a($.device_name)},onError:$=>{v(null),b($.message)}}),G=wt({mutationFn:$=>ke.createSmartPlug($),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:$=>{b($.message)}}),ee=wt({mutationFn:$=>ke.updateSmartPlug(t.id,$),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:$=>{b($.message)}}),Z=R?.filter($=>!W?.some(te=>te.printer_id===$.id&&te.id!==t?.id)),Q=$=>{if($.preventDefault(),b(null),!i.trim()){b("Name is required");return}if(!s.trim()){b("IP address is required");return}const X={name:i.trim(),ip_address:s.trim(),username:c.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:M,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:O||null};r?ee.mutate(X):G.mutate(X)},U=G.isPending||ee.isPending;return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:$=>$.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:Q,className:"p-6 space-y-4",children:[y&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:y}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:s,onChange:$=>{o($.target.value),v(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsxs(Le,{type:"button",variant:"secondary",onClick:()=>K.mutate(),disabled:!s.trim()||K.isPending,children:[K.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(yG,{className:"w-4 h-4"}),"Test"]})]})]}),x&&l.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${x.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:x.success?l.jsxs(l.Fragment,{children:[l.jsx(fi,{className:"w-5 h-5"}),l.jsxs("div",{children:[l.jsx("p",{className:"font-medium",children:"Connected!"}),l.jsxs("p",{className:"text-sm opacity-80",children:[x.device_name&&`Device: ${x.device_name} - `,"State: ",x.state]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx(qR,{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:$=>a($.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:$=>u($.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:$=>f($.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:$=>m($.target.value?Number($.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)"}),Z?.map($=>l.jsx("option",{value:$.id,children:$.name},$.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:M,onChange:$=>S($.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"})]})]}),M&&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:$=>T($.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:$=>N($.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:$=>C($.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:$=>F($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),l.jsx("input",{type:"time",value:O,onChange:$=>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"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:U,className:"flex-1",children:[U?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ro,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Pn({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return l.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:l.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const Z9e={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function Q9e({provider:t,onEdit:e}){const n=En(),[r,i]=E.useState(!1),[a,s]=E.useState(!1),[o,c]=E.useState(null),{data:u}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),d=u?.find(v=>v.id===t.printer_id),f=wt({mutationFn:v=>ke.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=wt({mutationFn:()=>ke.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=wt({mutationFn:()=>ke.testNotificationProvider(t.id),onSuccess:v=>{c(v),n.invalidateQueries({queryKey:["notification-providers"]})},onError:v=>{c({success:!1,message:v.message})}}),x=v=>v||"";return l.jsxs(l.Fragment,{children:[l.jsx(Nt,{className:"relative",children:l.jsxs(Rt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:l.jsx(wh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),l.jsx("p",{className:"text-sm text-bambu-gray",children:Z9e[t.provider_type]||t.provider_type})]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&l.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&t.last_error_at&&(!t.last_success||new Date(t.last_error_at)>new Date(t.last_success))&&l.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),l.jsx(Pn,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]})]}),d&&l.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),l.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&l.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:l.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),l.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&l.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&l.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&l.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&l.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&l.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&l.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&l.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&l.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&l.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&l.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&l.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&l.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&l.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&l.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[l.jsx(C1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&l.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[l.jsx(Zr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),l.jsx("div",{className:"mb-3",children:l.jsxs(Le,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{c(null),m.mutate()},className:"w-full",children:[m.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(GR,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&l.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?l.jsx(fi,{className:"w-4 h-4"}):l.jsx(gs,{className:"w-4 h-4"}),l.jsx("span",{children:o.message})]}),l.jsxs("button",{onClick:()=>s(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(HS,{className:"w-4 h-4"}),"Event Settings"]}),a?l.jsx(FS,{className:"w-4 h-4"}):l.jsx(uf,{className:"w-4 h-4"})]}),a&&l.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Enabled"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),l.jsx(Pn,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Started"}),l.jsx(Pn,{checked:t.on_print_start,onChange:v=>f.mutate({on_print_start:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),l.jsx(Pn,{checked:t.on_print_complete,onChange:v=>f.mutate({on_print_complete:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),l.jsx(Pn,{checked:t.on_print_failed,onChange:v=>f.mutate({on_print_failed:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),l.jsx(Pn,{checked:t.on_print_stopped,onChange:v=>f.mutate({on_print_stopped:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),l.jsx(Pn,{checked:t.on_print_progress,onChange:v=>f.mutate({on_print_progress:v})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),l.jsx(Pn,{checked:t.on_printer_offline,onChange:v=>f.mutate({on_printer_offline:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),l.jsx(Pn,{checked:t.on_printer_error,onChange:v=>f.mutate({on_printer_error:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),l.jsx(Pn,{checked:t.on_filament_low,onChange:v=>f.mutate({on_filament_low:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),l.jsx(Pn,{checked:t.on_maintenance_due??!1,onChange:v=>f.mutate({on_maintenance_due:v})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_humidity_high??!1,onChange:v=>f.mutate({on_ams_humidity_high:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_temperature_high??!1,onChange:v=>f.mutate({on_ams_temperature_high:v})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_ht_humidity_high??!1,onChange:v=>f.mutate({on_ams_ht_humidity_high:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_ht_temperature_high??!1,onChange:v=>f.mutate({on_ams_ht_temperature_high:v})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(C1,{className:"w-4 h-4 text-purple-400"}),l.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),l.jsx(Pn,{checked:t.quiet_hours_enabled,onChange:v=>f.mutate({quiet_hours_enabled:v})})]}),t.quiet_hours_enabled&&l.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-gray"}),l.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Zr,{className:"w-4 h-4 text-emerald-400"}),l.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),l.jsx(Pn,{checked:t.daily_digest_enabled,onChange:v=>f.mutate({daily_digest_enabled:v})})]}),t.daily_digest_enabled&&l.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-gray"}),l.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),l.jsxs("div",{className:"flex gap-2 pt-2",children:[l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[l.jsx($R,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})]})}),r&&l.jsx(Qr,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{g.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const p9=[{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 J9e({provider:t,onClose:e}){const n=En(),r=!!t,[i,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.provider_type||"email"),[c,u]=E.useState(t?.printer_id||null),[d,f]=E.useState(t?.quiet_hours_enabled||!1),[g,m]=E.useState(t?.quiet_hours_start||"22:00"),[x,v]=E.useState(t?.quiet_hours_end||"07:00"),[y,b]=E.useState(t?.daily_digest_enabled||!1),[M,S]=E.useState(t?.daily_digest_time||"08:00"),[A,T]=E.useState(t?.on_print_start??!1),[k,N]=E.useState(t?.on_print_complete??!0),[I,C]=E.useState(t?.on_print_failed??!0),[D,F]=E.useState(t?.on_print_stopped??!0),[O,q]=E.useState(t?.on_print_progress??!1),[R,W]=E.useState(t?.on_printer_offline??!1),[K,G]=E.useState(t?.on_printer_error??!1),[ee,Z]=E.useState(t?.on_filament_low??!1),[Q,U]=E.useState(t?.on_maintenance_due??!1),[$,X]=E.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([V,J])=>[V,String(J)])):{}),[te,fe]=E.useState(null),[pe,xe]=E.useState(null),{data:Ne}=vt({queryKey:["printers"],queryFn:ke.getPrinters});E.useEffect(()=>{const V=J=>{J.key==="Escape"&&e()};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[e]);const ie=wt({mutationFn:()=>ke.testNotificationConfig({provider_type:s,config:$}),onSuccess:V=>{fe(V),xe(null)},onError:V=>{fe({success:!1,message:V.message})}}),be=wt({mutationFn:V=>ke.createNotificationProvider(V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{xe(V.message)}}),je=wt({mutationFn:V=>ke.updateNotificationProvider(t.id,V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{xe(V.message)}}),he=V=>{if(V.preventDefault(),xe(null),!i.trim()){xe("Name is required");return}const J=B(s);for(const Ae of J)if(!$[Ae.key]?.trim()){xe(`${Ae.label} is required`);return}const se={name:i.trim(),provider_type:s,config:$,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?x:null,daily_digest_enabled:y,daily_digest_time:y?M:null,on_print_start:A,on_print_complete:k,on_print_failed:I,on_print_stopped:D,on_print_progress:O,on_printer_offline:R,on_printer_error:K,on_filament_low:ee,on_maintenance_due:Q};r?je.mutate(se):be.mutate(se)},ht=be.isPending||je.isPending,H=V=>{switch(V){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},B=V=>H(V).filter(J=>J.required),re=H(s);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:V=>V.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:he,className:"p-6 space-y-4",children:[pe&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:pe}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value:i,onChange:V=>a(V.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),l.jsx("select",{value:s,onChange:V=>{o(V.target.value),X({}),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:p9.map(V=>l.jsx("option",{value:V.value,children:V.label},V.value))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:p9.find(V=>V.value===s)?.description})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),re.map(V=>l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[V.label," ",V.required&&"*"]}),V.type==="select"&&V.options?l.jsx("select",{value:$[V.key]||V.options[0]?.value||"",onChange:J=>{X({...$,[V.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:V.options.map(J=>l.jsx("option",{value:J.value,children:J.label},J.value))}):l.jsx("input",{type:V.type,value:$[V.key]||"",onChange:J=>{X({...$,[V.key]:J.target.value}),fe(null)},placeholder:V.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},V.key))]}),l.jsx("div",{className:"flex gap-2",children:l.jsxs(Le,{type:"button",variant:"secondary",onClick:()=>{fe(null),ie.mutate()},disabled:ie.isPending||!$[B(s)[0]?.key],className:"flex-1",children:[ie.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(GR,{className:"w-4 h-4"}),"Test Configuration"]})}),te&&l.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${te.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:te.success?l.jsxs(l.Fragment,{children:[l.jsx(fi,{className:"w-5 h-5"}),l.jsx("span",{children:te.message})]}):l.jsxs(l.Fragment,{children:[l.jsx(gs,{className:"w-5 h-5"}),l.jsx("span",{children:te.message})]})}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),l.jsxs("select",{value:c??"",onChange:V=>u(V.target.value?Number(V.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"All printers"}),Ne?.map(V=>l.jsx("option",{value:V.id,children:V.name},V.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),l.jsx(Pn,{checked:d,onChange:f})]}),d&&l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),l.jsx("input",{type:"time",value:g,onChange:V=>m(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),l.jsx("input",{type:"time",value:x,onChange:V=>v(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),l.jsx(Pn,{checked:y,onChange:b})]}),y&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),l.jsx("input",{type:"time",value:M,onChange:V=>S(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),l.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Start"}),l.jsx(Pn,{checked:A,onChange:T})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Complete"}),l.jsx(Pn,{checked:k,onChange:N})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Failed"}),l.jsx(Pn,{checked:I,onChange:C})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Stopped"}),l.jsx(Pn,{checked:D,onChange:F})]}),l.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-sm text-white",children:"Progress"}),l.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),l.jsx(Pn,{checked:O,onChange:q})]})]})]}),l.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Offline"}),l.jsx(Pn,{checked:R,onChange:W})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Error"}),l.jsx(Pn,{checked:K,onChange:G})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),l.jsx(Pn,{checked:ee,onChange:Z})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),l.jsx(Pn,{checked:Q,onChange:U})]})]})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:ht,className:"flex-1",children:[ht?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ro,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function eGe({template:t,onClose:e}){const n=En(),r=E.useRef(null),[i,a]=E.useState(t.title_template),[s,o]=E.useState(t.body_template),[c,u]=E.useState(null),[d,f]=E.useState(!0),{data:g}=vt({queryKey:["template-variables"],queryFn:ke.getTemplateVariables}),m=g?.find(T=>T.event_type===t.event_type),{data:x,isLoading:v}=vt({queryKey:["template-preview",t.event_type,i,s],queryFn:()=>ke.previewTemplate({event_type:t.event_type,title_template:i,body_template:s}),enabled:d&&i.length>0&&s.length>0});E.useEffect(()=>{const T=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const y=wt({mutationFn:T=>ke.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),b=wt({mutationFn:()=>ke.resetNotificationTemplate(t.id),onSuccess:T=>{a(T.title_template),o(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{u(T.message)}}),M=T=>{if(T.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!s.trim()){u("Body is required");return}y.mutate({title_template:i,body_template:s})},S=T=>{const k=r.current;if(!k)return;const N=k.selectionStart,I=k.selectionEnd,C=s,D=C.substring(0,N),F=C.substring(I),O=D+`{${T}}`+F;o(O),setTimeout(()=>{k.focus();const q=N+T.length+2;k.setSelectionRange(q,q)},0)},A=i!==t.title_template||s!==t.body_template;return l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),l.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsxs("form",{onSubmit:M,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),l.jsx("input",{type:"text",value:i,onChange:T=>a(T.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),l.jsx("textarea",{ref:r,value:s,onChange:T=>o(T.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),m&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(T=>l.jsxs("button",{type:"button",onClick:()=>S(T),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[l.jsx(pr,{className:"w-3 h-3"}),T]},T))}),l.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(mm,{className:"w-4 h-4"}),"Live Preview"]}),l.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&l.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:v?l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[l.jsx(At,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),l.jsx("div",{className:"text-white font-medium",children:x.title})]}),l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),l.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):l.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[l.jsxs(Le,{type:"button",variant:"ghost",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-orange-400 hover:text-orange-300",children:[b.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin mr-2"}):l.jsx(Xm,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),l.jsxs(Le,{onClick:M,disabled:y.isPending||!A,children:[y.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin mr-2"}):l.jsx(Ro,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const tGe={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"},nGe={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 rGe({onClose:t}){const e=En(),{showToast:n}=ai(),[r,i]=E.useState(7),[a,s]=E.useState(null),[o,c]=E.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=wt({mutationFn:()=>ke.clearNotificationLogs(30),onSuccess:y=>{n(y.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:y=>{n(`Failed to clear logs: ${y.message}`,"error")}}),v=y=>{const b=new Date(y),S=new Date().getTime()-b.getTime();return S<6e4?"Just now":S<36e5?`${Math.floor(S/6e4)}m ago`:S<864e5?`${Math.floor(S/36e5)}h ago`:b.toLocaleDateString()+" "+b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[l.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(Nk,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),m&&l.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:l.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[l.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",l.jsx("span",{className:"text-white font-medium",children:m.total})," notifications"]}),l.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[l.jsx(fi,{className:"w-4 h-4"}),m.success_count," sent"]}),m.failure_count>0&&l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(gs,{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:y=>i(Number(y.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[l.jsx("option",{value:1,children:"Last 24 hours"}),l.jsx("option",{value:7,children:"Last 7 days"}),l.jsx("option",{value:30,children:"Last 30 days"}),l.jsx("option",{value:90,children:"Last 90 days"})]}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:o,onChange:y=>c(y.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),l.jsx("div",{className:"flex-1"}),l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:g,children:[g?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ta,{className:"w-4 h-4"}),"Refresh"]}),l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Clear Old"]})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?l.jsx("div",{className:"space-y-2",children:u.map(y=>l.jsx(iGe,{log:y,isExpanded:a===y.id,onToggle:()=>s(a===y.id?null:y.id),formatDate:v},y.id))}):l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(Nk,{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 iGe({log:t,isExpanded:e,onToggle:n,formatDate:r}){return l.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[l.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?l.jsx(fi,{className:"w-4 h-4 text-bambu-green shrink-0"}):l.jsx(gs,{className:"w-4 h-4 text-red-400 shrink-0"}),l.jsx("span",{className:`text-xs font-medium ${nGe[t.event_type]||"text-bambu-gray"}`,children:tGe[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(FS,{className:"w-4 h-4 text-bambu-gray shrink-0"}):l.jsx(uf,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&l.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),l.jsx("p",{className:"text-sm text-white",children:t.title})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),l.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),l.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),l.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[l.jsxs("span",{children:["Provider: ",t.provider_type]}),l.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const X_=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:l.jsx(WR,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:l.jsx(wh,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:l.jsx(to,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:l.jsx(Jp,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:l.jsx(Ts,{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(dG,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:l.jsx(ad,{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 aGe({onClose:t,onExport:e}){const{t:n}=Gm(),[r,i]=E.useState(()=>{const x={};return X_.forEach(v=>{x[v.id]=v.default}),x}),[a,s]=E.useState(!1),[o,c]=E.useState(!1);E.useEffect(()=>{const x=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(v=>({...v,[x]:!v[x]}))},d=()=>{const x={};X_.forEach(v=>{x[v.id]=!0}),i(x)},f=()=>{const x={};X_.forEach(v=>{x[v.id]=!1}),i(x)},g=Object.values(r).filter(Boolean).length,m=async()=>{c(!0);try{await e({...r,access_codes:a&&r.printers})}finally{c(!1)}};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o?void 0:t,children:l.jsx(Nt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:l.jsx(Es,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),l.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),l.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[l.jsx("button",{onClick:d,disabled:o,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),l.jsx("span",{className:"text-bambu-gray",children:"|"}),l.jsx("button",{onClick:f,disabled:o,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),l.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${o?"opacity-50 pointer-events-none":""}`,children:X_.map(x=>l.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[l.jsx("input",{type:"checkbox",checked:r[x.id],onChange:()=>u(x.id),disabled:o,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),l.jsx("div",{className:`${r[x.id]?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),l.jsx("div",{className:"text-xs text-bambu-gray",children:x.description})]})]},x.id))}),r.archives&&l.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(_h,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[l.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),l.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&l.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(Vp,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),l.jsx(Pn,{checked:a,onChange:s})]}),a&&l.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[l.jsx(ti,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:t,disabled:o,children:n("common.cancel",{defaultValue:"Cancel"})}),l.jsx(Le,{onClick:m,disabled:g===0||o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:o?l.jsxs(l.Fragment,{children:[l.jsx(At,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):l.jsxs(l.Fragment,{children:[l.jsx(Es,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const m9={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 sGe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=E.useState("options"),[a,s]=E.useState(!1),[o,c]=E.useState(null),[u,d]=E.useState(null),[f,g]=E.useState(new Set),m=E.useRef(null);E.useEffect(()=>{const S=A=>{A.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[t,r]);const x=S=>{const A=S.target.files?.[0];A&&c(A)},v=async()=>{if(o){i("restoring");try{const S=await e(o,a);d(S),i("result"),S.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},y=S=>{g(A=>{const T=new Set(A);return T.has(S)?T.delete(S):T.add(S),T})},b=u?.restored?Object.values(u.restored).reduce((S,A)=>S+A,0)+(u.files_restored||0):0,M=u?.total_skipped||0;return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:S=>{S.target===S.currentTarget&&r!=="restoring"&&t()},children:l.jsx(Nt,{className:"w-full max-w-lg",children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-full ${r==="result"&&u?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!u?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&u?.success?l.jsx(fi,{className:"w-5 h-5"}):r==="result"&&!u?.success?l.jsx(ti,{className:"w-5 h-5"}):l.jsx(vs,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&l.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),r==="options"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("input",{ref:m,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),l.jsx("button",{type:"button",onClick:()=>m.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:o?l.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[l.jsx(fi,{className:"w-5 h-5"}),l.jsx("span",{className:"font-medium",children:o.name})]}):l.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[l.jsx(vs,{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:[a?l.jsx(Ta,{className:"w-4 h-4 text-orange-400"}):l.jsx(N1,{className:"w-4 h-4 text-bambu-gray"}),a?"Replace existing data":"Keep existing data"]}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),l.jsx(Pn,{checked:a,onChange:s})]})}),a&&l.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(ti,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[l.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),l.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),l.jsxs(Le,{type:"button",onClick:v,disabled:!o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[l.jsx(vs,{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:M}),l.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,S])=>S>0)&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),l.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,S])=>S>0).map(([S,A])=>l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[l.jsx("span",{className:"text-white",children:m9[S]||S}),l.jsx("span",{className:"text-bambu-green font-medium",children:A})]},S)),(u.files_restored||0)>0&&l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[l.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),l.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,S])=>S>0)&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(N1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),l.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,S])=>S>0).map(([S,A])=>{const T=u.skipped_details?.[S]||[],k=f.has(S);return l.jsxs("div",{children:[l.jsxs("button",{onClick:()=>T.length>0&&y(S),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${T.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[l.jsxs("span",{className:"text-white flex items-center gap-2",children:[m9[S]||S,T.length>0&&(k?l.jsx(FS,{className:"w-3 h-3"}):l.jsx(uf,{className:"w-3 h-3"}))]}),l.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),k&&T.length>0&&l.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[T.slice(0,10).map((N,I)=>l.jsx("div",{children:N},I)),T.length>10&&l.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",T.length-10," more"]})]})]},S)})})]}),b===0&&M===0&&l.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),l.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:l.jsx(Le,{onClick:t,children:"Close"})})]})]})})})}async function oGe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function lGe(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 cGe(){const t=En(),[e,n]=E.useState(!1),[r,i]=E.useState(""),[a,s]=E.useState("auto"),[o,c]=E.useState(!1),[u,d]=E.useState("all"),[f,g]=E.useState(!1),{data:m,isLoading:x}=vt({queryKey:["spoolman-settings"],queryFn:oGe}),{data:v,isLoading:y,refetch:b}=vt({queryKey:["spoolman-status"],queryFn:ke.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=vt({queryKey:["printers"],queryFn:ke.getPrinters});E.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),i(m.spoolman_url||""),s(m.spoolman_sync_mode||"auto"),g(!0))},[m]),E.useEffect(()=>{if(!f||!m)return;if(m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==r||(m.spoolman_sync_mode||"auto")!==a){const q=setTimeout(()=>{S.mutate()},500);return()=>clearTimeout(q)}},[e,r,a,f]);const S=wt({mutationFn:()=>lGe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),A=wt({mutationFn:ke.connectSpoolman,onSuccess:()=>{b()}}),T=wt({mutationFn:ke.disconnectSpoolman,onSuccess:()=>{b()}}),k=wt({mutationFn:ke.syncAllPrintersAms,onSuccess:O=>{O.success}}),N=wt({mutationFn:O=>ke.syncPrinterAms(O),onSuccess:O=>{O.success}}),I=()=>{u==="all"?k.mutate():N.mutate(u)},C=k.isPending||N.isPending,D=u==="all"?k.data:N.data,F=u==="all"?k.isSuccess:N.isSuccess;return x?l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(pm,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),l.jsx(Rt,{children:l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(pm,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),S.isPending&&l.jsx(At,{className:"w-4 h-4 text-bambu-green animate-spin"}),o&&l.jsx(zh,{className:"w-4 h-4 text-bambu-green"})]})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Enable Spoolman"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:e,onChange:O=>n(O.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),l.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:O=>i(O.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),l.jsxs("select",{value:a,onChange:O=>s(O.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[l.jsx("option",{value:"auto",children:"Automatic"}),l.jsx("option",{value:"manual",children:"Manual Only"})]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&l.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),y?l.jsx(At,{className:"w-4 h-4 text-bambu-gray animate-spin"}):v?.connected?l.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[l.jsx(zh,{className:"w-4 h-4"}),"Connected"]}):l.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[l.jsx(Wt,{className:"w-4 h-4"}),"Disconnected"]})]}),l.jsx("div",{className:"flex gap-2",children:v?.connected?l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ble,{className:"w-4 h-4"}),"Disconnect"]}):l.jsxs(Le,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!r,children:[A.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Pk,{className:"w-4 h-4"}),"Connect"]})})]}),A.isError&&l.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:A.error.message}),v?.connected&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsxs("select",{value:u,onChange:O=>d(O.target.value==="all"?"all":Number(O.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[l.jsx("option",{value:"all",children:"All Printers"}),M?.map(O=>l.jsx("option",{value:O.id,children:O.name},O.id))]}),l.jsx(uf,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:I,disabled:C,children:[C?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ta,{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 uGe({link:t,onClose:e}){const n=En(),{theme:r}=xb(),i=!!t,a=E.useRef(null),[s,o]=E.useState(t?.name||""),[c,u]=E.useState(t?.url||""),[d,f]=E.useState(t?.icon||"link"),[g,m]=E.useState(!!t?.custom_icon),[x,v]=E.useState(t?.custom_icon?ke.getExternalLinkIconUrl(t.id):null),[y,b]=E.useState(null),[M,S]=E.useState(null);E.useEffect(()=>{const F=O=>{O.key==="Escape"&&e()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const A=wt({mutationFn:async F=>{const O=await ke.createExternalLink(F);return y?await ke.uploadExternalLinkIcon(O.id,y):O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),T=wt({mutationFn:async F=>{let O=await ke.updateExternalLink(t.id,F);return y?O=await ke.uploadExternalLinkIcon(t.id,y):!g&&t?.custom_icon&&(O=await ke.deleteExternalLinkIcon(t.id)),O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),k=F=>{const O=F.target.files?.[0];if(O){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(O.type)){S("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(O.size>1024*1024){S("Image file must be less than 1MB");return}b(O),m(!0);const R=new FileReader;R.onload=W=>{v(W.target?.result)},R.readAsDataURL(O)}},N=()=>{b(null),v(null),m(!1),a.current&&(a.current.value="")},I=F=>{if(F.preventDefault(),S(null),!s.trim()){S("Name is required");return}if(!c.trim()){S("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){S("URL must start with http:// or https://");return}const O={name:s.trim(),url:c.trim(),icon:d};i?T.mutate(O):A.mutate(O)},C=A.isPending||T.isPending,D=$S(d);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:F=>F.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:g&&x?l.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):l.jsx(D,{className:"w-5 h-5"})}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:I,className:"p-6 space-y-4",children:[M&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:M}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value:s,onChange: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:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:k}),g&&x?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),l.jsx("button",{type:"button",onClick:N,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:l.jsx(Rn,{className:"w-4 h-4"})})]}):l.jsxs(Le,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[l.jsx(vs,{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(Wue,{value:d,onChange:f})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:C,className:"flex-1",children:[C?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ro,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function dGe(){const t=En(),[e,n]=E.useState(!1),[r,i]=E.useState(null),[a,s]=E.useState(null),[o,c]=E.useState(null),{data:u,isLoading:d}=vt({queryKey:["external-links"],queryFn:ke.getExternalLinks}),f=wt({mutationFn:M=>ke.deleteExternalLink(M),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=wt({mutationFn:M=>ke.reorderExternalLinks(M),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=(M,S)=>{c(S),M.dataTransfer.effectAllowed="move"},x=M=>{M.preventDefault(),M.dataTransfer.dropEffect="move"},v=(M,S)=>{if(M.preventDefault(),o===null||o===S||!u)return;const A=u.map(I=>I.id),T=A.indexOf(o),k=A.indexOf(S);if(T===-1||k===-1)return;const N=[...A];N.splice(T,1),N.splice(k,0,o),g.mutate(N),c(null)},y=M=>{s(M)},b=()=>{a&&(f.mutate(a.id),s(null))};return l.jsxs(l.Fragment,{children:[l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Pk,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),l.jsxs(Le,{size:"sm",onClick:()=>n(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Link"]})]})}),l.jsxs(Rt,{children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?l.jsx("div",{className:"space-y-2",children:u.map(M=>{const S=$S(M.icon);return l.jsxs("div",{draggable:!0,onDragStart:A=>m(A,M.id),onDragOver:x,onDrop:A=>v(A,M.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${o===M.id?"opacity-50":""}`,children:[l.jsx(v0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:l.jsx(S,{className:"w-4 h-4"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-white font-medium truncate",children:M.name}),l.jsx(As,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),l.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:M.url})]}),l.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[l.jsx("button",{onClick:()=>i(M),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:()=>y(M),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]},M.id)})}):l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(Pk,{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(uGe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&l.jsx(Qr,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:b,onCancel:()=>s(null)})]})}function hGe(){const t=En(),{t:e,i18n:n}=Gm(),{showToast:r,showPersistentToast:i,dismissToast:a}=ai(),[s,o]=E.useState(null),[c,u]=E.useState(!1),[d,f]=E.useState(null),[g,m]=E.useState(!1),[x,v]=E.useState(null),[y,b]=E.useState(null),[M,S]=E.useState(!1),[A,T]=E.useState(SG()),[k,N]=E.useState("general"),[I,C]=E.useState(!1),[D,F]=E.useState(""),[O,q]=E.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[R,W]=E.useState(null),[K,G]=E.useState(null),[ee,Z]=E.useState(!1),[Q,U]=E.useState(!1),[$,X]=E.useState(null),[te,fe]=E.useState(!1),[pe,xe]=E.useState(!1),[Ne,ie]=E.useState(!1),[be,je]=E.useState(!1),he=ce=>{T(ce),Xue(ce)},ht=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:H,isLoading:B}=vt({queryKey:["settings"],queryFn:ke.getSettings}),{data:re,isLoading:V}=vt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs}),{data:J,isLoading:se}=vt({queryKey:["smart-plugs-energy",re?.map(ce=>ce.id)],queryFn:async()=>{if(!re||re.length===0)return null;const ce=await Promise.all(re.filter(Vt=>Vt.enabled).map(async Vt=>{try{const On=await ke.getSmartPlugStatus(Vt.id);return{plug:Vt,status:On}}catch{return{plug:Vt,status:null}}}));let st=0,xt=0,St=0,Qt=0,Ot=0;for(const{status:Vt}of ce)Vt?.reachable&&Vt.energy&&(Ot++,Vt.energy.power!=null&&(st+=Vt.energy.power),Vt.energy.today!=null&&(xt+=Vt.energy.today),Vt.energy.yesterday!=null&&(St+=Vt.energy.yesterday),Vt.energy.total!=null&&(Qt+=Vt.energy.total));return{totalPower:st,totalToday:xt,totalYesterday:St,totalLifetime:Qt,reachableCount:Ot,totalPlugs:re.filter(Vt=>Vt.enabled).length}},enabled:k==="plugs"&&!!re&&re.length>0,refetchInterval:k==="plugs"?1e4:!1}),{data:Ae,isLoading:Pe}=vt({queryKey:["notification-providers"],queryFn:ke.getNotificationProviders}),{data:Se,isLoading:z}=vt({queryKey:["api-keys"],queryFn:ke.getAPIKeys}),L=wt({mutationFn:ce=>ke.createAPIKey(ce),onSuccess:ce=>{W(ce.key||null),C(!1),F(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:ce=>{r(`Failed to create API key: ${ce.message}`,"error")}}),ne=wt({mutationFn:ce=>ke.deleteAPIKey(ce),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:ce=>{r(`Failed to delete API key: ${ce.message}`,"error")}}),{data:ve}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:we,isLoading:ye}=vt({queryKey:["notification-templates"],queryFn:ke.getNotificationTemplates}),{data:nt}=vt({queryKey:["ffmpeg-status"],queryFn:ke.checkFfmpeg}),{data:Be}=vt({queryKey:["version"],queryFn:ke.getVersion}),{data:ue,refetch:Ve,isRefetching:Fe}=vt({queryKey:["updateCheck"],queryFn:ke.checkForUpdates,staleTime:300*1e3}),{data:oe,refetch:Je}=vt({queryKey:["updateStatus"],queryFn:ke.getUpdateStatus,refetchInterval:ce=>{const st=ce.state.data;return st?.status==="downloading"||st?.status==="installing"?1e3:!1}}),He=wt({mutationFn:ke.applyUpdate,onSuccess:()=>{Je()}}),[Ke,ct]=E.useState(null),de=wt({mutationFn:ke.testAllNotificationProviders,onSuccess:ce=>{ct(ce),t.invalidateQueries({queryKey:["notification-providers"]}),ce.failed===0?r(`All ${ce.tested} providers tested successfully!`,"success"):r(`${ce.success}/${ce.tested} providers succeeded`,ce.failed>0?"error":"success")},onError:ce=>{r(`Failed to test providers: ${ce.message}`,"error")}}),Ye=wt({mutationFn:async ce=>{if(!re)return{success:0,failed:0};const st=re.filter(St=>St.enabled),xt=await Promise.all(st.map(async St=>{try{return await ke.controlSmartPlug(St.id,ce),{success:!0}}catch{return{success:!1}}}));return{success:xt.filter(St=>St.success).length,failed:xt.filter(St=>!St.success).length}},onSuccess:(ce,st)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),ce.failed===0?r(`All ${ce.success} plugs turned ${st}`,"success"):r(`${ce.success} plugs turned ${st}, ${ce.failed} failed`,"error")},onError:ce=>{r(`Failed: ${ce.message}`,"error")}}),ge=E.useRef(null),Ue=E.useRef(!0);E.useEffect(()=>{H&&!s&&(o(H),setTimeout(()=>{Ue.current=!1},100))},[H,s]);const Ce=wt({mutationFn:ke.updateSettings,onSuccess:ce=>{t.setQueryData(["settings"],ce),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:ce=>{r(`Failed to save: ${ce.message}`,"error")}});E.useEffect(()=>{if(!(Ue.current||!s||!H||!(H.auto_archive!==s.auto_archive||H.save_thumbnails!==s.save_thumbnails||H.capture_finish_photo!==s.capture_finish_photo||H.default_filament_cost!==s.default_filament_cost||H.currency!==s.currency||H.energy_cost_per_kwh!==s.energy_cost_per_kwh||H.energy_tracking_mode!==s.energy_tracking_mode||H.check_updates!==s.check_updates||H.notification_language!==s.notification_language||H.telemetry_enabled!==s.telemetry_enabled||H.ams_humidity_good!==s.ams_humidity_good||H.ams_humidity_fair!==s.ams_humidity_fair||H.ams_temp_good!==s.ams_temp_good||H.ams_temp_fair!==s.ams_temp_fair||H.ams_history_retention_days!==s.ams_history_retention_days||H.date_format!==s.date_format||H.time_format!==s.time_format||H.default_printer_id!==s.default_printer_id)))return ge.current&&clearTimeout(ge.current),ge.current=setTimeout(()=>{Ce.mutate(s)},500),()=>{ge.current&&clearTimeout(ge.current)}},[s,H,Ce]);const _e=E.useCallback((ce,st)=>{o(xt=>xt?{...xt,[ce]:st}:null)},[]);return B||!s?l.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"mb-8",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),l.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),l.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[l.jsx("button",{onClick:()=>N("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),l.jsxs("button",{onClick:()=>N("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${k==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(Jp,{className:"w-4 h-4"}),"Smart Plugs",re&&re.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:re.length})]}),l.jsxs("button",{onClick:()=>N("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${k==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(wh,{className:"w-4 h-4"}),"Notifications",Ae&&Ae.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ae.length})]}),l.jsxs("button",{onClick:()=>N("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${k==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(Vp,{className:"w-4 h-4"}),"API Keys",Se&&Se.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Se.length})]})]}),k==="general"&&l.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(y0,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),l.jsx("select",{value:n.language,onChange:ce=>n.changeLanguage(ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:NF.map(ce=>l.jsxs("option",{value:ce.code,children:[ce.nativeName," (",ce.name,")"]},ce.code))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),l.jsx("select",{value:A,onChange:ce=>he(ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:A0.map(ce=>l.jsx("option",{value:ce.to,children:e(ce.labelKey)},ce.id))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),l.jsxs("select",{value:s.date_format||"system",onChange:ce=>_e("date_format",ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"system",children:"System Default"}),l.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),l.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),l.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),l.jsxs("select",{value:s.time_format||"system",onChange:ce=>_e("time_format",ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"system",children:"System Default"}),l.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),l.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),l.jsxs("select",{value:s.default_printer_id??"",onChange:ce=>_e("default_printer_id",ce.target.value?Number(ce.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"No default (ask each time)"}),ve?.map(ce=>l.jsx("option",{value:ce.id,children:ce.name},ce.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Sidebar order"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:ht,children:[l.jsx(Xm,{className:"w-4 h-4"}),"Reset"]})]})]})]}),l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Auto-archive prints"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.auto_archive,onChange:ce=>_e("auto_archive",ce.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Save thumbnails"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.save_thumbnails,onChange:ce=>_e("save_thumbnails",ce.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Capture finish photo"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.capture_finish_photo,onChange:ce=>_e("capture_finish_photo",ce.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.capture_finish_photo&&nt&&!nt.installed&&l.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[l.jsx(ti,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),l.jsxs("div",{className:"text-sm",children:[l.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),l.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",l.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",l.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),l.jsx("input",{type:"number",step:"0.01",min:"0",value:s.default_filament_cost,onChange:ce=>_e("default_filament_cost",parseFloat(ce.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),l.jsxs("select",{value:s.currency,onChange:ce=>_e("currency",ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"USD",children:"USD ($)"}),l.jsx("option",{value:"EUR",children:"EUR (€)"}),l.jsx("option",{value:"GBP",children:"GBP (£)"}),l.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),l.jsx("option",{value:"JPY",children:"JPY (¥)"}),l.jsx("option",{value:"CNY",children:"CNY (¥)"}),l.jsx("option",{value:"CAD",children:"CAD ($)"}),l.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),l.jsx("input",{type:"number",step:"0.01",min:"0",value:s.energy_cost_per_kwh,onChange:ce=>_e("energy_cost_per_kwh",parseFloat(ce.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),l.jsxs("select",{value:s.energy_tracking_mode||"total",onChange:ce=>_e("energy_tracking_mode",ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"print",children:"Prints Only"}),l.jsx("option",{value:"total",children:"Total Consumption"})]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]})]}),l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(aG,{className:"w-4 h-4 text-blue-400"}),l.jsx("span",{className:"font-medium",children:"Humidity"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"0",max:"100",value:s.ams_humidity_good??40,onChange:ce=>_e("ams_humidity_good",parseInt(ce.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"0",max:"100",value:s.ams_humidity_fair??60,onChange:ce=>_e("ams_humidity_fair",parseInt(ce.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),l.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(Sh,{className:"w-4 h-4 text-orange-400"}),l.jsx("span",{className:"font-medium",children:"Temperature"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:s.ams_temp_good??28,onChange:ce=>_e("ams_temp_good",parseFloat(ce.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:s.ams_temp_fair??35,onChange:ce=>_e("ams_temp_fair",parseFloat(ce.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),l.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(pm,{className:"w-4 h-4 text-purple-400"}),l.jsx("span",{className:"font-medium",children:"History Retention"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"1",max:"365",value:s.ams_history_retention_days??30,onChange:ce=>_e("ams_history_retention_days",parseInt(ce.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]})]})]}),l.jsx(cGe,{})]}),l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[l.jsx(dGe,{}),l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Check for updates"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.check_updates,onChange:ce=>_e("check_updates",ce.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-white",children:e("settings.telemetry")}),l.jsxs("button",{onClick:()=>ie(!0),className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-bambu-dark rounded-full text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-colors",children:[l.jsx(_0,{className:"w-3 h-3"}),e("settings.telemetryLearnMore")]})]}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.telemetryDescription")})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.telemetry_enabled,onChange:ce=>_e("telemetry_enabled",ce.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Current version"}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Be?.version||"..."]})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>Ve(),disabled:Fe,children:[Fe?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ta,{className:"w-4 h-4"}),"Check now"]})]}),ue?.update_available?l.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",ue.latest_version]}),ue.release_name&&ue.release_name!==ue.latest_version&&l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:ue.release_name})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[ue.release_notes&&l.jsx("button",{onClick:()=>je(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),ue.release_url&&l.jsx("a",{href:ue.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:l.jsx(As,{className:"w-4 h-4"})})]})]}),oe?.status==="downloading"||oe?.status==="installing"?l.jsxs("div",{className:"mt-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[l.jsx(At,{className:"w-4 h-4 animate-spin"}),l.jsx("span",{children:oe.message})]}),l.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:l.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${oe.progress}%`}})})]}):oe?.status==="complete"?l.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:oe.message}):oe?.status==="error"?l.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:oe.error||oe.message}):l.jsxs(Le,{className:"mt-3",onClick:()=>He.mutate(),disabled:He.isPending,children:[He.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Es,{className:"w-4 h-4"}),"Install Update"]})]}):ue?.error?l.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",ue.error]}):ue&&!ue.update_available?l.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Backup Data"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>fe(!0),children:[l.jsx(Es,{className:"w-4 h-4"}),"Export"]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Restore Backup"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>xe(!0),children:[l.jsx(vs,{className:"w-4 h-4"}),"Restore"]})]}),l.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>Z(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Clear"]})]})}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>U(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),k==="plugs"&&l.jsxs("div",{className:"max-w-4xl",children:[l.jsxs("div",{className:"flex items-start justify-between mb-6",children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Jp,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect Tasmota-based smart plugs to automate power control and track energy usage for your printers."})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[re&&re.filter(ce=>ce.enabled).length>1&&l.jsxs(l.Fragment,{children:[l.jsxs(Le,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>X("on"),disabled:Ye.isPending,title:"Turn all plugs on",children:[Ye.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(bd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),l.jsxs(Le,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>X("off"),disabled:Ye.isPending,title:"Turn all plugs off",children:[Ye.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(VR,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),l.jsxs(Le,{className:"whitespace-nowrap",onClick:()=>{f(null),u(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),re&&re.length>0&&l.jsxs(Nt,{className:"mb-6",children:[l.jsx(Ha,{children:l.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[l.jsx(bm,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",se&&l.jsx(At,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),l.jsx(Rt,{children:J?l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(bm,{className:"w-3 h-3"}),"Current Power"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[J.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:[J.reachableCount,"/",J.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:[J.totalToday.toFixed(2),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),s&&s.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(J.totalToday*s.energy_cost_per_kwh).toFixed(2)," ",s.currency]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(gG,{className:"w-3 h-3"}),"Yesterday"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[J.totalYesterday.toFixed(2),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),s&&s.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(J.totalYesterday*s.energy_cost_per_kwh).toFixed(2)," ",s.currency]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(Ck,{className:"w-3 h-3"}),"Total"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[J.totalLifetime.toFixed(1),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),s&&s.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(J.totalLifetime*s.energy_cost_per_kwh).toFixed(2)," ",s.currency]})]})]}):se?null:l.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),V?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):re&&re.length>0?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:re.map(ce=>l.jsx(X9e,{plug:ce,onEdit:st=>{f(st),u(!0)}},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-12",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(Jp,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),l.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),l.jsxs(Le,{onClick:()=>{f(null),u(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),k==="notifications"&&l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(wh,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>S(!0),children:[l.jsx(Nk,{className:"w-4 h-4"}),"Log"]}),Ae&&Ae.length>0&&l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>{ct(null),de.mutate()},disabled:de.isPending,children:[de.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(GR,{className:"w-4 h-4"}),"Test All"]}),l.jsxs(Le,{size:"sm",onClick:()=>{v(null),m(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add"]})]})]}),l.jsx(Nt,{className:"mb-4",children:l.jsx(Rt,{className:"py-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),l.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),l.jsx("select",{value:s.notification_language||"en",onChange:ce=>_e("notification_language",ce.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:NF.map(ce=>l.jsx("option",{value:ce.code,children:ce.nativeName},ce.code))})]})})}),Ke&&l.jsx(Nt,{className:"mb-4",children:l.jsxs(Rt,{className:"py-3",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),l.jsx("button",{onClick:()=>ct(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[l.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[l.jsx(fi,{className:"w-4 h-4"}),Ke.success," passed"]}),Ke.failed>0&&l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(gs,{className:"w-4 h-4"}),Ke.failed," failed"]})]}),Ke.results.filter(ce=>!ce.success).length>0&&l.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Ke.results.filter(ce=>!ce.success).map(ce=>l.jsxs("div",{className:"text-xs text-red-400",children:[l.jsxs("span",{className:"font-medium",children:[ce.provider_name,":"]})," ",ce.message]},ce.provider_id))})]})}),Pe?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Ae&&Ae.length>0?l.jsx("div",{className:"space-y-3",children:Ae.map(ce=>l.jsx(Q9e,{provider:ce,onEdit:st=>{v(st),m(!0)}},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-8",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(wh,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),l.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),l.jsxs(Le,{size:"sm",onClick:()=>{v(null),m(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[l.jsx(to,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),l.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),ye?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):we&&we.length>0?l.jsx("div",{className:"space-y-2",children:we.map(ce=>l.jsx(Nt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>b(ce),children:l.jsx(Rt,{className:"py-2.5 px-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-white font-medium text-sm truncate",children:ce.name}),l.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:ce.title_template})]}),l.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:st=>{st.stopPropagation(),b(ce)},children:l.jsx($R,{className:"w-4 h-4 text-bambu-gray"})})]})})},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-8",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(to,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),k==="apikeys"&&l.jsxs("div",{className:"max-w-3xl",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Vp,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks. Use these keys to control your printers from automation tools like Home Assistant."})]}),l.jsxs(Le,{size:"sm",onClick:()=>C(!0),className:"flex-shrink-0",children:[l.jsx(pr,{className:"w-4 h-4"}),"Create Key"]})]}),R&&l.jsx(Nt,{className:"mb-6 border-bambu-green",children:l.jsx(Rt,{className:"py-4",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(fi,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),l.jsxs("div",{className:"flex-1",children:[l.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),l.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),l.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[l.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:R}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(R);else{const ce=document.createElement("textarea");ce.value=R,ce.style.position="fixed",ce.style.left="-999999px",document.body.appendChild(ce),ce.select(),document.execCommand("copy"),document.body.removeChild(ce)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:l.jsx(Hh,{className:"w-4 h-4"})})]}),l.jsx(Le,{variant:"secondary",size:"sm",className:"mt-3",onClick:()=>W(null),children:"Dismiss"})]})]})})}),I&&l.jsxs(Nt,{className:"mb-6",children:[l.jsx(Ha,{children:l.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),l.jsx("input",{type:"text",value:D,onChange:ce=>F(ce.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:O.can_read_status,onChange:ce=>q(st=>({...st,can_read_status:ce.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Read Status"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:O.can_queue,onChange:ce=>q(st=>({...st,can_queue:ce.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Manage Queue"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:O.can_control_printer,onChange:ce=>q(st=>({...st,can_control_printer:ce.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Control Printer"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[l.jsxs(Le,{onClick:()=>L.mutate({name:D||"Unnamed Key",...O}),disabled:L.isPending,children:[L.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(pr,{className:"w-4 h-4"}),"Create Key"]}),l.jsx(Le,{variant:"secondary",onClick:()=>C(!1),children:"Cancel"})]})]})]}),z?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Se&&Se.length>0?l.jsx("div",{className:"space-y-3",children:Se.map(ce=>l.jsx(Nt,{children:l.jsx(Rt,{className:"py-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(Vp,{className:`w-5 h-5 ${ce.enabled?"text-bambu-green":"text-bambu-gray"}`}),l.jsxs("div",{children:[l.jsx("p",{className:"text-white font-medium",children:ce.name}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[ce.key_prefix,"••••••••",ce.last_used&&` · Last used: ${new Date(ce.last_used).toLocaleDateString()}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex gap-1 text-xs",children:[ce.can_read_status&&l.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),ce.can_queue&&l.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),ce.can_control_printer&&l.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>G(ce.id),children:l.jsx(Rn,{className:"w-4 h-4 text-red-400"})})]})]})})},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-12",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(Vp,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),l.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),l.jsxs(Le,{onClick:()=>C(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),l.jsxs(Nt,{className:"mt-6",children:[l.jsx(Ha,{children:l.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),l.jsxs(Rt,{className:"space-y-3 text-sm",children:[l.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",l.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),l.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-blue-400",children:"GET"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),l.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-blue-400",children:"GET"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),l.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-green-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),l.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-orange-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),l.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-orange-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),l.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-red-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),l.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),K!==null&&l.jsx(Qr,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{ne.mutate(K),G(null)},onCancel:()=>G(null)}),c&&l.jsx(Y9e,{plug:d,onClose:()=>{u(!1),f(null)}}),g&&l.jsx(J9e,{provider:x,onClose:()=>{m(!1),v(null)}}),y&&l.jsx(eGe,{template:y,onClose:()=>b(null)}),M&&l.jsx(rGe,{onClose:()=>S(!1)}),ee&&l.jsx(Qr,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{Z(!1);try{const ce=await ke.clearNotificationLogs(30);r(ce.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>Z(!1)}),Q&&l.jsx(Qr,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{U(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>U(!1)}),$&&l.jsx(Qr,{title:`Turn All Plugs ${$==="on"?"On":"Off"}`,message:`This will turn ${$==="on"?"ON":"OFF"} all ${re?.filter(ce=>ce.enabled).length||0} enabled smart plugs. ${$==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${$==="on"?"On":"Off"}`,variant:$==="off"?"danger":"warning",onConfirm:()=>{const ce=$;X(null),Ye.mutate(ce)},onCancel:()=>X(null)}),te&&l.jsx(aGe,{onClose:()=>fe(!1),onExport:async ce=>{fe(!1);const st="backup-progress",xt=ce.archives;xt&&i(st,e("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:St,filename:Qt}=await ke.exportBackup(ce);xt&&a(st);const Ot=URL.createObjectURL(St),Vt=document.createElement("a");Vt.href=Ot,Vt.download=Qt,Vt.click(),URL.revokeObjectURL(Ot),r(e("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{xt&&a(st),r(e("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),pe&&l.jsx(sGe,{onClose:()=>xe(!1),onRestore:async(ce,st)=>await ke.importBackup(ce,st),onSuccess:()=>{t.invalidateQueries()}}),Ne&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>ie(!1),children:l.jsxs(Nt,{className:"w-full max-w-lg",onClick:ce=>ce.stopPropagation(),children:[l.jsxs(Ha,{className:"flex flex-row items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Kce,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.telemetryInfoTitle")})]}),l.jsx("button",{onClick:()=>ie(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsx("p",{className:"text-bambu-gray text-sm",children:e("settings.telemetryInfoIntro")}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoCollected")}),l.jsxs("ul",{className:"space-y-2 text-sm",children:[l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem1")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem2")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem3")})]})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoNotCollected")}),l.jsxs("ul",{className:"space-y-2 text-sm",children:[l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(gs,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem1")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(gs,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem2")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(gs,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem3")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(gs,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem4")})]})]})]}),l.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:e("settings.telemetryInfoFooter")}),l.jsx(Le,{onClick:()=>ie(!1),className:"w-full",children:e("common.close")})]})]})}),be&&ue?.release_notes&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>je(!1),children:l.jsxs(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:ce=>ce.stopPropagation(),children:[l.jsxs(Ha,{className:"flex flex-row items-center justify-between shrink-0",children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",ue.latest_version]}),ue.release_name&&ue.release_name!==ue.latest_version&&l.jsx("p",{className:"text-sm text-bambu-gray",children:ue.release_name})]}),l.jsx("button",{onClick:()=>je(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx(Rt,{className:"overflow-y-auto flex-1",children:l.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:ue.release_notes})}),l.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[ue.release_url&&l.jsx("a",{href:ue.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:l.jsxs(Le,{variant:"secondary",className:"w-full",children:[l.jsx(As,{className:"w-4 h-4"}),"View on GitHub"]})}),l.jsx(Le,{onClick:()=>je(!1),className:"flex-1",children:"Close"})]})]})})]})}const pte=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},fGe=t=>t.startsWith("HH")?"HF":"S",pGe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},MR=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 dk({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:s}){const o=fGe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return l.jsxs("div",{className:"flex items-center gap-2",children:[r&&l.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?l.jsx(Vh,{className:"w-4 h-4 text-bambu-green"}):l.jsx(gm,{className:"w-4 h-4"})}),l.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:pte(t.k_value)}),l.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),s&&l.jsx("span",{title:"Has note",children:l.jsx(hG,{className:"w-3 h-3 text-yellow-500"})}),l.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",c]})]}),s&&l.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:s,children:["Note: ",s.length>50?s.substring(0,50)+"...":s]})]}),!r&&n&&l.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:l.jsx(Hh,{className:"w-4 h-4"})})]})}function hk({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:s=null,onClose:o,onSave:c,onSaveNote:u}){const{showToast:d}=ai(),[f,g]=E.useState(t?.name||""),[m,x]=E.useState(t?.k_value?pte(t.k_value):"0.020"),[v,y]=E.useState(t?.filament_id||""),[b,M]=E.useState(t?.nozzle_id?pGe(t.nozzle_id):"HH00"),[S,A]=E.useState(t?.nozzle_diameter||n),[T,k]=E.useState(t?[t.extruder_id]:i?[0,1]:[0]),[N,I]=E.useState(!1),[C,D]=E.useState({current:0,total:0}),[F,O]=E.useState(a),q=mr.useMemo(()=>{const Q=new Map;for(const U of r)if(U.filament_id&&!Q.has(U.filament_id)){const $=MR(U.name||"");Q.set(U.filament_id,{id:U.filament_id,name:$||U.filament_id})}return Array.from(Q.values()).sort((U,$)=>U.name.localeCompare($.name))},[r]),R=wt({mutationFn:Q=>(console.log("[KProfile] Calling API..."),ke.setKProfile(e,Q)),onSuccess:Q=>{if(console.log("[KProfile] Save success:",Q),d("K-profile saved"),u&&F!==a){let U;F===""&&s?U=s:t&&t.slot_id>0?U=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:U=`name_${f}_${v}`,u(U,F)}I(!0),setTimeout(()=>{I(!1),c()},2500)},onError:Q=>{console.error("[KProfile] Save error:",Q),d(Q.message,"error"),I(!1)}}),W=wt({mutationFn:Q=>(console.log("[KProfile] Deleting profile..."),ke.deleteKProfile(e,Q)),onSuccess:Q=>{console.log("[KProfile] Delete success:",Q),d("K-profile deleted"),I(!0),setTimeout(()=>{I(!1),o()},4e3)},onError:Q=>{console.error("[KProfile] Delete error:",Q),d(Q.message,"error"),I(!1)}}),[K,G]=E.useState(!1),ee=()=>{t&&W.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},Z=async Q=>{if(Q.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const U=parseFloat(m).toFixed(6),$=`${b}-${S}`;if(t||T.length===1){const te={name:f,k_value:U,filament_id:v,nozzle_id:$,nozzle_diameter:S,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",te),R.mutate(te);return}I(!0),D({current:1,total:T.length});const X=T.map(te=>({name:f,k_value:U,filament_id:v,nozzle_id:$,nozzle_diameter:S,extruder_id:te,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${X.length} profiles in batch:`,X);try{if(await ke.setKProfilesBatch(e,X),d(`K-profile saved to ${T.length} extruders`),u&&F){const te=`name_${f}_${v}`;u(te,F)}}catch(te){console.error("[KProfile] Failed to save batch:",te),d("Failed to save K-profiles","error"),I(!1),D({current:0,total:0});return}D({current:T.length,total:T.length}),setTimeout(()=>{I(!1),D({current:0,total:0}),c()},3e3)};return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[l.jsxs(Nt,{className:"w-full max-w-md relative",children:[N&&l.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),l.jsx("p",{className:"text-white font-medium",children:C.total>1?`Saving to extruder ${C.current}/${C.total}...`:"Syncing with printer..."}),l.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),l.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:N,children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:Z,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),l.jsx("input",{type:"text",value:f,onChange:Q=>g(Q.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),l.jsx("input",{type:"text",inputMode:"decimal",value:m,onChange:Q=>{const U=Q.target.value;(U===""||/^\d*\.?\d*$/.test(U))&&x(U)},onBlur:Q=>{const U=parseFloat(Q.target.value);isNaN(U)||x((Math.trunc(U*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),l.jsxs("select",{value:v,onChange:Q=>{const U=Q.target.value;if(y(U),!t&&U&&!f){const $=q.find(X=>X.id===U);$&&g(`${b==="HH00"?"HF":"S"} ${$.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[l.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&l.jsx("option",{value:t.filament_id,children:q.find(Q=>Q.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(Q=>l.jsx("option",{value:Q.id,children:Q.name},Q.id))]}),!t&&q.length===0&&l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),l.jsxs("select",{value:b,onChange:Q=>{const U=Q.target.value;if(M(U),!t&&v&&!f){const $=q.find(X=>X.id===v);$&&g(`${U==="HS00"?"HF":"S"} ${$.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[l.jsx("option",{value:"HH00",children:"High Flow"}),l.jsx("option",{value:"HS00",children:"Standard"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),l.jsxs("select",{value:S,onChange:Q=>A(Q.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[l.jsx("option",{value:"0.2",children:"0.2mm"}),l.jsx("option",{value:"0.4",children:"0.4mm"}),l.jsx("option",{value:"0.6",children:"0.6mm"}),l.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?l.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):l.jsxs("div",{className:"flex gap-4",children:[l.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:Q=>{Q.target.checked?k([...T,1]):k(T.filter(U=>U!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),l.jsx("span",{className:"text-white",children:"Left"})]}),l.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:Q=>{Q.target.checked?k([...T,0]):k(T.filter(U=>U!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),l.jsx("span",{className:"text-white",children:"Right"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),l.jsx("textarea",{value:F,onChange:Q=>O(Q.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),l.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&l.jsx(Le,{type:"button",variant:"secondary",onClick:()=>G(!0),disabled:W.isPending||N,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"})}),l.jsx(Le,{type:"button",variant:"secondary",onClick:o,disabled:N,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:R.isPending||N,className:"flex-1",children:[R.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(zR,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:l.jsx(Nt,{className:"w-full max-w-sm",children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:l.jsx(Rn,{className:"w-5 h-5 text-red-500"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),l.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",l.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:()=>{G(!1),ee()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const Y_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function mGe(){const{showToast:t}=ai(),[e,n]=E.useState(null),[r,i]=E.useState(()=>localStorage.getItem(Y_.NOZZLE_DIAMETER)||"0.4"),[a,s]=E.useState(null),[o,c]=E.useState(!1),[u,d]=E.useState(null),[f,g]=E.useState(""),[m,x]=E.useState("all"),[v,y]=E.useState("all"),[b,M]=E.useState(()=>localStorage.getItem(Y_.SORT_OPTION)||"name"),[S,A]=E.useState(!1),[T,k]=E.useState(new Set),[N,I]=E.useState(!1),[C,D]=E.useState(!1),F=V=>`${V.slot_id}_${V.extruder_id}`;E.useEffect(()=>{localStorage.setItem(Y_.NOZZLE_DIAMETER,r)},[r]),E.useEffect(()=>{localStorage.setItem(Y_.SORT_OPTION,b)},[b]);const{data:O,isLoading:q}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:R,isLoading:W,isFetching:K,error:G,refetch:ee}=vt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const V=await ke.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",V?.profiles?.length||0,"profiles"),V},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Z}=vt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>ke.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:Q,refetch:U}=vt({queryKey:["kprofile-notes",e],queryFn:()=>ke.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),$=G?.message?.includes("not connected");E.useEffect(()=>{if(!e&&O&&O.length>0){const V=O.find(J=>J.is_active);V&&n(V.id)}},[e,O]),E.useEffect(()=>{if(e){const V=setTimeout(()=>{ee()},150);return()=>clearTimeout(V)}},[e,r]);const X=O?.filter(V=>V.is_active)||[],te=mr.useMemo(()=>R?.profiles?R.profiles.filter(J=>{const se=f.toLowerCase(),Ae=!se||J.name.toLowerCase().includes(se)||J.filament_id.toLowerCase().includes(se),Pe=m==="all"||m==="left"&&J.extruder_id===1||m==="right"&&J.extruder_id===0,Se=v==="all"||v==="hf"&&J.nozzle_id.startsWith("HH")||v==="s"&&J.nozzle_id.startsWith("HS");return Ae&&Pe&&Se}).sort((J,se)=>{switch(b){case"k_value":return parseFloat(J.k_value)-parseFloat(se.k_value);case"filament":return MR(J.name).localeCompare(MR(se.name));case"name":default:return J.name.localeCompare(se.name)}}):[],[R?.profiles,f,m,v,b]),fe=O?.find(V=>V.id===e),pe=fe?.nozzle_count===2;E.useEffect(()=>{const V=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||a||o||u||(J.key==="r"||J.key==="R"?(J.preventDefault(),ee()):J.key==="n"||J.key==="N"?(J.preventDefault(),c(!0)):J.key==="Escape"&&S&&(J.preventDefault(),A(!1),k(new Set)))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[a,o,u,S,ee]);const xe=E.useCallback(()=>{if(!R?.profiles||R.profiles.length===0){t("No profiles to export","error");return}const V={version:1,exported_at:new Date().toISOString(),printer:fe?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(Pe=>({name:Pe.name,k_value:Pe.k_value,filament_id:Pe.filament_id,nozzle_id:Pe.nozzle_id,nozzle_diameter:Pe.nozzle_diameter,extruder_id:Pe.extruder_id}))},J=new Blob([JSON.stringify(V,null,2)],{type:"application/json"}),se=URL.createObjectURL(J),Ae=document.createElement("a");Ae.href=se,Ae.download=`kprofiles_${fe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),URL.revokeObjectURL(se),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,fe,r,t]),Ne=E.useCallback(()=>{const V=document.createElement("input");V.type="file",V.accept=".json",V.onchange=async J=>{const se=J.target.files?.[0];if(se)try{const Ae=await se.text(),Pe=JSON.parse(Ae);if(!Pe.profiles||!Array.isArray(Pe.profiles)){t("Invalid file format","error");return}let Se=0;for(const z of Pe.profiles)if(!(!z.name||!z.k_value||!z.filament_id))try{await ke.setKProfile(e,{name:z.name,k_value:parseFloat(z.k_value).toFixed(6),filament_id:z.filament_id,nozzle_id:z.nozzle_id||`HH00-${r}`,nozzle_diameter:z.nozzle_diameter||r,extruder_id:z.extruder_id??0,slot_id:0}),Se++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",z.name,L)}t(`Imported ${Se} of ${Pe.profiles.length} profiles`),ee()}catch(Ae){console.error("Import error:",Ae),t("Failed to parse import file","error")}},V.click()},[e,r,t,ee]),ie=E.useCallback(V=>{k(J=>{const se=new Set(J);return se.has(V)?se.delete(V):se.add(V),se})},[]),be=E.useCallback(()=>{k(new Set(te.map(V=>F(V))))},[te,F]),je=E.useCallback(()=>{T.size!==0&&I(!0)},[T.size]),he=E.useCallback(async()=>{const V=te.filter(se=>T.has(F(se)));D(!0);let J=0;for(const se of V)try{await ke.deleteKProfile(e,{slot_id:se.slot_id,extruder_id:se.extruder_id,nozzle_id:se.nozzle_id,nozzle_diameter:se.nozzle_diameter,filament_id:se.filament_id,setting_id:se.setting_id}),J++,await new Promise(Ae=>setTimeout(Ae,300))}catch(Ae){console.error("Failed to delete profile:",se.name,Ae)}t(`Deleted ${J} profiles`),D(!1),I(!1),A(!1),k(new Set),ee()},[e,T,te,t,ee,F]),ht=E.useCallback(V=>{const J=[];return V.setting_id&&J.push(V.setting_id),J.push(`slot_${V.slot_id}_${V.filament_id}_${V.extruder_id}`),J.push(`name_${V.name}_${V.filament_id}`),J},[]),H=E.useCallback(async(V,J)=>{if(e)try{await ke.setKProfileNote(e,V,J),U()}catch(se){console.error("Failed to save note:",se),t("Failed to save note","error")}},[e,U,t]),B=E.useCallback(V=>{if(!Q?.notes)return{note:"",key:null};const J=ht(V);for(const se of J)if(Q.notes[se])return{note:Q.notes[se],key:se};return{note:"",key:null}},[Q,ht]),re=E.useCallback(V=>B(V).note,[B]);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"})}):!O||O.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(lo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),l.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):X.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(Ts,{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:V=>n(parseInt(V.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:X.map(V=>l.jsx("option",{value:V.id,children:V.name},V.id))})]}),l.jsxs("div",{className:"w-32",children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),l.jsxs("select",{value:r,onChange:V=>i(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"0.2",children:"0.2mm"}),l.jsx("option",{value:"0.4",children:"0.4mm"}),l.jsx("option",{value:"0.6",children:"0.6mm"}),l.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs(Le,{variant:"secondary",onClick:()=>ee(),disabled:K,children:[l.jsx(Ta,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),l.jsxs(Le,{onClick:()=>c(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),l.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[l.jsxs("div",{className:"flex-1 min-w-48 relative",children:[l.jsx(id,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:f,onChange:V=>g(V.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),pe&&l.jsx("div",{className:"w-36",children:l.jsxs("select",{value:m,onChange:V=>x(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"all",children:"All Extruders"}),l.jsx("option",{value:"left",children:"Left Only"}),l.jsx("option",{value:"right",children:"Right Only"})]})}),l.jsx("div",{className:"w-32",children:l.jsxs("select",{value:v,onChange:V=>y(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"all",children:"All Flow"}),l.jsx("option",{value:"hf",children:"HF Only"}),l.jsx("option",{value:"s",children:"S Only"})]})}),l.jsx("div",{className:"w-32",children:l.jsxs("select",{value:b,onChange:V=>M(V.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"name",children:"Sort: Name"}),l.jsx("option",{value:"k_value",children:"Sort: K-Value"}),l.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),l.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[l.jsxs(Le,{variant:"secondary",onClick:xe,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[l.jsx(Es,{className:"w-4 h-4"}),"Export"]}),l.jsxs(Le,{variant:"secondary",onClick:Ne,title:"Import profiles from JSON",children:[l.jsx(vs,{className:"w-4 h-4"}),"Import"]}),l.jsx("div",{className:"flex-1"}),S?l.jsxs(l.Fragment,{children:[l.jsxs(Le,{variant:"secondary",onClick:be,title:"Select all visible profiles",children:[l.jsx(Vh,{className:"w-4 h-4"}),"Select All"]}),l.jsxs(Le,{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(Rn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),l.jsxs(Le,{variant:"secondary",onClick:()=>{A(!1),k(new Set)},children:[l.jsx(Wt,{className:"w-4 h-4"}),"Cancel"]})]}):l.jsxs(Le,{variant:"secondary",onClick:()=>A(!0),disabled:!te.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"})}):$?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(qR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),l.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),l.jsxs(Le,{variant:"secondary",onClick:()=>ee(),children:[l.jsx(Ta,{className:"w-4 h-4"}),"Retry"]})]})}):te.length>0?pe?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:te.filter(V=>V.extruder_id===1).map(V=>l.jsx(dk,{profile:V,onEdit:()=>s(V),onCopy:()=>d(V),selectionMode:S,isSelected:T.has(F(V)),onToggleSelect:()=>ie(F(V)),note:re(V)},F(V)))})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),l.jsx("div",{className:"space-y-1",children:te.filter(V=>V.extruder_id===0).map(V=>l.jsx(dk,{profile:V,onEdit:()=>s(V),onCopy:()=>d(V),selectionMode:S,isSelected:T.has(F(V)),onToggleSelect:()=>ie(F(V)),note:re(V)},F(V)))})]})]}):l.jsx("div",{className:"space-y-1",children:te.map(V=>l.jsx(dk,{profile:V,onEdit:()=>s(V),onCopy:()=>d(V),selectionMode:S,isSelected:T.has(F(V)),onToggleSelect:()=>ie(F(V)),note:re(V)},F(V)))}):f||m!=="all"||v!=="all"?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(id,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),l.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(zR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),l.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),l.jsxs(Le,{onClick:()=>c(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:V,key:J}=B(a);return l.jsx(hk,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:Z?.profiles||R?.profiles,isDualNozzle:pe,initialNote:V,initialNoteKey:J,onSaveNote:H,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),s(null),ee()},onSave:()=>{s(null),ee()}})})(),o&&e&&l.jsx(hk,{printerId:e,nozzleDiameter:r,existingProfiles:Z?.profiles||R?.profiles,isDualNozzle:pe,onSaveNote:H,onClose:()=>{c(!1),ee()},onSave:()=>{c(!1),ee()}}),u&&e&&l.jsx(hk,{printerId:e,nozzleDiameter:r,existingProfiles:Z?.profiles||R?.profiles,isDualNozzle:pe,onSaveNote:H,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),ee()},onSave:()=>{d(null),ee()}}),N&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-sm",children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:l.jsx(Rn,{className:"w-5 h-5 text-red-500"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),l.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",l.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:()=>I(!1),disabled:C,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:he,disabled:C,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[C?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function xL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),s=a?(a[1]||a[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=o?o[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:s,layerHeight:c,filamentType:d}}function hb(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function gGe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),s=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:s<7?`${s}d ago`:e.toLocaleDateString()}function xGe({onSuccess:t}){const{showToast:e}=ai(),[n,r]=E.useState("email"),[i,a]=E.useState(""),[s,o]=E.useState(""),[c,u]=E.useState(""),[d,f]=E.useState(""),[g,m]=E.useState("global"),x=wt({mutationFn:()=>ke.cloudLogin(i,s,g),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):S.needs_verification?(e("Verification code sent to your email"),r("code")):e(S.message,"error")},onError:S=>e(S.message,"error")}),v=wt({mutationFn:()=>ke.cloudVerify(i,c),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):e(S.message,"error")},onError:S=>e(S.message,"error")}),y=wt({mutationFn:()=>ke.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:S=>e(S.message,"error")}),b=S=>{S.preventDefault(),n==="email"?x.mutate():n==="code"?v.mutate():n==="token"&&y.mutate()},M=x.isPending||v.isPending||y.isPending;return l.jsx(Nt,{className:"max-w-md mx-auto",children:l.jsxs(Rt,{children:[l.jsxs("div",{className:"text-center mb-6",children:[l.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:l.jsx(US,{className:"w-6 h-6 text-bambu-green"})}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),l.jsxs("form",{onSubmit:b,className:"space-y-4",children:[n==="email"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),l.jsx("input",{type:"email",value:i,onChange:S=>a(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),l.jsx("input",{type:"password",value:s,onChange:S=>o(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),l.jsxs("select",{value:g,onChange:S=>m(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"global",children:"Global"}),l.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),l.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),l.jsx("input",{type:"text",value:c,onChange:S=>u(S.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),l.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),l.jsx("textarea",{value:d,onChange:S=>f(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),l.jsxs("div",{className:"flex gap-2",children:[n==="code"&&l.jsx(Le,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),l.jsxs(Le,{type:"submit",disabled:M,className:"flex-1",children:[M?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(YF,{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(YF,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Lp({label:t,value:e,options:n,onChange:r}){const[i,a]=E.useState(!1),s=n.find(o=>o.value===e);return l.jsxs("div",{className:"relative",children:[l.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[l.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),l.jsx("span",{children:s?.label||"All"}),l.jsx(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:()=>a(!1)}),l.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(o=>l.jsxs("button",{onClick:()=>{r(o.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===o.value?"text-bambu-green":"text-white"}`,children:[l.jsx("span",{children:o.label}),o.count!==void 0&&l.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function bGe(){const[t,e]=E.useState(!1);E.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?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 fk({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:s}){const o=xL(t.name),c=hb(t.setting_id);return l.jsxs("div",{className:"flex items-center gap-2 group",children:[l.jsx("button",{onClick:e,disabled:s,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":s?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!s?"cursor-pointer":""}`,children:l.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&l.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:a+1}),!i&&c&&l.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),l.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),l.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:l.jsx(Hh,{className:"w-4 h-4"})})]})}function ER(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(a=>n+" "+a).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+" "+ER(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([a,s])=>n+" "+JSON.stringify(a)+": "+ER(s,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function yGe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=ai(),s=En(),[o,c]=E.useState(!1),{data:u,isLoading:d}=vt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ke.getCloudSettingDetail(t.setting_id)}),f=wt({mutationFn:()=>ke.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),s.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>a(x.message,"error")}),g=hb(t.setting_id),m=xL(t.name,u?.setting?.inherits);return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:l.jsxs(Rt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&l.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[l.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),m.printer&&l.jsxs(l.Fragment,{children:[l.jsx("span",{children:"•"}),l.jsx("span",{children:m.printer})]})]})]}),l.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?l.jsx("div",{className:"flex items-center justify-center py-16",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?l.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:ER(u)}):l.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),o?l.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[l.jsx(ti,{className:"w-5 h-5"}),l.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),l.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]}):l.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),l.jsxs(Le,{variant:"secondary",onClick:r,children:[l.jsx(Hh,{className:"w-4 h-4"}),"Duplicate"]}),g&&l.jsxs(l.Fragment,{children:[l.jsxs(Le,{variant:"secondary",onClick:i,disabled:d||!u,children:[l.jsx(rd,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Le,{variant:"danger",onClick:()=>c(!0),children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})})]})})})}function mte(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function gte(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function vGe({onClose:t,onApply:e}){const{showToast:n}=ai(),[r,i]=E.useState(mte),[a,s]=E.useState("all"),[o,c]=E.useState(null),[u,d]=E.useState(""),[f,g]=E.useState(""),[m,x]=E.useState("{}"),[v,y]=E.useState(null),[b,M]=E.useState(null),S=a==="all"?r:r.filter(O=>O.type===a),A=O=>{i(O),gte(O)},T=O=>{const q=r.filter(R=>R.id!==O);A(q),M(null),n("Template deleted")},k=O=>{c(O.id),d(O.name),g(O.description),x(JSON.stringify(O.settings,null,2)),y(null)},N=()=>{if(!(!o||!u.trim()))try{const O=JSON.parse(m),q=r.map(R=>R.id===o?{...R,name:u.trim(),description:f.trim(),settings:O}:R);A(q),c(null),n("Template updated")}catch(O){y(O.message)}},I=()=>{c(null),d(""),g(""),x("{}"),y(null)},C=O=>{const q=r.map(R=>R.id===O?{...R,showInModal:!R.showInModal}:R);A(q)},D={filament:{label:"Filament",icon:IR,color:"text-amber-400"},print:{label:"Process",icon:HS,color:"text-blue-400"},printer:{label:"Printer",icon:Ts,color:"text-purple-400"}},F=b?r.find(O=>O.id===b):null;return E.useEffect(()=>{const O=q=>{q.key==="Escape"&&(b?M(null):o?I():t())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[b,o,t]),l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:l.jsx(Nt,{className:"w-full max-w-md",children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:l.jsx(ti,{className:"w-6 h-6 text-red-400"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),l.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',l.jsx("span",{className:"font-medium",children:F.name}),'"?']}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:()=>M(null),className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:()=>T(b),className:"flex-1 bg-red-500 hover:bg-red-600",children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),l.jsx(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:l.jsxs(Rt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(M0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(O=>l.jsx("button",{onClick:()=>s(O),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:O==="all"?"All":D[O].label},O))]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:S.length===0?l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(M0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),l.jsx("p",{children:"No templates yet"}),l.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):l.jsx("div",{className:"space-y-2",children:S.map(O=>{const q=D[O.type],R=q.icon;return o===O.id?l.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[l.jsx("input",{type:"text",value:u,onChange:W=>d(W.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx("input",{type:"text",value:f,onChange:W=>g(W.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"mb-3",children:[l.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),l.jsx("textarea",{value:m,onChange:W=>{x(W.target.value),y(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${v?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),v&&l.jsx("p",{className:"text-xs text-red-400 mt-1",children:v})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{size:"sm",onClick:N,disabled:!u.trim(),children:[l.jsx(Ro,{className:"w-4 h-4"}),"Save"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:I,children:"Cancel"})]})]},O.id):l.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[l.jsx(R,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium text-white",children:O.name}),l.jsx("p",{className:"text-xs text-bambu-gray truncate",children:O.description})]}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(O.settings).length," fields"]}),l.jsx("button",{onClick:()=>C(O.id),className:`p-1 transition-colors ${O.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:O.showInModal?"Shown in modals":"Hidden in modals",children:O.showInModal?l.jsx(mm,{className:"w-4 h-4"}):l.jsx(FR,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>e(O),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),l.jsx("button",{onClick:()=>k(O),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:l.jsx(rd,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>M(O.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:l.jsx(Rn,{className:"w-4 h-4"})})]},O.id)})})})]})})]})}function xte({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,s]=E.useState("changes"),[o,c]=E.useState(""),u=E.useMemo(()=>{const m=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const v of m){if(v==="inherits"||v==="version")continue;const y=e[v],b=n[v],M=v in e,S=v in n;let A;!M&&S?A="added":M&&!S?A="removed":JSON.stringify(y)!==JSON.stringify(b)?A="changed":A="same",x.push({key:v,left:y,right:b,status:A})}return x.sort((v,y)=>{const b={changed:0,added:1,removed:2,same:3};return b[v.status]!==b[y.status]?b[v.status]-b[y.status]:v.key.localeCompare(y.key)})},[e,n]),d=E.useMemo(()=>{let m=[...u];if(a==="changes"&&(m=m.filter(x=>x.status!=="same")),o){const x=o.toLowerCase();m=m.filter(v=>v.key.toLowerCase().includes(x)||String(v.left).toLowerCase().includes(x)||String(v.right).toLowerCase().includes(x))}return m},[u,a,o]),f=E.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 v=x.split("\\n").length;if(v>1)return`[${v} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return E.useEffect(()=>{const m=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]),l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:l.jsxs(Rt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Qp,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),l.jsx("p",{className:"text-white font-medium truncate",children:r})]}),l.jsxs("div",{className:"text-center",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),l.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[l.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[l.jsx(pr,{className:"w-3.5 h-3.5"}),f.added," added"]}),l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(Rk,{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(Tk,{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:()=>s("changes"),className:`px-3 py-1.5 text-sm transition-colors ${a==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),l.jsx("button",{onClick:()=>s("all"),className:`px-3 py-1.5 text-sm transition-colors ${a==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(RA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),l.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):l.jsxs("table",{className:"w-full",children:[l.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:l.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[l.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),l.jsx("th",{className:"text-left p-3 w-1/3",children:r}),l.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),l.jsx("tbody",{children:d.map(m=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[m.status],v={added:l.jsx(pr,{className:"w-3.5 h-3.5 text-green-400"}),removed:l.jsx(Rk,{className:"w-3.5 h-3.5 text-red-400"}),changed:l.jsx(Tk,{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:[v,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 _Ge({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=ai(),i=En(),a=!!e?.setting_id,[s,o]=E.useState("common"),[c,u]=E.useState(e?.type||"filament"),[d,f]=E.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[g,m]=E.useState(e?.base_id||""),[x,v]=E.useState(""),[y,b]=E.useState(e?.setting||{inherits:""}),[M,S]=E.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,T]=E.useState(null),[k,N]=E.useState(""),[I,C]=E.useState(!1),[D,F]=E.useState(""),[O,q]=E.useState(!1),[R,W]=E.useState(mte),[K,G]=E.useState(!1),[ee,Z]=E.useState(""),[Q,U]=E.useState(""),[$,X]=E.useState(!0),[te,fe]=E.useState(null),[pe,xe]=E.useState(!1),Ne=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),ie=E.useMemo(()=>Ne.filter(oe=>hb(oe.setting_id)),[Ne]),{data:be}=vt({queryKey:["cloudFields",c],queryFn:()=>ke.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:je}=vt({queryKey:["allPresetDetails",c,ie.map(oe=>oe.setting_id).join(",")],queryFn:async()=>{const oe={};for(let He=0;He<ie.length;He+=5){const Ke=ie.slice(He,He+5);(await Promise.all(Ke.map(async de=>{try{const Ye=await ke.getCloudSettingDetail(de.setting_id);return{id:de.setting_id,detail:Ye}}catch{return null}}))).forEach(de=>{de&&(oe[de.id]=de.detail)})}return oe},enabled:ie.length>0,staleTime:1e3*60*10}),{data:he,isLoading:ht}=vt({queryKey:["cloudSettingDetail",g],queryFn:()=>ke.getCloudSettingDetail(g),enabled:!!g});E.useEffect(()=>{s!=="json"&&S(JSON.stringify(y,null,2))},[y,s]);const H=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(Je=>!hb(Je.setting_id)).sort((Je,He)=>Je.name.localeCompare(He.name)),[n,c]);E.useEffect(()=>{if(!g)return;const oe=H.find(Je=>Je.setting_id===g);oe&&(v(oe.name),a||(b({inherits:oe.name}),S(JSON.stringify({inherits:oe.name},null,2))))},[g,H,a]);const B=E.useMemo(()=>{const oe=be?.fields||[],Je=new Set(oe.map(de=>de.key)),He=new Set,Ke=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);je&&Object.values(je).forEach(de=>{de?.setting&&Object.keys(de.setting).forEach(Ye=>{!Je.has(Ye)&&!Ke.has(Ye)&&He.add(Ye)})}),Object.keys(y).forEach(de=>{!Je.has(de)&&!Ke.has(de)&&He.add(de)});const ct=Array.from(He).sort().map(de=>({key:de,label:de.replace(/_/g," ").replace(/\b\w/g,Ye=>Ye.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...oe,...ct]},[be,je,y]),re=B.filter(oe=>oe.label.toLowerCase().includes(k.toLowerCase())||oe.key.toLowerCase().includes(k.toLowerCase())),V=()=>{if(D.trim()){const oe=D.trim().toLowerCase().replace(/\s+/g,"_");J(oe,""),F(""),q(!1),r(`Field "${oe}" added`)}},J=(oe,Je)=>{b(He=>{const Ke={...He};return Je===""||Je===void 0?delete Ke[oe]:Ke[oe]=Je,Ke})},se=oe=>{b(Je=>({...Je,...oe.settings})),fe(oe.name),r("Template applied")},Ae=()=>{if(!ee.trim())return;const oe={...y};if(delete oe.inherits,Object.keys(oe).length===0){r("No overrides to save","error");return}const Je={id:Date.now().toString(),name:ee.trim(),description:Q.trim()||"Custom template",type:c,settings:oe,showInModal:$},He=[...R,Je];W(He),gte(He),G(!1),Z(""),U(""),X(!0),r("Template saved")},Pe=E.useMemo(()=>R.filter(oe=>oe.type===c&&oe.showInModal),[c,R]),Se=oe=>{S(oe);try{const Je=JSON.parse(oe);b(Je),T(null)}catch(Je){T(Je.message)}},z=oe=>{oe.preventDefault(),C(!1);const Je=oe.dataTransfer.files[0];if(Je&&Je.name.endsWith(".json")){const He=new FileReader;He.onload=Ke=>{try{const ct=Ke.target?.result,de=JSON.parse(ct),Ye=de.setting||de;b(ge=>({...ge,...Ye})),S(JSON.stringify({...y,...Ye},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},He.readAsText(Je)}},L=wt({mutationFn:()=>{const oe={...y},Je=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";oe[Je]=`"${d}"`;const He={type:c,name:d,base_id:g,setting:oe};return ke.createCloudSetting(He)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),ne=wt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return ke.updateCloudSetting(e.setting_id,{name:d,setting:y})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),ve=a?ne:L,we=he?.setting?.inherits,ye=we?H.find(oe=>oe.name===we):void 0,{data:nt}=vt({queryKey:["cloudSettingDetail",ye?.setting_id],queryFn:()=>ke.getCloudSettingDetail(ye.setting_id),enabled:!!ye?.setting_id}),Be=E.useMemo(()=>{const oe=nt?.setting||{},Je=he?.setting||{},He=g&&je?.[g]?.setting?je[g].setting:{};return{...oe,...Je,...He}},[g,he,nt,je]),ue=oe=>{if(oe==null)return"";if(Array.isArray(oe)){const Je=[...new Set(oe.map(He=>String(He)))];return Je.length===1?Je[0]:oe.join(", ")}return String(oe)},Ve=oe=>{const Je=y[oe.key],He=Be[oe.key],Ke=ue(He),ct=ht?"Loading...":Ke||"",de="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(oe.type==="boolean"){const Ye=Je==="1"||Je===void 0&&He==="1";return l.jsx("button",{type:"button",onClick:()=>J(oe.key,Je==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Ye?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:l.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Ye?"translate-x-3.5":"translate-x-0.5"}`})})}return oe.type==="select"?l.jsxs("select",{value:Je||"",onChange:Ye=>J(oe.key,Ye.target.value),className:de,children:[l.jsx("option",{value:"",children:ct}),oe.options?.map(Ye=>l.jsx("option",{value:Ye.value,children:Ye.label},Ye.value))]}):l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:oe.type==="number"?"number":"text",value:Je!==void 0?String(Je):"",onChange:Ye=>J(oe.key,Ye.target.value),step:oe.step,min:oe.min,max:oe.max,placeholder:ct,className:de}),oe.unit&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:oe.unit})]})},Fe=E.useMemo(()=>he?.setting?he.setting:{},[he]);return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:oe=>{oe.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:z,children:[pe&&g&&l.jsx(xte,{onClose:()=>xe(!1),leftPreset:Fe,rightPreset:y,leftLabel:`Base: ${x||g}`,rightLabel:`Current: ${d||"New Preset"}`}),l.jsx(Nt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:l.jsxs(Rt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:a?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[g&&l.jsxs("button",{onClick:()=>xe(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Compare with base preset",children:[l.jsx(Qp,{className:"w-4 h-4"}),"Compare"]}),l.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),I&&l.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:l.jsxs("div",{className:"text-center",children:[l.jsx(vs,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),l.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),l.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),l.jsxs("select",{value:c,onChange:oe=>{u(oe.target.value),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:oe=>m(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"Select base preset..."}),H.map(oe=>l.jsx("option",{value:oe.setting_id,children:oe.name},oe.setting_id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),l.jsx("input",{type:"text",value:d,onChange:oe=>f(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&l.jsx("div",{className:"text-xs text-bambu-gray",children:l.jsxs("p",{className:"flex items-center gap-1",children:[l.jsx(zh,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",l.jsx("span",{className:"text-white",children:x}),ht&&l.jsx(At,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[l.jsxs("button",{onClick:()=>o("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(ZF,{className:"w-4 h-4"}),"Common"]}),l.jsxs("button",{onClick:()=>o("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(HR,{className:"w-4 h-4"}),"All Fields"]}),l.jsxs("button",{onClick:()=>o("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(iG,{className:"w-4 h-4"}),"JSON",A&&l.jsx(lo,{className:"w-3 h-3 text-red-400"})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("button",{onClick:()=>{const oe={name:d,type:c,base_id:g,setting:y},Je=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),He=URL.createObjectURL(Je),Ke=document.createElement("a");Ke.href=He,Ke.download=`${d||"preset"}.json`,document.body.appendChild(Ke),Ke.click(),document.body.removeChild(Ke),URL.revokeObjectURL(He),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[l.jsx(Es,{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(vs,{className:"w-4 h-4"}),"Import"]}),l.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:oe=>{const Je=oe.target.files?.[0];if(Je){const He=new FileReader;He.onload=Ke=>{try{const ct=JSON.parse(Ke.target?.result),de=ct.setting||ct;b(Ye=>({...Ye,...de})),r("File imported")}catch{r("Invalid JSON","error")}},He.readAsText(Je)}}})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[s==="common"&&l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[l.jsx(M0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(y).filter(oe=>oe!=="inherits").length>0&&l.jsxs("button",{onClick:()=>G(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[l.jsx(Ro,{className:"w-3 h-3"}),"Save as template"]})]}),K&&l.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[l.jsx("input",{type:"text",value:ee,onChange:oe=>Z(oe.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx("input",{type:"text",value:Q,onChange:oe=>U(oe.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{size:"sm",onClick:Ae,disabled:!ee.trim(),children:[l.jsx(Ro,{className:"w-3 h-3"}),"Save"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]}),l.jsxs("button",{onClick:()=>X(!$),className:`flex items-center gap-1.5 text-xs transition-colors ${$?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[$?l.jsx(mm,{className:"w-3.5 h-3.5"}):l.jsx(FR,{className:"w-3.5 h-3.5"}),$?"Show in modals":"Hidden in modals"]})]})]}),te&&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:te})]}),l.jsx("button",{onClick:()=>fe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Pe.map(oe=>l.jsxs("button",{onClick:()=>se(oe),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[l.jsx("p",{className:"text-sm font-medium text-white",children:oe.name}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:oe.description})]},oe.id)),Pe.length===0&&l.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:"No templates selected. Use the Templates button to enable templates for quick access."})]}),l.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),l.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:B.slice(0,10).map(oe=>l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:oe.label}),l.jsx("div",{className:"w-48",children:Ve(oe)})]},oe.key))})]}),Object.keys(y).length>1&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(y).filter(([oe])=>oe!=="inherits").map(([oe,Je])=>l.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[oe,": ",String(Je).slice(0,20),l.jsx("button",{onClick:()=>J(oe,void 0),className:"hover:text-white",children:l.jsx(Wt,{className:"w-3 h-3"})})]},oe))})]})]}),s==="fields"&&l.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[l.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),l.jsx("span",{className:"text-xs text-bambu-gray",children:je?`${B.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:oe=>N(oe.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[re.filter(oe=>!(oe.key in y)).map(oe=>{const Je=Be[oe.key],He=ue(Je);return l.jsxs("div",{onClick:()=>{b(Ke=>({...Ke,[oe.key]:He||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-sm text-white truncate",children:oe.label}),l.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:oe.key})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[He&&l.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:He,children:[He.slice(0,20),He.length>20?"...":""]}),l.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:l.jsx(pr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},oe.key)}),re.filter(oe=>!(oe.key in y)).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:O?l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:D,onChange:oe=>F(oe.target.value),onKeyDown:oe=>oe.key==="Enter"&&V(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx(Le,{size:"sm",onClick:V,disabled:!D.trim(),children:l.jsx(pr,{className:"w-4 h-4"})}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>{q(!1),F("")},children:l.jsx(Wt,{className:"w-4 h-4"})})]}):l.jsxs("button",{onClick:()=>q(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[l.jsx(pr,{className:"w-4 h-4"}),"Add custom field"]})})]}),l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[l.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),l.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(y).filter(oe=>oe!=="inherits").length," fields"]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(y).filter(([oe])=>oe!=="inherits").map(([oe,Je])=>{const He=B.find(Ke=>Ke.key===oe);return l.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-white",children:He?.label||oe}),l.jsx("p",{className:"text-xs text-bambu-gray-dark",children:oe})]}),l.jsx("button",{onClick:()=>J(oe,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),He?Ve(He):l.jsx("input",{type:"text",value:String(Je),onChange:Ke=>J(oe,Ke.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},oe)}),Object.keys(y).filter(oe=>oe!=="inherits").length===0&&l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(ZF,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),l.jsx("p",{className:"text-sm",children:"No overrides yet"}),l.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(y).filter(oe=>oe!=="inherits").length>0&&l.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:l.jsxs("button",{onClick:()=>{G(!0),o("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[l.jsx(Ro,{className:"w-4 h-4"}),"Save as template"]})})]})]}),s==="json"&&l.jsxs("div",{className:"space-y-2",children:[A&&l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(lo,{className:"w-4 h-4"}),A]}),l.jsx("textarea",{value:M,onChange:oe=>Se(oe.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),l.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:()=>ve.mutate(),disabled:ve.isPending||!d.trim()||!a&&!g||!!A,className:"flex-1",children:[ve.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):a?l.jsx(Ro,{className:"w-4 h-4"}):l.jsx(pr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function wGe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,s]=E.useState(""),[o,c]=E.useState("all"),[u,d]=E.useState("all"),[f,g]=E.useState("all"),[m,x]=E.useState("all"),[v,y]=E.useState("all"),[b,M]=E.useState("all"),[S,A]=E.useState(null),[T,k]=E.useState(!1),[N,I]=E.useState(!1),[C,D]=E.useState(null),[F,O]=E.useState(null),[q,R]=E.useState(null),[W,K]=E.useState(!1),[G,ee]=E.useState([null,null]),[Z,Q]=E.useState(!1),[U,$]=E.useState(null),X=En(),te=E.useMemo(()=>[...t.filament.map(re=>({...re,type:"filament"})),...t.printer.map(re=>({...re,type:"printer"})),...t.process.map(re=>({...re,type:"process"}))].map(re=>({...re,meta:xL(re.name)})),[t]),fe=E.useMemo(()=>{const B=new Set,re=new Set,V=new Set;return te.forEach(J=>{J.meta.nozzle&&B.add(J.meta.nozzle),J.meta.filamentType&&re.add(J.meta.filamentType),J.meta.layerHeight&&V.add(J.meta.layerHeight)}),{printers:i.map(J=>({id:J.id.toString(),name:J.name})),nozzles:Array.from(B).sort((J,se)=>parseFloat(J)-parseFloat(se)),filaments:Array.from(re).sort(),layerHeights:Array.from(V).sort((J,se)=>parseFloat(J)-parseFloat(se))}},[te,i]),pe=E.useMemo(()=>f==="all"?null:i.find(re=>re.id.toString()===f)?.model||null,[f,i]),xe=E.useMemo(()=>te.filter(B=>o==="all"||B.type===o).filter(B=>{if(u==="all")return!0;const re=hb(B.setting_id);return u==="custom"?re:!re}).filter(B=>{if(f==="all"||!pe)return!0;const re=B.meta.printer?.toLowerCase()||"",V=pe.toLowerCase();return re.includes(V)||V.includes(re)}).filter(B=>m==="all"||B.meta.nozzle===m).filter(B=>v==="all"||B.meta.filamentType===v).filter(B=>b==="all"||B.meta.layerHeight===b).filter(B=>a===""||B.name.toLowerCase().includes(a.toLowerCase())).sort((B,re)=>B.name.localeCompare(re.name)),[te,o,u,f,pe,m,v,b,a]),Ne=B=>{if(W){const re=G[0]?.setting_id===B.setting_id,V=G[1]?.setting_id===B.setting_id;if(re)ee([G[1],null]);else if(V)ee([G[0],null]);else if(!G[0])ee([B,null]);else if(G[1]){if(G[0].type!==B.type)return;ee([G[0],B])}else{if(G[0].type!==B.type)return;ee([G[0],B])}}else A(B)},ie=B=>{if(G[0]?.setting_id===B.setting_id)return 0;if(G[1]?.setting_id===B.setting_id)return 1},be=async B=>{try{const re=await ke.getCloudSettingDetail(B.setting_id),V=B.type==="process"?"print":B.type;D({type:V,name:B.name,base_id:re.base_id||"GFSA00",setting:re.setting||{}}),A(null)}catch(re){console.error("Failed to fetch preset details for duplication:",re)}},je=async B=>{try{X.removeQueries({queryKey:["cloudSettingDetail",B.setting_id]});const re=await ke.getCloudSettingDetail(B.setting_id),V=B.type==="process"?"print":B.type;O({type:V,name:B.name,base_id:re.base_id||"GFSA00",setting:re.setting||{},setting_id:B.setting_id}),A(null)}catch(re){console.error("Failed to fetch preset details for editing:",re)}},he=()=>{c("all"),d("all"),g("all"),x("all"),y("all"),M("all"),s("")},ht=o!=="all"||u!=="all"||f!=="all"||m!=="all"||v!=="all"||b!=="all"||a!=="",H=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:a,onChange:B=>s(B.target.value),placeholder:"Search presets...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),ee([null,null])):K(!0)},children:[l.jsx(Qp,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),l.jsxs(Le,{variant:"secondary",onClick:()=>I(!0),children:[l.jsx(M0,{className:"w-4 h-4"}),"Templates"]}),l.jsxs(Le,{variant:"secondary",onClick:n,disabled:r,children:[l.jsx(Ta,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),l.jsxs(Le,{onClick:()=>k(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"New Preset"]})]})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx(UR,{className:"w-4 h-4 text-bambu-gray"}),l.jsx(Lp,{label:"Type",value:o,options:[{value:"all",label:"All",count:H},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:B=>c(B)}),l.jsx(Lp,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:B=>d(B)}),fe.printers.length>0&&l.jsx(Lp,{label:"Printer",value:f,options:[{value:"all",label:"All"},...fe.printers.map(B=>({value:B.id,label:B.name}))],onChange:g}),fe.nozzles.length>0&&l.jsx(Lp,{label:"Nozzle",value:m,options:[{value:"all",label:"All"},...fe.nozzles.map(B=>({value:B,label:B}))],onChange:x}),fe.filaments.length>0&&(o==="all"||o==="filament")&&l.jsx(Lp,{label:"Filament",value:v,options:[{value:"all",label:"All"},...fe.filaments.map(B=>({value:B,label:B}))],onChange:y}),fe.layerHeights.length>0&&(o==="all"||o==="process")&&l.jsx(Lp,{label:"Layer",value:b,options:[{value:"all",label:"All"},...fe.layerHeights.map(B=>({value:B,label:B}))],onChange:M}),ht&&l.jsx("button",{onClick:he,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),W&&l.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx(Qp,{className:"w-5 h-5 text-blue-400"}),l.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),l.jsx("span",{className:"text-bambu-gray",children:G[0]?`Select another ${G[0].type} preset`:"Click two presets of the same type to compare"})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[0]?G[0].name:"1. Select first"}),l.jsx(Tk,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[1]?G[1].name:"2. Select second"})]}),G[0]&&G[1]&&l.jsxs(Le,{size:"sm",onClick:async()=>{try{const[B,re]=await Promise.all([ke.getCloudSettingDetail(G[0].setting_id),ke.getCloudSettingDetail(G[1].setting_id)]);$([B.setting||{},re.setting||{}]),Q(!0)}catch{}},children:[l.jsx(Qp,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),l.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(_r,{className:"w-3 h-3"}),"Last synced: ",gGe(e.toISOString())]}),l.jsxs("span",{children:["Showing ",xe.length," of ",H," presets"]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),l.jsx("span",{children:"= My preset (editable)"})]})]}),xe.length===0?l.jsxs("div",{className:"text-center py-16",children:[l.jsx($h,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),l.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),ht&&l.jsx("button",{onClick:he,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(IR,{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(B=>B.type==="filament").length,")"]})]}),l.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(B=>B.type==="filament").map(B=>l.jsx(fk,{setting:B,onClick:()=>Ne(B),onDuplicate:()=>be(B),compareMode:W,isCompareSelected:ie(B)!==void 0,compareIndex:ie(B),compareDisabled:W&&!!G[0]&&G[0].type!==B.type},B.setting_id)),xe.filter(B=>B.type==="filament").length===0&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(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(B=>B.type==="process").length,")"]})]}),l.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(B=>B.type==="process").map(B=>l.jsx(fk,{setting:B,onClick:()=>Ne(B),onDuplicate:()=>be(B),compareMode:W,isCompareSelected:ie(B)!==void 0,compareIndex:ie(B),compareDisabled:W&&!!G[0]&&G[0].type!==B.type},B.setting_id)),xe.filter(B=>B.type==="process").length===0&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(Ts,{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(B=>B.type==="printer").length,")"]})]}),l.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(B=>B.type==="printer").map(B=>l.jsx(fk,{setting:B,onClick:()=>Ne(B),onDuplicate:()=>be(B),compareMode:W,isCompareSelected:ie(B)!==void 0,compareIndex:ie(B),compareDisabled:W&&!!G[0]&&G[0].type!==B.type},B.setting_id)),xe.filter(B=>B.type==="printer").length===0&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),S&&l.jsx(yGe,{setting:S,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>be(S),onEdit:()=>je(S)}),(T||C||F||q)&&l.jsx(_Ge,{onClose:()=>{k(!1),D(null),O(null),R(null)},initialData:F||C||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),N&&l.jsx(vGe,{onClose:()=>I(!1),onApply:B=>{R({type:B.type,setting:B.settings}),I(!1)}}),Z&&U&&G[0]&&G[1]&&l.jsx(xte,{onClose:()=>{Q(!1),$(null)},leftPreset:U[0],rightPreset:U[1],leftLabel:G[0].name,rightLabel:G[1].name})]})}function SGe(){const t=En(),{showToast:e}=ai(),[n,r]=E.useState("cloud"),[i,a]=E.useState(),{data:s,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:!!s?.is_authenticated,retry:!1,staleTime:1e3*60*5});E.useEffect(()=>{g&&a(new Date(g))},[g]);const m=wt({mutationFn:ke.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return o?l.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):l.jsxs("div",{className:"p-6 lg:p-8",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),l.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[l.jsxs("button",{onClick:()=>r("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(US,{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(zR,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&l.jsxs(l.Fragment,{children:[s?.is_authenticated&&l.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),l.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",l.jsx("span",{className:"text-white",children:s.email})]})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>m.mutate(),disabled:m.isPending,children:[l.jsx(Zle,{className:"w-4 h-4"}),"Logout"]})]}),s?.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(wGe,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):l.jsxs("div",{className:"text-center py-16",children:[l.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),l.jsx(Le,{onClick:()=>f(),children:"Retry"})]}):l.jsx(xGe,{onSuccess:x})]}),n==="kprofiles"&&l.jsx(mGe,{}),l.jsx(bGe,{})]})}const Vx={Droplet:IR,Flame:dle,Ruler:Fce,Sparkles:M0,Square:gm,Cable:loe,Wrench:ad,Calendar:Zr,Timer:Uu,Cog:Foe,Fan:ele,Zap:bm,Wind:Oue,Thermometer:Sh,Layers:$h,Box:fm,Target:fG,RefreshCw:Ta,Settings:WR,Filter:UR,CircleDot:Aoe};function f0(t){return t&&Vx[t]||ad}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 pk(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 MGe({item:t,onPerform:e,onToggle:n}){const r=f0(t.maintenance_type_icon),i=t.interval_type||"hours",s=(()=>{if(i==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),o=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",c=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${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:`${s}%`}})})}),l.jsxs("div",{className:`text-xs flex items-center gap-1 ${o()}`,children:[t.is_due&&l.jsx(ti,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&l.jsx(_r,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&l.jsx(zh,{className:"w-3 h-3"}),d()]})]}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx(Pn,{checked:t.enabled,onChange:f=>n(t.id,f)}),l.jsxs(Le,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[l.jsx(Xm,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function EGe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=E.useState(!0),[s,o]=E.useState(!1),[c,u]=E.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((m,x)=>m.is_due&&!x.is_due?-1:!m.is_due&&x.is_due?1:m.is_warning&&!x.is_warning?-1:!m.is_warning&&x.is_warning?1:m.maintenance_type_id-x.maintenance_type_id),f=d.find(m=>m.enabled&&(m.is_due||m.is_warning)),g=()=>{const m=parseFloat(c);!isNaN(m)&&m>=0&&(r(t.printer_id,m),o(!1))};return l.jsxs(Nt,{className:"overflow-hidden",children:[l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),l.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&l.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[l.jsx(ti,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&l.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[l.jsx(_r,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&l.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[l.jsx(zh,{className:"w-3 h-3"}),"All good"]})]})]}),l.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[i?l.jsx(FS,{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(Uu,{className:"w-4 h-4 text-bambu-gray"})}),s?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",value:c,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&g(),m.key==="Escape"&&o(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),l.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),l.jsx(Le,{size:"sm",onClick:g,children:"Save"}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"Cancel"})]}):l.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),o(!0)},className:"group",children:[l.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.floor(t.total_print_hours)," hours",l.jsx(S0,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),l.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const m=f0(f.maintenance_type_icon);return l.jsx(m,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),l.jsxs("div",{children:[l.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),l.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&l.jsx(Rt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:l.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(m=>l.jsx(MGe,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function AGe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a}){const[s,o]=E.useState(null),[c,u]=E.useState(""),[d,f]=E.useState("hours"),[g,m]=E.useState(!1),[x,v]=E.useState(""),[y,b]=E.useState("100"),[M,S]=E.useState("hours"),[A,T]=E.useState("Wrench"),[k,N]=E.useState(null),[I,C]=E.useState(""),[D,F]=E.useState(""),[O,q]=E.useState("hours"),[R,W]=E.useState("Wrench"),K=X=>{N(X),C(X.name),F(X.default_interval_hours.toString()),q(X.interval_type||"hours"),W(X.icon||"Wrench")},G=()=>{k&&I.trim()&&parseFloat(D)>0&&(i(k.id,{name:I.trim(),default_interval_hours:parseFloat(D),interval_type:O,icon:R}),N(null))},ee=(X,te,fe)=>{const pe=parseFloat(c);if(!isNaN(pe)&&pe>0){const xe=Math.abs(pe-te)<.01?null:pe;n(X,{custom_interval_hours:xe,custom_interval_type:d!==fe?d:null})}o(null)},Z=X=>{X.preventDefault(),x.trim()&&parseFloat(y)>0&&(r({name:x.trim(),default_interval_hours:parseFloat(y),interval_type:M,icon:A}),v(""),b("100"),S("hours"),m(!1))},Q=t?.map(X=>({printerId:X.printer_id,printerName:X.printer_name,items:X.maintenance_items.sort((te,fe)=>te.maintenance_type_id-fe.maintenance_type_id)})).sort((X,te)=>X.printerName.localeCompare(te.printerName))||[],U=e.filter(X=>X.is_system),$=e.filter(X=>!X.is_system);return l.jsxs("div",{className:"space-y-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),l.jsxs(Le,{onClick:()=>m(!g),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),g&&l.jsx(Nt,{className:"mb-6",children:l.jsx(Rt,{className:"py-4",children:l.jsxs("form",{onSubmit:Z,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:X=>v(X.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:M,onChange:X=>{S(X.target.value),X.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 (",M==="days"?"days":"hours",")"]}),l.jsx("input",{type:"number",value:y,onChange:X=>b(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),l.jsxs("div",{className:"mt-4 flex items-end justify-between",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),l.jsx("div",{className:"flex gap-1",children:Object.keys(Vx).map(X=>{const te=Vx[X];return l.jsx("button",{type:"button",onClick:()=>T(X),className:`p-2 rounded-lg transition-colors ${A===X?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:l.jsx(te,{className:"w-4 h-4"})},X)})})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),l.jsx(Le,{type:"submit",disabled:!x.trim(),children:"Add Type"})]})]})]})})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[U.map(X=>{const te=f0(X.icon),fe=X.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(te,{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:X.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(Uu,{className:"w-3 h-3"}),pk(X.default_interval_hours,fe)]})]})]})},X.id)}),$.map(X=>{const te=f0(X.icon),fe=X.interval_type||"hours";return k?.id===X.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:O,onChange:xe=>q(xe.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]}),l.jsx("input",{type:"number",value:D,onChange:xe=>F(xe.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),l.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Vx).map(xe=>{const Ne=Vx[xe];return l.jsx("button",{type:"button",onClick:()=>W(xe),className:`p-1.5 rounded transition-colors ${R===xe?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:l.jsx(Ne,{className:"w-3.5 h-3.5"})},xe)})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{size:"sm",onClick:G,disabled:!I.trim(),children:"Save"}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>N(null),children:"Cancel"})]})]})},X.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(te,{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:X.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(Uu,{className:"w-3 h-3"}),pk(X.default_interval_hours,fe)]})]}),l.jsx("button",{onClick:()=>K(X),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:l.jsx(S0,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>{confirm(`Delete "${X.name}"?`)&&a(X.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(Rn,{className:"w-4 h-4"})})]})},X.id)})]})]}),Q.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),l.jsx("div",{className:"space-y-4",children:Q.map(X=>l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-4",children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:X.printerName}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:X.items.map(te=>{const fe=f0(te.maintenance_type_icon),pe=e.find(je=>je.id===te.maintenance_type_id),xe=pe?.default_interval_hours||te.interval_hours,Ne=pe?.interval_type||"hours",ie=te.interval_type||"hours",be=s===te.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:te.maintenance_type_name}),be?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(Uu,{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"&&ee(te.id,xe,Ne),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(Le,{size:"sm",onClick:()=>ee(te.id,xe,Ne),children:"OK"})]}):l.jsxs("button",{onClick:()=>{o(te.id),u(te.interval_hours.toString()),f(ie)},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:[ie==="days"?l.jsx(Zr,{className:"w-3 h-3"}):l.jsx(Uu,{className:"w-3 h-3"}),pk(te.interval_hours,ie),l.jsx(S0,{className:"w-3 h-3 text-bambu-gray"})]})]},te.id)})})]})},X.printerId))})]}),Q.length===0&&l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-12",children:[l.jsx(_r,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),l.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),l.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function TGe(){const t=En(),{showToast:e}=ai(),[n,r]=E.useState("status"),{data:i,isLoading:a}=vt({queryKey:["maintenanceOverview"],queryFn:ke.getMaintenanceOverview}),{data:s}=vt({queryKey:["maintenanceTypes"],queryFn:ke.getMaintenanceTypes}),o=wt({mutationFn:({id:M,notes:S})=>ke.performMaintenance(M,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:M=>{e(M.message,"error")}}),c=wt({mutationFn:({id:M,data:S})=>ke.updateMaintenanceItem(M,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{e(M.message,"error")}}),u=wt({mutationFn:ke.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:M=>{e(M.message,"error")}}),d=wt({mutationFn:({id:M,data:S})=>ke.updateMaintenanceType(M,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:M=>{e(M.message,"error")}}),f=wt({mutationFn:ke.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:M=>{e(M.message,"error")}}),g=wt({mutationFn:({printerId:M,hours:S})=>ke.setPrinterHours(M,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:M=>{e(M.message,"error")}}),m=M=>{o.mutate({id:M})},x=(M,S)=>{c.mutate({id:M,data:{enabled:S}})},v=(M,S)=>{g.mutate({printerId:M,hours:S})};if(a)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 y=i?.reduce((M,S)=>M+S.due_count,0)||0,b=i?.reduce((M,S)=>M+S.warning_count,0)||0;return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),l.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?l.jsxs(l.Fragment,{children:[y>0&&l.jsxs("span",{className:"text-red-400",children:[y," task",y!==1?"s":""," overdue"]}),y>0&&b>0&&" · ",b>0&&l.jsxs("span",{className:"text-amber-400",children:[b," due soon"]}),y===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((M,S)=>{const A=M.due_count*10+M.warning_count,T=S.due_count*10+S.warning_count;return A!==T?T-A:M.printer_name.localeCompare(S.printer_name)}).map(M=>l.jsx(EGe,{overview:M,onPerform:m,onToggle:x,onSetHours:v},M.printer_id)):l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-16",children:[l.jsx(ad,{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(AGe,{overview:i,types:s||[],onUpdateInterval:(M,S)=>c.mutate({id:M,data:S}),onAddType:M=>u.mutate(M),onUpdateType:(M,S)=>d.mutate({id:M,data:S}),onDeleteType:M=>f.mutate(M)})]})}const g9=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function CGe({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.description||""),[c,u]=E.useState(t?.color||g9[0]),[d,f]=E.useState(t?.target_count?.toString()||""),[g,m]=E.useState(t?.status||"active"),x=v=>{v.preventDefault(),n({name:i.trim(),description:s.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:v=>a(v.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Voron 2.4 Build",required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),l.jsx("textarea",{value:s,onChange:v=>o(v.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:g9.map(v=>l.jsx("button",{type:"button",onClick:()=>u(v),className:`w-8 h-8 rounded-full transition-transform ${c===v?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:v}},v))})]}),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:v=>f(v.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:v=>m(v.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[l.jsx("option",{value:"active",children:"Active"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"archived",children:"Archived"})]})]}),l.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),l.jsx(Le,{type:"submit",disabled:!i.trim()||r,children:r?l.jsx(At,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function NGe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.progress_percent??0,a=t.status==="completed",s=t.status==="archived";return l.jsx(Nt,{className:"hover:border-bambu-gray/30 transition-colors cursor-pointer",onClick:e,children:l.jsxs(Rt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:t.color||"#6b7280"}}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),t.description&&l.jsx("p",{className:"text-sm text-bambu-gray/70 mt-0.5 line-clamp-1",children:t.description})]})]}),l.jsxs("div",{className:"flex items-center gap-1",onClick:o=>o.stopPropagation(),children:[a&&l.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded",children:"Completed"}),s&&l.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded",children:"Archived"}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,className:"p-1",children:l.jsx(S0,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"p-1 text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]}),t.target_count&&l.jsxs("div",{className:"mb-3",children:[l.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[l.jsxs("span",{children:[t.archive_count," / ",t.target_count," prints"]}),l.jsxs("span",{children:[i.toFixed(0),"%"]})]}),l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full transition-all duration-300",style:{width:`${Math.min(i,100)}%`,backgroundColor:i>=100?"#22c55e":t.color||"#6b7280"}})})]}),t.archives&&t.archives.length>0&&l.jsx("div",{className:"mb-3",children:l.jsxs("div",{className:"flex gap-2",children:[t.archives.slice(0,5).map(o=>l.jsxs("a",{href:`/archives?search=${encodeURIComponent(o.print_name||"")}`,onClick:c=>c.stopPropagation(),className:"relative w-14 h-14 rounded-lg bg-bambu-dark flex-shrink-0 overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:o.print_name||"Unknown",children:[o.thumbnail_path?l.jsx("img",{src:`/api/v1/archives/${o.id}/thumbnail`,alt:o.print_name||"",className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:l.jsx(w0,{className:"w-6 h-6"})}),o.status==="failed"&&l.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:l.jsx("span",{className:"text-white text-xs font-bold",children:"✗"})})]},o.id)),t.archive_count>5&&l.jsxs("div",{className:"w-14 h-14 rounded-lg bg-bambu-dark flex-shrink-0 flex items-center justify-center text-sm text-bambu-gray border border-bambu-dark-tertiary",children:["+",t.archive_count-5]})]})}),l.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[l.jsxs("div",{className:"flex items-center gap-1",title:"Archives",children:[l.jsx(_h,{className:"w-4 h-4"}),l.jsx("span",{children:t.archive_count})]}),l.jsxs("div",{className:"flex items-center gap-1",title:"Queued",children:[l.jsx(Wle,{className:"w-4 h-4"}),l.jsx("span",{children:t.queue_count})]})]})]})})}function kGe(){const t=En(),{showToast:e}=ai(),[n,r]=E.useState(!1),[i,a]=E.useState(),[s,o]=E.useState("active"),[c,u]=E.useState(null),{data:d,isLoading:f}=vt({queryKey:["projects",s==="all"?void 0:s],queryFn:()=>ke.getProjects(s==="all"?void 0:s)}),g=wt({mutationFn:A=>ke.createProject(A),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),e("Project created","success")},onError:A=>{e(A.message,"error")}}),m=wt({mutationFn:({id:A,data:T})=>ke.updateProject(A,T),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),a(void 0),e("Project updated","success")},onError:A=>{e(A.message,"error")}}),x=wt({mutationFn:A=>ke.deleteProject(A),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),u(null),e("Project deleted","success")},onError:A=>{e(A.message,"error")}}),v=A=>{i?m.mutate({id:i.id,data:A}):g.mutate(A)},y=A=>{a(A),r(!0)},b=A=>{y(A)},M=A=>{u(A)},S=()=>{c!==null&&x.mutate(c)};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(qu,{className:"w-6 h-6 text-bambu-green"}),l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Projects"})]}),l.jsxs(Le,{onClick:()=>r(!0),children:[l.jsx(pr,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),l.jsx("div",{className:"flex gap-2",children:["active","completed","archived","all"].map(A=>l.jsx("button",{onClick:()=>o(A),className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${s===A?"bg-bambu-green text-white":"bg-bambu-card text-bambu-gray hover:bg-bambu-gray/20"}`,children:A.charAt(0).toUpperCase()+A.slice(1)},A))}),f?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green"})}):d?.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(qu,{className:"w-12 h-12 text-bambu-gray/50 mx-auto mb-4"}),l.jsx("p",{className:"text-bambu-gray",children:"No projects found"}),l.jsx("p",{className:"text-bambu-gray/70 text-sm mt-1",children:"Create a project to group related prints together"})]})}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:d?.map(A=>l.jsx(NGe,{project:A,onClick:()=>b(A),onEdit:()=>y(A),onDelete:()=>M(A.id)},A.id))}),c!==null&&l.jsx(Qr,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:S,onCancel:()=>u(null)}),n&&l.jsx(CGe,{project:i,onClose:()=>{r(!1),a(void 0)},onSave:v,isLoading:g.isPending||m.isPending})]})}function PGe(){const{printerId:t}=F9(),e=parseInt(t||"0",10),[n,r]=E.useState("stream"),[i,a]=E.useState(!1),[s,o]=E.useState(!0),[c,u]=E.useState(Date.now()),[d,f]=E.useState(!1),[g,m]=E.useState(!1),x=E.useRef(null),v=E.useRef(null),{data:y}=vt({queryKey:["printer",e],queryFn:()=>ke.getPrinter(e),enabled:e>0});E.useEffect(()=>(y&&(document.title=`${y.name} - Camera`),()=>{document.title="Bambuddy"}),[y]),E.useEffect(()=>{const C=`/api/v1/printers/${e}/camera/stop`,D=()=>{e>0&&navigator.sendBeacon(C)},F=()=>{document.visibilityState==="hidden"&&e>0&&navigator.sendBeacon(C)};return window.addEventListener("beforeunload",D),document.addEventListener("visibilitychange",F),()=>{window.removeEventListener("beforeunload",D),document.removeEventListener("visibilitychange",F),x.current&&(x.current.src=""),e>0&&navigator.sendBeacon(C)}},[e]),E.useEffect(()=>{if(s&&!d){const D=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(D)}},[n,s,c,d]),E.useEffect(()=>{const C=()=>{m(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",C),()=>document.removeEventListener("fullscreenchange",C)},[]);const b=()=>{a(!0),o(!1)},M=()=>{o(!1),a(!1)},S=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},A=C=>{n===C||d||(f(!0),o(!0),a(!1),x.current&&(x.current.src=""),n==="stream"&&S(),setTimeout(()=>{r(C),u(Date.now()),f(!1)},100))},T=()=>{d||(f(!0),o(!0),a(!1),x.current&&(x.current.src=""),n==="stream"&&S(),setTimeout(()=>{u(Date.now()),f(!1)},100))},k=()=>{v.current&&(document.fullscreenElement?document.exitFullscreen():v.current.requestFullscreen())},N=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,I=s||d;return e?l.jsxs("div",{ref:v,className:"min-h-screen bg-black flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[l.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[l.jsx(b0,{className:"w-4 h-4"}),y?.name||`Printer ${e}`]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[l.jsx("button",{onClick:()=>A("stream"),disabled:I,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),l.jsx("button",{onClick:()=>A("snapshot"),disabled:I,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),l.jsx("button",{onClick:T,disabled:I,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:l.jsx(Ta,{className:`w-4 h-4 text-bambu-gray ${I?"animate-spin":""}`})}),l.jsx("button",{onClick:k,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?l.jsx(fce,{className:"w-4 h-4 text-bambu-gray"}):l.jsx(ace,{className:"w-4 h-4 text-bambu-gray"})})]})]}),l.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:l.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(s||d)&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:l.jsxs("div",{className:"text-center",children:[l.jsx(Ta,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),i&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:l.jsxs("div",{className:"text-center p-4",children:[l.jsx(ti,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),l.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),l.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),l.jsx("button",{onClick:T,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),l.jsx("img",{ref:x,src:N,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:N?b:void 0,onLoad:N?M: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 RGe(){const{id:t}=F9(),{theme:e}=xb(),{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 Fr({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 x9({percent:t,color:e="bg-bambu-green"}){return l.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function eh({title:t,icon:e,children:n}){return l.jsxs(Nt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(e,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function DGe(){const{t}=Gm(),{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 a=e.storage.disk_percent_used>90?"bg-red-500":e.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",s=e.memory.percent_used>90?"bg-red-500":e.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return l.jsxs("div",{className:"p-6 space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),l.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),l.jsxs("button",{onClick:()=>r(),disabled:i,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[l.jsx(Ta,{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(Fr,{icon:th,label:t("system.version","Version"),value:`v${e.app.version}`}),l.jsx(Fr,{icon:_r,label:t("system.uptime","System Uptime"),value:e.system.uptime_formatted}),l.jsx(Fr,{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(Fr,{icon:_h,label:t("system.totalArchives","Total Archives"),value:e.database.archives}),l.jsx(Fr,{icon:Moe,label:t("system.completed","Completed"),value:e.database.archives_completed,color:"text-green-500"}),l.jsx(Fr,{icon:gs,label:t("system.failed","Failed"),value:e.database.archives_failed,color:"text-red-500"}),l.jsx(Fr,{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(Fr,{icon:Ts,label:t("system.printers","Printers"),value:e.database.printers}),l.jsx(Fr,{icon:dG,label:t("system.filaments","Filaments"),value:e.database.filaments}),l.jsx(Fr,{icon:qu,label:t("system.projects","Projects"),value:e.database.projects}),l.jsx(Fr,{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(Fr,{icon:_r,label:t("system.totalPrintTime","Total Print Time"),value:e.database.total_print_time_formatted}),l.jsx(Fr,{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:Ts,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:BR,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(x9,{percent:e.storage.disk_percent_used,color:a}),l.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.storage.disk_free_formatted," ",t("system.free","free")," (",(100-e.storage.disk_percent_used).toFixed(1),"%)"]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsx(Fr,{icon:_h,label:t("system.archiveStorage","Archive Storage"),value:e.storage.archive_size_formatted}),l.jsx(Fr,{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:oce,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(x9,{percent:e.memory.percent_used,color:s}),l.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.memory.available_formatted," ",t("system.available","available")]})]})})}),l.jsx(eh,{title:t("system.cpu","CPU"),icon:gv,children:l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsx(Fr,{icon:gv,label:t("system.cores","Cores"),value:e.cpu.count,subValue:`${e.cpu.count_logical} logical`}),l.jsx(Fr,{icon:gv,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(Fr,{icon:th,label:t("system.os","Operating System"),value:e.system.platform,subValue:e.system.platform_release}),l.jsx(Fr,{icon:gv,label:t("system.architecture","Architecture"),value:e.system.architecture}),l.jsx(Fr,{icon:th,label:t("system.python","Python"),value:e.system.python_version}),l.jsx(Fr,{icon:_r,label:t("system.bootTime","Boot Time"),value:new Date(e.system.boot_time).toLocaleString()})]})})]})}function jGe(){const t=E.useRef(null),e=E.useRef(null),n=En(),[r,i]=E.useState(!1),a=E.useRef(new Set),s=E.useRef(null),o=E.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const g=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,m=new WebSocket(g);let x=null;m.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),x=window.setInterval(()=>{m.readyState===WebSocket.OPEN&&m.send(JSON.stringify({type:"ping"}))},3e4)},m.onmessage=v=>{try{const y=JSON.parse(v.data);u(y)}catch{}},m.onclose=v=>{console.log("[WebSocket] Closed",v.code,v.reason),x&&(clearInterval(x),x=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{o()},3e3)},m.onerror=v=>{console.error("[WebSocket] Error",v),m.close()},t.current=m},[]),c=E.useCallback(f=>{a.current.add(f),s.current&&clearTimeout(s.current),s.current=window.setTimeout(()=>{const g=Array.from(a.current);a.current.clear(),s.current=null,requestAnimationFrame(()=>{g.forEach(m=>{n.invalidateQueries({queryKey:[m]})})})},100)},[n]),u=E.useCallback(f=>{switch(f.type){case"printer_status":f.printer_id!==void 0&&n.setQueryData(["printerStatus",f.printer_id],g=>{const m={...g,...f.data};return m.wifi_signal==null&&g?.wifi_signal!=null&&(m.wifi_signal=g.wifi_signal),m});break;case"print_complete":c("archives"),c("archiveStats");break;case"archive_created":c("archives"),c("archiveStats");break;case"archive_updated":c("archives");break}},[n,c]);E.useEffect(()=>(o(),()=>{e.current&&clearTimeout(e.current),s.current&&clearTimeout(s.current),t.current&&t.current.close()}),[o]);const d=E.useCallback(f=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(f))},[]);return{isConnected:r,sendMessage:d}}const OGe=new Nse({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function LGe({children:t}){return jGe(),l.jsx(l.Fragment,{children:t})}function IGe(){return l.jsx($ue,{children:l.jsx(Jue,{children:l.jsx(kse,{client:OGe,children:l.jsx(LGe,{children:l.jsx(Zae,{children:l.jsxs(Cae,{children:[l.jsx(fs,{path:"/camera/:printerId",element:l.jsx(PGe,{})}),l.jsxs(fs,{path:"/",element:l.jsx(Yue,{}),children:[l.jsx(fs,{index:!0,element:l.jsx(wCe,{})}),l.jsx(fs,{path:"archives",element:l.jsx(XVe,{})}),l.jsx(fs,{path:"queue",element:l.jsx(j9e,{})}),l.jsx(fs,{path:"stats",element:l.jsx(K9e,{})}),l.jsx(fs,{path:"profiles",element:l.jsx(SGe,{})}),l.jsx(fs,{path:"maintenance",element:l.jsx(TGe,{})}),l.jsx(fs,{path:"projects",element:l.jsx(kGe,{})}),l.jsx(fs,{path:"settings",element:l.jsx(hGe,{})}),l.jsx(fs,{path:"system",element:l.jsx(DGe,{})}),l.jsx(fs,{path:"external/:id",element:l.jsx(RGe,{})})]})]})})})})})})}Rre.createRoot(document.getElementById("root")).render(l.jsx(E.StrictMode,{children:l.jsx(IGe,{})}));
|