| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611 |
- function Fne(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var Yv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function oo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var K2={exports:{}},Wg={};var AU;function zne(){if(AU)return Wg;AU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var a=null;if(s!==void 0&&(a=""+s),i.key!==void 0&&(a=""+i.key),"key"in i){s={};for(var o in i)o!=="key"&&(s[o]=i[o])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:a,ref:i!==void 0?i:null,props:s}}return Wg.Fragment=e,Wg.jsx=n,Wg.jsxs=n,Wg}var TU;function Bne(){return TU||(TU=1,K2.exports=zne()),K2.exports}var c=Bne(),X2={exports:{}},Qt={};var CU;function Hne(){if(CU)return Qt;CU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function m(U){return U===null||typeof U!="object"?null:(U=g&&U[g]||U["@@iterator"],typeof U=="function"?U:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,v={};function b(U,$,ee){this.props=U,this.context=$,this.refs=v,this.updater=ee||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 E(){}E.prototype=b.prototype;function S(U,$,ee){this.props=U,this.context=$,this.refs=v,this.updater=ee||x}var A=S.prototype=new E;A.constructor=S,y(A,b.prototype),A.isPureReactComponent=!0;var T=Array.isArray;function P(){}var C={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function N(U,$,ee){var ae=ee.ref;return{$$typeof:t,type:U,key:$,ref:ae!==void 0?ae:null,props:ee}}function D(U,$){return N(U.type,$,U.props)}function F(U){return typeof U=="object"&&U!==null&&U.$$typeof===t}function L(U){var $={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(ee){return $[ee]})}var q=/\/+/g;function R(U,$){return typeof U=="object"&&U!==null&&U.key!=null?L(""+U.key):$.toString(36)}function V(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(P,P):(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,$,ee,ae,fe){var ue=typeof U;(ue==="undefined"||ue==="boolean")&&(U=null);var xe=!1;if(U===null)xe=!0;else switch(ue){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),$,ee,ae,fe)}}if(xe)return fe=fe(U),xe=ae===""?"."+R(U,0):ae,T(fe)?(ee="",xe!=null&&(ee=xe.replace(q,"$&/")+"/"),K(fe,$,ee,"",function(ve){return ve})):fe!=null&&(F(fe)&&(fe=D(fe,ee+(fe.key==null||U&&U.key===fe.key?"":(""+fe.key).replace(q,"$&/")+"/")+xe)),$.push(fe)),1;xe=0;var Me=ae===""?".":ae+":";if(T(U))for(var se=0;se<U.length;se++)ae=U[se],ue=Me+R(ae,se),xe+=K(ae,$,ee,ue,fe);else if(se=m(U),typeof se=="function")for(U=se.call(U),se=0;!(ae=U.next()).done;)ae=ae.value,ue=Me+R(ae,se++),xe+=K(ae,$,ee,ue,fe);else if(ue==="object"){if(typeof U.then=="function")return K(V(U),$,ee,ae,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 W(U,$,ee){if(U==null)return U;var ae=[],fe=0;return K(U,ae,"","",function(ue){return $.call(ee,ue,fe++)}),ae}function ne(U){if(U._status===-1){var $=U._result;$=$(),$.then(function(ee){(U._status===0||U._status===-1)&&(U._status=1,U._result=ee)},function(ee){(U._status===0||U._status===-1)&&(U._status=2,U._result=ee)}),U._status===-1&&(U._status=0,U._result=$)}if(U._status===1)return U._result.default;throw U._result}var Y=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var $=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)},Z={map:W,forEach:function(U,$,ee){W(U,function(){$.apply(this,arguments)},ee)},count:function(U){var $=0;return W(U,function(){$++}),$},toArray:function(U){return W(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 Qt.Activity=f,Qt.Children=Z,Qt.Component=b,Qt.Fragment=n,Qt.Profiler=i,Qt.PureComponent=S,Qt.StrictMode=r,Qt.Suspense=l,Qt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,Qt.__COMPILER_RUNTIME={__proto__:null,c:function(U){return C.H.useMemoCache(U)}},Qt.cache=function(U){return function(){return U.apply(null,arguments)}},Qt.cacheSignal=function(){return null},Qt.cloneElement=function(U,$,ee){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var ae=y({},U.props),fe=U.key;if($!=null)for(ue in $.key!==void 0&&(fe=""+$.key),$)!I.call($,ue)||ue==="key"||ue==="__self"||ue==="__source"||ue==="ref"&&$.ref===void 0||(ae[ue]=$[ue]);var ue=arguments.length-2;if(ue===1)ae.children=ee;else if(1<ue){for(var xe=Array(ue),Me=0;Me<ue;Me++)xe[Me]=arguments[Me+2];ae.children=xe}return N(U.type,fe,ae)},Qt.createContext=function(U){return U={$$typeof:a,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:s,_context:U},U},Qt.createElement=function(U,$,ee){var ae,fe={},ue=null;if($!=null)for(ae in $.key!==void 0&&(ue=""+$.key),$)I.call($,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(fe[ae]=$[ae]);var xe=arguments.length-2;if(xe===1)fe.children=ee;else if(1<xe){for(var Me=Array(xe),se=0;se<xe;se++)Me[se]=arguments[se+2];fe.children=Me}if(U&&U.defaultProps)for(ae in xe=U.defaultProps,xe)fe[ae]===void 0&&(fe[ae]=xe[ae]);return N(U,ue,fe)},Qt.createRef=function(){return{current:null}},Qt.forwardRef=function(U){return{$$typeof:o,render:U}},Qt.isValidElement=F,Qt.lazy=function(U){return{$$typeof:d,_payload:{_status:-1,_result:U},_init:ne}},Qt.memo=function(U,$){return{$$typeof:u,type:U,compare:$===void 0?null:$}},Qt.startTransition=function(U){var $=C.T,ee={};C.T=ee;try{var ae=U(),fe=C.S;fe!==null&&fe(ee,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(P,Y)}catch(ue){Y(ue)}finally{$!==null&&ee.types!==null&&($.types=ee.types),C.T=$}},Qt.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},Qt.use=function(U){return C.H.use(U)},Qt.useActionState=function(U,$,ee){return C.H.useActionState(U,$,ee)},Qt.useCallback=function(U,$){return C.H.useCallback(U,$)},Qt.useContext=function(U){return C.H.useContext(U)},Qt.useDebugValue=function(){},Qt.useDeferredValue=function(U,$){return C.H.useDeferredValue(U,$)},Qt.useEffect=function(U,$){return C.H.useEffect(U,$)},Qt.useEffectEvent=function(U){return C.H.useEffectEvent(U)},Qt.useId=function(){return C.H.useId()},Qt.useImperativeHandle=function(U,$,ee){return C.H.useImperativeHandle(U,$,ee)},Qt.useInsertionEffect=function(U,$){return C.H.useInsertionEffect(U,$)},Qt.useLayoutEffect=function(U,$){return C.H.useLayoutEffect(U,$)},Qt.useMemo=function(U,$){return C.H.useMemo(U,$)},Qt.useOptimistic=function(U,$){return C.H.useOptimistic(U,$)},Qt.useReducer=function(U,$,ee){return C.H.useReducer(U,$,ee)},Qt.useRef=function(U){return C.H.useRef(U)},Qt.useState=function(U){return C.H.useState(U)},Qt.useSyncExternalStore=function(U,$,ee){return C.H.useSyncExternalStore(U,$,ee)},Qt.useTransition=function(){return C.H.useTransition()},Qt.version="19.2.0",Qt}var NU;function Dm(){return NU||(NU=1,X2.exports=Hne()),X2.exports}var M=Dm();const pr=oo(M),$ne=Fne({__proto__:null,default:pr},[M]);var Y2={exports:{}},qg={},Z2={exports:{}},Q2={};var kU;function Vne(){return kU||(kU=1,(function(t){function e(K,W){var ne=K.length;K.push(W);e:for(;0<ne;){var Y=ne-1>>>1,Z=K[Y];if(0<i(Z,W))K[Y]=W,K[ne]=Z,ne=Y;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var W=K[0],ne=K.pop();if(ne!==W){K[0]=ne;e:for(var Y=0,Z=K.length,U=Z>>>1;Y<U;){var $=2*(Y+1)-1,ee=K[$],ae=$+1,fe=K[ae];if(0>i(ee,ne))ae<Z&&0>i(fe,ee)?(K[Y]=fe,K[ae]=ne,Y=ae):(K[Y]=ee,K[$]=ne,Y=$);else if(ae<Z&&0>i(fe,ne))K[Y]=fe,K[ae]=ne,Y=ae;else break e}}return W}function i(K,W){var ne=K.sortIndex-W.sortIndex;return ne!==0?ne:K.id-W.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();t.unstable_now=function(){return a.now()-o}}var l=[],u=[],d=1,f=null,g=3,m=!1,x=!1,y=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function A(K){for(var W=n(u);W!==null;){if(W.callback===null)r(u);else if(W.startTime<=K)r(u),W.sortIndex=W.expirationTime,e(l,W);else break;W=n(u)}}function T(K){if(y=!1,A(K),!x)if(n(l)!==null)x=!0,P||(P=!0,L());else{var W=n(u);W!==null&&V(T,W.startTime-K)}}var P=!1,C=-1,I=5,N=-1;function D(){return v?!0:!(t.unstable_now()-N<I)}function F(){if(v=!1,P){var K=t.unstable_now();N=K;var W=!0;try{e:{x=!1,y&&(y=!1,E(C),C=-1),m=!0;var ne=g;try{t:{for(A(K),f=n(l);f!==null&&!(f.expirationTime>K&&D());){var Y=f.callback;if(typeof Y=="function"){f.callback=null,g=f.priorityLevel;var Z=Y(f.expirationTime<=K);if(K=t.unstable_now(),typeof Z=="function"){f.callback=Z,A(K),W=!0;break t}f===n(l)&&r(l),A(K)}else r(l);f=n(l)}if(f!==null)W=!0;else{var U=n(u);U!==null&&V(T,U.startTime-K),W=!1}}break e}finally{f=null,g=ne,m=!1}W=void 0}}finally{W?L():P=!1}}}var L;if(typeof S=="function")L=function(){S(F)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,R=q.port2;q.port1.onmessage=F,L=function(){R.postMessage(null)}}else L=function(){b(F,0)};function V(K,W){C=b(function(){K(t.unstable_now())},W)}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 W=3;break;default:W=g}var ne=g;g=W;try{return K()}finally{g=ne}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function(K,W){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var ne=g;g=K;try{return W()}finally{g=ne}},t.unstable_scheduleCallback=function(K,W,ne){var Y=t.unstable_now();switch(typeof ne=="object"&&ne!==null?(ne=ne.delay,ne=typeof ne=="number"&&0<ne?Y+ne:Y):ne=Y,K){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=ne+Z,K={id:d++,callback:W,priorityLevel:K,startTime:ne,expirationTime:Z,sortIndex:-1},ne>Y?(K.sortIndex=ne,e(u,K),n(l)===null&&K===n(u)&&(y?(E(C),C=-1):y=!0,V(T,ne-Y))):(K.sortIndex=Z,e(l,K),x||m||(x=!0,P||(P=!0,L()))),K},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(K){var W=g;return function(){var ne=g;g=W;try{return K.apply(this,arguments)}finally{g=ne}}}})(Q2)),Q2}var PU;function Gne(){return PU||(PU=1,Z2.exports=Vne()),Z2.exports}var J2={exports:{}},es={};var RU;function Wne(){if(RU)return es;RU=1;var t=Dm();function e(l){var u="https://react.dev/errors/"+l;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function s(l,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:l,containerInfo:u,implementation:d}}var a=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(l,u){if(l==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return es.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,es.createPortal=function(l,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return s(l,u,null,d)},es.flushSync=function(l){var u=a.T,d=r.p;try{if(a.T=null,r.p=2,l)return l()}finally{a.T=u,r.p=d,r.d.f()}},es.preconnect=function(l,u){typeof l=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(l,u))},es.prefetchDNS=function(l){typeof l=="string"&&r.d.D(l)},es.preinit=function(l,u){if(typeof l=="string"&&u&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin),g=typeof u.integrity=="string"?u.integrity:void 0,m=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(l,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:m}):d==="script"&&r.d.X(l,{crossOrigin:f,integrity:g,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},es.preinitModule=function(l,u){if(typeof l=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=o(u.as,u.crossOrigin);r.d.M(l,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(l)},es.preload=function(l,u){if(typeof l=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin);r.d.L(l,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},es.preloadModule=function(l,u){if(typeof l=="string")if(u){var d=o(u.as,u.crossOrigin);r.d.m(l,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(l)},es.requestFormReset=function(l){r.d.r(l)},es.unstable_batchedUpdates=function(l,u){return l(u)},es.useFormState=function(l,u,d){return a.H.useFormState(l,u,d)},es.useFormStatus=function(){return a.H.useHostTransitionStatus()},es.version="19.2.0",es}var DU;function H9(){if(DU)return J2.exports;DU=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(),J2.exports=Wne(),J2.exports}var OU;function qne(){if(OU)return qg;OU=1;var t=Gne(),e=Dm(),n=H9();function r(h){var p="https://react.dev/errors/"+h;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)p+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function s(h){var p=h,_=h;if(h.alternate)for(;p.return;)p=p.return;else{h=p;do p=h,(p.flags&4098)!==0&&(_=p.return),h=p.return;while(h)}return p.tag===3?_:null}function a(h){if(h.tag===13){var p=h.memoizedState;if(p===null&&(h=h.alternate,h!==null&&(p=h.memoizedState)),p!==null)return p.dehydrated}return null}function o(h){if(h.tag===31){var p=h.memoizedState;if(p===null&&(h=h.alternate,h!==null&&(p=h.memoizedState)),p!==null)return p.dehydrated}return null}function l(h){if(s(h)!==h)throw Error(r(188))}function u(h){var p=h.alternate;if(!p){if(p=s(h),p===null)throw Error(r(188));return p!==h?null:h}for(var _=h,w=p;;){var k=_.return;if(k===null)break;var O=k.alternate;if(O===null){if(w=k.return,w!==null){_=w;continue}break}if(k.child===O.child){for(O=k.child;O;){if(O===_)return l(k),h;if(O===w)return l(k),p;O=O.sibling}throw Error(r(188))}if(_.return!==w.return)_=k,w=O;else{for(var X=!1,oe=k.child;oe;){if(oe===_){X=!0,_=k,w=O;break}if(oe===w){X=!0,w=k,_=O;break}oe=oe.sibling}if(!X){for(oe=O.child;oe;){if(oe===_){X=!0,_=O,w=k;break}if(oe===w){X=!0,w=O,_=k;break}oe=oe.sibling}if(!X)throw Error(r(189))}}if(_.alternate!==w)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:p}function d(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h;for(h=h.child;h!==null;){if(p=d(h),p!==null)return p;h=h.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),S=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function L(h){return h===null||typeof h!="object"?null:(h=F&&h[F]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function R(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===q?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case y:return"Fragment";case b:return"Profiler";case v:return"StrictMode";case T:return"Suspense";case P:return"SuspenseList";case N:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case S:return h.displayName||"Context";case E:return(h._context.displayName||"Context")+".Consumer";case A:var p=h.render;return h=h.displayName,h||(h=p.displayName||p.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case C: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 V=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},Y=[],Z=-1;function U(h){return{current:h}}function $(h){0>Z||(h.current=Y[Z],Y[Z]=null,Z--)}function ee(h,p){Z++,Y[Z]=h.current,h.current=p}var ae=U(null),fe=U(null),ue=U(null),xe=U(null);function Me(h,p){switch(ee(ue,p),ee(fe,h),ee(ae,null),p.nodeType){case 9:case 11:h=(h=p.documentElement)&&(h=h.namespaceURI)?X4(h):0;break;default:if(h=p.tagName,p=p.namespaceURI)p=X4(p),h=Y4(p,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}$(ae),ee(ae,h)}function se(){$(ae),$(fe),$(ue)}function ve(h){h.memoizedState!==null&&ee(xe,h);var p=ae.current,_=Y4(p,h.type);p!==_&&(ee(fe,h),ee(ae,_))}function je(h){fe.current===h&&($(ae),$(fe)),xe.current===h&&($(xe),Hg._currentValue=ne)}var de,ut;function H(h){if(de===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);de=p&&p[1]||"",ut=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+de+h+ut}var z=!1;function re(h,p){if(!h||z)return"";z=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var w={DetermineComponentFrameRoot:function(){try{if(p){var dt=function(){throw Error()};if(Object.defineProperty(dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(dt,[])}catch(it){var Qe=it}Reflect.construct(h,[],dt)}else{try{dt.call()}catch(it){Qe=it}h.call(dt.prototype)}}else{try{throw Error()}catch(it){Qe=it}(dt=h())&&typeof dt.catch=="function"&&dt.catch(function(){})}}catch(it){if(it&&Qe&&typeof it.stack=="string")return[it.stack,Qe.stack]}return[null,null]}};w.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var k=Object.getOwnPropertyDescriptor(w.DetermineComponentFrameRoot,"name");k&&k.configurable&&Object.defineProperty(w.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var O=w.DetermineComponentFrameRoot(),X=O[0],oe=O[1];if(X&&oe){var Ee=X.split(`
- `),qe=oe.split(`
- `);for(k=w=0;w<Ee.length&&!Ee[w].includes("DetermineComponentFrameRoot");)w++;for(;k<qe.length&&!qe[k].includes("DetermineComponentFrameRoot");)k++;if(w===Ee.length||k===qe.length)for(w=Ee.length-1,k=qe.length-1;1<=w&&0<=k&&Ee[w]!==qe[k];)k--;for(;1<=w&&0<=k;w--,k--)if(Ee[w]!==qe[k]){if(w!==1||k!==1)do if(w--,k--,0>k||Ee[w]!==qe[k]){var lt=`
- `+Ee[w].replace(" at new "," at ");return h.displayName&<.includes("<anonymous>")&&(lt=lt.replace("<anonymous>",h.displayName)),lt}while(1<=w&&0<=k);break}}}finally{z=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?H(_):""}function G(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+=G(h,_),_=h,h=h.return;while(h);return p}catch(w){return`
- Error generating stack: `+w.message+`
- `+w.stack}}var le=Object.prototype.hasOwnProperty,ke=t.unstable_scheduleCallback,Ne=t.unstable_cancelCallback,we=t.unstable_shouldYield,B=t.unstable_requestPaint,j=t.unstable_now,te=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,_e=t.unstable_UserBlockingPriority,ge=t.unstable_NormalPriority,me=t.unstable_LowPriority,Ae=t.unstable_IdlePriority,ze=t.log,st=t.unstable_setDisableYieldValue,Ve=null,ce=null;function Ye(h){if(typeof ze=="function"&&st(h),ce&&typeof ce.setStrictMode=="function")try{ce.setStrictMode(Ve,h)}catch{}}var $e=Math.clz32?Math.clz32:Q,Ze=Math.log,at=Math.LN2;function Q(h){return h>>>=0,h===0?32:31-(Ze(h)/at|0)|0}var Fe=256,pe=262144,Ue=4194304;function Ce(h){var p=h&42;if(p!==0)return p;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function ye(h,p,_){var w=h.pendingLanes;if(w===0)return 0;var k=0,O=h.suspendedLanes,X=h.pingedLanes;h=h.warmLanes;var oe=w&134217727;return oe!==0?(w=oe&~O,w!==0?k=Ce(w):(X&=oe,X!==0?k=Ce(X):_||(_=oe&~h,_!==0&&(k=Ce(_))))):(oe=w&~O,oe!==0?k=Ce(oe):X!==0?k=Ce(X):_||(_=w&~h,_!==0&&(k=Ce(_)))),k===0?0:p!==0&&p!==k&&(p&O)===0&&(O=k&-k,_=p&-p,O>=_||O===32&&(_&4194048)!==0)?p:k}function He(h,p){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&p)===0}function ht(h,p){switch(h){case 1:case 2:case 4:case 8:case 64:return p+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return p+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function wt(){var h=Ue;return Ue<<=1,(Ue&62914560)===0&&(Ue=4194304),h}function Ot(h){for(var p=[],_=0;31>_;_++)p.push(h);return p}function cn(h,p){h.pendingLanes|=p,p!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function It(h,p,_,w,k,O){var X=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var oe=h.entanglements,Ee=h.expirationTimes,qe=h.hiddenUpdates;for(_=X&~_;0<_;){var lt=31-$e(_),dt=1<<lt;oe[lt]=0,Ee[lt]=-1;var Qe=qe[lt];if(Qe!==null)for(qe[lt]=null,lt=0;lt<Qe.length;lt++){var it=Qe[lt];it!==null&&(it.lane&=-536870913)}_&=~dt}w!==0&&Rn(h,w,0),O!==0&&k===0&&h.tag!==0&&(h.suspendedLanes|=O&~(X&~p))}function Rn(h,p,_){h.pendingLanes|=p,h.suspendedLanes&=~p;var w=31-$e(p);h.entangledLanes|=p,h.entanglements[w]=h.entanglements[w]|1073741824|_&261930}function Kn(h,p){var _=h.entangledLanes|=p;for(h=h.entanglements;_;){var w=31-$e(_),k=1<<w;k&p|h[w]&p&&(h[w]|=p),_&=~k}}function _i(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 wi(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Ii(){var h=W.p;return h!==0?h:(h=window.event,h===void 0?32:vU(h.type))}function Ji(h,p){var _=W.p;try{return W.p=h,p()}finally{W.p=_}}var Ur=Math.random().toString(36).slice(2),xr="__reactFiber$"+Ur,kr="__reactProps$"+Ur,co="__reactContainer$"+Ur,Ic="__reactEvents$"+Ur,he="__reactListeners$"+Ur,Ge="__reactHandles$"+Ur,tt="__reactResources$"+Ur,rt="__reactMarker$"+Ur;function et(h){delete h[xr],delete h[kr],delete h[Ic],delete h[he],delete h[Ge]}function St(h){var p=h[xr];if(p)return p;for(var _=h.parentNode;_;){if(p=_[co]||_[xr]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(h=rU(h);h!==null;){if(_=h[xr])return _;h=rU(h)}return p}h=_,_=h.parentNode}return null}function ie(h){if(h=h[xr]||h[co]){var p=h.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return h}return null}function Se(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h.stateNode;throw Error(r(33))}function Le(h){var p=h[tt];return p||(p=h[tt]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Oe(h){h[rt]=!0}var Te=new Set,ot={};function ft(h,p){bt(h,p),bt(h+"Capture",p)}function bt(h,p){for(ot[h]=p,h=0;h<p.length;h++)Te.add(p[h])}var xt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),jt={},Mt={};function mt(h){return le.call(Mt,h)?!0:le.call(jt,h)?!1:xt.test(h)?Mt[h]=!0:(jt[h]=!0,!1)}function Kt(h,p,_){if(mt(p))if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(p);return;case"boolean":var w=p.toLowerCase().slice(0,5);if(w!=="data-"&&w!=="aria-"){h.removeAttribute(p);return}}h.setAttribute(p,""+_)}}function Ft(h,p,_){if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(p);return}h.setAttribute(p,""+_)}}function nn(h,p,_,w){if(w===null)h.removeAttribute(_);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(p,_,""+w)}}function dn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function gn(h){var p=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Ut(h,p,_){var w=Object.getOwnPropertyDescriptor(h.constructor.prototype,p);if(!h.hasOwnProperty(p)&&typeof w<"u"&&typeof w.get=="function"&&typeof w.set=="function"){var k=w.get,O=w.set;return Object.defineProperty(h,p,{configurable:!0,get:function(){return k.call(this)},set:function(X){_=""+X,O.call(this,X)}}),Object.defineProperty(h,p,{enumerable:w.enumerable}),{getValue:function(){return _},setValue:function(X){_=""+X},stopTracking:function(){h._valueTracker=null,delete h[p]}}}}function Zt(h){if(!h._valueTracker){var p=gn(h)?"checked":"value";h._valueTracker=Ut(h,p,""+h[p])}}function Jt(h){if(!h)return!1;var p=h._valueTracker;if(!p)return!0;var _=p.getValue(),w="";return h&&(w=gn(h)?h.checked?"true":"false":h.value),h=w,h!==_?(p.setValue(h),!0):!1}function Sr(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 Pr=/[\n"\\]/g;function Pn(h){return h.replace(Pr,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function uo(h,p,_,w,k,O,X,oe){h.name="",X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?h.type=X:h.removeAttribute("type"),p!=null?X==="number"?(p===0&&h.value===""||h.value!=p)&&(h.value=""+dn(p)):h.value!==""+dn(p)&&(h.value=""+dn(p)):X!=="submit"&&X!=="reset"||h.removeAttribute("value"),p!=null?Si(h,X,dn(p)):_!=null?Si(h,X,dn(_)):w!=null&&h.removeAttribute("value"),k==null&&O!=null&&(h.defaultChecked=!!O),k!=null&&(h.checked=k&&typeof k!="function"&&typeof k!="symbol"),oe!=null&&typeof oe!="function"&&typeof oe!="symbol"&&typeof oe!="boolean"?h.name=""+dn(oe):h.removeAttribute("name")}function Dn(h,p,_,w,k,O,X,oe){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(h.type=O),p!=null||_!=null){if(!(O!=="submit"&&O!=="reset"||p!=null)){Zt(h);return}_=_!=null?""+dn(_):"",p=p!=null?""+dn(p):_,oe||p===h.value||(h.value=p),h.defaultValue=p}w=w??k,w=typeof w!="function"&&typeof w!="symbol"&&!!w,h.checked=oe?h.checked:!!w,h.defaultChecked=!!w,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(h.name=X),Zt(h)}function Si(h,p,_){p==="number"&&Sr(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function ai(h,p,_,w){if(h=h.options,p){p={};for(var k=0;k<_.length;k++)p["$"+_[k]]=!0;for(_=0;_<h.length;_++)k=p.hasOwnProperty("$"+h[_].value),h[_].selected!==k&&(h[_].selected=k),k&&w&&(h[_].defaultSelected=!0)}else{for(_=""+dn(_),p=null,k=0;k<h.length;k++){if(h[k].value===_){h[k].selected=!0,w&&(h[k].defaultSelected=!0);return}p!==null||h[k].disabled||(p=h[k])}p!==null&&(p.selected=!0)}}function Ei(h,p,_){if(p!=null&&(p=""+dn(p),p!==h.value&&(h.value=p),_==null)){h.defaultValue!==p&&(h.defaultValue=p);return}h.defaultValue=_!=null?""+dn(_):""}function Ui(h,p,_,w){if(p==null){if(w!=null){if(_!=null)throw Error(r(92));if(V(w)){if(1<w.length)throw Error(r(93));w=w[0]}_=w}_==null&&(_=""),p=_}_=dn(p),h.defaultValue=_,w=h.textContent,w===_&&w!==""&&w!==null&&(h.value=w),Zt(h)}function Bo(h,p){if(p){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=p;return}}h.textContent=p}var bl=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 Wj(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||bl.has(p)?p==="float"?h.cssFloat=_:h[p]=(""+_).trim():h[p]=_+"px"}function qj(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 k in p)w=p[k],p.hasOwnProperty(k)&&_[k]!==w&&Wj(h,k,w)}else for(var O in p)p.hasOwnProperty(O)&&Wj(h,O,p[O])}function VE(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 jee=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"]]),Lee=/^[\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 Bb(h){return Lee.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function vl(){}var GE=null;function WE(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var lf=null,cf=null;function Kj(h){var p=ie(h);if(p&&(h=p.stateNode)){var _=h[kr]||null;e:switch(h=p.stateNode,p.type){case"input":if(uo(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Pn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var w=_[p];if(w!==h&&w.form===h.form){var k=w[kr]||null;if(!k)throw Error(r(90));uo(w,k.value,k.defaultValue,k.defaultValue,k.checked,k.defaultChecked,k.type,k.name)}}for(p=0;p<_.length;p++)w=_[p],w.form===h.form&&Jt(w)}break e;case"textarea":Ei(h,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&ai(h,!!_.multiple,p,!1)}}}var qE=!1;function Xj(h,p,_){if(qE)return h(p,_);qE=!0;try{var w=h(p);return w}finally{if(qE=!1,(lf!==null||cf!==null)&&(Cv(),lf&&(p=lf,h=cf,cf=lf=null,Kj(p),h)))for(p=0;p<h.length;p++)Kj(h[p])}}function sg(h,p){var _=h.stateNode;if(_===null)return null;var w=_[kr]||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 yl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),KE=!1;if(yl)try{var ag={};Object.defineProperty(ag,"passive",{get:function(){KE=!0}}),window.addEventListener("test",ag,ag),window.removeEventListener("test",ag,ag)}catch{KE=!1}var Uc=null,XE=null,Hb=null;function Yj(){if(Hb)return Hb;var h,p=XE,_=p.length,w,k="value"in Uc?Uc.value:Uc.textContent,O=k.length;for(h=0;h<_&&p[h]===k[h];h++);var X=_-h;for(w=1;w<=X&&p[_-w]===k[O-w];w++);return Hb=k.slice(h,1<w?1-w:void 0)}function $b(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 Vb(){return!0}function Zj(){return!1}function Ps(h){function p(_,w,k,O,X){this._reactName=_,this._targetInst=k,this.type=w,this.nativeEvent=O,this.target=X,this.currentTarget=null;for(var oe in h)h.hasOwnProperty(oe)&&(_=h[oe],this[oe]=_?_(O):O[oe]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?Vb:Zj,this.isPropagationStopped=Zj,this}return f(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Vb)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Vb)},persist:function(){},isPersistent:Vb}),p}var yd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gb=Ps(yd),og=f({},yd,{view:0,detail:0}),Iee=Ps(og),YE,ZE,lg,Wb=f({},og,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:JE,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!==lg&&(lg&&h.type==="mousemove"?(YE=h.screenX-lg.screenX,ZE=h.screenY-lg.screenY):ZE=YE=0,lg=h),YE)},movementY:function(h){return"movementY"in h?h.movementY:ZE}}),Qj=Ps(Wb),Uee=f({},Wb,{dataTransfer:0}),Fee=Ps(Uee),zee=f({},og,{relatedTarget:0}),QE=Ps(zee),Bee=f({},yd,{animationName:0,elapsedTime:0,pseudoElement:0}),Hee=Ps(Bee),$ee=f({},yd,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),Vee=Ps($ee),Gee=f({},yd,{data:0}),Jj=Ps(Gee),Wee={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},qee={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"},Kee={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Xee(h){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(h):(h=Kee[h])?!!p[h]:!1}function JE(){return Xee}var Yee=f({},og,{key:function(h){if(h.key){var p=Wee[h.key]||h.key;if(p!=="Unidentified")return p}return h.type==="keypress"?(h=$b(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?qee[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:JE,charCode:function(h){return h.type==="keypress"?$b(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?$b(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Zee=Ps(Yee),Qee=f({},Wb,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),eL=Ps(Qee),Jee=f({},og,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:JE}),ete=Ps(Jee),tte=f({},yd,{propertyName:0,elapsedTime:0,pseudoElement:0}),nte=Ps(tte),rte=f({},Wb,{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}),ite=Ps(rte),ste=f({},yd,{newState:0,oldState:0}),ate=Ps(ste),ote=[9,13,27,32],eM=yl&&"CompositionEvent"in window,cg=null;yl&&"documentMode"in document&&(cg=document.documentMode);var lte=yl&&"TextEvent"in window&&!cg,tL=yl&&(!eM||cg&&8<cg&&11>=cg),nL=" ",rL=!1;function iL(h,p){switch(h){case"keyup":return ote.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function sL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var uf=!1;function cte(h,p){switch(h){case"compositionend":return sL(p);case"keypress":return p.which!==32?null:(rL=!0,nL);case"textInput":return h=p.data,h===nL&&rL?null:h;default:return null}}function ute(h,p){if(uf)return h==="compositionend"||!eM&&iL(h,p)?(h=Yj(),Hb=XE=Uc=null,uf=!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 dte={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 aL(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p==="input"?!!dte[h.type]:p==="textarea"}function oL(h,p,_,w){lf?cf?cf.push(w):cf=[w]:lf=w,p=jv(p,"onChange"),0<p.length&&(_=new Gb("onChange","change",null,_,w),h.push({event:_,listeners:p}))}var ug=null,dg=null;function hte(h){$4(h,0)}function qb(h){var p=Se(h);if(Jt(p))return h}function lL(h,p){if(h==="change")return p}var cL=!1;if(yl){var tM;if(yl){var nM="oninput"in document;if(!nM){var uL=document.createElement("div");uL.setAttribute("oninput","return;"),nM=typeof uL.oninput=="function"}tM=nM}else tM=!1;cL=tM&&(!document.documentMode||9<document.documentMode)}function dL(){ug&&(ug.detachEvent("onpropertychange",hL),dg=ug=null)}function hL(h){if(h.propertyName==="value"&&qb(dg)){var p=[];oL(p,dg,h,WE(h)),Xj(hte,p)}}function fte(h,p,_){h==="focusin"?(dL(),ug=p,dg=_,ug.attachEvent("onpropertychange",hL)):h==="focusout"&&dL()}function pte(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return qb(dg)}function mte(h,p){if(h==="click")return qb(p)}function gte(h,p){if(h==="input"||h==="change")return qb(p)}function xte(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var Js=typeof Object.is=="function"?Object.is:xte;function hg(h,p){if(Js(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 k=_[w];if(!le.call(p,k)||!Js(h[k],p[k]))return!1}return!0}function fL(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function pL(h,p){var _=fL(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}_=fL(_)}}function mL(h,p){return h&&p?h===p?!0:h&&h.nodeType===3?!1:p&&p.nodeType===3?mL(h,p.parentNode):"contains"in h?h.contains(p):h.compareDocumentPosition?!!(h.compareDocumentPosition(p)&16):!1:!1}function gL(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var p=Sr(h.document);p instanceof h.HTMLIFrameElement;){try{var _=typeof p.contentWindow.location.href=="string"}catch{_=!1}if(_)h=p.contentWindow;else break;p=Sr(h.document)}return p}function rM(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 bte=yl&&"documentMode"in document&&11>=document.documentMode,df=null,iM=null,fg=null,sM=!1;function xL(h,p,_){var w=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;sM||df==null||df!==Sr(w)||(w=df,"selectionStart"in w&&rM(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}),fg&&hg(fg,w)||(fg=w,w=jv(iM,"onSelect"),0<w.length&&(p=new Gb("onSelect","select",null,p,_),h.push({event:p,listeners:w}),p.target=df)))}function _d(h,p){var _={};return _[h.toLowerCase()]=p.toLowerCase(),_["Webkit"+h]="webkit"+p,_["Moz"+h]="moz"+p,_}var hf={animationend:_d("Animation","AnimationEnd"),animationiteration:_d("Animation","AnimationIteration"),animationstart:_d("Animation","AnimationStart"),transitionrun:_d("Transition","TransitionRun"),transitionstart:_d("Transition","TransitionStart"),transitioncancel:_d("Transition","TransitionCancel"),transitionend:_d("Transition","TransitionEnd")},aM={},bL={};yl&&(bL=document.createElement("div").style,"AnimationEvent"in window||(delete hf.animationend.animation,delete hf.animationiteration.animation,delete hf.animationstart.animation),"TransitionEvent"in window||delete hf.transitionend.transition);function wd(h){if(aM[h])return aM[h];if(!hf[h])return h;var p=hf[h],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in bL)return aM[h]=p[_];return h}var vL=wd("animationend"),yL=wd("animationiteration"),_L=wd("animationstart"),vte=wd("transitionrun"),yte=wd("transitionstart"),_te=wd("transitioncancel"),wL=wd("transitionend"),SL=new Map,oM="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(" ");oM.push("scrollEnd");function ho(h,p){SL.set(h,p),ft(p,[h])}var Kb=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)},Sa=[],ff=0,lM=0;function Xb(){for(var h=ff,p=lM=ff=0;p<h;){var _=Sa[p];Sa[p++]=null;var w=Sa[p];Sa[p++]=null;var k=Sa[p];Sa[p++]=null;var O=Sa[p];if(Sa[p++]=null,w!==null&&k!==null){var X=w.pending;X===null?k.next=k:(k.next=X.next,X.next=k),w.pending=k}O!==0&&EL(_,k,O)}}function Yb(h,p,_,w){Sa[ff++]=h,Sa[ff++]=p,Sa[ff++]=_,Sa[ff++]=w,lM|=w,h.lanes|=w,h=h.alternate,h!==null&&(h.lanes|=w)}function cM(h,p,_,w){return Yb(h,p,_,w),Zb(h)}function Sd(h,p){return Yb(h,null,null,p),Zb(h)}function EL(h,p,_){h.lanes|=_;var w=h.alternate;w!==null&&(w.lanes|=_);for(var k=!1,O=h.return;O!==null;)O.childLanes|=_,w=O.alternate,w!==null&&(w.childLanes|=_),O.tag===22&&(h=O.stateNode,h===null||h._visibility&1||(k=!0)),h=O,O=O.return;return h.tag===3?(O=h.stateNode,k&&p!==null&&(k=31-$e(_),h=O.hiddenUpdates,w=h[k],w===null?h[k]=[p]:w.push(p),p.lane=_|536870912),O):null}function Zb(h){if(50<jg)throw jg=0,b2=null,Error(r(185));for(var p=h.return;p!==null;)h=p,p=h.return;return h.tag===3?h.stateNode:null}var pf={};function wte(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 ea(h,p,_,w){return new wte(h,p,_,w)}function uM(h){return h=h.prototype,!(!h||!h.isReactComponent)}function _l(h,p){var _=h.alternate;return _===null?(_=ea(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 ML(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 Qb(h,p,_,w,k,O){var X=0;if(w=h,typeof h=="function")uM(h)&&(X=1);else if(typeof h=="string")X=Tne(h,_,ae.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case N:return h=ea(31,_,p,k),h.elementType=N,h.lanes=O,h;case y:return Ed(_.children,k,O,p);case v:X=8,k|=24;break;case b:return h=ea(12,_,p,k|2),h.elementType=b,h.lanes=O,h;case T:return h=ea(13,_,p,k),h.elementType=T,h.lanes=O,h;case P:return h=ea(19,_,p,k),h.elementType=P,h.lanes=O,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case S:X=10;break e;case E:X=9;break e;case A:X=11;break e;case C:X=14;break e;case I:X=16,w=null;break e}X=29,_=Error(r(130,h===null?"null":typeof h,"")),w=null}return p=ea(X,_,p,k),p.elementType=h,p.type=w,p.lanes=O,p}function Ed(h,p,_,w){return h=ea(7,h,w,p),h.lanes=_,h}function dM(h,p,_){return h=ea(6,h,null,p),h.lanes=_,h}function AL(h){var p=ea(18,null,null,0);return p.stateNode=h,p}function hM(h,p,_){return p=ea(4,h.children!==null?h.children:[],h.key,p),p.lanes=_,p.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},p}var TL=new WeakMap;function Ea(h,p){if(typeof h=="object"&&h!==null){var _=TL.get(h);return _!==void 0?_:(p={value:h,source:p,stack:J(p)},TL.set(h,p),p)}return{value:h,source:p,stack:J(p)}}var mf=[],gf=0,Jb=null,pg=0,Ma=[],Aa=0,Fc=null,Ho=1,$o="";function wl(h,p){mf[gf++]=pg,mf[gf++]=Jb,Jb=h,pg=p}function CL(h,p,_){Ma[Aa++]=Ho,Ma[Aa++]=$o,Ma[Aa++]=Fc,Fc=h;var w=Ho;h=$o;var k=32-$e(w)-1;w&=~(1<<k),_+=1;var O=32-$e(p)+k;if(30<O){var X=k-k%5;O=(w&(1<<X)-1).toString(32),w>>=X,k-=X,Ho=1<<32-$e(p)+k|_<<k|w,$o=O+h}else Ho=1<<O|_<<k|w,$o=h}function fM(h){h.return!==null&&(wl(h,1),CL(h,1,0))}function pM(h){for(;h===Jb;)Jb=mf[--gf],mf[gf]=null,pg=mf[--gf],mf[gf]=null;for(;h===Fc;)Fc=Ma[--Aa],Ma[Aa]=null,$o=Ma[--Aa],Ma[Aa]=null,Ho=Ma[--Aa],Ma[Aa]=null}function NL(h,p){Ma[Aa++]=Ho,Ma[Aa++]=$o,Ma[Aa++]=Fc,Ho=p.id,$o=p.overflow,Fc=h}var Fi=null,ir=null,yn=!1,zc=null,Ta=!1,mM=Error(r(519));function Bc(h){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw mg(Ea(p,h)),mM}function kL(h){var p=h.stateNode,_=h.type,w=h.memoizedProps;switch(p[xr]=h,p[kr]=w,_){case"dialog":pn("cancel",p),pn("close",p);break;case"iframe":case"object":case"embed":pn("load",p);break;case"video":case"audio":for(_=0;_<Ig.length;_++)pn(Ig[_],p);break;case"source":pn("error",p);break;case"img":case"image":case"link":pn("error",p),pn("load",p);break;case"details":pn("toggle",p);break;case"input":pn("invalid",p),Dn(p,w.value,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name,!0);break;case"select":pn("invalid",p);break;case"textarea":pn("invalid",p),Ui(p,w.value,w.defaultValue,w.children)}_=w.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||w.suppressHydrationWarning===!0||q4(p.textContent,_)?(w.popover!=null&&(pn("beforetoggle",p),pn("toggle",p)),w.onScroll!=null&&pn("scroll",p),w.onScrollEnd!=null&&pn("scrollend",p),w.onClick!=null&&(p.onclick=vl),p=!0):p=!1,p||Bc(h,!0)}function PL(h){for(Fi=h.return;Fi;)switch(Fi.tag){case 5:case 31:case 13:Ta=!1;return;case 27:case 3:Ta=!0;return;default:Fi=Fi.return}}function xf(h){if(h!==Fi)return!1;if(!yn)return PL(h),yn=!0,!1;var p=h.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||D2(h.type,h.memoizedProps)),_=!_),_&&ir&&Bc(h),PL(h),p===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));ir=nU(h)}else if(p===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));ir=nU(h)}else p===27?(p=ir,tu(h.type)?(h=U2,U2=null,ir=h):ir=p):ir=Fi?Na(h.stateNode.nextSibling):null;return!0}function Md(){ir=Fi=null,yn=!1}function gM(){var h=zc;return h!==null&&(js===null?js=h:js.push.apply(js,h),zc=null),h}function mg(h){zc===null?zc=[h]:zc.push(h)}var xM=U(null),Ad=null,Sl=null;function Hc(h,p,_){ee(xM,p._currentValue),p._currentValue=_}function El(h){h._currentValue=xM.current,$(xM)}function bM(h,p,_){for(;h!==null;){var w=h.alternate;if((h.childLanes&p)!==p?(h.childLanes|=p,w!==null&&(w.childLanes|=p)):w!==null&&(w.childLanes&p)!==p&&(w.childLanes|=p),h===_)break;h=h.return}}function vM(h,p,_,w){var k=h.child;for(k!==null&&(k.return=h);k!==null;){var O=k.dependencies;if(O!==null){var X=k.child;O=O.firstContext;e:for(;O!==null;){var oe=O;O=k;for(var Ee=0;Ee<p.length;Ee++)if(oe.context===p[Ee]){O.lanes|=_,oe=O.alternate,oe!==null&&(oe.lanes|=_),bM(O.return,_,h),w||(X=null);break e}O=oe.next}}else if(k.tag===18){if(X=k.return,X===null)throw Error(r(341));X.lanes|=_,O=X.alternate,O!==null&&(O.lanes|=_),bM(X,_,h),X=null}else X=k.child;if(X!==null)X.return=k;else for(X=k;X!==null;){if(X===h){X=null;break}if(k=X.sibling,k!==null){k.return=X.return,X=k;break}X=X.return}k=X}}function bf(h,p,_,w){h=null;for(var k=p,O=!1;k!==null;){if(!O){if((k.flags&524288)!==0)O=!0;else if((k.flags&262144)!==0)break}if(k.tag===10){var X=k.alternate;if(X===null)throw Error(r(387));if(X=X.memoizedProps,X!==null){var oe=k.type;Js(k.pendingProps.value,X.value)||(h!==null?h.push(oe):h=[oe])}}else if(k===xe.current){if(X=k.alternate,X===null)throw Error(r(387));X.memoizedState.memoizedState!==k.memoizedState.memoizedState&&(h!==null?h.push(Hg):h=[Hg])}k=k.return}h!==null&&vM(p,h,_,w),p.flags|=262144}function ev(h){for(h=h.firstContext;h!==null;){if(!Js(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Td(h){Ad=h,Sl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function zi(h){return RL(Ad,h)}function tv(h,p){return Ad===null&&Td(h),RL(h,p)}function RL(h,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},Sl===null){if(h===null)throw Error(r(308));Sl=p,h.dependencies={lanes:0,firstContext:p},h.flags|=524288}else Sl=Sl.next=p;return _}var Ste=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 _()})}},Ete=t.unstable_scheduleCallback,Mte=t.unstable_NormalPriority,Fr={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function yM(){return{controller:new Ste,data:new Map,refCount:0}}function gg(h){h.refCount--,h.refCount===0&&Ete(Mte,function(){h.controller.abort()})}var xg=null,_M=0,vf=0,yf=null;function Ate(h,p){if(xg===null){var _=xg=[];_M=0,vf=E2(),yf={status:"pending",value:void 0,then:function(w){_.push(w)}}}return _M++,p.then(DL,DL),p}function DL(){if(--_M===0&&xg!==null){yf!==null&&(yf.status="fulfilled");var h=xg;xg=null,vf=0,yf=null;for(var p=0;p<h.length;p++)(0,h[p])()}}function Tte(h,p){var _=[],w={status:"pending",value:null,reason:null,then:function(k){_.push(k)}};return h.then(function(){w.status="fulfilled",w.value=p;for(var k=0;k<_.length;k++)(0,_[k])(p)},function(k){for(w.status="rejected",w.reason=k,k=0;k<_.length;k++)(0,_[k])(void 0)}),w}var OL=K.S;K.S=function(h,p){x4=j(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&Ate(h,p),OL!==null&&OL(h,p)};var Cd=U(null);function wM(){var h=Cd.current;return h!==null?h:Xn.pooledCache}function nv(h,p){p===null?ee(Cd,Cd.current):ee(Cd,p.pool)}function jL(){var h=wM();return h===null?null:{parent:Fr._currentValue,pool:h}}var _f=Error(r(460)),SM=Error(r(474)),rv=Error(r(542)),iv={then:function(){}};function LL(h){return h=h.status,h==="fulfilled"||h==="rejected"}function IL(h,p,_){switch(_=h[_],_===void 0?h.push(p):_!==p&&(p.then(vl,vl),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,FL(h),h;default:if(typeof p.status=="string")p.then(vl,vl);else{if(h=Xn,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=p,h.status="pending",h.then(function(w){if(p.status==="pending"){var k=p;k.status="fulfilled",k.value=w}},function(w){if(p.status==="pending"){var k=p;k.status="rejected",k.reason=w}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,FL(h),h}throw kd=p,_f}}function Nd(h){try{var p=h._init;return p(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(kd=_,_f):_}}var kd=null;function UL(){if(kd===null)throw Error(r(459));var h=kd;return kd=null,h}function FL(h){if(h===_f||h===rv)throw Error(r(483))}var wf=null,bg=0;function sv(h){var p=bg;return bg+=1,wf===null&&(wf=[]),IL(wf,h,p)}function vg(h,p){p=p.props.ref,h.ref=p!==void 0?p:null}function av(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 zL(h){function p(Be,Re){if(h){var We=Be.deletions;We===null?(Be.deletions=[Re],Be.flags|=16):We.push(Re)}}function _(Be,Re){if(!h)return null;for(;Re!==null;)p(Be,Re),Re=Re.sibling;return null}function w(Be){for(var Re=new Map;Be!==null;)Be.key!==null?Re.set(Be.key,Be):Re.set(Be.index,Be),Be=Be.sibling;return Re}function k(Be,Re){return Be=_l(Be,Re),Be.index=0,Be.sibling=null,Be}function O(Be,Re,We){return Be.index=We,h?(We=Be.alternate,We!==null?(We=We.index,We<Re?(Be.flags|=67108866,Re):We):(Be.flags|=67108866,Re)):(Be.flags|=1048576,Re)}function X(Be){return h&&Be.alternate===null&&(Be.flags|=67108866),Be}function oe(Be,Re,We,ct){return Re===null||Re.tag!==6?(Re=dM(We,Be.mode,ct),Re.return=Be,Re):(Re=k(Re,We),Re.return=Be,Re)}function Ee(Be,Re,We,ct){var zt=We.type;return zt===y?lt(Be,Re,We.props.children,ct,We.key):Re!==null&&(Re.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&Nd(zt)===Re.type)?(Re=k(Re,We.props),vg(Re,We),Re.return=Be,Re):(Re=Qb(We.type,We.key,We.props,null,Be.mode,ct),vg(Re,We),Re.return=Be,Re)}function qe(Be,Re,We,ct){return Re===null||Re.tag!==4||Re.stateNode.containerInfo!==We.containerInfo||Re.stateNode.implementation!==We.implementation?(Re=hM(We,Be.mode,ct),Re.return=Be,Re):(Re=k(Re,We.children||[]),Re.return=Be,Re)}function lt(Be,Re,We,ct,zt){return Re===null||Re.tag!==7?(Re=Ed(We,Be.mode,ct,zt),Re.return=Be,Re):(Re=k(Re,We),Re.return=Be,Re)}function dt(Be,Re,We){if(typeof Re=="string"&&Re!==""||typeof Re=="number"||typeof Re=="bigint")return Re=dM(""+Re,Be.mode,We),Re.return=Be,Re;if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case m:return We=Qb(Re.type,Re.key,Re.props,null,Be.mode,We),vg(We,Re),We.return=Be,We;case x:return Re=hM(Re,Be.mode,We),Re.return=Be,Re;case I:return Re=Nd(Re),dt(Be,Re,We)}if(V(Re)||L(Re))return Re=Ed(Re,Be.mode,We,null),Re.return=Be,Re;if(typeof Re.then=="function")return dt(Be,sv(Re),We);if(Re.$$typeof===S)return dt(Be,tv(Be,Re),We);av(Be,Re)}return null}function Qe(Be,Re,We,ct){var zt=Re!==null?Re.key:null;if(typeof We=="string"&&We!==""||typeof We=="number"||typeof We=="bigint")return zt!==null?null:oe(Be,Re,""+We,ct);if(typeof We=="object"&&We!==null){switch(We.$$typeof){case m:return We.key===zt?Ee(Be,Re,We,ct):null;case x:return We.key===zt?qe(Be,Re,We,ct):null;case I:return We=Nd(We),Qe(Be,Re,We,ct)}if(V(We)||L(We))return zt!==null?null:lt(Be,Re,We,ct,null);if(typeof We.then=="function")return Qe(Be,Re,sv(We),ct);if(We.$$typeof===S)return Qe(Be,Re,tv(Be,We),ct);av(Be,We)}return null}function it(Be,Re,We,ct,zt){if(typeof ct=="string"&&ct!==""||typeof ct=="number"||typeof ct=="bigint")return Be=Be.get(We)||null,oe(Re,Be,""+ct,zt);if(typeof ct=="object"&&ct!==null){switch(ct.$$typeof){case m:return Be=Be.get(ct.key===null?We:ct.key)||null,Ee(Re,Be,ct,zt);case x:return Be=Be.get(ct.key===null?We:ct.key)||null,qe(Re,Be,ct,zt);case I:return ct=Nd(ct),it(Be,Re,We,ct,zt)}if(V(ct)||L(ct))return Be=Be.get(We)||null,lt(Re,Be,ct,zt,null);if(typeof ct.then=="function")return it(Be,Re,We,sv(ct),zt);if(ct.$$typeof===S)return it(Be,Re,We,tv(Re,ct),zt);av(Re,ct)}return null}function Rt(Be,Re,We,ct){for(var zt=null,En=null,Lt=Re,tn=Re=0,bn=null;Lt!==null&&tn<We.length;tn++){Lt.index>tn?(bn=Lt,Lt=null):bn=Lt.sibling;var Mn=Qe(Be,Lt,We[tn],ct);if(Mn===null){Lt===null&&(Lt=bn);break}h&&Lt&&Mn.alternate===null&&p(Be,Lt),Re=O(Mn,Re,tn),En===null?zt=Mn:En.sibling=Mn,En=Mn,Lt=bn}if(tn===We.length)return _(Be,Lt),yn&&wl(Be,tn),zt;if(Lt===null){for(;tn<We.length;tn++)Lt=dt(Be,We[tn],ct),Lt!==null&&(Re=O(Lt,Re,tn),En===null?zt=Lt:En.sibling=Lt,En=Lt);return yn&&wl(Be,tn),zt}for(Lt=w(Lt);tn<We.length;tn++)bn=it(Lt,Be,tn,We[tn],ct),bn!==null&&(h&&bn.alternate!==null&&Lt.delete(bn.key===null?tn:bn.key),Re=O(bn,Re,tn),En===null?zt=bn:En.sibling=bn,En=bn);return h&&Lt.forEach(function(au){return p(Be,au)}),yn&&wl(Be,tn),zt}function Vt(Be,Re,We,ct){if(We==null)throw Error(r(151));for(var zt=null,En=null,Lt=Re,tn=Re=0,bn=null,Mn=We.next();Lt!==null&&!Mn.done;tn++,Mn=We.next()){Lt.index>tn?(bn=Lt,Lt=null):bn=Lt.sibling;var au=Qe(Be,Lt,Mn.value,ct);if(au===null){Lt===null&&(Lt=bn);break}h&&Lt&&au.alternate===null&&p(Be,Lt),Re=O(au,Re,tn),En===null?zt=au:En.sibling=au,En=au,Lt=bn}if(Mn.done)return _(Be,Lt),yn&&wl(Be,tn),zt;if(Lt===null){for(;!Mn.done;tn++,Mn=We.next())Mn=dt(Be,Mn.value,ct),Mn!==null&&(Re=O(Mn,Re,tn),En===null?zt=Mn:En.sibling=Mn,En=Mn);return yn&&wl(Be,tn),zt}for(Lt=w(Lt);!Mn.done;tn++,Mn=We.next())Mn=it(Lt,Be,tn,Mn.value,ct),Mn!==null&&(h&&Mn.alternate!==null&&Lt.delete(Mn.key===null?tn:Mn.key),Re=O(Mn,Re,tn),En===null?zt=Mn:En.sibling=Mn,En=Mn);return h&&Lt.forEach(function(Une){return p(Be,Une)}),yn&&wl(Be,tn),zt}function zn(Be,Re,We,ct){if(typeof We=="object"&&We!==null&&We.type===y&&We.key===null&&(We=We.props.children),typeof We=="object"&&We!==null){switch(We.$$typeof){case m:e:{for(var zt=We.key;Re!==null;){if(Re.key===zt){if(zt=We.type,zt===y){if(Re.tag===7){_(Be,Re.sibling),ct=k(Re,We.props.children),ct.return=Be,Be=ct;break e}}else if(Re.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&Nd(zt)===Re.type){_(Be,Re.sibling),ct=k(Re,We.props),vg(ct,We),ct.return=Be,Be=ct;break e}_(Be,Re);break}else p(Be,Re);Re=Re.sibling}We.type===y?(ct=Ed(We.props.children,Be.mode,ct,We.key),ct.return=Be,Be=ct):(ct=Qb(We.type,We.key,We.props,null,Be.mode,ct),vg(ct,We),ct.return=Be,Be=ct)}return X(Be);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){_(Be,Re.sibling),ct=k(Re,We.children||[]),ct.return=Be,Be=ct;break e}else{_(Be,Re);break}else p(Be,Re);Re=Re.sibling}ct=hM(We,Be.mode,ct),ct.return=Be,Be=ct}return X(Be);case I:return We=Nd(We),zn(Be,Re,We,ct)}if(V(We))return Rt(Be,Re,We,ct);if(L(We)){if(zt=L(We),typeof zt!="function")throw Error(r(150));return We=zt.call(We),Vt(Be,Re,We,ct)}if(typeof We.then=="function")return zn(Be,Re,sv(We),ct);if(We.$$typeof===S)return zn(Be,Re,tv(Be,We),ct);av(Be,We)}return typeof We=="string"&&We!==""||typeof We=="number"||typeof We=="bigint"?(We=""+We,Re!==null&&Re.tag===6?(_(Be,Re.sibling),ct=k(Re,We),ct.return=Be,Be=ct):(_(Be,Re),ct=dM(We,Be.mode,ct),ct.return=Be,Be=ct),X(Be)):_(Be,Re)}return function(Be,Re,We,ct){try{bg=0;var zt=zn(Be,Re,We,ct);return wf=null,zt}catch(Lt){if(Lt===_f||Lt===rv)throw Lt;var En=ea(29,Lt,null,Be.mode);return En.lanes=ct,En.return=Be,En}finally{}}}var Pd=zL(!0),BL=zL(!1),$c=!1;function EM(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function MM(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 Vc(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Gc(h,p,_){var w=h.updateQueue;if(w===null)return null;if(w=w.shared,(Nn&2)!==0){var k=w.pending;return k===null?p.next=p:(p.next=k.next,k.next=p),w.pending=p,p=Zb(h),EL(h,null,_),p}return Yb(h,w,p,_),Zb(h)}function yg(h,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var w=p.lanes;w&=h.pendingLanes,_|=w,p.lanes=_,Kn(h,_)}}function AM(h,p){var _=h.updateQueue,w=h.alternate;if(w!==null&&(w=w.updateQueue,_===w)){var k=null,O=null;if(_=_.firstBaseUpdate,_!==null){do{var X={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};O===null?k=O=X:O=O.next=X,_=_.next}while(_!==null);O===null?k=O=p:O=O.next=p}else k=O=p;_={baseState:w.baseState,firstBaseUpdate:k,lastBaseUpdate:O,shared:w.shared,callbacks:w.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=p:h.next=p,_.lastBaseUpdate=p}var TM=!1;function _g(){if(TM){var h=yf;if(h!==null)throw h}}function wg(h,p,_,w){TM=!1;var k=h.updateQueue;$c=!1;var O=k.firstBaseUpdate,X=k.lastBaseUpdate,oe=k.shared.pending;if(oe!==null){k.shared.pending=null;var Ee=oe,qe=Ee.next;Ee.next=null,X===null?O=qe:X.next=qe,X=Ee;var lt=h.alternate;lt!==null&&(lt=lt.updateQueue,oe=lt.lastBaseUpdate,oe!==X&&(oe===null?lt.firstBaseUpdate=qe:oe.next=qe,lt.lastBaseUpdate=Ee))}if(O!==null){var dt=k.baseState;X=0,lt=qe=Ee=null,oe=O;do{var Qe=oe.lane&-536870913,it=Qe!==oe.lane;if(it?(xn&Qe)===Qe:(w&Qe)===Qe){Qe!==0&&Qe===vf&&(TM=!0),lt!==null&&(lt=lt.next={lane:0,tag:oe.tag,payload:oe.payload,callback:null,next:null});e:{var Rt=h,Vt=oe;Qe=p;var zn=_;switch(Vt.tag){case 1:if(Rt=Vt.payload,typeof Rt=="function"){dt=Rt.call(zn,dt,Qe);break e}dt=Rt;break e;case 3:Rt.flags=Rt.flags&-65537|128;case 0:if(Rt=Vt.payload,Qe=typeof Rt=="function"?Rt.call(zn,dt,Qe):Rt,Qe==null)break e;dt=f({},dt,Qe);break e;case 2:$c=!0}}Qe=oe.callback,Qe!==null&&(h.flags|=64,it&&(h.flags|=8192),it=k.callbacks,it===null?k.callbacks=[Qe]:it.push(Qe))}else it={lane:Qe,tag:oe.tag,payload:oe.payload,callback:oe.callback,next:null},lt===null?(qe=lt=it,Ee=dt):lt=lt.next=it,X|=Qe;if(oe=oe.next,oe===null){if(oe=k.shared.pending,oe===null)break;it=oe,oe=it.next,it.next=null,k.lastBaseUpdate=it,k.shared.pending=null}}while(!0);lt===null&&(Ee=dt),k.baseState=Ee,k.firstBaseUpdate=qe,k.lastBaseUpdate=lt,O===null&&(k.shared.lanes=0),Yc|=X,h.lanes=X,h.memoizedState=dt}}function HL(h,p){if(typeof h!="function")throw Error(r(191,h));h.call(p)}function $L(h,p){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)HL(_[h],p)}var Sf=U(null),ov=U(0);function VL(h,p){h=Dl,ee(ov,h),ee(Sf,p),Dl=h|p.baseLanes}function CM(){ee(ov,Dl),ee(Sf,Sf.current)}function NM(){Dl=ov.current,$(Sf),$(ov)}var ta=U(null),Ca=null;function Wc(h){var p=h.alternate;ee(Rr,Rr.current&1),ee(ta,h),Ca===null&&(p===null||Sf.current!==null||p.memoizedState!==null)&&(Ca=h)}function kM(h){ee(Rr,Rr.current),ee(ta,h),Ca===null&&(Ca=h)}function GL(h){h.tag===22?(ee(Rr,Rr.current),ee(ta,h),Ca===null&&(Ca=h)):qc()}function qc(){ee(Rr,Rr.current),ee(ta,ta.current)}function na(h){$(ta),Ca===h&&(Ca=null),$(Rr)}var Rr=U(0);function lv(h){for(var p=h;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||L2(_)||I2(_)))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 Ml=0,en=null,Un=null,zr=null,cv=!1,Ef=!1,Rd=!1,uv=0,Sg=0,Mf=null,Cte=0;function Er(){throw Error(r(321))}function PM(h,p){if(p===null)return!1;for(var _=0;_<p.length&&_<h.length;_++)if(!Js(h[_],p[_]))return!1;return!0}function RM(h,p,_,w,k,O){return Ml=O,en=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,K.H=h===null||h.memoizedState===null?CI:qM,Rd=!1,O=_(w,k),Rd=!1,Ef&&(O=qL(p,_,w,k)),WL(h),O}function WL(h){K.H=Ag;var p=Un!==null&&Un.next!==null;if(Ml=0,zr=Un=en=null,cv=!1,Sg=0,Mf=null,p)throw Error(r(300));h===null||Br||(h=h.dependencies,h!==null&&ev(h)&&(Br=!0))}function qL(h,p,_,w){en=h;var k=0;do{if(Ef&&(Mf=null),Sg=0,Ef=!1,25<=k)throw Error(r(301));if(k+=1,zr=Un=null,h.updateQueue!=null){var O=h.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}K.H=NI,O=p(_,w)}while(Ef);return O}function Nte(){var h=K.H,p=h.useState()[0];return p=typeof p.then=="function"?Eg(p):p,h=h.useState()[0],(Un!==null?Un.memoizedState:null)!==h&&(en.flags|=1024),p}function DM(){var h=uv!==0;return uv=0,h}function OM(h,p,_){p.updateQueue=h.updateQueue,p.flags&=-2053,h.lanes&=~_}function jM(h){if(cv){for(h=h.memoizedState;h!==null;){var p=h.queue;p!==null&&(p.pending=null),h=h.next}cv=!1}Ml=0,zr=Un=en=null,Ef=!1,Sg=uv=0,Mf=null}function gs(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return zr===null?en.memoizedState=zr=h:zr=zr.next=h,zr}function Dr(){if(Un===null){var h=en.alternate;h=h!==null?h.memoizedState:null}else h=Un.next;var p=zr===null?en.memoizedState:zr.next;if(p!==null)zr=p,Un=h;else{if(h===null)throw en.alternate===null?Error(r(467)):Error(r(310));Un=h,h={memoizedState:Un.memoizedState,baseState:Un.baseState,baseQueue:Un.baseQueue,queue:Un.queue,next:null},zr===null?en.memoizedState=zr=h:zr=zr.next=h}return zr}function dv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Eg(h){var p=Sg;return Sg+=1,Mf===null&&(Mf=[]),h=IL(Mf,h,p),p=en,(zr===null?p.memoizedState:zr.next)===null&&(p=p.alternate,K.H=p===null||p.memoizedState===null?CI:qM),h}function hv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Eg(h);if(h.$$typeof===S)return zi(h)}throw Error(r(438,String(h)))}function LM(h){var p=null,_=en.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var w=en.alternate;w!==null&&(w=w.updateQueue,w!==null&&(w=w.memoCache,w!=null&&(p={data:w.data.map(function(k){return k.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=dv(),en.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(h),w=0;w<h;w++)_[w]=D;return p.index++,_}function Al(h,p){return typeof p=="function"?p(h):p}function fv(h){var p=Dr();return IM(p,Un,h)}function IM(h,p,_){var w=h.queue;if(w===null)throw Error(r(311));w.lastRenderedReducer=_;var k=h.baseQueue,O=w.pending;if(O!==null){if(k!==null){var X=k.next;k.next=O.next,O.next=X}p.baseQueue=k=O,w.pending=null}if(O=h.baseState,k===null)h.memoizedState=O;else{p=k.next;var oe=X=null,Ee=null,qe=p,lt=!1;do{var dt=qe.lane&-536870913;if(dt!==qe.lane?(xn&dt)===dt:(Ml&dt)===dt){var Qe=qe.revertLane;if(Qe===0)Ee!==null&&(Ee=Ee.next={lane:0,revertLane:0,gesture:null,action:qe.action,hasEagerState:qe.hasEagerState,eagerState:qe.eagerState,next:null}),dt===vf&&(lt=!0);else if((Ml&Qe)===Qe){qe=qe.next,Qe===vf&&(lt=!0);continue}else dt={lane:0,revertLane:qe.revertLane,gesture:null,action:qe.action,hasEagerState:qe.hasEagerState,eagerState:qe.eagerState,next:null},Ee===null?(oe=Ee=dt,X=O):Ee=Ee.next=dt,en.lanes|=Qe,Yc|=Qe;dt=qe.action,Rd&&_(O,dt),O=qe.hasEagerState?qe.eagerState:_(O,dt)}else Qe={lane:dt,revertLane:qe.revertLane,gesture:qe.gesture,action:qe.action,hasEagerState:qe.hasEagerState,eagerState:qe.eagerState,next:null},Ee===null?(oe=Ee=Qe,X=O):Ee=Ee.next=Qe,en.lanes|=dt,Yc|=dt;qe=qe.next}while(qe!==null&&qe!==p);if(Ee===null?X=O:Ee.next=oe,!Js(O,h.memoizedState)&&(Br=!0,lt&&(_=yf,_!==null)))throw _;h.memoizedState=O,h.baseState=X,h.baseQueue=Ee,w.lastRenderedState=O}return k===null&&(w.lanes=0),[h.memoizedState,w.dispatch]}function UM(h){var p=Dr(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var w=_.dispatch,k=_.pending,O=p.memoizedState;if(k!==null){_.pending=null;var X=k=k.next;do O=h(O,X.action),X=X.next;while(X!==k);Js(O,p.memoizedState)||(Br=!0),p.memoizedState=O,p.baseQueue===null&&(p.baseState=O),_.lastRenderedState=O}return[O,w]}function KL(h,p,_){var w=en,k=Dr(),O=yn;if(O){if(_===void 0)throw Error(r(407));_=_()}else _=p();var X=!Js((Un||k).memoizedState,_);if(X&&(k.memoizedState=_,Br=!0),k=k.queue,BM(ZL.bind(null,w,k,h),[h]),k.getSnapshot!==p||X||zr!==null&&zr.memoizedState.tag&1){if(w.flags|=2048,Af(9,{destroy:void 0},YL.bind(null,w,k,_,p),null),Xn===null)throw Error(r(349));O||(Ml&127)!==0||XL(w,p,_)}return _}function XL(h,p,_){h.flags|=16384,h={getSnapshot:p,value:_},p=en.updateQueue,p===null?(p=dv(),en.updateQueue=p,p.stores=[h]):(_=p.stores,_===null?p.stores=[h]:_.push(h))}function YL(h,p,_,w){p.value=_,p.getSnapshot=w,QL(p)&&JL(h)}function ZL(h,p,_){return _(function(){QL(p)&&JL(h)})}function QL(h){var p=h.getSnapshot;h=h.value;try{var _=p();return!Js(h,_)}catch{return!0}}function JL(h){var p=Sd(h,2);p!==null&&Ls(p,h,2)}function FM(h){var p=gs();if(typeof h=="function"){var _=h;if(h=_(),Rd){Ye(!0);try{_()}finally{Ye(!1)}}}return p.memoizedState=p.baseState=h,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Al,lastRenderedState:h},p}function eI(h,p,_,w){return h.baseState=_,IM(h,Un,typeof w=="function"?w:Al)}function kte(h,p,_,w,k){if(gv(h))throw Error(r(485));if(h=p.action,h!==null){var O={payload:k,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(X){O.listeners.push(X)}};K.T!==null?_(!0):O.isTransition=!1,w(O),_=p.pending,_===null?(O.next=p.pending=O,tI(p,O)):(O.next=_.next,p.pending=_.next=O)}}function tI(h,p){var _=p.action,w=p.payload,k=h.state;if(p.isTransition){var O=K.T,X={};K.T=X;try{var oe=_(k,w),Ee=K.S;Ee!==null&&Ee(X,oe),nI(h,p,oe)}catch(qe){zM(h,p,qe)}finally{O!==null&&X.types!==null&&(O.types=X.types),K.T=O}}else try{O=_(k,w),nI(h,p,O)}catch(qe){zM(h,p,qe)}}function nI(h,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(w){rI(h,p,w)},function(w){return zM(h,p,w)}):rI(h,p,_)}function rI(h,p,_){p.status="fulfilled",p.value=_,iI(p),h.state=_,p=h.pending,p!==null&&(_=p.next,_===p?h.pending=null:(_=_.next,p.next=_,tI(h,_)))}function zM(h,p,_){var w=h.pending;if(h.pending=null,w!==null){w=w.next;do p.status="rejected",p.reason=_,iI(p),p=p.next;while(p!==w)}h.action=null}function iI(h){h=h.listeners;for(var p=0;p<h.length;p++)(0,h[p])()}function sI(h,p){return p}function aI(h,p){if(yn){var _=Xn.formState;if(_!==null){e:{var w=en;if(yn){if(ir){t:{for(var k=ir,O=Ta;k.nodeType!==8;){if(!O){k=null;break t}if(k=Na(k.nextSibling),k===null){k=null;break t}}O=k.data,k=O==="F!"||O==="F"?k:null}if(k){ir=Na(k.nextSibling),w=k.data==="F!";break e}}Bc(w)}w=!1}w&&(p=_[0])}}return _=gs(),_.memoizedState=_.baseState=p,w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:sI,lastRenderedState:p},_.queue=w,_=MI.bind(null,en,w),w.dispatch=_,w=FM(!1),O=WM.bind(null,en,!1,w.queue),w=gs(),k={state:p,dispatch:null,action:h,pending:null},w.queue=k,_=kte.bind(null,en,k,O,_),k.dispatch=_,w.memoizedState=h,[p,_,!1]}function oI(h){var p=Dr();return lI(p,Un,h)}function lI(h,p,_){if(p=IM(h,p,sI)[0],h=fv(Al)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var w=Eg(p)}catch(X){throw X===_f?rv:X}else w=p;p=Dr();var k=p.queue,O=k.dispatch;return _!==p.memoizedState&&(en.flags|=2048,Af(9,{destroy:void 0},Pte.bind(null,k,_),null)),[w,O,h]}function Pte(h,p){h.action=p}function cI(h){var p=Dr(),_=Un;if(_!==null)return lI(p,_,h);Dr(),p=p.memoizedState,_=Dr();var w=_.queue.dispatch;return _.memoizedState=h,[p,w,!1]}function Af(h,p,_,w){return h={tag:h,create:_,deps:w,inst:p,next:null},p=en.updateQueue,p===null&&(p=dv(),en.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=h.next=h:(w=_.next,_.next=h,h.next=w,p.lastEffect=h),h}function uI(){return Dr().memoizedState}function pv(h,p,_,w){var k=gs();en.flags|=h,k.memoizedState=Af(1|p,{destroy:void 0},_,w===void 0?null:w)}function mv(h,p,_,w){var k=Dr();w=w===void 0?null:w;var O=k.memoizedState.inst;Un!==null&&w!==null&&PM(w,Un.memoizedState.deps)?k.memoizedState=Af(p,O,_,w):(en.flags|=h,k.memoizedState=Af(1|p,O,_,w))}function dI(h,p){pv(8390656,8,h,p)}function BM(h,p){mv(2048,8,h,p)}function Rte(h){en.flags|=4;var p=en.updateQueue;if(p===null)p=dv(),en.updateQueue=p,p.events=[h];else{var _=p.events;_===null?p.events=[h]:_.push(h)}}function hI(h){var p=Dr().memoizedState;return Rte({ref:p,nextImpl:h}),function(){if((Nn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function fI(h,p){return mv(4,2,h,p)}function pI(h,p){return mv(4,4,h,p)}function mI(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 gI(h,p,_){_=_!=null?_.concat([h]):null,mv(4,4,mI.bind(null,p,h),_)}function HM(){}function xI(h,p){var _=Dr();p=p===void 0?null:p;var w=_.memoizedState;return p!==null&&PM(p,w[1])?w[0]:(_.memoizedState=[h,p],h)}function bI(h,p){var _=Dr();p=p===void 0?null:p;var w=_.memoizedState;if(p!==null&&PM(p,w[1]))return w[0];if(w=h(),Rd){Ye(!0);try{h()}finally{Ye(!1)}}return _.memoizedState=[w,p],w}function $M(h,p,_){return _===void 0||(Ml&1073741824)!==0&&(xn&261930)===0?h.memoizedState=p:(h.memoizedState=_,h=v4(),en.lanes|=h,Yc|=h,_)}function vI(h,p,_,w){return Js(_,p)?_:Sf.current!==null?(h=$M(h,_,w),Js(h,p)||(Br=!0),h):(Ml&42)===0||(Ml&1073741824)!==0&&(xn&261930)===0?(Br=!0,h.memoizedState=_):(h=v4(),en.lanes|=h,Yc|=h,p)}function yI(h,p,_,w,k){var O=W.p;W.p=O!==0&&8>O?O:8;var X=K.T,oe={};K.T=oe,WM(h,!1,p,_);try{var Ee=k(),qe=K.S;if(qe!==null&&qe(oe,Ee),Ee!==null&&typeof Ee=="object"&&typeof Ee.then=="function"){var lt=Tte(Ee,w);Mg(h,p,lt,sa(h))}else Mg(h,p,w,sa(h))}catch(dt){Mg(h,p,{then:function(){},status:"rejected",reason:dt},sa())}finally{W.p=O,X!==null&&oe.types!==null&&(X.types=oe.types),K.T=X}}function Dte(){}function VM(h,p,_,w){if(h.tag!==5)throw Error(r(476));var k=_I(h).queue;yI(h,k,p,ne,_===null?Dte:function(){return wI(h),_(w)})}function _I(h){var p=h.memoizedState;if(p!==null)return p;p={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Al,lastRenderedState:ne},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Al,lastRenderedState:_},next:null},h.memoizedState=p,h=h.alternate,h!==null&&(h.memoizedState=p),p}function wI(h){var p=_I(h);p.next===null&&(p=h.alternate.memoizedState),Mg(h,p.next.queue,{},sa())}function GM(){return zi(Hg)}function SI(){return Dr().memoizedState}function EI(){return Dr().memoizedState}function Ote(h){for(var p=h.return;p!==null;){switch(p.tag){case 24:case 3:var _=sa();h=Vc(_);var w=Gc(p,h,_);w!==null&&(Ls(w,p,_),yg(w,p,_)),p={cache:yM()},h.payload=p;return}p=p.return}}function jte(h,p,_){var w=sa();_={lane:w,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},gv(h)?AI(p,_):(_=cM(h,p,_,w),_!==null&&(Ls(_,h,w),TI(_,p,w)))}function MI(h,p,_){var w=sa();Mg(h,p,_,w)}function Mg(h,p,_,w){var k={lane:w,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(gv(h))AI(p,k);else{var O=h.alternate;if(h.lanes===0&&(O===null||O.lanes===0)&&(O=p.lastRenderedReducer,O!==null))try{var X=p.lastRenderedState,oe=O(X,_);if(k.hasEagerState=!0,k.eagerState=oe,Js(oe,X))return Yb(h,p,k,0),Xn===null&&Xb(),!1}catch{}finally{}if(_=cM(h,p,k,w),_!==null)return Ls(_,h,w),TI(_,p,w),!0}return!1}function WM(h,p,_,w){if(w={lane:2,revertLane:E2(),gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},gv(h)){if(p)throw Error(r(479))}else p=cM(h,_,w,2),p!==null&&Ls(p,h,2)}function gv(h){var p=h.alternate;return h===en||p!==null&&p===en}function AI(h,p){Ef=cv=!0;var _=h.pending;_===null?p.next=p:(p.next=_.next,_.next=p),h.pending=p}function TI(h,p,_){if((_&4194048)!==0){var w=p.lanes;w&=h.pendingLanes,_|=w,p.lanes=_,Kn(h,_)}}var Ag={readContext:zi,use:hv,useCallback:Er,useContext:Er,useEffect:Er,useImperativeHandle:Er,useLayoutEffect:Er,useInsertionEffect:Er,useMemo:Er,useReducer:Er,useRef:Er,useState:Er,useDebugValue:Er,useDeferredValue:Er,useTransition:Er,useSyncExternalStore:Er,useId:Er,useHostTransitionStatus:Er,useFormState:Er,useActionState:Er,useOptimistic:Er,useMemoCache:Er,useCacheRefresh:Er};Ag.useEffectEvent=Er;var CI={readContext:zi,use:hv,useCallback:function(h,p){return gs().memoizedState=[h,p===void 0?null:p],h},useContext:zi,useEffect:dI,useImperativeHandle:function(h,p,_){_=_!=null?_.concat([h]):null,pv(4194308,4,mI.bind(null,p,h),_)},useLayoutEffect:function(h,p){return pv(4194308,4,h,p)},useInsertionEffect:function(h,p){pv(4,2,h,p)},useMemo:function(h,p){var _=gs();p=p===void 0?null:p;var w=h();if(Rd){Ye(!0);try{h()}finally{Ye(!1)}}return _.memoizedState=[w,p],w},useReducer:function(h,p,_){var w=gs();if(_!==void 0){var k=_(p);if(Rd){Ye(!0);try{_(p)}finally{Ye(!1)}}}else k=p;return w.memoizedState=w.baseState=k,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:k},w.queue=h,h=h.dispatch=jte.bind(null,en,h),[w.memoizedState,h]},useRef:function(h){var p=gs();return h={current:h},p.memoizedState=h},useState:function(h){h=FM(h);var p=h.queue,_=MI.bind(null,en,p);return p.dispatch=_,[h.memoizedState,_]},useDebugValue:HM,useDeferredValue:function(h,p){var _=gs();return $M(_,h,p)},useTransition:function(){var h=FM(!1);return h=yI.bind(null,en,h.queue,!0,!1),gs().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,p,_){var w=en,k=gs();if(yn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Xn===null)throw Error(r(349));(xn&127)!==0||XL(w,p,_)}k.memoizedState=_;var O={value:_,getSnapshot:p};return k.queue=O,dI(ZL.bind(null,w,O,h),[h]),w.flags|=2048,Af(9,{destroy:void 0},YL.bind(null,w,O,_,p),null),_},useId:function(){var h=gs(),p=Xn.identifierPrefix;if(yn){var _=$o,w=Ho;_=(w&~(1<<32-$e(w)-1)).toString(32)+_,p="_"+p+"R_"+_,_=uv++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=Cte++,p="_"+p+"r_"+_.toString(32)+"_";return h.memoizedState=p},useHostTransitionStatus:GM,useFormState:aI,useActionState:aI,useOptimistic:function(h){var p=gs();p.memoizedState=p.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=WM.bind(null,en,!0,_),_.dispatch=p,[h,p]},useMemoCache:LM,useCacheRefresh:function(){return gs().memoizedState=Ote.bind(null,en)},useEffectEvent:function(h){var p=gs(),_={impl:h};return p.memoizedState=_,function(){if((Nn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},qM={readContext:zi,use:hv,useCallback:xI,useContext:zi,useEffect:BM,useImperativeHandle:gI,useInsertionEffect:fI,useLayoutEffect:pI,useMemo:bI,useReducer:fv,useRef:uI,useState:function(){return fv(Al)},useDebugValue:HM,useDeferredValue:function(h,p){var _=Dr();return vI(_,Un.memoizedState,h,p)},useTransition:function(){var h=fv(Al)[0],p=Dr().memoizedState;return[typeof h=="boolean"?h:Eg(h),p]},useSyncExternalStore:KL,useId:SI,useHostTransitionStatus:GM,useFormState:oI,useActionState:oI,useOptimistic:function(h,p){var _=Dr();return eI(_,Un,h,p)},useMemoCache:LM,useCacheRefresh:EI};qM.useEffectEvent=hI;var NI={readContext:zi,use:hv,useCallback:xI,useContext:zi,useEffect:BM,useImperativeHandle:gI,useInsertionEffect:fI,useLayoutEffect:pI,useMemo:bI,useReducer:UM,useRef:uI,useState:function(){return UM(Al)},useDebugValue:HM,useDeferredValue:function(h,p){var _=Dr();return Un===null?$M(_,h,p):vI(_,Un.memoizedState,h,p)},useTransition:function(){var h=UM(Al)[0],p=Dr().memoizedState;return[typeof h=="boolean"?h:Eg(h),p]},useSyncExternalStore:KL,useId:SI,useHostTransitionStatus:GM,useFormState:cI,useActionState:cI,useOptimistic:function(h,p){var _=Dr();return Un!==null?eI(_,Un,h,p):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:LM,useCacheRefresh:EI};NI.useEffectEvent=hI;function KM(h,p,_,w){p=h.memoizedState,_=_(w,p),_=_==null?p:f({},p,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var XM={enqueueSetState:function(h,p,_){h=h._reactInternals;var w=sa(),k=Vc(w);k.payload=p,_!=null&&(k.callback=_),p=Gc(h,k,w),p!==null&&(Ls(p,h,w),yg(p,h,w))},enqueueReplaceState:function(h,p,_){h=h._reactInternals;var w=sa(),k=Vc(w);k.tag=1,k.payload=p,_!=null&&(k.callback=_),p=Gc(h,k,w),p!==null&&(Ls(p,h,w),yg(p,h,w))},enqueueForceUpdate:function(h,p){h=h._reactInternals;var _=sa(),w=Vc(_);w.tag=2,p!=null&&(w.callback=p),p=Gc(h,w,_),p!==null&&(Ls(p,h,_),yg(p,h,_))}};function kI(h,p,_,w,k,O,X){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(w,O,X):p.prototype&&p.prototype.isPureReactComponent?!hg(_,w)||!hg(k,O):!0}function PI(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&&XM.enqueueReplaceState(p,p.state,null)}function Dd(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 k in h)_[k]===void 0&&(_[k]=h[k])}return _}function RI(h){Kb(h)}function DI(h){console.error(h)}function OI(h){Kb(h)}function xv(h,p){try{var _=h.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(w){setTimeout(function(){throw w})}}function jI(h,p,_){try{var w=h.onCaughtError;w(_.value,{componentStack:_.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(k){setTimeout(function(){throw k})}}function YM(h,p,_){return _=Vc(_),_.tag=3,_.payload={element:null},_.callback=function(){xv(h,p)},_}function LI(h){return h=Vc(h),h.tag=3,h}function II(h,p,_,w){var k=_.type.getDerivedStateFromError;if(typeof k=="function"){var O=w.value;h.payload=function(){return k(O)},h.callback=function(){jI(p,_,w)}}var X=_.stateNode;X!==null&&typeof X.componentDidCatch=="function"&&(h.callback=function(){jI(p,_,w),typeof k!="function"&&(Zc===null?Zc=new Set([this]):Zc.add(this));var oe=w.stack;this.componentDidCatch(w.value,{componentStack:oe!==null?oe:""})})}function Lte(h,p,_,w,k){if(_.flags|=32768,w!==null&&typeof w=="object"&&typeof w.then=="function"){if(p=_.alternate,p!==null&&bf(p,_,k,!0),_=ta.current,_!==null){switch(_.tag){case 31:case 13:return Ca===null?Nv():_.alternate===null&&Mr===0&&(Mr=3),_.flags&=-257,_.flags|=65536,_.lanes=k,w===iv?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([w]):p.add(w),_2(h,w,k)),!1;case 22:return _.flags|=65536,w===iv?_.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)),_2(h,w,k)),!1}throw Error(r(435,_.tag))}return _2(h,w,k),Nv(),!1}if(yn)return p=ta.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=k,w!==mM&&(h=Error(r(422),{cause:w}),mg(Ea(h,_)))):(w!==mM&&(p=Error(r(423),{cause:w}),mg(Ea(p,_))),h=h.current.alternate,h.flags|=65536,k&=-k,h.lanes|=k,w=Ea(w,_),k=YM(h.stateNode,w,k),AM(h,k),Mr!==4&&(Mr=2)),!1;var O=Error(r(520),{cause:w});if(O=Ea(O,_),Og===null?Og=[O]:Og.push(O),Mr!==4&&(Mr=2),p===null)return!0;w=Ea(w,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,h=k&-k,_.lanes|=h,h=YM(_.stateNode,w,h),AM(_,h),!1;case 1:if(p=_.type,O=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Zc===null||!Zc.has(O))))return _.flags|=65536,k&=-k,_.lanes|=k,k=LI(k),II(k,h,_,w),AM(_,k),!1}_=_.return}while(_!==null);return!1}var ZM=Error(r(461)),Br=!1;function Bi(h,p,_,w){p.child=h===null?BL(p,null,_,w):Pd(p,h.child,_,w)}function UI(h,p,_,w,k){_=_.render;var O=p.ref;if("ref"in w){var X={};for(var oe in w)oe!=="ref"&&(X[oe]=w[oe])}else X=w;return Td(p),w=RM(h,p,_,X,O,k),oe=DM(),h!==null&&!Br?(OM(h,p,k),Tl(h,p,k)):(yn&&oe&&fM(p),p.flags|=1,Bi(h,p,w,k),p.child)}function FI(h,p,_,w,k){if(h===null){var O=_.type;return typeof O=="function"&&!uM(O)&&O.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=O,zI(h,p,O,w,k)):(h=Qb(_.type,null,w,p,p.mode,k),h.ref=p.ref,h.return=p,p.child=h)}if(O=h.child,!s2(h,k)){var X=O.memoizedProps;if(_=_.compare,_=_!==null?_:hg,_(X,w)&&h.ref===p.ref)return Tl(h,p,k)}return p.flags|=1,h=_l(O,w),h.ref=p.ref,h.return=p,p.child=h}function zI(h,p,_,w,k){if(h!==null){var O=h.memoizedProps;if(hg(O,w)&&h.ref===p.ref)if(Br=!1,p.pendingProps=w=O,s2(h,k))(h.flags&131072)!==0&&(Br=!0);else return p.lanes=h.lanes,Tl(h,p,k)}return QM(h,p,_,w,k)}function BI(h,p,_,w){var k=w.children,O=h!==null?h.memoizedState:null;if(h===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),w.mode==="hidden"){if((p.flags&128)!==0){if(O=O!==null?O.baseLanes|_:_,h!==null){for(w=p.child=h.child,k=0;w!==null;)k=k|w.lanes|w.childLanes,w=w.sibling;w=k&~O}else w=0,p.child=null;return HI(h,p,O,_,w)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},h!==null&&nv(p,O!==null?O.cachePool:null),O!==null?VL(p,O):CM(),GL(p);else return w=p.lanes=536870912,HI(h,p,O!==null?O.baseLanes|_:_,_,w)}else O!==null?(nv(p,O.cachePool),VL(p,O),qc(),p.memoizedState=null):(h!==null&&nv(p,null),CM(),qc());return Bi(h,p,k,_),p.child}function Tg(h,p){return h!==null&&h.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function HI(h,p,_,w,k){var O=wM();return O=O===null?null:{parent:Fr._currentValue,pool:O},p.memoizedState={baseLanes:_,cachePool:O},h!==null&&nv(p,null),CM(),GL(p),h!==null&&bf(h,p,w,!0),p.childLanes=k,null}function bv(h,p){return p=yv({mode:p.mode,children:p.children},h.mode),p.ref=h.ref,h.child=p,p.return=h,p}function $I(h,p,_){return Pd(p,h.child,null,_),h=bv(p,p.pendingProps),h.flags|=2,na(p),p.memoizedState=null,h}function Ite(h,p,_){var w=p.pendingProps,k=(p.flags&128)!==0;if(p.flags&=-129,h===null){if(yn){if(w.mode==="hidden")return h=bv(p,w),p.lanes=536870912,Tg(null,h);if(kM(p),(h=ir)?(h=tU(h,Ta),h=h!==null&&h.data==="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Fc!==null?{id:Ho,overflow:$o}:null,retryLane:536870912,hydrationErrors:null},_=AL(h),_.return=p,p.child=_,Fi=p,ir=null)):h=null,h===null)throw Bc(p);return p.lanes=536870912,null}return bv(p,w)}var O=h.memoizedState;if(O!==null){var X=O.dehydrated;if(kM(p),k)if(p.flags&256)p.flags&=-257,p=$I(h,p,_);else if(p.memoizedState!==null)p.child=h.child,p.flags|=128,p=null;else throw Error(r(558));else if(Br||bf(h,p,_,!1),k=(_&h.childLanes)!==0,Br||k){if(w=Xn,w!==null&&(X=_i(w,_),X!==0&&X!==O.retryLane))throw O.retryLane=X,Sd(h,X),Ls(w,h,X),ZM;Nv(),p=$I(h,p,_)}else h=O.treeContext,ir=Na(X.nextSibling),Fi=p,yn=!0,zc=null,Ta=!1,h!==null&&NL(p,h),p=bv(p,w),p.flags|=4096;return p}return h=_l(h.child,{mode:w.mode,children:w.children}),h.ref=p.ref,p.child=h,h.return=p,h}function vv(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 QM(h,p,_,w,k){return Td(p),_=RM(h,p,_,w,void 0,k),w=DM(),h!==null&&!Br?(OM(h,p,k),Tl(h,p,k)):(yn&&w&&fM(p),p.flags|=1,Bi(h,p,_,k),p.child)}function VI(h,p,_,w,k,O){return Td(p),p.updateQueue=null,_=qL(p,w,_,k),WL(h),w=DM(),h!==null&&!Br?(OM(h,p,O),Tl(h,p,O)):(yn&&w&&fM(p),p.flags|=1,Bi(h,p,_,O),p.child)}function GI(h,p,_,w,k){if(Td(p),p.stateNode===null){var O=pf,X=_.contextType;typeof X=="object"&&X!==null&&(O=zi(X)),O=new _(w,O),p.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=XM,p.stateNode=O,O._reactInternals=p,O=p.stateNode,O.props=w,O.state=p.memoizedState,O.refs={},EM(p),X=_.contextType,O.context=typeof X=="object"&&X!==null?zi(X):pf,O.state=p.memoizedState,X=_.getDerivedStateFromProps,typeof X=="function"&&(KM(p,_,X,w),O.state=p.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(X=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),X!==O.state&&XM.enqueueReplaceState(O,O.state,null),wg(p,w,O,k),_g(),O.state=p.memoizedState),typeof O.componentDidMount=="function"&&(p.flags|=4194308),w=!0}else if(h===null){O=p.stateNode;var oe=p.memoizedProps,Ee=Dd(_,oe);O.props=Ee;var qe=O.context,lt=_.contextType;X=pf,typeof lt=="object"&<!==null&&(X=zi(lt));var dt=_.getDerivedStateFromProps;lt=typeof dt=="function"||typeof O.getSnapshotBeforeUpdate=="function",oe=p.pendingProps!==oe,lt||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(oe||qe!==X)&&PI(p,O,w,X),$c=!1;var Qe=p.memoizedState;O.state=Qe,wg(p,w,O,k),_g(),qe=p.memoizedState,oe||Qe!==qe||$c?(typeof dt=="function"&&(KM(p,_,dt,w),qe=p.memoizedState),(Ee=$c||kI(p,_,Ee,w,Qe,qe,X))?(lt||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(p.flags|=4194308)):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=w,p.memoizedState=qe),O.props=w,O.state=qe,O.context=X,w=Ee):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),w=!1)}else{O=p.stateNode,MM(h,p),X=p.memoizedProps,lt=Dd(_,X),O.props=lt,dt=p.pendingProps,Qe=O.context,qe=_.contextType,Ee=pf,typeof qe=="object"&&qe!==null&&(Ee=zi(qe)),oe=_.getDerivedStateFromProps,(qe=typeof oe=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(X!==dt||Qe!==Ee)&&PI(p,O,w,Ee),$c=!1,Qe=p.memoizedState,O.state=Qe,wg(p,w,O,k),_g();var it=p.memoizedState;X!==dt||Qe!==it||$c||h!==null&&h.dependencies!==null&&ev(h.dependencies)?(typeof oe=="function"&&(KM(p,_,oe,w),it=p.memoizedState),(lt=$c||kI(p,_,lt,w,Qe,it,Ee)||h!==null&&h.dependencies!==null&&ev(h.dependencies))?(qe||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(w,it,Ee),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(w,it,Ee)),typeof O.componentDidUpdate=="function"&&(p.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof O.componentDidUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=1024),p.memoizedProps=w,p.memoizedState=it),O.props=w,O.state=it,O.context=Ee,w=lt):(typeof O.componentDidUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=1024),w=!1)}return O=w,vv(h,p),w=(p.flags&128)!==0,O||w?(O=p.stateNode,_=w&&typeof _.getDerivedStateFromError!="function"?null:O.render(),p.flags|=1,h!==null&&w?(p.child=Pd(p,h.child,null,k),p.child=Pd(p,null,_,k)):Bi(h,p,_,k),p.memoizedState=O.state,h=p.child):h=Tl(h,p,k),h}function WI(h,p,_,w){return Md(),p.flags|=256,Bi(h,p,_,w),p.child}var JM={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function e2(h){return{baseLanes:h,cachePool:jL()}}function t2(h,p,_){return h=h!==null?h.childLanes&~_:0,p&&(h|=ia),h}function qI(h,p,_){var w=p.pendingProps,k=!1,O=(p.flags&128)!==0,X;if((X=O)||(X=h!==null&&h.memoizedState===null?!1:(Rr.current&2)!==0),X&&(k=!0,p.flags&=-129),X=(p.flags&32)!==0,p.flags&=-33,h===null){if(yn){if(k?Wc(p):qc(),(h=ir)?(h=tU(h,Ta),h=h!==null&&h.data!=="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Fc!==null?{id:Ho,overflow:$o}:null,retryLane:536870912,hydrationErrors:null},_=AL(h),_.return=p,p.child=_,Fi=p,ir=null)):h=null,h===null)throw Bc(p);return I2(h)?p.lanes=32:p.lanes=536870912,null}var oe=w.children;return w=w.fallback,k?(qc(),k=p.mode,oe=yv({mode:"hidden",children:oe},k),w=Ed(w,k,_,null),oe.return=p,w.return=p,oe.sibling=w,p.child=oe,w=p.child,w.memoizedState=e2(_),w.childLanes=t2(h,X,_),p.memoizedState=JM,Tg(null,w)):(Wc(p),n2(p,oe))}var Ee=h.memoizedState;if(Ee!==null&&(oe=Ee.dehydrated,oe!==null)){if(O)p.flags&256?(Wc(p),p.flags&=-257,p=r2(h,p,_)):p.memoizedState!==null?(qc(),p.child=h.child,p.flags|=128,p=null):(qc(),oe=w.fallback,k=p.mode,w=yv({mode:"visible",children:w.children},k),oe=Ed(oe,k,_,null),oe.flags|=2,w.return=p,oe.return=p,w.sibling=oe,p.child=w,Pd(p,h.child,null,_),w=p.child,w.memoizedState=e2(_),w.childLanes=t2(h,X,_),p.memoizedState=JM,p=Tg(null,w));else if(Wc(p),I2(oe)){if(X=oe.nextSibling&&oe.nextSibling.dataset,X)var qe=X.dgst;X=qe,w=Error(r(419)),w.stack="",w.digest=X,mg({value:w,source:null,stack:null}),p=r2(h,p,_)}else if(Br||bf(h,p,_,!1),X=(_&h.childLanes)!==0,Br||X){if(X=Xn,X!==null&&(w=_i(X,_),w!==0&&w!==Ee.retryLane))throw Ee.retryLane=w,Sd(h,w),Ls(X,h,w),ZM;L2(oe)||Nv(),p=r2(h,p,_)}else L2(oe)?(p.flags|=192,p.child=h.child,p=null):(h=Ee.treeContext,ir=Na(oe.nextSibling),Fi=p,yn=!0,zc=null,Ta=!1,h!==null&&NL(p,h),p=n2(p,w.children),p.flags|=4096);return p}return k?(qc(),oe=w.fallback,k=p.mode,Ee=h.child,qe=Ee.sibling,w=_l(Ee,{mode:"hidden",children:w.children}),w.subtreeFlags=Ee.subtreeFlags&65011712,qe!==null?oe=_l(qe,oe):(oe=Ed(oe,k,_,null),oe.flags|=2),oe.return=p,w.return=p,w.sibling=oe,p.child=w,Tg(null,w),w=p.child,oe=h.child.memoizedState,oe===null?oe=e2(_):(k=oe.cachePool,k!==null?(Ee=Fr._currentValue,k=k.parent!==Ee?{parent:Ee,pool:Ee}:k):k=jL(),oe={baseLanes:oe.baseLanes|_,cachePool:k}),w.memoizedState=oe,w.childLanes=t2(h,X,_),p.memoizedState=JM,Tg(h.child,w)):(Wc(p),_=h.child,h=_.sibling,_=_l(_,{mode:"visible",children:w.children}),_.return=p,_.sibling=null,h!==null&&(X=p.deletions,X===null?(p.deletions=[h],p.flags|=16):X.push(h)),p.child=_,p.memoizedState=null,_)}function n2(h,p){return p=yv({mode:"visible",children:p},h.mode),p.return=h,h.child=p}function yv(h,p){return h=ea(22,h,null,p),h.lanes=0,h}function r2(h,p,_){return Pd(p,h.child,null,_),h=n2(p,p.pendingProps.children),h.flags|=2,p.memoizedState=null,h}function KI(h,p,_){h.lanes|=p;var w=h.alternate;w!==null&&(w.lanes|=p),bM(h.return,p,_)}function i2(h,p,_,w,k,O){var X=h.memoizedState;X===null?h.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:w,tail:_,tailMode:k,treeForkCount:O}:(X.isBackwards=p,X.rendering=null,X.renderingStartTime=0,X.last=w,X.tail=_,X.tailMode=k,X.treeForkCount=O)}function XI(h,p,_){var w=p.pendingProps,k=w.revealOrder,O=w.tail;w=w.children;var X=Rr.current,oe=(X&2)!==0;if(oe?(X=X&1|2,p.flags|=128):X&=1,ee(Rr,X),Bi(h,p,w,_),w=yn?pg:0,!oe&&h!==null&&(h.flags&128)!==0)e:for(h=p.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&KI(h,_,p);else if(h.tag===19)KI(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(k){case"forwards":for(_=p.child,k=null;_!==null;)h=_.alternate,h!==null&&lv(h)===null&&(k=_),_=_.sibling;_=k,_===null?(k=p.child,p.child=null):(k=_.sibling,_.sibling=null),i2(p,!1,k,_,O,w);break;case"backwards":case"unstable_legacy-backwards":for(_=null,k=p.child,p.child=null;k!==null;){if(h=k.alternate,h!==null&&lv(h)===null){p.child=k;break}h=k.sibling,k.sibling=_,_=k,k=h}i2(p,!0,_,null,O,w);break;case"together":i2(p,!1,null,null,void 0,w);break;default:p.memoizedState=null}return p.child}function Tl(h,p,_){if(h!==null&&(p.dependencies=h.dependencies),Yc|=p.lanes,(_&p.childLanes)===0)if(h!==null){if(bf(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,_=_l(h,h.pendingProps),p.child=_,_.return=p;h.sibling!==null;)h=h.sibling,_=_.sibling=_l(h,h.pendingProps),_.return=p;_.sibling=null}return p.child}function s2(h,p){return(h.lanes&p)!==0?!0:(h=h.dependencies,!!(h!==null&&ev(h)))}function Ute(h,p,_){switch(p.tag){case 3:Me(p,p.stateNode.containerInfo),Hc(p,Fr,h.memoizedState.cache),Md();break;case 27:case 5:ve(p);break;case 4:Me(p,p.stateNode.containerInfo);break;case 10:Hc(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,kM(p),null;break;case 13:var w=p.memoizedState;if(w!==null)return w.dehydrated!==null?(Wc(p),p.flags|=128,null):(_&p.child.childLanes)!==0?qI(h,p,_):(Wc(p),h=Tl(h,p,_),h!==null?h.sibling:null);Wc(p);break;case 19:var k=(h.flags&128)!==0;if(w=(_&p.childLanes)!==0,w||(bf(h,p,_,!1),w=(_&p.childLanes)!==0),k){if(w)return XI(h,p,_);p.flags|=128}if(k=p.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),ee(Rr,Rr.current),w)break;return null;case 22:return p.lanes=0,BI(h,p,_,p.pendingProps);case 24:Hc(p,Fr,h.memoizedState.cache)}return Tl(h,p,_)}function YI(h,p,_){if(h!==null)if(h.memoizedProps!==p.pendingProps)Br=!0;else{if(!s2(h,_)&&(p.flags&128)===0)return Br=!1,Ute(h,p,_);Br=(h.flags&131072)!==0}else Br=!1,yn&&(p.flags&1048576)!==0&&CL(p,pg,p.index);switch(p.lanes=0,p.tag){case 16:e:{var w=p.pendingProps;if(h=Nd(p.elementType),p.type=h,typeof h=="function")uM(h)?(w=Dd(h,w),p.tag=1,p=GI(null,p,h,w,_)):(p.tag=0,p=QM(null,p,h,w,_));else{if(h!=null){var k=h.$$typeof;if(k===A){p.tag=11,p=UI(null,p,h,w,_);break e}else if(k===C){p.tag=14,p=FI(null,p,h,w,_);break e}}throw p=R(h)||h,Error(r(306,p,""))}}return p;case 0:return QM(h,p,p.type,p.pendingProps,_);case 1:return w=p.type,k=Dd(w,p.pendingProps),GI(h,p,w,k,_);case 3:e:{if(Me(p,p.stateNode.containerInfo),h===null)throw Error(r(387));w=p.pendingProps;var O=p.memoizedState;k=O.element,MM(h,p),wg(p,w,null,_);var X=p.memoizedState;if(w=X.cache,Hc(p,Fr,w),w!==O.cache&&vM(p,[Fr],_,!0),_g(),w=X.element,O.isDehydrated)if(O={element:w,isDehydrated:!1,cache:X.cache},p.updateQueue.baseState=O,p.memoizedState=O,p.flags&256){p=WI(h,p,w,_);break e}else if(w!==k){k=Ea(Error(r(424)),p),mg(k),p=WI(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(ir=Na(h.firstChild),Fi=p,yn=!0,zc=null,Ta=!0,_=BL(p,null,w,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Md(),w===k){p=Tl(h,p,_);break e}Bi(h,p,w,_)}p=p.child}return p;case 26:return vv(h,p),h===null?(_=oU(p.type,null,p.pendingProps,null))?p.memoizedState=_:yn||(_=p.type,h=p.pendingProps,w=Lv(ue.current).createElement(_),w[xr]=p,w[kr]=h,Hi(w,_,h),Oe(w),p.stateNode=w):p.memoizedState=oU(p.type,h.memoizedProps,p.pendingProps,h.memoizedState),null;case 27:return ve(p),h===null&&yn&&(w=p.stateNode=iU(p.type,p.pendingProps,ue.current),Fi=p,Ta=!0,k=ir,tu(p.type)?(U2=k,ir=Na(w.firstChild)):ir=k),Bi(h,p,p.pendingProps.children,_),vv(h,p),h===null&&(p.flags|=4194304),p.child;case 5:return h===null&&yn&&((k=w=ir)&&(w=pne(w,p.type,p.pendingProps,Ta),w!==null?(p.stateNode=w,Fi=p,ir=Na(w.firstChild),Ta=!1,k=!0):k=!1),k||Bc(p)),ve(p),k=p.type,O=p.pendingProps,X=h!==null?h.memoizedProps:null,w=O.children,D2(k,O)?w=null:X!==null&&D2(k,X)&&(p.flags|=32),p.memoizedState!==null&&(k=RM(h,p,Nte,null,null,_),Hg._currentValue=k),vv(h,p),Bi(h,p,w,_),p.child;case 6:return h===null&&yn&&((h=_=ir)&&(_=mne(_,p.pendingProps,Ta),_!==null?(p.stateNode=_,Fi=p,ir=null,h=!0):h=!1),h||Bc(p)),null;case 13:return qI(h,p,_);case 4:return Me(p,p.stateNode.containerInfo),w=p.pendingProps,h===null?p.child=Pd(p,null,w,_):Bi(h,p,w,_),p.child;case 11:return UI(h,p,p.type,p.pendingProps,_);case 7:return Bi(h,p,p.pendingProps,_),p.child;case 8:return Bi(h,p,p.pendingProps.children,_),p.child;case 12:return Bi(h,p,p.pendingProps.children,_),p.child;case 10:return w=p.pendingProps,Hc(p,p.type,w.value),Bi(h,p,w.children,_),p.child;case 9:return k=p.type._context,w=p.pendingProps.children,Td(p),k=zi(k),w=w(k),p.flags|=1,Bi(h,p,w,_),p.child;case 14:return FI(h,p,p.type,p.pendingProps,_);case 15:return zI(h,p,p.type,p.pendingProps,_);case 19:return XI(h,p,_);case 31:return Ite(h,p,_);case 22:return BI(h,p,_,p.pendingProps);case 24:return Td(p),w=zi(Fr),h===null?(k=wM(),k===null&&(k=Xn,O=yM(),k.pooledCache=O,O.refCount++,O!==null&&(k.pooledCacheLanes|=_),k=O),p.memoizedState={parent:w,cache:k},EM(p),Hc(p,Fr,k)):((h.lanes&_)!==0&&(MM(h,p),wg(p,null,null,_),_g()),k=h.memoizedState,O=p.memoizedState,k.parent!==w?(k={parent:w,cache:w},p.memoizedState=k,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=k),Hc(p,Fr,w)):(w=O.cache,Hc(p,Fr,w),w!==k.cache&&vM(p,[Fr],_,!0))),Bi(h,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function Cl(h){h.flags|=4}function a2(h,p,_,w,k){if((p=(h.mode&32)!==0)&&(p=!1),p){if(h.flags|=16777216,(k&335544128)===k)if(h.stateNode.complete)h.flags|=8192;else if(S4())h.flags|=8192;else throw kd=iv,SM}else h.flags&=-16777217}function ZI(h,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!hU(p))if(S4())h.flags|=8192;else throw kd=iv,SM}function _v(h,p){p!==null&&(h.flags|=4),h.flags&16384&&(p=h.tag!==22?wt():536870912,h.lanes|=p,kf|=p)}function Cg(h,p){if(!yn)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 sr(h){var p=h.alternate!==null&&h.alternate.child===h.child,_=0,w=0;if(p)for(var k=h.child;k!==null;)_|=k.lanes|k.childLanes,w|=k.subtreeFlags&65011712,w|=k.flags&65011712,k.return=h,k=k.sibling;else for(k=h.child;k!==null;)_|=k.lanes|k.childLanes,w|=k.subtreeFlags,w|=k.flags,k.return=h,k=k.sibling;return h.subtreeFlags|=w,h.childLanes=_,p}function Fte(h,p,_){var w=p.pendingProps;switch(pM(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return sr(p),null;case 1:return sr(p),null;case 3:return _=p.stateNode,w=null,h!==null&&(w=h.memoizedState.cache),p.memoizedState.cache!==w&&(p.flags|=2048),El(Fr),se(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(xf(p)?Cl(p):h===null||h.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,gM())),sr(p),null;case 26:var k=p.type,O=p.memoizedState;return h===null?(Cl(p),O!==null?(sr(p),ZI(p,O)):(sr(p),a2(p,k,null,w,_))):O?O!==h.memoizedState?(Cl(p),sr(p),ZI(p,O)):(sr(p),p.flags&=-16777217):(h=h.memoizedProps,h!==w&&Cl(p),sr(p),a2(p,k,h,w,_)),null;case 27:if(je(p),_=ue.current,k=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==w&&Cl(p);else{if(!w){if(p.stateNode===null)throw Error(r(166));return sr(p),null}h=ae.current,xf(p)?kL(p):(h=iU(k,w,_),p.stateNode=h,Cl(p))}return sr(p),null;case 5:if(je(p),k=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==w&&Cl(p);else{if(!w){if(p.stateNode===null)throw Error(r(166));return sr(p),null}if(O=ae.current,xf(p))kL(p);else{var X=Lv(ue.current);switch(O){case 1:O=X.createElementNS("http://www.w3.org/2000/svg",k);break;case 2:O=X.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;default:switch(k){case"svg":O=X.createElementNS("http://www.w3.org/2000/svg",k);break;case"math":O=X.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;case"script":O=X.createElement("div"),O.innerHTML="<script><\/script>",O=O.removeChild(O.firstChild);break;case"select":O=typeof w.is=="string"?X.createElement("select",{is:w.is}):X.createElement("select"),w.multiple?O.multiple=!0:w.size&&(O.size=w.size);break;default:O=typeof w.is=="string"?X.createElement(k,{is:w.is}):X.createElement(k)}}O[xr]=p,O[kr]=w;e:for(X=p.child;X!==null;){if(X.tag===5||X.tag===6)O.appendChild(X.stateNode);else if(X.tag!==4&&X.tag!==27&&X.child!==null){X.child.return=X,X=X.child;continue}if(X===p)break e;for(;X.sibling===null;){if(X.return===null||X.return===p)break e;X=X.return}X.sibling.return=X.return,X=X.sibling}p.stateNode=O;e:switch(Hi(O,k,w),k){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}w&&Cl(p)}}return sr(p),a2(p,p.type,h===null?null:h.memoizedProps,p.pendingProps,_),null;case 6:if(h&&p.stateNode!=null)h.memoizedProps!==w&&Cl(p);else{if(typeof w!="string"&&p.stateNode===null)throw Error(r(166));if(h=ue.current,xf(p)){if(h=p.stateNode,_=p.memoizedProps,w=null,k=Fi,k!==null)switch(k.tag){case 27:case 5:w=k.memoizedProps}h[xr]=p,h=!!(h.nodeValue===_||w!==null&&w.suppressHydrationWarning===!0||q4(h.nodeValue,_)),h||Bc(p,!0)}else h=Lv(h).createTextNode(w),h[xr]=p,p.stateNode=h}return sr(p),null;case 31:if(_=p.memoizedState,h===null||h.memoizedState!==null){if(w=xf(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[xr]=p}else Md(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;sr(p),h=!1}else _=gM(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return p.flags&256?(na(p),p):(na(p),null);if((p.flags&128)!==0)throw Error(r(558))}return sr(p),null;case 13:if(w=p.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(k=xf(p),w!==null&&w.dehydrated!==null){if(h===null){if(!k)throw Error(r(318));if(k=p.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(r(317));k[xr]=p}else Md(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;sr(p),k=!1}else k=gM(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=k),k=!0;if(!k)return p.flags&256?(na(p),p):(na(p),null)}return na(p),(p.flags&128)!==0?(p.lanes=_,p):(_=w!==null,h=h!==null&&h.memoizedState!==null,_&&(w=p.child,k=null,w.alternate!==null&&w.alternate.memoizedState!==null&&w.alternate.memoizedState.cachePool!==null&&(k=w.alternate.memoizedState.cachePool.pool),O=null,w.memoizedState!==null&&w.memoizedState.cachePool!==null&&(O=w.memoizedState.cachePool.pool),O!==k&&(w.flags|=2048)),_!==h&&_&&(p.child.flags|=8192),_v(p,p.updateQueue),sr(p),null);case 4:return se(),h===null&&C2(p.stateNode.containerInfo),sr(p),null;case 10:return El(p.type),sr(p),null;case 19:if($(Rr),w=p.memoizedState,w===null)return sr(p),null;if(k=(p.flags&128)!==0,O=w.rendering,O===null)if(k)Cg(w,!1);else{if(Mr!==0||h!==null&&(h.flags&128)!==0)for(h=p.child;h!==null;){if(O=lv(h),O!==null){for(p.flags|=128,Cg(w,!1),h=O.updateQueue,p.updateQueue=h,_v(p,h),p.subtreeFlags=0,h=_,_=p.child;_!==null;)ML(_,h),_=_.sibling;return ee(Rr,Rr.current&1|2),yn&&wl(p,w.treeForkCount),p.child}h=h.sibling}w.tail!==null&&j()>Av&&(p.flags|=128,k=!0,Cg(w,!1),p.lanes=4194304)}else{if(!k)if(h=lv(O),h!==null){if(p.flags|=128,k=!0,h=h.updateQueue,p.updateQueue=h,_v(p,h),Cg(w,!0),w.tail===null&&w.tailMode==="hidden"&&!O.alternate&&!yn)return sr(p),null}else 2*j()-w.renderingStartTime>Av&&_!==536870912&&(p.flags|=128,k=!0,Cg(w,!1),p.lanes=4194304);w.isBackwards?(O.sibling=p.child,p.child=O):(h=w.last,h!==null?h.sibling=O:p.child=O,w.last=O)}return w.tail!==null?(h=w.tail,w.rendering=h,w.tail=h.sibling,w.renderingStartTime=j(),h.sibling=null,_=Rr.current,ee(Rr,k?_&1|2:_&1),yn&&wl(p,w.treeForkCount),h):(sr(p),null);case 22:case 23:return na(p),NM(),w=p.memoizedState!==null,h!==null?h.memoizedState!==null!==w&&(p.flags|=8192):w&&(p.flags|=8192),w?(_&536870912)!==0&&(p.flags&128)===0&&(sr(p),p.subtreeFlags&6&&(p.flags|=8192)):sr(p),_=p.updateQueue,_!==null&&_v(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&&$(Cd),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),El(Fr),sr(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function zte(h,p){switch(pM(p),p.tag){case 1:return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 3:return El(Fr),se(),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(na(p),p.alternate===null)throw Error(r(340));Md()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 13:if(na(p),h=p.memoizedState,h!==null&&h.dehydrated!==null){if(p.alternate===null)throw Error(r(340));Md()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 19:return $(Rr),null;case 4:return se(),null;case 10:return El(p.type),null;case 22:case 23:return na(p),NM(),h!==null&&$(Cd),h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 24:return El(Fr),null;case 25:return null;default:return null}}function QI(h,p){switch(pM(p),p.tag){case 3:El(Fr),se();break;case 26:case 27:case 5:je(p);break;case 4:se();break;case 31:p.memoizedState!==null&&na(p);break;case 13:na(p);break;case 19:$(Rr);break;case 10:El(p.type);break;case 22:case 23:na(p),NM(),h!==null&&$(Cd);break;case 24:El(Fr)}}function Ng(h,p){try{var _=p.updateQueue,w=_!==null?_.lastEffect:null;if(w!==null){var k=w.next;_=k;do{if((_.tag&h)===h){w=void 0;var O=_.create,X=_.inst;w=O(),X.destroy=w}_=_.next}while(_!==k)}}catch(oe){jn(p,p.return,oe)}}function Kc(h,p,_){try{var w=p.updateQueue,k=w!==null?w.lastEffect:null;if(k!==null){var O=k.next;w=O;do{if((w.tag&h)===h){var X=w.inst,oe=X.destroy;if(oe!==void 0){X.destroy=void 0,k=p;var Ee=_,qe=oe;try{qe()}catch(lt){jn(k,Ee,lt)}}}w=w.next}while(w!==O)}}catch(lt){jn(p,p.return,lt)}}function JI(h){var p=h.updateQueue;if(p!==null){var _=h.stateNode;try{$L(p,_)}catch(w){jn(h,h.return,w)}}}function e4(h,p,_){_.props=Dd(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(w){jn(h,p,w)}}function kg(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(k){jn(h,p,k)}}function Vo(h,p){var _=h.ref,w=h.refCleanup;if(_!==null)if(typeof w=="function")try{w()}catch(k){jn(h,p,k)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(k){jn(h,p,k)}else _.current=null}function t4(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(k){jn(h,h.return,k)}}function o2(h,p,_){try{var w=h.stateNode;lne(w,h.type,_,p),w[kr]=p}catch(k){jn(h,h.return,k)}}function n4(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&tu(h.type)||h.tag===4}function l2(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||n4(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&&tu(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function c2(h,p,_){var w=h.tag;if(w===5||w===6)h=h.stateNode,p?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,p):(p=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,p.appendChild(h),_=_._reactRootContainer,_!=null||p.onclick!==null||(p.onclick=vl));else if(w!==4&&(w===27&&tu(h.type)&&(_=h.stateNode,p=null),h=h.child,h!==null))for(c2(h,p,_),h=h.sibling;h!==null;)c2(h,p,_),h=h.sibling}function wv(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&&tu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(wv(h,p,_),h=h.sibling;h!==null;)wv(h,p,_),h=h.sibling}function r4(h){var p=h.stateNode,_=h.memoizedProps;try{for(var w=h.type,k=p.attributes;k.length;)p.removeAttributeNode(k[0]);Hi(p,w,_),p[xr]=h,p[kr]=_}catch(O){jn(h,h.return,O)}}var Nl=!1,Hr=!1,u2=!1,i4=typeof WeakSet=="function"?WeakSet:Set,Mi=null;function Bte(h,p){if(h=h.containerInfo,P2=$v,h=gL(h),rM(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 k=w.anchorOffset,O=w.focusNode;w=w.focusOffset;try{_.nodeType,O.nodeType}catch{_=null;break e}var X=0,oe=-1,Ee=-1,qe=0,lt=0,dt=h,Qe=null;t:for(;;){for(var it;dt!==_||k!==0&&dt.nodeType!==3||(oe=X+k),dt!==O||w!==0&&dt.nodeType!==3||(Ee=X+w),dt.nodeType===3&&(X+=dt.nodeValue.length),(it=dt.firstChild)!==null;)Qe=dt,dt=it;for(;;){if(dt===h)break t;if(Qe===_&&++qe===k&&(oe=X),Qe===O&&++lt===w&&(Ee=X),(it=dt.nextSibling)!==null)break;dt=Qe,Qe=dt.parentNode}dt=it}_=oe===-1||Ee===-1?null:{start:oe,end:Ee}}else _=null}_=_||{start:0,end:0}}else _=null;for(R2={focusedElem:h,selectionRange:_},$v=!1,Mi=p;Mi!==null;)if(p=Mi,h=p.child,(p.subtreeFlags&1028)!==0&&h!==null)h.return=p,Mi=h;else for(;Mi!==null;){switch(p=Mi,O=p.alternate,h=p.flags,p.tag){case 0:if((h&4)!==0&&(h=p.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)k=h[_],k.ref.impl=k.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&O!==null){h=void 0,_=p,k=O.memoizedProps,O=O.memoizedState,w=_.stateNode;try{var Rt=Dd(_.type,k);h=w.getSnapshotBeforeUpdate(Rt,O),w.__reactInternalSnapshotBeforeUpdate=h}catch(Vt){jn(_,_.return,Vt)}}break;case 3:if((h&1024)!==0){if(h=p.stateNode.containerInfo,_=h.nodeType,_===9)j2(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":j2(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,Mi=h;break}Mi=p.return}}function s4(h,p,_){var w=_.flags;switch(_.tag){case 0:case 11:case 15:Pl(h,_),w&4&&Ng(5,_);break;case 1:if(Pl(h,_),w&4)if(h=_.stateNode,p===null)try{h.componentDidMount()}catch(X){jn(_,_.return,X)}else{var k=Dd(_.type,p.memoizedProps);p=p.memoizedState;try{h.componentDidUpdate(k,p,h.__reactInternalSnapshotBeforeUpdate)}catch(X){jn(_,_.return,X)}}w&64&&JI(_),w&512&&kg(_,_.return);break;case 3:if(Pl(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{$L(h,p)}catch(X){jn(_,_.return,X)}}break;case 27:p===null&&w&4&&r4(_);case 26:case 5:Pl(h,_),p===null&&w&4&&t4(_),w&512&&kg(_,_.return);break;case 12:Pl(h,_);break;case 31:Pl(h,_),w&4&&l4(h,_);break;case 13:Pl(h,_),w&4&&c4(h,_),w&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Yte.bind(null,_),gne(h,_))));break;case 22:if(w=_.memoizedState!==null||Nl,!w){p=p!==null&&p.memoizedState!==null||Hr,k=Nl;var O=Hr;Nl=w,(Hr=p)&&!O?Rl(h,_,(_.subtreeFlags&8772)!==0):Pl(h,_),Nl=k,Hr=O}break;case 30:break;default:Pl(h,_)}}function a4(h){var p=h.alternate;p!==null&&(h.alternate=null,a4(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 dr=null,Rs=!1;function kl(h,p,_){for(_=_.child;_!==null;)o4(h,p,_),_=_.sibling}function o4(h,p,_){if(ce&&typeof ce.onCommitFiberUnmount=="function")try{ce.onCommitFiberUnmount(Ve,_)}catch{}switch(_.tag){case 26:Hr||Vo(_,p),kl(h,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Hr||Vo(_,p);var w=dr,k=Rs;tu(_.type)&&(dr=_.stateNode,Rs=!1),kl(h,p,_),Fg(_.stateNode),dr=w,Rs=k;break;case 5:Hr||Vo(_,p);case 6:if(w=dr,k=Rs,dr=null,kl(h,p,_),dr=w,Rs=k,dr!==null)if(Rs)try{(dr.nodeType===9?dr.body:dr.nodeName==="HTML"?dr.ownerDocument.body:dr).removeChild(_.stateNode)}catch(O){jn(_,p,O)}else try{dr.removeChild(_.stateNode)}catch(O){jn(_,p,O)}break;case 18:dr!==null&&(Rs?(h=dr,J4(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Uf(h)):J4(dr,_.stateNode));break;case 4:w=dr,k=Rs,dr=_.stateNode.containerInfo,Rs=!0,kl(h,p,_),dr=w,Rs=k;break;case 0:case 11:case 14:case 15:Kc(2,_,p),Hr||Kc(4,_,p),kl(h,p,_);break;case 1:Hr||(Vo(_,p),w=_.stateNode,typeof w.componentWillUnmount=="function"&&e4(_,p,w)),kl(h,p,_);break;case 21:kl(h,p,_);break;case 22:Hr=(w=Hr)||_.memoizedState!==null,kl(h,p,_),Hr=w;break;default:kl(h,p,_)}}function l4(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Uf(h)}catch(_){jn(p,p.return,_)}}}function c4(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Uf(h)}catch(_){jn(p,p.return,_)}}function Hte(h){switch(h.tag){case 31:case 13:case 19:var p=h.stateNode;return p===null&&(p=h.stateNode=new i4),p;case 22:return h=h.stateNode,p=h._retryCache,p===null&&(p=h._retryCache=new i4),p;default:throw Error(r(435,h.tag))}}function Sv(h,p){var _=Hte(h);p.forEach(function(w){if(!_.has(w)){_.add(w);var k=Zte.bind(null,h,w);w.then(k,k)}})}function Ds(h,p){var _=p.deletions;if(_!==null)for(var w=0;w<_.length;w++){var k=_[w],O=h,X=p,oe=X;e:for(;oe!==null;){switch(oe.tag){case 27:if(tu(oe.type)){dr=oe.stateNode,Rs=!1;break e}break;case 5:dr=oe.stateNode,Rs=!1;break e;case 3:case 4:dr=oe.stateNode.containerInfo,Rs=!0;break e}oe=oe.return}if(dr===null)throw Error(r(160));o4(O,X,k),dr=null,Rs=!1,O=k.alternate,O!==null&&(O.return=null),k.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)u4(p,h),p=p.sibling}var fo=null;function u4(h,p){var _=h.alternate,w=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Ds(p,h),Os(h),w&4&&(Kc(3,h,h.return),Ng(3,h),Kc(5,h,h.return));break;case 1:Ds(p,h),Os(h),w&512&&(Hr||_===null||Vo(_,_.return)),w&64&&Nl&&(h=h.updateQueue,h!==null&&(w=h.callbacks,w!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?w:_.concat(w))));break;case 26:var k=fo;if(Ds(p,h),Os(h),w&512&&(Hr||_===null||Vo(_,_.return)),w&4){var O=_!==null?_.memoizedState:null;if(w=h.memoizedState,_===null)if(w===null)if(h.stateNode===null){e:{w=h.type,_=h.memoizedProps,k=k.ownerDocument||k;t:switch(w){case"title":O=k.getElementsByTagName("title")[0],(!O||O[rt]||O[xr]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=k.createElement(w),k.head.insertBefore(O,k.querySelector("head > title"))),Hi(O,w,_),O[xr]=h,Oe(O),w=O;break e;case"link":var X=uU("link","href",k).get(w+(_.href||""));if(X){for(var oe=0;oe<X.length;oe++)if(O=X[oe],O.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&O.getAttribute("rel")===(_.rel==null?null:_.rel)&&O.getAttribute("title")===(_.title==null?null:_.title)&&O.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){X.splice(oe,1);break t}}O=k.createElement(w),Hi(O,w,_),k.head.appendChild(O);break;case"meta":if(X=uU("meta","content",k).get(w+(_.content||""))){for(oe=0;oe<X.length;oe++)if(O=X[oe],O.getAttribute("content")===(_.content==null?null:""+_.content)&&O.getAttribute("name")===(_.name==null?null:_.name)&&O.getAttribute("property")===(_.property==null?null:_.property)&&O.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&O.getAttribute("charset")===(_.charSet==null?null:_.charSet)){X.splice(oe,1);break t}}O=k.createElement(w),Hi(O,w,_),k.head.appendChild(O);break;default:throw Error(r(468,w))}O[xr]=h,Oe(O),w=O}h.stateNode=w}else dU(k,h.type,h.stateNode);else h.stateNode=cU(k,w,h.memoizedProps);else O!==w?(O===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):O.count--,w===null?dU(k,h.type,h.stateNode):cU(k,w,h.memoizedProps)):w===null&&h.stateNode!==null&&o2(h,h.memoizedProps,_.memoizedProps)}break;case 27:Ds(p,h),Os(h),w&512&&(Hr||_===null||Vo(_,_.return)),_!==null&&w&4&&o2(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Ds(p,h),Os(h),w&512&&(Hr||_===null||Vo(_,_.return)),h.flags&32){k=h.stateNode;try{Bo(k,"")}catch(Rt){jn(h,h.return,Rt)}}w&4&&h.stateNode!=null&&(k=h.memoizedProps,o2(h,k,_!==null?_.memoizedProps:k)),w&1024&&(u2=!0);break;case 6:if(Ds(p,h),Os(h),w&4){if(h.stateNode===null)throw Error(r(162));w=h.memoizedProps,_=h.stateNode;try{_.nodeValue=w}catch(Rt){jn(h,h.return,Rt)}}break;case 3:if(Fv=null,k=fo,fo=Iv(p.containerInfo),Ds(p,h),fo=k,Os(h),w&4&&_!==null&&_.memoizedState.isDehydrated)try{Uf(p.containerInfo)}catch(Rt){jn(h,h.return,Rt)}u2&&(u2=!1,d4(h));break;case 4:w=fo,fo=Iv(h.stateNode.containerInfo),Ds(p,h),Os(h),fo=w;break;case 12:Ds(p,h),Os(h);break;case 31:Ds(p,h),Os(h),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Sv(h,w)));break;case 13:Ds(p,h),Os(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(Mv=j()),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Sv(h,w)));break;case 22:k=h.memoizedState!==null;var Ee=_!==null&&_.memoizedState!==null,qe=Nl,lt=Hr;if(Nl=qe||k,Hr=lt||Ee,Ds(p,h),Hr=lt,Nl=qe,Os(h),w&8192)e:for(p=h.stateNode,p._visibility=k?p._visibility&-2:p._visibility|1,k&&(_===null||Ee||Nl||Hr||Od(h)),_=null,p=h;;){if(p.tag===5||p.tag===26){if(_===null){Ee=_=p;try{if(O=Ee.stateNode,k)X=O.style,typeof X.setProperty=="function"?X.setProperty("display","none","important"):X.display="none";else{oe=Ee.stateNode;var dt=Ee.memoizedProps.style,Qe=dt!=null&&dt.hasOwnProperty("display")?dt.display:null;oe.style.display=Qe==null||typeof Qe=="boolean"?"":(""+Qe).trim()}}catch(Rt){jn(Ee,Ee.return,Rt)}}}else if(p.tag===6){if(_===null){Ee=p;try{Ee.stateNode.nodeValue=k?"":Ee.memoizedProps}catch(Rt){jn(Ee,Ee.return,Rt)}}}else if(p.tag===18){if(_===null){Ee=p;try{var it=Ee.stateNode;k?eU(it,!0):eU(Ee.stateNode,!1)}catch(Rt){jn(Ee,Ee.return,Rt)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===h)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break e;for(;p.sibling===null;){if(p.return===null||p.return===h)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}w&4&&(w=h.updateQueue,w!==null&&(_=w.retryQueue,_!==null&&(w.retryQueue=null,Sv(h,_))));break;case 19:Ds(p,h),Os(h),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Sv(h,w)));break;case 30:break;case 21:break;default:Ds(p,h),Os(h)}}function Os(h){var p=h.flags;if(p&2){try{for(var _,w=h.return;w!==null;){if(n4(w)){_=w;break}w=w.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var k=_.stateNode,O=l2(h);wv(h,O,k);break;case 5:var X=_.stateNode;_.flags&32&&(Bo(X,""),_.flags&=-33);var oe=l2(h);wv(h,oe,X);break;case 3:case 4:var Ee=_.stateNode.containerInfo,qe=l2(h);c2(h,qe,Ee);break;default:throw Error(r(161))}}catch(lt){jn(h,h.return,lt)}h.flags&=-3}p&4096&&(h.flags&=-4097)}function d4(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var p=h;d4(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),h=h.sibling}}function Pl(h,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)s4(h,p.alternate,p),p=p.sibling}function Od(h){for(h=h.child;h!==null;){var p=h;switch(p.tag){case 0:case 11:case 14:case 15:Kc(4,p,p.return),Od(p);break;case 1:Vo(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&e4(p,p.return,_),Od(p);break;case 27:Fg(p.stateNode);case 26:case 5:Vo(p,p.return),Od(p);break;case 22:p.memoizedState===null&&Od(p);break;case 30:Od(p);break;default:Od(p)}h=h.sibling}}function Rl(h,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var w=p.alternate,k=h,O=p,X=O.flags;switch(O.tag){case 0:case 11:case 15:Rl(k,O,_),Ng(4,O);break;case 1:if(Rl(k,O,_),w=O,k=w.stateNode,typeof k.componentDidMount=="function")try{k.componentDidMount()}catch(qe){jn(w,w.return,qe)}if(w=O,k=w.updateQueue,k!==null){var oe=w.stateNode;try{var Ee=k.shared.hiddenCallbacks;if(Ee!==null)for(k.shared.hiddenCallbacks=null,k=0;k<Ee.length;k++)HL(Ee[k],oe)}catch(qe){jn(w,w.return,qe)}}_&&X&64&&JI(O),kg(O,O.return);break;case 27:r4(O);case 26:case 5:Rl(k,O,_),_&&w===null&&X&4&&t4(O),kg(O,O.return);break;case 12:Rl(k,O,_);break;case 31:Rl(k,O,_),_&&X&4&&l4(k,O);break;case 13:Rl(k,O,_),_&&X&4&&c4(k,O);break;case 22:O.memoizedState===null&&Rl(k,O,_),kg(O,O.return);break;case 30:break;default:Rl(k,O,_)}p=p.sibling}}function d2(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&&gg(_))}function h2(h,p){h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&gg(h))}function po(h,p,_,w){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)h4(h,p,_,w),p=p.sibling}function h4(h,p,_,w){var k=p.flags;switch(p.tag){case 0:case 11:case 15:po(h,p,_,w),k&2048&&Ng(9,p);break;case 1:po(h,p,_,w);break;case 3:po(h,p,_,w),k&2048&&(h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&gg(h)));break;case 12:if(k&2048){po(h,p,_,w),h=p.stateNode;try{var O=p.memoizedProps,X=O.id,oe=O.onPostCommit;typeof oe=="function"&&oe(X,p.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ee){jn(p,p.return,Ee)}}else po(h,p,_,w);break;case 31:po(h,p,_,w);break;case 13:po(h,p,_,w);break;case 23:break;case 22:O=p.stateNode,X=p.alternate,p.memoizedState!==null?O._visibility&2?po(h,p,_,w):Pg(h,p):O._visibility&2?po(h,p,_,w):(O._visibility|=2,Tf(h,p,_,w,(p.subtreeFlags&10256)!==0||!1)),k&2048&&d2(X,p);break;case 24:po(h,p,_,w),k&2048&&h2(p.alternate,p);break;default:po(h,p,_,w)}}function Tf(h,p,_,w,k){for(k=k&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var O=h,X=p,oe=_,Ee=w,qe=X.flags;switch(X.tag){case 0:case 11:case 15:Tf(O,X,oe,Ee,k),Ng(8,X);break;case 23:break;case 22:var lt=X.stateNode;X.memoizedState!==null?lt._visibility&2?Tf(O,X,oe,Ee,k):Pg(O,X):(lt._visibility|=2,Tf(O,X,oe,Ee,k)),k&&qe&2048&&d2(X.alternate,X);break;case 24:Tf(O,X,oe,Ee,k),k&&qe&2048&&h2(X.alternate,X);break;default:Tf(O,X,oe,Ee,k)}p=p.sibling}}function Pg(h,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=h,w=p,k=w.flags;switch(w.tag){case 22:Pg(_,w),k&2048&&d2(w.alternate,w);break;case 24:Pg(_,w),k&2048&&h2(w.alternate,w);break;default:Pg(_,w)}p=p.sibling}}var Rg=8192;function Cf(h,p,_){if(h.subtreeFlags&Rg)for(h=h.child;h!==null;)f4(h,p,_),h=h.sibling}function f4(h,p,_){switch(h.tag){case 26:Cf(h,p,_),h.flags&Rg&&h.memoizedState!==null&&Cne(_,fo,h.memoizedState,h.memoizedProps);break;case 5:Cf(h,p,_);break;case 3:case 4:var w=fo;fo=Iv(h.stateNode.containerInfo),Cf(h,p,_),fo=w;break;case 22:h.memoizedState===null&&(w=h.alternate,w!==null&&w.memoizedState!==null?(w=Rg,Rg=16777216,Cf(h,p,_),Rg=w):Cf(h,p,_));break;default:Cf(h,p,_)}}function p4(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 Dg(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var w=p[_];Mi=w,g4(w,h)}p4(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)m4(h),h=h.sibling}function m4(h){switch(h.tag){case 0:case 11:case 15:Dg(h),h.flags&2048&&Kc(9,h,h.return);break;case 3:Dg(h);break;case 12:Dg(h);break;case 22:var p=h.stateNode;h.memoizedState!==null&&p._visibility&2&&(h.return===null||h.return.tag!==13)?(p._visibility&=-3,Ev(h)):Dg(h);break;default:Dg(h)}}function Ev(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var w=p[_];Mi=w,g4(w,h)}p4(h)}for(h=h.child;h!==null;){switch(p=h,p.tag){case 0:case 11:case 15:Kc(8,p,p.return),Ev(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,Ev(p));break;default:Ev(p)}h=h.sibling}}function g4(h,p){for(;Mi!==null;){var _=Mi;switch(_.tag){case 0:case 11:case 15:Kc(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:gg(_.memoizedState.cache)}if(w=_.child,w!==null)w.return=_,Mi=w;else e:for(_=h;Mi!==null;){w=Mi;var k=w.sibling,O=w.return;if(a4(w),w===_){Mi=null;break e}if(k!==null){k.return=O,Mi=k;break e}Mi=O}}}var $te={getCacheForType:function(h){var p=zi(Fr),_=p.data.get(h);return _===void 0&&(_=h(),p.data.set(h,_)),_},cacheSignal:function(){return zi(Fr).controller.signal}},Vte=typeof WeakMap=="function"?WeakMap:Map,Nn=0,Xn=null,fn=null,xn=0,On=0,ra=null,Xc=!1,Nf=!1,f2=!1,Dl=0,Mr=0,Yc=0,jd=0,p2=0,ia=0,kf=0,Og=null,js=null,m2=!1,Mv=0,x4=0,Av=1/0,Tv=null,Zc=null,oi=0,Qc=null,Pf=null,Ol=0,g2=0,x2=null,b4=null,jg=0,b2=null;function sa(){return(Nn&2)!==0&&xn!==0?xn&-xn:K.T!==null?E2():Ii()}function v4(){if(ia===0)if((xn&536870912)===0||yn){var h=pe;pe<<=1,(pe&3932160)===0&&(pe=262144),ia=h}else ia=536870912;return h=ta.current,h!==null&&(h.flags|=32),ia}function Ls(h,p,_){(h===Xn&&(On===2||On===9)||h.cancelPendingCommit!==null)&&(Rf(h,0),Jc(h,xn,ia,!1)),cn(h,_),((Nn&2)===0||h!==Xn)&&(h===Xn&&((Nn&2)===0&&(jd|=_),Mr===4&&Jc(h,xn,ia,!1)),Go(h))}function y4(h,p,_){if((Nn&6)!==0)throw Error(r(327));var w=!_&&(p&127)===0&&(p&h.expiredLanes)===0||He(h,p),k=w?qte(h,p):y2(h,p,!0),O=w;do{if(k===0){Nf&&!w&&Jc(h,p,0,!1);break}else{if(_=h.current.alternate,O&&!Gte(_)){k=y2(h,p,!1),O=!1;continue}if(k===2){if(O=p,h.errorRecoveryDisabledLanes&O)var X=0;else X=h.pendingLanes&-536870913,X=X!==0?X:X&536870912?536870912:0;if(X!==0){p=X;e:{var oe=h;k=Og;var Ee=oe.current.memoizedState.isDehydrated;if(Ee&&(Rf(oe,X).flags|=256),X=y2(oe,X,!1),X!==2){if(f2&&!Ee){oe.errorRecoveryDisabledLanes|=O,jd|=O,k=4;break e}O=js,js=k,O!==null&&(js===null?js=O:js.push.apply(js,O))}k=X}if(O=!1,k!==2)continue}}if(k===1){Rf(h,0),Jc(h,p,0,!0);break}e:{switch(w=h,O=k,O){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:Jc(w,p,ia,!Xc);break e;case 2:js=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(k=Mv+300-j(),10<k)){if(Jc(w,p,ia,!Xc),ye(w,0,!0)!==0)break e;Ol=p,w.timeoutHandle=Z4(_4.bind(null,w,_,js,Tv,m2,p,ia,jd,kf,Xc,O,"Throttled",-0,0),k);break e}_4(w,_,js,Tv,m2,p,ia,jd,kf,Xc,O,null,-0,0)}}break}while(!0);Go(h)}function _4(h,p,_,w,k,O,X,oe,Ee,qe,lt,dt,Qe,it){if(h.timeoutHandle=-1,dt=p.subtreeFlags,dt&8192||(dt&16785408)===16785408){dt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:vl},f4(p,O,dt);var Rt=(O&62914560)===O?Mv-j():(O&4194048)===O?x4-j():0;if(Rt=Nne(dt,Rt),Rt!==null){Ol=O,h.cancelPendingCommit=Rt(N4.bind(null,h,p,O,_,w,k,X,oe,Ee,lt,dt,null,Qe,it)),Jc(h,O,X,!qe);return}}N4(h,p,O,_,w,k,X,oe,Ee)}function Gte(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 k=_[w],O=k.getSnapshot;k=k.value;try{if(!Js(O(),k))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 Jc(h,p,_,w){p&=~p2,p&=~jd,h.suspendedLanes|=p,h.pingedLanes&=~p,w&&(h.warmLanes|=p),w=h.expirationTimes;for(var k=p;0<k;){var O=31-$e(k),X=1<<O;w[O]=-1,k&=~X}_!==0&&Rn(h,_,p)}function Cv(){return(Nn&6)===0?(Lg(0),!1):!0}function v2(){if(fn!==null){if(On===0)var h=fn.return;else h=fn,Sl=Ad=null,jM(h),wf=null,bg=0,h=fn;for(;h!==null;)QI(h.alternate,h),h=h.return;fn=null}}function Rf(h,p){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,dne(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Ol=0,v2(),Xn=h,fn=_=_l(h.current,null),xn=p,On=0,ra=null,Xc=!1,Nf=He(h,p),f2=!1,kf=ia=p2=jd=Yc=Mr=0,js=Og=null,m2=!1,(p&8)!==0&&(p|=p&32);var w=h.entangledLanes;if(w!==0)for(h=h.entanglements,w&=p;0<w;){var k=31-$e(w),O=1<<k;p|=h[k],w&=~O}return Dl=p,Xb(),_}function w4(h,p){en=null,K.H=Ag,p===_f||p===rv?(p=UL(),On=3):p===SM?(p=UL(),On=4):On=p===ZM?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,ra=p,fn===null&&(Mr=1,xv(h,Ea(p,h.current)))}function S4(){var h=ta.current;return h===null?!0:(xn&4194048)===xn?Ca===null:(xn&62914560)===xn||(xn&536870912)!==0?h===Ca:!1}function E4(){var h=K.H;return K.H=Ag,h===null?Ag:h}function M4(){var h=K.A;return K.A=$te,h}function Nv(){Mr=4,Xc||(xn&4194048)!==xn&&ta.current!==null||(Nf=!0),(Yc&134217727)===0&&(jd&134217727)===0||Xn===null||Jc(Xn,xn,ia,!1)}function y2(h,p,_){var w=Nn;Nn|=2;var k=E4(),O=M4();(Xn!==h||xn!==p)&&(Tv=null,Rf(h,p)),p=!1;var X=Mr;e:do try{if(On!==0&&fn!==null){var oe=fn,Ee=ra;switch(On){case 8:v2(),X=6;break e;case 3:case 2:case 9:case 6:ta.current===null&&(p=!0);var qe=On;if(On=0,ra=null,Df(h,oe,Ee,qe),_&&Nf){X=0;break e}break;default:qe=On,On=0,ra=null,Df(h,oe,Ee,qe)}}Wte(),X=Mr;break}catch(lt){w4(h,lt)}while(!0);return p&&h.shellSuspendCounter++,Sl=Ad=null,Nn=w,K.H=k,K.A=O,fn===null&&(Xn=null,xn=0,Xb()),X}function Wte(){for(;fn!==null;)A4(fn)}function qte(h,p){var _=Nn;Nn|=2;var w=E4(),k=M4();Xn!==h||xn!==p?(Tv=null,Av=j()+500,Rf(h,p)):Nf=He(h,p);e:do try{if(On!==0&&fn!==null){p=fn;var O=ra;t:switch(On){case 1:On=0,ra=null,Df(h,p,O,1);break;case 2:case 9:if(LL(O)){On=0,ra=null,T4(p);break}p=function(){On!==2&&On!==9||Xn!==h||(On=7),Go(h)},O.then(p,p);break e;case 3:On=7;break e;case 4:On=5;break e;case 7:LL(O)?(On=0,ra=null,T4(p)):(On=0,ra=null,Df(h,p,O,7));break;case 5:var X=null;switch(fn.tag){case 26:X=fn.memoizedState;case 5:case 27:var oe=fn;if(X?hU(X):oe.stateNode.complete){On=0,ra=null;var Ee=oe.sibling;if(Ee!==null)fn=Ee;else{var qe=oe.return;qe!==null?(fn=qe,kv(qe)):fn=null}break t}}On=0,ra=null,Df(h,p,O,5);break;case 6:On=0,ra=null,Df(h,p,O,6);break;case 8:v2(),Mr=6;break e;default:throw Error(r(462))}}Kte();break}catch(lt){w4(h,lt)}while(!0);return Sl=Ad=null,K.H=w,K.A=k,Nn=_,fn!==null?0:(Xn=null,xn=0,Xb(),Mr)}function Kte(){for(;fn!==null&&!we();)A4(fn)}function A4(h){var p=YI(h.alternate,h,Dl);h.memoizedProps=h.pendingProps,p===null?kv(h):fn=p}function T4(h){var p=h,_=p.alternate;switch(p.tag){case 15:case 0:p=VI(_,p,p.pendingProps,p.type,void 0,xn);break;case 11:p=VI(_,p,p.pendingProps,p.type.render,p.ref,xn);break;case 5:jM(p);default:QI(_,p),p=fn=ML(p,Dl),p=YI(_,p,Dl)}h.memoizedProps=h.pendingProps,p===null?kv(h):fn=p}function Df(h,p,_,w){Sl=Ad=null,jM(p),wf=null,bg=0;var k=p.return;try{if(Lte(h,k,p,_,xn)){Mr=1,xv(h,Ea(_,h.current)),fn=null;return}}catch(O){if(k!==null)throw fn=k,O;Mr=1,xv(h,Ea(_,h.current)),fn=null;return}p.flags&32768?(yn||w===1?h=!0:Nf||(xn&536870912)!==0?h=!1:(Xc=h=!0,(w===2||w===9||w===3||w===6)&&(w=ta.current,w!==null&&w.tag===13&&(w.flags|=16384))),C4(p,h)):kv(p)}function kv(h){var p=h;do{if((p.flags&32768)!==0){C4(p,Xc);return}h=p.return;var _=Fte(p.alternate,p,Dl);if(_!==null){fn=_;return}if(p=p.sibling,p!==null){fn=p;return}fn=p=h}while(p!==null);Mr===0&&(Mr=5)}function C4(h,p){do{var _=zte(h.alternate,h);if(_!==null){_.flags&=32767,fn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(h=h.sibling,h!==null)){fn=h;return}fn=h=_}while(h!==null);Mr=6,fn=null}function N4(h,p,_,w,k,O,X,oe,Ee){h.cancelPendingCommit=null;do Pv();while(oi!==0);if((Nn&6)!==0)throw Error(r(327));if(p!==null){if(p===h.current)throw Error(r(177));if(O=p.lanes|p.childLanes,O|=lM,It(h,_,O,X,oe,Ee),h===Xn&&(fn=Xn=null,xn=0),Pf=p,Qc=h,Ol=_,g2=O,x2=k,b4=w,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Qte(ge,function(){return O4(),null})):(h.callbackNode=null,h.callbackPriority=0),w=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||w){w=K.T,K.T=null,k=W.p,W.p=2,X=Nn,Nn|=4;try{Bte(h,p,_)}finally{Nn=X,W.p=k,K.T=w}}oi=1,k4(),P4(),R4()}}function k4(){if(oi===1){oi=0;var h=Qc,p=Pf,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var w=W.p;W.p=2;var k=Nn;Nn|=4;try{u4(p,h);var O=R2,X=gL(h.containerInfo),oe=O.focusedElem,Ee=O.selectionRange;if(X!==oe&&oe&&oe.ownerDocument&&mL(oe.ownerDocument.documentElement,oe)){if(Ee!==null&&rM(oe)){var qe=Ee.start,lt=Ee.end;if(lt===void 0&&(lt=qe),"selectionStart"in oe)oe.selectionStart=qe,oe.selectionEnd=Math.min(lt,oe.value.length);else{var dt=oe.ownerDocument||document,Qe=dt&&dt.defaultView||window;if(Qe.getSelection){var it=Qe.getSelection(),Rt=oe.textContent.length,Vt=Math.min(Ee.start,Rt),zn=Ee.end===void 0?Vt:Math.min(Ee.end,Rt);!it.extend&&Vt>zn&&(X=zn,zn=Vt,Vt=X);var Be=pL(oe,Vt),Re=pL(oe,zn);if(Be&&Re&&(it.rangeCount!==1||it.anchorNode!==Be.node||it.anchorOffset!==Be.offset||it.focusNode!==Re.node||it.focusOffset!==Re.offset)){var We=dt.createRange();We.setStart(Be.node,Be.offset),it.removeAllRanges(),Vt>zn?(it.addRange(We),it.extend(Re.node,Re.offset)):(We.setEnd(Re.node,Re.offset),it.addRange(We))}}}}for(dt=[],it=oe;it=it.parentNode;)it.nodeType===1&&dt.push({element:it,left:it.scrollLeft,top:it.scrollTop});for(typeof oe.focus=="function"&&oe.focus(),oe=0;oe<dt.length;oe++){var ct=dt[oe];ct.element.scrollLeft=ct.left,ct.element.scrollTop=ct.top}}$v=!!P2,R2=P2=null}finally{Nn=k,W.p=w,K.T=_}}h.current=p,oi=2}}function P4(){if(oi===2){oi=0;var h=Qc,p=Pf,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var w=W.p;W.p=2;var k=Nn;Nn|=4;try{s4(h,p.alternate,p)}finally{Nn=k,W.p=w,K.T=_}}oi=3}}function R4(){if(oi===4||oi===3){oi=0,B();var h=Qc,p=Pf,_=Ol,w=b4;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?oi=5:(oi=0,Pf=Qc=null,D4(h,h.pendingLanes));var k=h.pendingLanes;if(k===0&&(Zc=null),wi(_),p=p.stateNode,ce&&typeof ce.onCommitFiberRoot=="function")try{ce.onCommitFiberRoot(Ve,p,void 0,(p.current.flags&128)===128)}catch{}if(w!==null){p=K.T,k=W.p,W.p=2,K.T=null;try{for(var O=h.onRecoverableError,X=0;X<w.length;X++){var oe=w[X];O(oe.value,{componentStack:oe.stack})}}finally{K.T=p,W.p=k}}(Ol&3)!==0&&Pv(),Go(h),k=h.pendingLanes,(_&261930)!==0&&(k&42)!==0?h===b2?jg++:(jg=0,b2=h):jg=0,Lg(0)}}function D4(h,p){(h.pooledCacheLanes&=p)===0&&(p=h.pooledCache,p!=null&&(h.pooledCache=null,gg(p)))}function Pv(){return k4(),P4(),R4(),O4()}function O4(){if(oi!==5)return!1;var h=Qc,p=g2;g2=0;var _=wi(Ol),w=K.T,k=W.p;try{W.p=32>_?32:_,K.T=null,_=x2,x2=null;var O=Qc,X=Ol;if(oi=0,Pf=Qc=null,Ol=0,(Nn&6)!==0)throw Error(r(331));var oe=Nn;if(Nn|=4,m4(O.current),h4(O,O.current,X,_),Nn=oe,Lg(0,!1),ce&&typeof ce.onPostCommitFiberRoot=="function")try{ce.onPostCommitFiberRoot(Ve,O)}catch{}return!0}finally{W.p=k,K.T=w,D4(h,p)}}function j4(h,p,_){p=Ea(_,p),p=YM(h.stateNode,p,2),h=Gc(h,p,2),h!==null&&(cn(h,2),Go(h))}function jn(h,p,_){if(h.tag===3)j4(h,h,_);else for(;p!==null;){if(p.tag===3){j4(p,h,_);break}else if(p.tag===1){var w=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(Zc===null||!Zc.has(w))){h=Ea(_,h),_=LI(2),w=Gc(p,_,2),w!==null&&(II(_,w,p,h),cn(w,2),Go(w));break}}p=p.return}}function _2(h,p,_){var w=h.pingCache;if(w===null){w=h.pingCache=new Vte;var k=new Set;w.set(p,k)}else k=w.get(p),k===void 0&&(k=new Set,w.set(p,k));k.has(_)||(f2=!0,k.add(_),h=Xte.bind(null,h,p,_),p.then(h,h))}function Xte(h,p,_){var w=h.pingCache;w!==null&&w.delete(p),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,Xn===h&&(xn&_)===_&&(Mr===4||Mr===3&&(xn&62914560)===xn&&300>j()-Mv?(Nn&2)===0&&Rf(h,0):p2|=_,kf===xn&&(kf=0)),Go(h)}function L4(h,p){p===0&&(p=wt()),h=Sd(h,p),h!==null&&(cn(h,p),Go(h))}function Yte(h){var p=h.memoizedState,_=0;p!==null&&(_=p.retryLane),L4(h,_)}function Zte(h,p){var _=0;switch(h.tag){case 31:case 13:var w=h.stateNode,k=h.memoizedState;k!==null&&(_=k.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),L4(h,_)}function Qte(h,p){return ke(h,p)}var Rv=null,Of=null,w2=!1,Dv=!1,S2=!1,eu=0;function Go(h){h!==Of&&h.next===null&&(Of===null?Rv=Of=h:Of=Of.next=h),Dv=!0,w2||(w2=!0,ene())}function Lg(h,p){if(!S2&&Dv){S2=!0;do for(var _=!1,w=Rv;w!==null;){if(h!==0){var k=w.pendingLanes;if(k===0)var O=0;else{var X=w.suspendedLanes,oe=w.pingedLanes;O=(1<<31-$e(42|h)+1)-1,O&=k&~(X&~oe),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(_=!0,z4(w,O))}else O=xn,O=ye(w,w===Xn?O:0,w.cancelPendingCommit!==null||w.timeoutHandle!==-1),(O&3)===0||He(w,O)||(_=!0,z4(w,O));w=w.next}while(_);S2=!1}}function Jte(){I4()}function I4(){Dv=w2=!1;var h=0;eu!==0&&une()&&(h=eu);for(var p=j(),_=null,w=Rv;w!==null;){var k=w.next,O=U4(w,p);O===0?(w.next=null,_===null?Rv=k:_.next=k,k===null&&(Of=_)):(_=w,(h!==0||(O&3)!==0)&&(Dv=!0)),w=k}oi!==0&&oi!==5||Lg(h),eu!==0&&(eu=0)}function U4(h,p){for(var _=h.suspendedLanes,w=h.pingedLanes,k=h.expirationTimes,O=h.pendingLanes&-62914561;0<O;){var X=31-$e(O),oe=1<<X,Ee=k[X];Ee===-1?((oe&_)===0||(oe&w)!==0)&&(k[X]=ht(oe,p)):Ee<=p&&(h.expiredLanes|=oe),O&=~oe}if(p=Xn,_=xn,_=ye(h,h===p?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),w=h.callbackNode,_===0||h===p&&(On===2||On===9)||h.cancelPendingCommit!==null)return w!==null&&w!==null&&Ne(w),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||He(h,_)){if(p=_&-_,p===h.callbackPriority)return p;switch(w!==null&&Ne(w),wi(_)){case 2:case 8:_=_e;break;case 32:_=ge;break;case 268435456:_=Ae;break;default:_=ge}return w=F4.bind(null,h),_=ke(_,w),h.callbackPriority=p,h.callbackNode=_,p}return w!==null&&w!==null&&Ne(w),h.callbackPriority=2,h.callbackNode=null,2}function F4(h,p){if(oi!==0&&oi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Pv()&&h.callbackNode!==_)return null;var w=xn;return w=ye(h,h===Xn?w:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),w===0?null:(y4(h,w,p),U4(h,j()),h.callbackNode!=null&&h.callbackNode===_?F4.bind(null,h):null)}function z4(h,p){if(Pv())return null;y4(h,p,!0)}function ene(){hne(function(){(Nn&6)!==0?ke(be,Jte):I4()})}function E2(){if(eu===0){var h=vf;h===0&&(h=Fe,Fe<<=1,(Fe&261888)===0&&(Fe=256)),eu=h}return eu}function B4(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:Bb(""+h)}function H4(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 tne(h,p,_,w,k){if(p==="submit"&&_&&_.stateNode===k){var O=B4((k[kr]||null).action),X=w.submitter;X&&(p=(p=X[kr]||null)?B4(p.formAction):X.getAttribute("formAction"),p!==null&&(O=p,X=null));var oe=new Gb("action","action",null,w,k);h.push({event:oe,listeners:[{instance:null,listener:function(){if(w.defaultPrevented){if(eu!==0){var Ee=X?H4(k,X):new FormData(k);VM(_,{pending:!0,data:Ee,method:k.method,action:O},null,Ee)}}else typeof O=="function"&&(oe.preventDefault(),Ee=X?H4(k,X):new FormData(k),VM(_,{pending:!0,data:Ee,method:k.method,action:O},O,Ee))},currentTarget:k}]})}}for(var M2=0;M2<oM.length;M2++){var A2=oM[M2],nne=A2.toLowerCase(),rne=A2[0].toUpperCase()+A2.slice(1);ho(nne,"on"+rne)}ho(vL,"onAnimationEnd"),ho(yL,"onAnimationIteration"),ho(_L,"onAnimationStart"),ho("dblclick","onDoubleClick"),ho("focusin","onFocus"),ho("focusout","onBlur"),ho(vte,"onTransitionRun"),ho(yte,"onTransitionStart"),ho(_te,"onTransitionCancel"),ho(wL,"onTransitionEnd"),bt("onMouseEnter",["mouseout","mouseover"]),bt("onMouseLeave",["mouseout","mouseover"]),bt("onPointerEnter",["pointerout","pointerover"]),bt("onPointerLeave",["pointerout","pointerover"]),ft("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ft("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ft("onBeforeInput",["compositionend","keypress","textInput","paste"]),ft("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ig="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(" "),ine=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ig));function $4(h,p){p=(p&4)!==0;for(var _=0;_<h.length;_++){var w=h[_],k=w.event;w=w.listeners;e:{var O=void 0;if(p)for(var X=w.length-1;0<=X;X--){var oe=w[X],Ee=oe.instance,qe=oe.currentTarget;if(oe=oe.listener,Ee!==O&&k.isPropagationStopped())break e;O=oe,k.currentTarget=qe;try{O(k)}catch(lt){Kb(lt)}k.currentTarget=null,O=Ee}else for(X=0;X<w.length;X++){if(oe=w[X],Ee=oe.instance,qe=oe.currentTarget,oe=oe.listener,Ee!==O&&k.isPropagationStopped())break e;O=oe,k.currentTarget=qe;try{O(k)}catch(lt){Kb(lt)}k.currentTarget=null,O=Ee}}}}function pn(h,p){var _=p[Ic];_===void 0&&(_=p[Ic]=new Set);var w=h+"__bubble";_.has(w)||(V4(p,h,2,!1),_.add(w))}function T2(h,p,_){var w=0;p&&(w|=4),V4(_,h,w,p)}var Ov="_reactListening"+Math.random().toString(36).slice(2);function C2(h){if(!h[Ov]){h[Ov]=!0,Te.forEach(function(_){_!=="selectionchange"&&(ine.has(_)||T2(_,!1,h),T2(_,!0,h))});var p=h.nodeType===9?h:h.ownerDocument;p===null||p[Ov]||(p[Ov]=!0,T2("selectionchange",!1,p))}}function V4(h,p,_,w){switch(vU(p)){case 2:var k=Rne;break;case 8:k=Dne;break;default:k=$2}_=k.bind(null,p,_,h),k=void 0,!KE||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(k=!0),w?k!==void 0?h.addEventListener(p,_,{capture:!0,passive:k}):h.addEventListener(p,_,!0):k!==void 0?h.addEventListener(p,_,{passive:k}):h.addEventListener(p,_,!1)}function N2(h,p,_,w,k){var O=w;if((p&1)===0&&(p&2)===0&&w!==null)e:for(;;){if(w===null)return;var X=w.tag;if(X===3||X===4){var oe=w.stateNode.containerInfo;if(oe===k)break;if(X===4)for(X=w.return;X!==null;){var Ee=X.tag;if((Ee===3||Ee===4)&&X.stateNode.containerInfo===k)return;X=X.return}for(;oe!==null;){if(X=St(oe),X===null)return;if(Ee=X.tag,Ee===5||Ee===6||Ee===26||Ee===27){w=O=X;continue e}oe=oe.parentNode}}w=w.return}Xj(function(){var qe=O,lt=WE(_),dt=[];e:{var Qe=SL.get(h);if(Qe!==void 0){var it=Gb,Rt=h;switch(h){case"keypress":if($b(_)===0)break e;case"keydown":case"keyup":it=Zee;break;case"focusin":Rt="focus",it=QE;break;case"focusout":Rt="blur",it=QE;break;case"beforeblur":case"afterblur":it=QE;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":it=Qj;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":it=Fee;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":it=ete;break;case vL:case yL:case _L:it=Hee;break;case wL:it=nte;break;case"scroll":case"scrollend":it=Iee;break;case"wheel":it=ite;break;case"copy":case"cut":case"paste":it=Vee;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":it=eL;break;case"toggle":case"beforetoggle":it=ate}var Vt=(p&4)!==0,zn=!Vt&&(h==="scroll"||h==="scrollend"),Be=Vt?Qe!==null?Qe+"Capture":null:Qe;Vt=[];for(var Re=qe,We;Re!==null;){var ct=Re;if(We=ct.stateNode,ct=ct.tag,ct!==5&&ct!==26&&ct!==27||We===null||Be===null||(ct=sg(Re,Be),ct!=null&&Vt.push(Ug(Re,ct,We))),zn)break;Re=Re.return}0<Vt.length&&(Qe=new it(Qe,Rt,null,_,lt),dt.push({event:Qe,listeners:Vt}))}}if((p&7)===0){e:{if(Qe=h==="mouseover"||h==="pointerover",it=h==="mouseout"||h==="pointerout",Qe&&_!==GE&&(Rt=_.relatedTarget||_.fromElement)&&(St(Rt)||Rt[co]))break e;if((it||Qe)&&(Qe=lt.window===lt?lt:(Qe=lt.ownerDocument)?Qe.defaultView||Qe.parentWindow:window,it?(Rt=_.relatedTarget||_.toElement,it=qe,Rt=Rt?St(Rt):null,Rt!==null&&(zn=s(Rt),Vt=Rt.tag,Rt!==zn||Vt!==5&&Vt!==27&&Vt!==6)&&(Rt=null)):(it=null,Rt=qe),it!==Rt)){if(Vt=Qj,ct="onMouseLeave",Be="onMouseEnter",Re="mouse",(h==="pointerout"||h==="pointerover")&&(Vt=eL,ct="onPointerLeave",Be="onPointerEnter",Re="pointer"),zn=it==null?Qe:Se(it),We=Rt==null?Qe:Se(Rt),Qe=new Vt(ct,Re+"leave",it,_,lt),Qe.target=zn,Qe.relatedTarget=We,ct=null,St(lt)===qe&&(Vt=new Vt(Be,Re+"enter",Rt,_,lt),Vt.target=We,Vt.relatedTarget=zn,ct=Vt),zn=ct,it&&Rt)t:{for(Vt=sne,Be=it,Re=Rt,We=0,ct=Be;ct;ct=Vt(ct))We++;ct=0;for(var zt=Re;zt;zt=Vt(zt))ct++;for(;0<We-ct;)Be=Vt(Be),We--;for(;0<ct-We;)Re=Vt(Re),ct--;for(;We--;){if(Be===Re||Re!==null&&Be===Re.alternate){Vt=Be;break t}Be=Vt(Be),Re=Vt(Re)}Vt=null}else Vt=null;it!==null&&G4(dt,Qe,it,Vt,!1),Rt!==null&&zn!==null&&G4(dt,zn,Rt,Vt,!0)}}e:{if(Qe=qe?Se(qe):window,it=Qe.nodeName&&Qe.nodeName.toLowerCase(),it==="select"||it==="input"&&Qe.type==="file")var En=lL;else if(aL(Qe))if(cL)En=gte;else{En=pte;var Lt=fte}else it=Qe.nodeName,!it||it.toLowerCase()!=="input"||Qe.type!=="checkbox"&&Qe.type!=="radio"?qe&&VE(qe.elementType)&&(En=lL):En=mte;if(En&&(En=En(h,qe))){oL(dt,En,_,lt);break e}Lt&&Lt(h,Qe,qe),h==="focusout"&&qe&&Qe.type==="number"&&qe.memoizedProps.value!=null&&Si(Qe,"number",Qe.value)}switch(Lt=qe?Se(qe):window,h){case"focusin":(aL(Lt)||Lt.contentEditable==="true")&&(df=Lt,iM=qe,fg=null);break;case"focusout":fg=iM=df=null;break;case"mousedown":sM=!0;break;case"contextmenu":case"mouseup":case"dragend":sM=!1,xL(dt,_,lt);break;case"selectionchange":if(bte)break;case"keydown":case"keyup":xL(dt,_,lt)}var tn;if(eM)e:{switch(h){case"compositionstart":var bn="onCompositionStart";break e;case"compositionend":bn="onCompositionEnd";break e;case"compositionupdate":bn="onCompositionUpdate";break e}bn=void 0}else uf?iL(h,_)&&(bn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(bn="onCompositionStart");bn&&(tL&&_.locale!=="ko"&&(uf||bn!=="onCompositionStart"?bn==="onCompositionEnd"&&uf&&(tn=Yj()):(Uc=lt,XE="value"in Uc?Uc.value:Uc.textContent,uf=!0)),Lt=jv(qe,bn),0<Lt.length&&(bn=new Jj(bn,h,null,_,lt),dt.push({event:bn,listeners:Lt}),tn?bn.data=tn:(tn=sL(_),tn!==null&&(bn.data=tn)))),(tn=lte?cte(h,_):ute(h,_))&&(bn=jv(qe,"onBeforeInput"),0<bn.length&&(Lt=new Jj("onBeforeInput","beforeinput",null,_,lt),dt.push({event:Lt,listeners:bn}),Lt.data=tn)),tne(dt,h,qe,_,lt)}$4(dt,p)})}function Ug(h,p,_){return{instance:h,listener:p,currentTarget:_}}function jv(h,p){for(var _=p+"Capture",w=[];h!==null;){var k=h,O=k.stateNode;if(k=k.tag,k!==5&&k!==26&&k!==27||O===null||(k=sg(h,_),k!=null&&w.unshift(Ug(h,k,O)),k=sg(h,p),k!=null&&w.push(Ug(h,k,O))),h.tag===3)return w;h=h.return}return[]}function sne(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function G4(h,p,_,w,k){for(var O=p._reactName,X=[];_!==null&&_!==w;){var oe=_,Ee=oe.alternate,qe=oe.stateNode;if(oe=oe.tag,Ee!==null&&Ee===w)break;oe!==5&&oe!==26&&oe!==27||qe===null||(Ee=qe,k?(qe=sg(_,O),qe!=null&&X.unshift(Ug(_,qe,Ee))):k||(qe=sg(_,O),qe!=null&&X.push(Ug(_,qe,Ee)))),_=_.return}X.length!==0&&h.push({event:p,listeners:X})}var ane=/\r\n?/g,one=/\u0000|\uFFFD/g;function W4(h){return(typeof h=="string"?h:""+h).replace(ane,`
- `).replace(one,"")}function q4(h,p){return p=W4(p),W4(h)===p}function Fn(h,p,_,w,k,O){switch(_){case"children":typeof w=="string"?p==="body"||p==="textarea"&&w===""||Bo(h,w):(typeof w=="number"||typeof w=="bigint")&&p!=="body"&&Bo(h,""+w);break;case"className":Ft(h,"class",w);break;case"tabIndex":Ft(h,"tabindex",w);break;case"dir":case"role":case"viewBox":case"width":case"height":Ft(h,_,w);break;case"style":qj(h,w,O);break;case"data":if(p!=="object"){Ft(h,"data",w);break}case"src":case"href":if(w===""&&(p!=="a"||_!=="href")){h.removeAttribute(_);break}if(w==null||typeof w=="function"||typeof w=="symbol"||typeof w=="boolean"){h.removeAttribute(_);break}w=Bb(""+w),h.setAttribute(_,w);break;case"action":case"formAction":if(typeof w=="function"){h.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof O=="function"&&(_==="formAction"?(p!=="input"&&Fn(h,p,"name",k.name,k,null),Fn(h,p,"formEncType",k.formEncType,k,null),Fn(h,p,"formMethod",k.formMethod,k,null),Fn(h,p,"formTarget",k.formTarget,k,null)):(Fn(h,p,"encType",k.encType,k,null),Fn(h,p,"method",k.method,k,null),Fn(h,p,"target",k.target,k,null)));if(w==null||typeof w=="symbol"||typeof w=="boolean"){h.removeAttribute(_);break}w=Bb(""+w),h.setAttribute(_,w);break;case"onClick":w!=null&&(h.onclick=vl);break;case"onScroll":w!=null&&pn("scroll",h);break;case"onScrollEnd":w!=null&&pn("scrollend",h);break;case"dangerouslySetInnerHTML":if(w!=null){if(typeof w!="object"||!("__html"in w))throw Error(r(61));if(_=w.__html,_!=null){if(k.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}_=Bb(""+w),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":w!=null&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,""+w):h.removeAttribute(_);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":w&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":w===!0?h.setAttribute(_,""):w!==!1&&w!=null&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,w):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":w!=null&&typeof w!="function"&&typeof w!="symbol"&&!isNaN(w)&&1<=w?h.setAttribute(_,w):h.removeAttribute(_);break;case"rowSpan":case"start":w==null||typeof w=="function"||typeof w=="symbol"||isNaN(w)?h.removeAttribute(_):h.setAttribute(_,w);break;case"popover":pn("beforetoggle",h),pn("toggle",h),Kt(h,"popover",w);break;case"xlinkActuate":nn(h,"http://www.w3.org/1999/xlink","xlink:actuate",w);break;case"xlinkArcrole":nn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",w);break;case"xlinkRole":nn(h,"http://www.w3.org/1999/xlink","xlink:role",w);break;case"xlinkShow":nn(h,"http://www.w3.org/1999/xlink","xlink:show",w);break;case"xlinkTitle":nn(h,"http://www.w3.org/1999/xlink","xlink:title",w);break;case"xlinkType":nn(h,"http://www.w3.org/1999/xlink","xlink:type",w);break;case"xmlBase":nn(h,"http://www.w3.org/XML/1998/namespace","xml:base",w);break;case"xmlLang":nn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",w);break;case"xmlSpace":nn(h,"http://www.w3.org/XML/1998/namespace","xml:space",w);break;case"is":Kt(h,"is",w);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=jee.get(_)||_,Kt(h,_,w))}}function k2(h,p,_,w,k,O){switch(_){case"style":qj(h,w,O);break;case"dangerouslySetInnerHTML":if(w!=null){if(typeof w!="object"||!("__html"in w))throw Error(r(61));if(_=w.__html,_!=null){if(k.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof w=="string"?Bo(h,w):(typeof w=="number"||typeof w=="bigint")&&Bo(h,""+w);break;case"onScroll":w!=null&&pn("scroll",h);break;case"onScrollEnd":w!=null&&pn("scrollend",h);break;case"onClick":w!=null&&(h.onclick=vl);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"&&(k=_.endsWith("Capture"),p=_.slice(2,k?_.length-7:void 0),O=h[kr]||null,O=O!=null?O[_]:null,typeof O=="function"&&h.removeEventListener(p,O,k),typeof w=="function")){typeof O!="function"&&O!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(p,w,k);break e}_ in h?h[_]=w:w===!0?h.setAttribute(_,""):Kt(h,_,w)}}}function Hi(h,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":pn("error",h),pn("load",h);var w=!1,k=!1,O;for(O in _)if(_.hasOwnProperty(O)){var X=_[O];if(X!=null)switch(O){case"src":w=!0;break;case"srcSet":k=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Fn(h,p,O,X,_,null)}}k&&Fn(h,p,"srcSet",_.srcSet,_,null),w&&Fn(h,p,"src",_.src,_,null);return;case"input":pn("invalid",h);var oe=O=X=k=null,Ee=null,qe=null;for(w in _)if(_.hasOwnProperty(w)){var lt=_[w];if(lt!=null)switch(w){case"name":k=lt;break;case"type":X=lt;break;case"checked":Ee=lt;break;case"defaultChecked":qe=lt;break;case"value":O=lt;break;case"defaultValue":oe=lt;break;case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(r(137,p));break;default:Fn(h,p,w,lt,_,null)}}Dn(h,O,oe,Ee,qe,X,k,!1);return;case"select":pn("invalid",h),w=X=O=null;for(k in _)if(_.hasOwnProperty(k)&&(oe=_[k],oe!=null))switch(k){case"value":O=oe;break;case"defaultValue":X=oe;break;case"multiple":w=oe;default:Fn(h,p,k,oe,_,null)}p=O,_=X,h.multiple=!!w,p!=null?ai(h,!!w,p,!1):_!=null&&ai(h,!!w,_,!0);return;case"textarea":pn("invalid",h),O=k=w=null;for(X in _)if(_.hasOwnProperty(X)&&(oe=_[X],oe!=null))switch(X){case"value":w=oe;break;case"defaultValue":k=oe;break;case"children":O=oe;break;case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(91));break;default:Fn(h,p,X,oe,_,null)}Ui(h,w,k,O);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:Fn(h,p,Ee,w,_,null)}return;case"dialog":pn("beforetoggle",h),pn("toggle",h),pn("cancel",h),pn("close",h);break;case"iframe":case"object":pn("load",h);break;case"video":case"audio":for(w=0;w<Ig.length;w++)pn(Ig[w],h);break;case"image":pn("error",h),pn("load",h);break;case"details":pn("toggle",h);break;case"embed":case"source":case"link":pn("error",h),pn("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(qe in _)if(_.hasOwnProperty(qe)&&(w=_[qe],w!=null))switch(qe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Fn(h,p,qe,w,_,null)}return;default:if(VE(p)){for(lt in _)_.hasOwnProperty(lt)&&(w=_[lt],w!==void 0&&k2(h,p,lt,w,_,void 0));return}}for(oe in _)_.hasOwnProperty(oe)&&(w=_[oe],w!=null&&Fn(h,p,oe,w,_,null))}function lne(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 k=null,O=null,X=null,oe=null,Ee=null,qe=null,lt=null;for(it in _){var dt=_[it];if(_.hasOwnProperty(it)&&dt!=null)switch(it){case"checked":break;case"value":break;case"defaultValue":Ee=dt;default:w.hasOwnProperty(it)||Fn(h,p,it,null,w,dt)}}for(var Qe in w){var it=w[Qe];if(dt=_[Qe],w.hasOwnProperty(Qe)&&(it!=null||dt!=null))switch(Qe){case"type":O=it;break;case"name":k=it;break;case"checked":qe=it;break;case"defaultChecked":lt=it;break;case"value":X=it;break;case"defaultValue":oe=it;break;case"children":case"dangerouslySetInnerHTML":if(it!=null)throw Error(r(137,p));break;default:it!==dt&&Fn(h,p,Qe,it,w,dt)}}uo(h,X,oe,Ee,qe,lt,O,k);return;case"select":it=X=oe=Qe=null;for(O in _)if(Ee=_[O],_.hasOwnProperty(O)&&Ee!=null)switch(O){case"value":break;case"multiple":it=Ee;default:w.hasOwnProperty(O)||Fn(h,p,O,null,w,Ee)}for(k in w)if(O=w[k],Ee=_[k],w.hasOwnProperty(k)&&(O!=null||Ee!=null))switch(k){case"value":Qe=O;break;case"defaultValue":oe=O;break;case"multiple":X=O;default:O!==Ee&&Fn(h,p,k,O,w,Ee)}p=oe,_=X,w=it,Qe!=null?ai(h,!!_,Qe,!1):!!w!=!!_&&(p!=null?ai(h,!!_,p,!0):ai(h,!!_,_?[]:"",!1));return;case"textarea":it=Qe=null;for(oe in _)if(k=_[oe],_.hasOwnProperty(oe)&&k!=null&&!w.hasOwnProperty(oe))switch(oe){case"value":break;case"children":break;default:Fn(h,p,oe,null,w,k)}for(X in w)if(k=w[X],O=_[X],w.hasOwnProperty(X)&&(k!=null||O!=null))switch(X){case"value":Qe=k;break;case"defaultValue":it=k;break;case"children":break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(r(91));break;default:k!==O&&Fn(h,p,X,k,w,O)}Ei(h,Qe,it);return;case"option":for(var Rt in _)if(Qe=_[Rt],_.hasOwnProperty(Rt)&&Qe!=null&&!w.hasOwnProperty(Rt))switch(Rt){case"selected":h.selected=!1;break;default:Fn(h,p,Rt,null,w,Qe)}for(Ee in w)if(Qe=w[Ee],it=_[Ee],w.hasOwnProperty(Ee)&&Qe!==it&&(Qe!=null||it!=null))switch(Ee){case"selected":h.selected=Qe&&typeof Qe!="function"&&typeof Qe!="symbol";break;default:Fn(h,p,Ee,Qe,w,it)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Vt in _)Qe=_[Vt],_.hasOwnProperty(Vt)&&Qe!=null&&!w.hasOwnProperty(Vt)&&Fn(h,p,Vt,null,w,Qe);for(qe in w)if(Qe=w[qe],it=_[qe],w.hasOwnProperty(qe)&&Qe!==it&&(Qe!=null||it!=null))switch(qe){case"children":case"dangerouslySetInnerHTML":if(Qe!=null)throw Error(r(137,p));break;default:Fn(h,p,qe,Qe,w,it)}return;default:if(VE(p)){for(var zn in _)Qe=_[zn],_.hasOwnProperty(zn)&&Qe!==void 0&&!w.hasOwnProperty(zn)&&k2(h,p,zn,void 0,w,Qe);for(lt in w)Qe=w[lt],it=_[lt],!w.hasOwnProperty(lt)||Qe===it||Qe===void 0&&it===void 0||k2(h,p,lt,Qe,w,it);return}}for(var Be in _)Qe=_[Be],_.hasOwnProperty(Be)&&Qe!=null&&!w.hasOwnProperty(Be)&&Fn(h,p,Be,null,w,Qe);for(dt in w)Qe=w[dt],it=_[dt],!w.hasOwnProperty(dt)||Qe===it||Qe==null&&it==null||Fn(h,p,dt,Qe,w,it)}function K4(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function cne(){if(typeof performance.getEntriesByType=="function"){for(var h=0,p=0,_=performance.getEntriesByType("resource"),w=0;w<_.length;w++){var k=_[w],O=k.transferSize,X=k.initiatorType,oe=k.duration;if(O&&oe&&K4(X)){for(X=0,oe=k.responseEnd,w+=1;w<_.length;w++){var Ee=_[w],qe=Ee.startTime;if(qe>oe)break;var lt=Ee.transferSize,dt=Ee.initiatorType;lt&&K4(dt)&&(Ee=Ee.responseEnd,X+=lt*(Ee<oe?1:(oe-qe)/(Ee-qe)))}if(--w,p+=8*(O+X)/(k.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 P2=null,R2=null;function Lv(h){return h.nodeType===9?h:h.ownerDocument}function X4(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 Y4(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 D2(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 O2=null;function une(){var h=window.event;return h&&h.type==="popstate"?h===O2?!1:(O2=h,!0):(O2=null,!1)}var Z4=typeof setTimeout=="function"?setTimeout:void 0,dne=typeof clearTimeout=="function"?clearTimeout:void 0,Q4=typeof Promise=="function"?Promise:void 0,hne=typeof queueMicrotask=="function"?queueMicrotask:typeof Q4<"u"?function(h){return Q4.resolve(null).then(h).catch(fne)}:Z4;function fne(h){setTimeout(function(){throw h})}function tu(h){return h==="head"}function J4(h,p){var _=p,w=0;do{var k=_.nextSibling;if(h.removeChild(_),k&&k.nodeType===8)if(_=k.data,_==="/$"||_==="/&"){if(w===0){h.removeChild(k),Uf(p);return}w--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")w++;else if(_==="html")Fg(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Fg(_);for(var O=_.firstChild;O;){var X=O.nextSibling,oe=O.nodeName;O[rt]||oe==="SCRIPT"||oe==="STYLE"||oe==="LINK"&&O.rel.toLowerCase()==="stylesheet"||_.removeChild(O),O=X}}else _==="body"&&Fg(h.ownerDocument.body);_=k}while(_);Uf(p)}function eU(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 j2(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":j2(_),et(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function pne(h,p,_,w){for(;h.nodeType===1;){var k=_;if(h.nodeName.toLowerCase()!==p.toLowerCase()){if(!w&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(w){if(!h[rt])switch(p){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(O=h.getAttribute("rel"),O==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(O!==k.rel||h.getAttribute("href")!==(k.href==null||k.href===""?null:k.href)||h.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin)||h.getAttribute("title")!==(k.title==null?null:k.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(O=h.getAttribute("src"),(O!==(k.src==null?null:k.src)||h.getAttribute("type")!==(k.type==null?null:k.type)||h.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin))&&O&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(p==="input"&&h.type==="hidden"){var O=k.name==null?null:""+k.name;if(k.type==="hidden"&&h.getAttribute("name")===O)return h}else return h;if(h=Na(h.nextSibling),h===null)break}return null}function mne(h,p,_){if(p==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=Na(h.nextSibling),h===null))return null;return h}function tU(h,p){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!p||(h=Na(h.nextSibling),h===null))return null;return h}function L2(h){return h.data==="$?"||h.data==="$~"}function I2(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function gne(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 Na(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 U2=null;function nU(h){h=h.nextSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(p===0)return Na(h.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}h=h.nextSibling}return null}function rU(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 iU(h,p,_){switch(p=Lv(_),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 Fg(h){for(var p=h.attributes;p.length;)h.removeAttributeNode(p[0]);et(h)}var ka=new Map,sU=new Set;function Iv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var jl=W.d;W.d={f:xne,r:bne,D:vne,C:yne,L:_ne,m:wne,X:Ene,S:Sne,M:Mne};function xne(){var h=jl.f(),p=Cv();return h||p}function bne(h){var p=ie(h);p!==null&&p.tag===5&&p.type==="form"?wI(p):jl.r(h)}var jf=typeof document>"u"?null:document;function aU(h,p,_){var w=jf;if(w&&typeof p=="string"&&p){var k=Pn(p);k='link[rel="'+h+'"][href="'+k+'"]',typeof _=="string"&&(k+='[crossorigin="'+_+'"]'),sU.has(k)||(sU.add(k),h={rel:h,crossOrigin:_,href:p},w.querySelector(k)===null&&(p=w.createElement("link"),Hi(p,"link",h),Oe(p),w.head.appendChild(p)))}}function vne(h){jl.D(h),aU("dns-prefetch",h,null)}function yne(h,p){jl.C(h,p),aU("preconnect",h,p)}function _ne(h,p,_){jl.L(h,p,_);var w=jf;if(w&&h&&p){var k='link[rel="preload"][as="'+Pn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(k+='[imagesrcset="'+Pn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(k+='[imagesizes="'+Pn(_.imageSizes)+'"]')):k+='[href="'+Pn(h)+'"]';var O=k;switch(p){case"style":O=Lf(h);break;case"script":O=If(h)}ka.has(O)||(h=f({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:h,as:p},_),ka.set(O,h),w.querySelector(k)!==null||p==="style"&&w.querySelector(zg(O))||p==="script"&&w.querySelector(Bg(O))||(p=w.createElement("link"),Hi(p,"link",h),Oe(p),w.head.appendChild(p)))}}function wne(h,p){jl.m(h,p);var _=jf;if(_&&h){var w=p&&typeof p.as=="string"?p.as:"script",k='link[rel="modulepreload"][as="'+Pn(w)+'"][href="'+Pn(h)+'"]',O=k;switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=If(h)}if(!ka.has(O)&&(h=f({rel:"modulepreload",href:h},p),ka.set(O,h),_.querySelector(k)===null)){switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Bg(O)))return}w=_.createElement("link"),Hi(w,"link",h),Oe(w),_.head.appendChild(w)}}}function Sne(h,p,_){jl.S(h,p,_);var w=jf;if(w&&h){var k=Le(w).hoistableStyles,O=Lf(h);p=p||"default";var X=k.get(O);if(!X){var oe={loading:0,preload:null};if(X=w.querySelector(zg(O)))oe.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":p},_),(_=ka.get(O))&&F2(h,_);var Ee=X=w.createElement("link");Oe(Ee),Hi(Ee,"link",h),Ee._p=new Promise(function(qe,lt){Ee.onload=qe,Ee.onerror=lt}),Ee.addEventListener("load",function(){oe.loading|=1}),Ee.addEventListener("error",function(){oe.loading|=2}),oe.loading|=4,Uv(X,p,w)}X={type:"stylesheet",instance:X,count:1,state:oe},k.set(O,X)}}}function Ene(h,p){jl.X(h,p);var _=jf;if(_&&h){var w=Le(_).hoistableScripts,k=If(h),O=w.get(k);O||(O=_.querySelector(Bg(k)),O||(h=f({src:h,async:!0},p),(p=ka.get(k))&&z2(h,p),O=_.createElement("script"),Oe(O),Hi(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},w.set(k,O))}}function Mne(h,p){jl.M(h,p);var _=jf;if(_&&h){var w=Le(_).hoistableScripts,k=If(h),O=w.get(k);O||(O=_.querySelector(Bg(k)),O||(h=f({src:h,async:!0,type:"module"},p),(p=ka.get(k))&&z2(h,p),O=_.createElement("script"),Oe(O),Hi(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},w.set(k,O))}}function oU(h,p,_,w){var k=(k=ue.current)?Iv(k):null;if(!k)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(p=Lf(_.href),_=Le(k).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=Lf(_.href);var O=Le(k).hoistableStyles,X=O.get(h);if(X||(k=k.ownerDocument||k,X={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(h,X),(O=k.querySelector(zg(h)))&&!O._p&&(X.instance=O,X.state.loading=5),ka.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},ka.set(h,_),O||Ane(k,h,_,X.state))),p&&w===null)throw Error(r(528,""));return X}if(p&&w!==null)throw Error(r(529,""));return null;case"script":return p=_.async,_=_.src,typeof _=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=If(_),_=Le(k).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 Lf(h){return'href="'+Pn(h)+'"'}function zg(h){return'link[rel="stylesheet"]['+h+"]"}function lU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function Ane(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}),Hi(p,"link",_),Oe(p),h.head.appendChild(p))}function If(h){return'[src="'+Pn(h)+'"]'}function Bg(h){return"script[async]"+h}function cU(h,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var w=h.querySelector('style[data-href~="'+Pn(_.href)+'"]');if(w)return p.instance=w,Oe(w),w;var k=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return w=(h.ownerDocument||h).createElement("style"),Oe(w),Hi(w,"style",k),Uv(w,_.precedence,h),p.instance=w;case"stylesheet":k=Lf(_.href);var O=h.querySelector(zg(k));if(O)return p.state.loading|=4,p.instance=O,Oe(O),O;w=lU(_),(k=ka.get(k))&&F2(w,k),O=(h.ownerDocument||h).createElement("link"),Oe(O);var X=O;return X._p=new Promise(function(oe,Ee){X.onload=oe,X.onerror=Ee}),Hi(O,"link",w),p.state.loading|=4,Uv(O,_.precedence,h),p.instance=O;case"script":return O=If(_.src),(k=h.querySelector(Bg(O)))?(p.instance=k,Oe(k),k):(w=_,(k=ka.get(O))&&(w=f({},_),z2(w,k)),h=h.ownerDocument||h,k=h.createElement("script"),Oe(k),Hi(k,"link",w),h.head.appendChild(k),p.instance=k);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,Uv(w,_.precedence,h));return p.instance}function Uv(h,p,_){for(var w=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=w.length?w[w.length-1]:null,O=k,X=0;X<w.length;X++){var oe=w[X];if(oe.dataset.precedence===p)O=oe;else if(O!==k)break}O?O.parentNode.insertBefore(h,O.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(h,p.firstChild))}function F2(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.title==null&&(h.title=p.title)}function z2(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.integrity==null&&(h.integrity=p.integrity)}var Fv=null;function uU(h,p,_){if(Fv===null){var w=new Map,k=Fv=new Map;k.set(_,w)}else k=Fv,w=k.get(_),w||(w=new Map,k.set(_,w));if(w.has(h))return w;for(w.set(h,null),_=_.getElementsByTagName(h),k=0;k<_.length;k++){var O=_[k];if(!(O[rt]||O[xr]||h==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var X=O.getAttribute(p)||"";X=h+X;var oe=w.get(X);oe?oe.push(O):w.set(X,[O])}}return w}function dU(h,p,_){h=h.ownerDocument||h,h.head.insertBefore(_,p==="title"?h.querySelector("head > title"):null)}function Tne(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 hU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function Cne(h,p,_,w){if(_.type==="stylesheet"&&(typeof w.media!="string"||matchMedia(w.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var k=Lf(w.href),O=p.querySelector(zg(k));if(O){p=O._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(h.count++,h=zv.bind(h),p.then(h,h)),_.state.loading|=4,_.instance=O,Oe(O);return}O=p.ownerDocument||p,w=lU(w),(k=ka.get(k))&&F2(w,k),O=O.createElement("link"),Oe(O);var X=O;X._p=new Promise(function(oe,Ee){X.onload=oe,X.onerror=Ee}),Hi(O,"link",w),_.instance=O}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=zv.bind(h),p.addEventListener("load",_),p.addEventListener("error",_))}}var B2=0;function Nne(h,p){return h.stylesheets&&h.count===0&&Hv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var w=setTimeout(function(){if(h.stylesheets&&Hv(h,h.stylesheets),h.unsuspend){var O=h.unsuspend;h.unsuspend=null,O()}},6e4+p);0<h.imgBytes&&B2===0&&(B2=62500*cne());var k=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&Hv(h,h.stylesheets),h.unsuspend)){var O=h.unsuspend;h.unsuspend=null,O()}},(h.imgBytes>B2?50:800)+p);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(w),clearTimeout(k)}}:null}function zv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Hv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var Bv=null;function Hv(h,p){h.stylesheets=null,h.unsuspend!==null&&(h.count++,Bv=new Map,p.forEach(kne,h),Bv=null,zv.call(h))}function kne(h,p){if(!(p.state.loading&4)){var _=Bv.get(h);if(_)var w=_.get(null);else{_=new Map,Bv.set(h,_);for(var k=h.querySelectorAll("link[data-precedence],style[data-precedence]"),O=0;O<k.length;O++){var X=k[O];(X.nodeName==="LINK"||X.getAttribute("media")!=="not all")&&(_.set(X.dataset.precedence,X),w=X)}w&&_.set(null,w)}k=p.instance,X=k.getAttribute("data-precedence"),O=_.get(X)||w,O===w&&_.set(null,k),_.set(X,k),this.count++,w=zv.bind(this),k.addEventListener("load",w),k.addEventListener("error",w),O?O.parentNode.insertBefore(k,O.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(k,h.firstChild)),p.state.loading|=4}}var Hg={$$typeof:S,Provider:null,Consumer:null,_currentValue:ne,_currentValue2:ne,_threadCount:0};function Pne(h,p,_,w,k,O,X,oe,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=Ot(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ot(0),this.hiddenUpdates=Ot(null),this.identifierPrefix=w,this.onUncaughtError=k,this.onCaughtError=O,this.onRecoverableError=X,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ee,this.incompleteTransitions=new Map}function fU(h,p,_,w,k,O,X,oe,Ee,qe,lt,dt){return h=new Pne(h,p,_,X,Ee,qe,lt,dt,oe),p=1,O===!0&&(p|=24),O=ea(3,null,null,p),h.current=O,O.stateNode=h,p=yM(),p.refCount++,h.pooledCache=p,p.refCount++,O.memoizedState={element:w,isDehydrated:_,cache:p},EM(O),h}function pU(h){return h?(h=pf,h):pf}function mU(h,p,_,w,k,O){k=pU(k),w.context===null?w.context=k:w.pendingContext=k,w=Vc(p),w.payload={element:_},O=O===void 0?null:O,O!==null&&(w.callback=O),_=Gc(h,w,p),_!==null&&(Ls(_,h,p),yg(_,h,p))}function gU(h,p){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<p?_:p}}function H2(h,p){gU(h,p),(h=h.alternate)&&gU(h,p)}function xU(h){if(h.tag===13||h.tag===31){var p=Sd(h,67108864);p!==null&&Ls(p,h,67108864),H2(h,67108864)}}function bU(h){if(h.tag===13||h.tag===31){var p=sa();p=si(p);var _=Sd(h,p);_!==null&&Ls(_,h,p),H2(h,p)}}var $v=!0;function Rne(h,p,_,w){var k=K.T;K.T=null;var O=W.p;try{W.p=2,$2(h,p,_,w)}finally{W.p=O,K.T=k}}function Dne(h,p,_,w){var k=K.T;K.T=null;var O=W.p;try{W.p=8,$2(h,p,_,w)}finally{W.p=O,K.T=k}}function $2(h,p,_,w){if($v){var k=V2(w);if(k===null)N2(h,p,w,Vv,_),yU(h,w);else if(jne(k,h,p,_,w))w.stopPropagation();else if(yU(h,w),p&4&&-1<One.indexOf(h)){for(;k!==null;){var O=ie(k);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var X=Ce(O.pendingLanes);if(X!==0){var oe=O;for(oe.pendingLanes|=2,oe.entangledLanes|=2;X;){var Ee=1<<31-$e(X);oe.entanglements[1]|=Ee,X&=~Ee}Go(O),(Nn&6)===0&&(Av=j()+500,Lg(0))}}break;case 31:case 13:oe=Sd(O,2),oe!==null&&Ls(oe,O,2),Cv(),H2(O,2)}if(O=V2(w),O===null&&N2(h,p,w,Vv,_),O===k)break;k=O}k!==null&&w.stopPropagation()}else N2(h,p,w,null,_)}}function V2(h){return h=WE(h),G2(h)}var Vv=null;function G2(h){if(Vv=null,h=St(h),h!==null){var p=s(h);if(p===null)h=null;else{var _=p.tag;if(_===13){if(h=a(p),h!==null)return h;h=null}else if(_===31){if(h=o(p),h!==null)return h;h=null}else if(_===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;h=null}else p!==h&&(h=null)}}return Vv=h,null}function vU(h){switch(h){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(te()){case be:return 2;case _e:return 8;case ge:case me:return 32;case Ae:return 268435456;default:return 32}default:return 32}}var W2=!1,nu=null,ru=null,iu=null,$g=new Map,Vg=new Map,su=[],One="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 yU(h,p){switch(h){case"focusin":case"focusout":nu=null;break;case"dragenter":case"dragleave":ru=null;break;case"mouseover":case"mouseout":iu=null;break;case"pointerover":case"pointerout":$g.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vg.delete(p.pointerId)}}function Gg(h,p,_,w,k,O){return h===null||h.nativeEvent!==O?(h={blockedOn:p,domEventName:_,eventSystemFlags:w,nativeEvent:O,targetContainers:[k]},p!==null&&(p=ie(p),p!==null&&xU(p)),h):(h.eventSystemFlags|=w,p=h.targetContainers,k!==null&&p.indexOf(k)===-1&&p.push(k),h)}function jne(h,p,_,w,k){switch(p){case"focusin":return nu=Gg(nu,h,p,_,w,k),!0;case"dragenter":return ru=Gg(ru,h,p,_,w,k),!0;case"mouseover":return iu=Gg(iu,h,p,_,w,k),!0;case"pointerover":var O=k.pointerId;return $g.set(O,Gg($g.get(O)||null,h,p,_,w,k)),!0;case"gotpointercapture":return O=k.pointerId,Vg.set(O,Gg(Vg.get(O)||null,h,p,_,w,k)),!0}return!1}function _U(h){var p=St(h.target);if(p!==null){var _=s(p);if(_!==null){if(p=_.tag,p===13){if(p=a(_),p!==null){h.blockedOn=p,Ji(h.priority,function(){bU(_)});return}}else if(p===31){if(p=o(_),p!==null){h.blockedOn=p,Ji(h.priority,function(){bU(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function Gv(h){if(h.blockedOn!==null)return!1;for(var p=h.targetContainers;0<p.length;){var _=V2(h.nativeEvent);if(_===null){_=h.nativeEvent;var w=new _.constructor(_.type,_);GE=w,_.target.dispatchEvent(w),GE=null}else return p=ie(_),p!==null&&xU(p),h.blockedOn=_,!1;p.shift()}return!0}function wU(h,p,_){Gv(h)&&_.delete(p)}function Lne(){W2=!1,nu!==null&&Gv(nu)&&(nu=null),ru!==null&&Gv(ru)&&(ru=null),iu!==null&&Gv(iu)&&(iu=null),$g.forEach(wU),Vg.forEach(wU)}function Wv(h,p){h.blockedOn===p&&(h.blockedOn=null,W2||(W2=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Lne)))}var qv=null;function SU(h){qv!==h&&(qv=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){qv===h&&(qv=null);for(var p=0;p<h.length;p+=3){var _=h[p],w=h[p+1],k=h[p+2];if(typeof w!="function"){if(G2(w||_)===null)continue;break}var O=ie(_);O!==null&&(h.splice(p,3),p-=3,VM(O,{pending:!0,data:k,method:_.method,action:w},w,k))}}))}function Uf(h){function p(Ee){return Wv(Ee,h)}nu!==null&&Wv(nu,h),ru!==null&&Wv(ru,h),iu!==null&&Wv(iu,h),$g.forEach(p),Vg.forEach(p);for(var _=0;_<su.length;_++){var w=su[_];w.blockedOn===h&&(w.blockedOn=null)}for(;0<su.length&&(_=su[0],_.blockedOn===null);)_U(_),_.blockedOn===null&&su.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(w=0;w<_.length;w+=3){var k=_[w],O=_[w+1],X=k[kr]||null;if(typeof O=="function")X||SU(_);else if(X){var oe=null;if(O&&O.hasAttribute("formAction")){if(k=O,X=O[kr]||null)oe=X.formAction;else if(G2(k)!==null)continue}else oe=X.action;typeof oe=="function"?_[w+1]=oe:(_.splice(w,3),w-=3),SU(_)}}}function EU(){function h(O){O.canIntercept&&O.info==="react-transition"&&O.intercept({handler:function(){return new Promise(function(X){return k=X})},focusReset:"manual",scroll:"manual"})}function p(){k!==null&&(k(),k=null),w||setTimeout(_,20)}function _(){if(!w&&!navigation.transition){var O=navigation.currentEntry;O&&O.url!=null&&navigation.navigate(O.url,{state:O.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var w=!1,k=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),k!==null&&(k(),k=null)}}}function q2(h){this._internalRoot=h}Kv.prototype.render=q2.prototype.render=function(h){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,w=sa();mU(_,w,h,p,null,null)},Kv.prototype.unmount=q2.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var p=h.containerInfo;mU(h.current,2,null,h,null,null),Cv(),p[co]=null}};function Kv(h){this._internalRoot=h}Kv.prototype.unstable_scheduleHydration=function(h){if(h){var p=Ii();h={blockedOn:null,target:h,priority:p};for(var _=0;_<su.length&&p!==0&&p<su[_].priority;_++);su.splice(_,0,h),_===0&&_U(h)}};var MU=e.version;if(MU!=="19.2.0")throw Error(r(527,MU,"19.2.0"));W.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 Ine={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Xv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xv.isDisabled&&Xv.supportsFiber)try{Ve=Xv.inject(Ine),ce=Xv}catch{}}return qg.createRoot=function(h,p){if(!i(h))throw Error(r(299));var _=!1,w="",k=RI,O=DI,X=OI;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(w=p.identifierPrefix),p.onUncaughtError!==void 0&&(k=p.onUncaughtError),p.onCaughtError!==void 0&&(O=p.onCaughtError),p.onRecoverableError!==void 0&&(X=p.onRecoverableError)),p=fU(h,1,!1,null,null,_,w,null,k,O,X,EU),h[co]=p.current,C2(h),new q2(p)},qg.hydrateRoot=function(h,p,_){if(!i(h))throw Error(r(299));var w=!1,k="",O=RI,X=DI,oe=OI,Ee=null;return _!=null&&(_.unstable_strictMode===!0&&(w=!0),_.identifierPrefix!==void 0&&(k=_.identifierPrefix),_.onUncaughtError!==void 0&&(O=_.onUncaughtError),_.onCaughtError!==void 0&&(X=_.onCaughtError),_.onRecoverableError!==void 0&&(oe=_.onRecoverableError),_.formState!==void 0&&(Ee=_.formState)),p=fU(h,1,!0,p,_??null,w,k,Ee,O,X,oe,EU),p.context=pU(null),_=p.current,w=sa(),w=si(w),k=Vc(w),k.callback=null,Gc(_,k,w),_=w,p.current.lanes=_,cn(p,_),Go(p),h[co]=p.current,C2(h),new Kv(p)},qg.version="19.2.0",qg}var jU;function Kne(){if(jU)return Y2.exports;jU=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Y2.exports=qne(),Y2.exports}var Xne=Kne();const Wt=t=>typeof t=="string",Kg=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},LU=t=>t==null?"":""+t,Yne=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Zne=/###/g,IU=t=>t&&t.indexOf("###")>-1?t.replace(Zne,"."):t,UU=t=>!t||Wt(t),Rx=(t,e,n)=>{const r=Wt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(UU(t))return{};const s=IU(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return UU(t)?{}:{obj:t,k:IU(r[i])}},FU=(t,e,n)=>{const{obj:r,k:i}=Rx(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],a=e.slice(0,e.length-1),o=Rx(t,a,Object);for(;o.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),o=Rx(t,a,Object),o?.obj&&typeof o.obj[`${o.k}.${s}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${s}`]=n},Qne=(t,e,n,r)=>{const{obj:i,k:s}=Rx(t,e,Object);i[s]=i[s]||[],i[s].push(n)},t1=(t,e)=>{const{obj:n,k:r}=Rx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Jne=(t,e,n)=>{const r=t1(t,n);return r!==void 0?r:t1(e,n)},$9=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Wt(t[r])||t[r]instanceof String||Wt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):$9(t[r],e[r],n):t[r]=e[r]);return t},Ff=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var ere={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const tre=t=>Wt(t)?t.replace(/[&<>"'\/]/g,e=>ere[e]):t;class nre{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 rre=[" ",",","?","!",";"],ire=new nre(20),sre=(t,e,n)=>{e=e||"",n=n||"";const r=rre.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=ire.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let s=!i.test(t);if(!s){const a=t.indexOf(n);a>0&&!i.test(t.substring(0,a))&&(s=!0)}return s},GN=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let a,o="";for(let l=s;l<r.length;++l)if(l!==s&&(o+=n),o+=r[l],a=i[o],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=a}return i},n0=t=>t?.replace("_","-"),are={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 n1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||are,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(Wt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new n1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new n1(this.logger,e)}}var tl=new n1;let cS=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,s])=>{for(let a=0;a<s;a++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let a=0;a<s;a++)i.apply(i,[e,...n])})}};class zU extends cS{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],r&&(Array.isArray(r)?o.push(...r):Wt(r)&&s?o.push(...r.split(s)):o.push(r)));const l=t1(this.data,o);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),l||!a||!Wt(r)?l:GN(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let o=[e,n];r&&(o=o.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(o=e.split("."),i=n,n=o[1]),this.addNamespaces(n),FU(this.data,o,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(Wt(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s,a={silent:!1,skipCopy:!1}){let o=[e,n];e.indexOf(".")>-1&&(o=e.split("."),i=r,r=n,n=o[1]),this.addNamespaces(n);let l=t1(this.data,o)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?$9(l,r,s):l={...l,...r},FU(this.data,o,l),a.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var V9={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,i)??e}),e}};const G9=Symbol("i18next/PATH_KEY");function ore(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===G9?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function WN(t,e){const{[G9]:n}=t(ore());return n.join(e?.keySeparator??".")}const BU={},eA=t=>!Wt(t)&&typeof t!="boolean"&&typeof t!="number";class r1 extends cS{constructor(e,n={}){super(),Yne(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=tl.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const s=eA(i.res);return!(r.returnObjects===!1&&s)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const a=r&&e.indexOf(r)>-1,o=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!sre(e,r,i);if(a&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:Wt(s)?[s]:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return{key:e,namespaces:Wt(s)?[s]:s}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=WN(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:l}=this.extractFromKey(e[e.length-1],i),u=l[l.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?s?{res:`${u}${d}${o}`,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${o}`:s?{res:o,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:o;const m=this.resolve(e,i);let x=m?.res;const y=m?.usedKey||o,v=m?.exactUsedKey||o,b=["[object Number]","[object Function]","[object RegExp]"],E=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!Wt(i.count),T=r1.hasDefaultValue(i),P=A?this.pluralResolver.getSuffix(f,i.count,i):"",C=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",I=A&&!i.ordinal&&i.count===0,N=I&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${P}`]||i[`defaultValue${C}`]||i.defaultValue;let D=x;S&&!x&&T&&(D=N);const F=eA(D),L=Object.prototype.toString.apply(D);if(S&&D&&F&&b.indexOf(L)<0&&!(Wt(E)&&Array.isArray(D))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,D,{...i,ns:l}):`key '${o} (${this.language})' returned an object instead of string.`;return s?(m.res=q,m.usedParams=this.getUsedParamsDetails(i),m):q}if(a){const q=Array.isArray(D),R=q?[]:{},V=q?v:y;for(const K in D)if(Object.prototype.hasOwnProperty.call(D,K)){const W=`${V}${a}${K}`;T&&!x?R[K]=this.translate(W,{...i,defaultValue:eA(N)?N[K]:void 0,joinArrays:!1,ns:l}):R[K]=this.translate(W,{...i,joinArrays:!1,ns:l}),R[K]===W&&(R[K]=D[K])}x=R}}else if(S&&Wt(E)&&Array.isArray(x))x=x.join(E),x&&(x=this.extendTranslation(x,e,i,r));else{let q=!1,R=!1;!this.isValidLookup(x)&&T&&(q=!0,x=N),this.isValidLookup(x)||(R=!0,x=o);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:x,W=T&&N!==x&&this.options.updateMissing;if(R||q||W){if(this.logger.log(W?"updateKey":"missingKey",f,u,o,W?N:x),a){const U=this.resolve(o,{...i,keySeparator:!1});U&&U.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let ne=[];const Y=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Y&&Y[0])for(let U=0;U<Y.length;U++)ne.push(Y[U]);else this.options.saveMissingTo==="all"?ne=this.languageUtils.toResolveHierarchy(i.lng||this.language):ne.push(i.lng||this.language);const Z=(U,$,ee)=>{const ae=T&&ee!==x?ee:K;this.options.missingKeyHandler?this.options.missingKeyHandler(U,u,$,ae,W,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(U,u,$,ae,W,i),this.emit("missingKey",U,u,$,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?ne.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(ee=>{Z([U],o+ee,i[`defaultValue${ee}`]||N)})}):Z(ne,o,N))}x=this.extendTranslation(x,e,i,m,r),R&&x===o&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${o}`),(R||q)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${o}`:o,q?x:void 0,i))}return s?(m.res=x,m.usedParams=this.getUsedParamsDetails(i),m):x}extendTranslation(e,n,r,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const l=Wt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(l){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!Wt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),l){const f=e.match(this.interpolator.nestingRegexp),g=f&&f.length;u<g&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>s?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const a=r.postProcess||this.options.postProcess,o=Wt(a)?[a]:a;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=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,s,a,o;return Wt(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(l,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const g=n.count!==void 0&&!Wt(n.count),m=g&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(Wt(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{this.isValidLookup(r)||(o=v,!BU[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(BU[`${y[0]}-${v}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(b=>{if(this.isValidLookup(r))return;a=b;const E=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(E,d,b,v,n);else{let A;g&&(A=this.pluralResolver.getSuffix(b,n.count,n));const T=`${this.options.pluralSeparator}zero`,P=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&A.indexOf(P)===0&&E.push(d+A.replace(P,this.options.pluralSeparator)),E.push(d+A),m&&E.push(d+T)),x){const C=`${d}${this.options.contextSeparator||"_"}${n.context}`;E.push(C),g&&(n.ordinal&&A.indexOf(P)===0&&E.push(C+A.replace(P,this.options.pluralSeparator)),E.push(C+A),m&&E.push(C+T))}}let S;for(;S=E.pop();)this.isValidLookup(r)||(s=S,r=this.getResource(b,v,S,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!Wt(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class HU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=tl.create("languageUtils")}getScriptPartFromCode(e){if(e=n0(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=n0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Wt(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(a=>{if(a===s)return a;if(!(a.indexOf("-")<0&&s.indexOf("-")<0)&&(a.indexOf("-")>0&&s.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===s||a.indexOf(s)===0&&s.length>1))return a})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),Wt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],s=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return Wt(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):Wt(e)&&s(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const $U={zero:0,one:1,two:2,few:3,many:4,other:5},VU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class lre{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=tl.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=n0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),VU;if(!e.match(/-|_/))return VU;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,n)}return this.pluralRulesCache[s]=a,a}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>$U[i]-$U[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const GU=(t,e,n,r=".",i=!0)=>{let s=Jne(t,e,n);return!s&&i&&Wt(n)&&(s=GN(t,n,r),s===void 0&&(s=GN(e,n,r))),s},tA=t=>t.replace(/\$/g,"$$$$");class cre{constructor(e={}){this.logger=tl.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:a,suffix:o,suffixEscaped:l,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:g,nestingPrefixEscaped:m,nestingSuffix:x,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:b,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:tre,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Ff(s):a||"{{",this.suffix=o?Ff(o):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=g?Ff(g):m||Ff("$t("),this.nestingSuffix=x?Ff(x):y||Ff(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=b||1e3,this.alwaysFormat=E!==void 0?E:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let s,a,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const b=GU(n,l,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(b,void 0,r,{...i,...n,interpolationkey:m}):b}const x=m.split(this.formatSeparator),y=x.shift().trim(),v=x.join(this.formatSeparator).trim();return this.format(GU(n,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),v,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>tA(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?tA(this.escape(m)):tA(m)}].forEach(m=>{for(o=0;s=m.regex.exec(e);){const x=s[1].trim();if(a=u(x),a===void 0)if(typeof d=="function"){const v=d(e,s,i);a=Wt(v)?v:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))a="";else if(f){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),a="";else!Wt(a)&&!this.useRawValueToEscape&&(a=LU(a));const y=m.safeValue(a);if(e=e.replace(s[0],y),f?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=s[0].length):m.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,a;const o=(l,u)=>{const d=this.nestingOptionsSeparator;if(l.indexOf(d)<0)return l;const f=l.split(new RegExp(`${d}[ ]*{`));let g=`{${f[1]}`;l=f[0],g=this.interpolate(g,a);const m=g.match(/'/g),x=g.match(/"/g);((m?.length??0)%2===0&&!x||x.length%2!==0)&&(g=g.replace(/'/g,'"'));try{a=JSON.parse(g),u&&(a={...u,...a})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${d}${g}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a={...r},a=a.replace&&!Wt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(l=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),s=n(o.call(this,i[1].trim(),a),a),s&&i[0]===e&&!Wt(s))return s;Wt(s)||(s=LU(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),l.length&&(s=l.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const ure=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(a=>{if(a){const[o,...l]=a.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),d=o.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},WU=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const a=r+JSON.stringify(s);let o=e[a];return o||(o=t(n0(r),i),e[a]=o),o(n)}},dre=t=>(e,n,r)=>t(n0(n),r)(e);class hre{constructor(e={}){this.logger=tl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?WU:dre;this.formats={number:r((i,s)=>{const a=new Intl.NumberFormat(i,{...s});return o=>a.format(o)}),currency:r((i,s)=>{const a=new Intl.NumberFormat(i,{...s,style:"currency"});return o=>a.format(o)}),datetime:r((i,s)=>{const a=new Intl.DateTimeFormat(i,{...s});return o=>a.format(o)}),relativetime:r((i,s)=>{const a=new Intl.RelativeTimeFormat(i,{...s});return o=>a.format(o,s.range||"day")}),list:r((i,s)=>{const a=new Intl.ListFormat(i,{...s});return o=>a.format(o)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=WU(n)}format(e,n,r,i={}){const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(o=>o.indexOf(")")>-1)){const o=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,o)].join(this.formatSeparator)}return s.reduce((o,l)=>{const{formatName:u,formatOptions:d}=ure(l);if(this.formats[u]){let f=o;try{const g=i?.formatParams?.[i.interpolationkey]||{},m=g.locale||g.lng||i.locale||i.lng||r;f=this.formats[u](o,m,{...d,...i,...g})}catch(g){this.logger.warn(g)}return f}else this.logger.warn(`there was no format function for ${u}`);return o},e)}}const fre=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class pre extends cS{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=tl.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const s={},a={},o={},l={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const g=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?a[g]===void 0&&(a[g]=!0):(this.state[g]=1,d=!1,a[g]===void 0&&(a[g]=!0),s[g]===void 0&&(s[g]=!0),l[f]===void 0&&(l[f]=!0)))}),d||(o[u]=!0)}),(Object.keys(s).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],a=i[1];n&&this.emit("failedLoading",s,a,n),!n&&r&&this.store.addResourceBundle(s,a,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const o={};this.queue.forEach(l=>{Qne(l.loaded,[s],a),fre(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{o[u]||(o[u]={});const d=l.loaded[u];d.length&&d.forEach(f=>{o[u][f]===void 0&&(o[u][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r,i=0,s=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:a});return}this.readingCalls++;const o=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,a)},s);return}a(u,d)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const u=l(e,n);u&&typeof u.then=="function"?u.then(d=>o(null,d)).catch(o):o(null,u)}catch(u){o(u)}return}return l(e,n,o)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();Wt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Wt(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(a,o)=>{a&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,a),!a&&o&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,o),this.loaded(e,a,o)})}saveMissing(e,n,r,i,s,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const l={...a,isUpdate:s},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,l):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>o(null,f)).catch(o):o(null,d)}catch(d){o(d)}else u(e,n,r,i,o,l)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const qU=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),Wt(t[1])&&(e.defaultValue=t[1]),Wt(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),KU=t=>(Wt(t.ns)&&(t.ns=[t.ns]),Wt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Wt(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),Zv=()=>{},mre=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Dx extends cS{constructor(e={},n){if(super(),this.options=KU(e),this.services={},this.logger=tl,this.modules={external:[]},mre(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(Wt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=qU();this.options={...r,...this.options,...KU(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?tl.init(i(this.modules.logger),this.options):tl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=hre;const d=new HU(this.options);this.store=new zU(this.options.resources,this.options);const f=this.services;f.logger=tl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new lre(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 cre(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new pre(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 r1(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=Zv),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=Kg(),l=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),o}loadResources(e,n=Zv){let r=n;const i=Wt(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],a=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(u=>{u!=="cimode"&&s.indexOf(u)<0&&s.push(u)})};i?a(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>a(l)),this.options.preload?.forEach?.(o=>a(o)),this.services.backendConnector.load(s,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(o)})}else r(null)}reloadResources(e,n,r){const i=Kg();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=Zv),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&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=Kg();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},s=(o,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(o,(...u)=>this.t(...u))},a=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const l=Wt(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(Wt(o)?[o]:o);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{s(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),r}getFixedT(e,n,r){const i=(s,a,...o)=>{let l;typeof a!="object"?l=this.options.overloadTranslationOptionHandler([s,a].concat(o)):l={...a},l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return l.keyPrefix&&Array.isArray(s)?d=s.map(f=>(typeof f=="function"&&(f=WN(f,{...this.options,...a})),`${l.keyPrefix}${u}${f}`)):(typeof s=="function"&&(s=WN(s,{...this.options,...a})),d=l.keyPrefix?`${l.keyPrefix}${u}${s}`:s),this.t(d,l)};return Wt(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(o,l)=>{const u=this.services.backendConnector.state[`${o}|${l}`];return u===-1||u===0||u===2};if(n.precheck){const o=n.precheck(this,a);if(o!==void 0)return o}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,e)&&(!i||a(s,e)))}loadNamespaces(e,n){const r=Kg();return this.options.ns?(Wt(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Kg();Wt(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return s.length?(this.options.preload=i.concat(s),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const s=i.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new HU(qU());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 Dx(e,n);return r.createInstance=Dx.createInstance,r}cloneInstance(e={},n=Zv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Dx(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(o=>{s[o]=this[o]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const o=Object.keys(this.store.data).reduce((l,u)=>(l[u]={...this.store.data[u]},l[u]=Object.keys(l[u]).reduce((d,f)=>(d[f]={...l[u][f]},d),l[u]),l),{});s.store=new zU(o,i),s.services.resourceStore=s.store}return s.translator=new r1(s.services,i),s.translator.on("*",(o,...l)=>{s.emit(o,...l)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const ks=Dx.createInstance();ks.createInstance;ks.dir;ks.init;ks.loadResources;ks.reloadResources;ks.use;ks.changeLanguage;ks.getFixedT;ks.t;ks.exists;ks.setDefaultNamespace;ks.hasLoadedNamespace;ks.loadNamespaces;ks.loadLanguages;const gre=(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);Ch(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},XU={},W9=(t,e,n,r)=>{Ch(n)&&XU[n]||(Ch(n)&&(XU[n]=new Date),gre(t,e,n,r))},q9=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},qN=(t,e,n)=>{t.loadNamespaces(e,q9(t,n))},YU=(t,e,n,r)=>{if(Ch(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return qN(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,q9(t,r))},xre=(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}}),Ch=t=>typeof t=="string",bre=t=>typeof t=="object"&&t!==null,vre=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,yre={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},_re=t=>yre[t],wre=t=>t.replace(vre,_re);let KN={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:wre};const Sre=(t={})=>{KN={...KN,...t}},Ere=()=>KN;let K9;const Mre=t=>{K9=t},Are=()=>K9,Tre={type:"3rdParty",init(t){Sre(t.options.react),Mre(t)}},Cre=M.createContext();class Nre{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var nA={exports:{}},rA={};var ZU;function kre(){if(ZU)return rA;ZU=1;var t=Dm();function e(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,a=t.useDebugValue;function o(f,g){var m=g(),x=r({inst:{value:m,getSnapshot:g}}),y=x[0].inst,v=x[1];return s(function(){y.value=m,y.getSnapshot=g,l(y)&&v({inst:y})},[f,m,g]),i(function(){return l(y)&&v({inst:y}),f(function(){l(y)&&v({inst:y})})},[f]),a(m),m}function l(f){var g=f.getSnapshot;f=f.value;try{var m=g();return!n(f,m)}catch{return!0}}function u(f,g){return g()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:o;return rA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,rA}var QU;function X9(){return QU||(QU=1,nA.exports=kre()),nA.exports}var rR=X9();const Pre=(t,e)=>Ch(e)?e:bre(e)&&Ch(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Rre={t:Pre,ready:!1},Dre=()=>()=>{},uS=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=M.useContext(Cre)||{},s=n||r||Are();s&&!s.reportNamespaces&&(s.reportNamespaces=new Nre),s||W9(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const a=M.useMemo(()=>({...Ere(),...s?.options?.react,...e}),[s,e]),{useSuspense:o,keyPrefix:l}=a,u=i||s?.options?.defaultNS,d=Ch(u)?[u]:u||["translation"],f=M.useMemo(()=>d,d);s?.reportNamespaces?.addUsedNamespaces?.(f);const g=M.useRef(0),m=M.useCallback(N=>{if(!s)return Dre;const{bindI18n:D,bindI18nStore:F}=a,L=()=>{g.current+=1,N()};return D&&s.on(D,L),F&&s.store.on(F,L),()=>{D&&D.split(" ").forEach(q=>s.off(q,L)),F&&F.split(" ").forEach(q=>s.store.off(q,L))}},[s,a]),x=M.useRef(),y=M.useCallback(()=>{if(!s)return Rre;const N=!!(s.isInitialized||s.initializedStoreOnce)&&f.every(V=>xre(V,s,a)),D=e.lng||s.language,F=g.current,L=x.current;if(L&&L.ready===N&&L.lng===D&&L.keyPrefix===l&&L.revision===F)return L;const R={t:s.getFixedT(D,a.nsMode==="fallback"?f:f[0],l),ready:N,lng:D,keyPrefix:l,revision:F};return x.current=R,R},[s,f,l,a,e.lng]),[v,b]=M.useState(0),{t:E,ready:S}=rR.useSyncExternalStore(m,y,y);M.useEffect(()=>{if(s&&!S&&!o){const N=()=>b(D=>D+1);e.lng?YU(s,e.lng,f,N):qN(s,f,N)}},[s,e.lng,f,S,o,v]);const A=s||{},T=M.useRef(null),P=M.useRef(),C=N=>{const D=Object.getOwnPropertyDescriptors(N);D.__original&&delete D.__original;const F=Object.create(Object.getPrototypeOf(N),D);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:N,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},I=M.useMemo(()=>{const N=A,D=N?.language;let F=N;N&&(T.current&&T.current.__original===N?P.current!==D?(F=C(N),T.current=F,P.current=D):F=T.current:(F=C(N),T.current=F,P.current=D));const L=[E,F,S];return L.t=E,L.i18n=F,L.ready=S,L},[E,A,S,A.resolvedLanguage,A.language,A.languages]);if(s&&o&&!S)throw new Promise(N=>{const D=()=>N();e.lng?YU(s,e.lng,f,D):qN(s,f,D)});return I},{slice:Ore,forEach:jre}=[];function Lre(t){return jre.call(Ore.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Ire(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 JU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Ure=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let s=`${t}=${i}`;if(r.maxAge>0){const a=r.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(a)}`}if(r.domain){if(!JU.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!JU.test(r.path))throw new TypeError("option path is invalid");s+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(s+="; HttpOnly"),r.secure&&(s+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(s+="; Partitioned"),s},e5={create(t,e,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=Ure(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 Fre={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return e5.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&e5.create(n,t,r,i,s)}},zre={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const s=r.substring(1).split("&");for(let a=0;a<s.length;a++){const o=s[a].indexOf("=");o>0&&s[a].substring(0,o)===e&&(n=s[a].substring(o+1))}}return n}},Bre={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const s=i.substring(1);if(e){const a=s.split("&");for(let o=0;o<a.length;o++){const l=a[o].indexOf("=");l>0&&a[o].substring(0,l)===e&&(r=a[o].substring(l+1))}}if(r)return r;if(!r&&n>-1){const a=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(a)?a[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let zf=null;const t5=()=>{if(zf!==null)return zf;try{if(zf=typeof window<"u"&&window.localStorage!==null,!zf)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{zf=!1}return zf};var Hre={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&t5())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&t5()&&window.localStorage.setItem(n,t)}};let Bf=null;const n5=()=>{if(Bf!==null)return Bf;try{if(Bf=typeof window<"u"&&window.sessionStorage!==null,!Bf)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Bf=!1}return Bf};var $re={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&n5())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&n5()&&window.sessionStorage.setItem(n,t)}},Vre={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let s=0;s<n.length;s++)e.push(n[s]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},Gre={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}},Wre={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}},qre={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 Y9=!1;try{document.cookie,Y9=!0}catch{}const Z9=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Y9||Z9.splice(1,1);const Kre=()=>({order:Z9,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Q9{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=Lre(n,this.options||{},Kre()),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(Fre),this.addDetector(zre),this.addDetector(Hre),this.addDetector($re),this.addDetector(Vre),this.addDetector(Gre),this.addDetector(Wre),this.addDetector(qre),this.addDetector(Bre)}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&&!Ire(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)}))}}Q9.type="languageDetector";const Xre={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",settings:"Settings",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},Yre={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",settings:"Einstellungen",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},Zre={en:{translation:Xre},de:{translation:Yre}};ks.use(Q9).use(Tre).init({resources:Zre,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const r5=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var i5="popstate";function Qre(t={}){function e(r,i){let{pathname:s,search:a,hash:o}=r.location;return XN("",{pathname:s,search:a,hash:o},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:r0(i)}return eie(e,n,null,t)}function vr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Do(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Jre(){return Math.random().toString(36).substring(2,10)}function s5(t,e){return{usr:t.state,key:t.key,idx:e}}function XN(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Om(e):e,state:n,key:e&&e.key||r||Jre()}}function r0({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 Om(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 eie(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,a=i.history,o="POP",l=null,u=d();u==null&&(u=0,a.replaceState({...a.state,idx:u},""));function d(){return(a.state||{idx:null}).idx}function f(){o="POP";let v=d(),b=v==null?null:v-u;u=v,l&&l({action:o,location:y.location,delta:b})}function g(v,b){o="PUSH";let E=XN(y.location,v,b);u=d()+1;let S=s5(E,u),A=y.createHref(E);try{a.pushState(S,"",A)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(A)}s&&l&&l({action:o,location:y.location,delta:1})}function m(v,b){o="REPLACE";let E=XN(y.location,v,b);u=d();let S=s5(E,u),A=y.createHref(E);a.replaceState(S,"",A),s&&l&&l({action:o,location:y.location,delta:0})}function x(v){return tie(v)}let y={get action(){return o},get location(){return t(i,a)},listen(v){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(i5,f),l=v,()=>{i.removeEventListener(i5,f),l=null}},createHref(v){return e(i,v)},createURL:x,encodeLocation(v){let b=x(v);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:g,replace:m,go(v){return a.go(v)}};return y}function tie(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:r0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function J9(t,e,n="/"){return nie(t,e,n,!1)}function nie(t,e,n,r){let i=typeof e=="string"?Om(e):e,s=vc(i.pathname||"/",n);if(s==null)return null;let a=eG(t);rie(a);let o=null;for(let l=0;o==null&&l<a.length;++l){let u=pie(s);o=hie(a[l],u,r)}return o}function eG(t,e=[],n=[],r="",i=!1){let s=(a,o,l=i,u)=>{let d={relativePath:u===void 0?a.path||"":u,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&l)return;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=dc([r,d.relativePath]),g=n.concat(d);a.children&&a.children.length>0&&(vr(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),eG(a.children,e,g,f,l)),!(a.path==null&&!a.index)&&e.push({path:f,score:uie(f,a.index),routesMeta:g})};return t.forEach((a,o)=>{if(a.path===""||!a.path?.includes("?"))s(a,o);else for(let l of tG(a.path))s(a,o,!0,l)}),e}function tG(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let a=tG(r.join("/")),o=[];return o.push(...a.map(l=>l===""?s:[s,l].join("/"))),i&&o.push(...a),o.map(l=>t.startsWith("/")&&l===""?"/":l)}function rie(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:die(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var iie=/^:[\w-]+$/,sie=3,aie=2,oie=1,lie=10,cie=-2,a5=t=>t==="*";function uie(t,e){let n=t.split("/"),r=n.length;return n.some(a5)&&(r+=cie),e&&(r+=aie),n.filter(i=>!a5(i)).reduce((i,s)=>i+(iie.test(s)?sie:s===""?oie:lie),r)}function die(t,e){return t.length===e.length&&t.slice(0,-1).every((r,i)=>r===e[i])?t[t.length-1]-e[e.length-1]:0}function hie(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",a=[];for(let o=0;o<r.length;++o){let l=r[o],u=o===r.length-1,d=s==="/"?e:e.slice(s.length)||"/",f=i1({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},d),g=l.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=i1({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),a.push({params:i,pathname:dc([s,f.pathname]),pathnameBase:vie(dc([s,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(s=dc([s,f.pathnameBase]))}return a}function i1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=fie(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let s=i[0],a=s.replace(/(.)\/+$/,"$1"),o=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},g)=>{if(d==="*"){let x=o[g]||"";a=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const m=o[g];return f&&!m?u[d]=void 0:u[d]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:a,pattern:t}}function fie(t,e=!1,n=!0){Do(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,o,l)=>(r.push({paramName:o,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function pie(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Do(!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 vc(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 mie=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,gie=t=>mie.test(t);function xie(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Om(t):t,s;if(n)if(gie(n))s=n;else{if(n.includes("//")){let a=n;n=n.replace(/\/\/+/g,"/"),Do(!1,`Pathnames cannot have embedded double slashes - normalizing ${a} -> ${n}`)}n.startsWith("/")?s=o5(n.substring(1),"/"):s=o5(n,e)}else s=e;return{pathname:s,search:yie(r),hash:_ie(i)}}function o5(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 iA(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 bie(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function nG(t){let e=bie(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function rG(t,e,n,r=!1){let i;typeof t=="string"?i=Om(t):(i={...t},vr(!i.pathname||!i.pathname.includes("?"),iA("?","pathname","search",i)),vr(!i.pathname||!i.pathname.includes("#"),iA("#","pathname","hash",i)),vr(!i.search||!i.search.includes("#"),iA("#","search","hash",i)));let s=t===""||i.pathname==="",a=s?"/":i.pathname,o;if(a==null)o=n;else{let f=e.length-1;if(!r&&a.startsWith("..")){let g=a.split("/");for(;g[0]==="..";)g.shift(),f-=1;i.pathname=g.join("/")}o=f>=0?e[f]:"/"}let l=xie(i,o),u=a&&a!=="/"&&a.endsWith("/"),d=(s||a===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(u||d)&&(l.pathname+="/"),l}var dc=t=>t.join("/").replace(/\/\/+/g,"/"),vie=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),yie=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,_ie=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function wie(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 iG=["POST","PUT","PATCH","DELETE"];new Set(iG);var Sie=["GET",...iG];new Set(Sie);var jm=M.createContext(null);jm.displayName="DataRouter";var dS=M.createContext(null);dS.displayName="DataRouterState";M.createContext(!1);var sG=M.createContext({isTransitioning:!1});sG.displayName="ViewTransition";var Eie=M.createContext(new Map);Eie.displayName="Fetchers";var Mie=M.createContext(null);Mie.displayName="Await";var gl=M.createContext(null);gl.displayName="Navigation";var eb=M.createContext(null);eb.displayName="Location";var Uo=M.createContext({outlet:null,matches:[],isDataRoute:!1});Uo.displayName="Route";var iR=M.createContext(null);iR.displayName="RouteError";function Aie(t,{relative:e}={}){vr(tb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=M.useContext(gl),{hash:i,pathname:s,search:a}=nb(t,{relative:e}),o=s;return n!=="/"&&(o=s==="/"?n:dc([n,s])),r.createHref({pathname:o,search:a,hash:i})}function tb(){return M.useContext(eb)!=null}function dd(){return vr(tb(),"useLocation() may be used only in the context of a <Router> component."),M.useContext(eb).location}var aG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function oG(t){M.useContext(gl).static||M.useLayoutEffect(t)}function sR(){let{isDataRoute:t}=M.useContext(Uo);return t?Bie():Tie()}function Tie(){vr(tb(),"useNavigate() may be used only in the context of a <Router> component.");let t=M.useContext(jm),{basename:e,navigator:n}=M.useContext(gl),{matches:r}=M.useContext(Uo),{pathname:i}=dd(),s=JSON.stringify(nG(r)),a=M.useRef(!1);return oG(()=>{a.current=!0}),M.useCallback((l,u={})=>{if(Do(a.current,aG),!a.current)return;if(typeof l=="number"){n.go(l);return}let d=rG(l,JSON.parse(s),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:dc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,s,i,t])}var Cie=M.createContext(null);function Nie(t){let e=M.useContext(Uo).outlet;return M.useMemo(()=>e&&M.createElement(Cie.Provider,{value:t},e),[e,t])}function lG(){let{matches:t}=M.useContext(Uo),e=t[t.length-1];return e?e.params:{}}function nb(t,{relative:e}={}){let{matches:n}=M.useContext(Uo),{pathname:r}=dd(),i=JSON.stringify(nG(n));return M.useMemo(()=>rG(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function kie(t,e){return cG(t,e)}function cG(t,e,n,r,i){vr(tb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=M.useContext(gl),{matches:a}=M.useContext(Uo),o=a[a.length-1],l=o?o.params:{},u=o?o.pathname:"/",d=o?o.pathnameBase:"/",f=o&&o.route;{let E=f&&f.path||"";uG(u,!f||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${E}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let g=dd(),m;if(e){let E=typeof e=="string"?Om(e):e;vr(d==="/"||E.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${E.pathname}" was given in the \`location\` prop.`),m=E}else m=g;let x=m.pathname||"/",y=x;if(d!=="/"){let E=d.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(E.length).join("/")}let v=J9(t,{pathname:y});Do(f||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Do(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=jie(v&&v.map(E=>Object.assign({},E,{params:Object.assign({},l,E.params),pathname:dc([d,s.encodeLocation?s.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?d:dc([d,s.encodeLocation?s.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),a,n,r,i);return e&&b?M.createElement(eb.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},b):b}function Pie(){let t=zie(),e=wie(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},a=null;return console.error("Error handled by React Router default ErrorBoundary:",t),a=M.createElement(M.Fragment,null,M.createElement("p",null,"💿 Hey developer 👋"),M.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",M.createElement("code",{style:s},"ErrorBoundary")," or"," ",M.createElement("code",{style:s},"errorElement")," prop on your route.")),M.createElement(M.Fragment,null,M.createElement("h2",null,"Unexpected Application Error!"),M.createElement("h3",{style:{fontStyle:"italic"}},e),n?M.createElement("pre",{style:i},n):null,a)}var Rie=M.createElement(Pie,null),Die=class extends M.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?M.createElement(Uo.Provider,{value:this.props.routeContext},M.createElement(iR.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Oie({routeContext:t,match:e,children:n}){let r=M.useContext(jm);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),M.createElement(Uo.Provider,{value:t},n)}function jie(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let s=t,a=n?.errors;if(a!=null){let d=s.findIndex(f=>f.route.id&&a?.[f.route.id]!==void 0);vr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,d+1))}let o=!1,l=-1;if(n)for(let d=0;d<s.length;d++){let f=s[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(l=d),f.route.id){let{loaderData:g,errors:m}=n,x=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||x){o=!0,l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return s.reduceRight((d,f,g)=>{let m,x=!1,y=null,v=null;n&&(m=a&&f.route.id?a[f.route.id]:void 0,y=f.route.errorElement||Rie,o&&(l<0&&g===0?(uG("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,v=null):l===g&&(x=!0,v=f.route.hydrateFallbackElement||null)));let b=e.concat(s.slice(0,g+1)),E=()=>{let S;return m?S=y:x?S=v:f.route.Component?S=M.createElement(f.route.Component,null):f.route.element?S=f.route.element:S=d,M.createElement(Oie,{match:f,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:S})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?M.createElement(Die,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:E(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):E()},null)}function aR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Lie(t){let e=M.useContext(jm);return vr(e,aR(t)),e}function Iie(t){let e=M.useContext(dS);return vr(e,aR(t)),e}function Uie(t){let e=M.useContext(Uo);return vr(e,aR(t)),e}function oR(t){let e=Uie(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 Fie(){return oR("useRouteId")}function zie(){let t=M.useContext(iR),e=Iie("useRouteError"),n=oR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Bie(){let{router:t}=Lie("useNavigate"),e=oR("useNavigate"),n=M.useRef(!1);return oG(()=>{n.current=!0}),M.useCallback(async(i,s={})=>{Do(n.current,aG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var l5={};function uG(t,e,n){!e&&!l5[t]&&(l5[t]=!0,Do(!1,n))}M.memo(Hie);function Hie({routes:t,future:e,state:n,unstable_onError:r}){return cG(t,void 0,n,r,e)}function $ie(t){return Nie(t.context)}function La(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 Vie({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1}){vr(!tb(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let a=t.replace(/^\/*/,"/"),o=M.useMemo(()=>({basename:a,navigator:i,static:s,future:{}}),[a,i,s]);typeof n=="string"&&(n=Om(n));let{pathname:l="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,m=M.useMemo(()=>{let x=vc(l,a);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:g},navigationType:r}},[a,l,u,d,f,g,r]);return Do(m!=null,`<Router basename="${a}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:M.createElement(gl.Provider,{value:o},M.createElement(eb.Provider,{children:e,value:m}))}function Gie({children:t,location:e}){return kie(YN(t),e)}function YN(t,e=[]){let n=[];return M.Children.forEach(t,(r,i)=>{if(!M.isValidElement(r))return;let s=[...e,i];if(r.type===M.Fragment){n.push.apply(n,YN(r.props.children,s));return}vr(r.type===La,`[${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 a={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(a.children=YN(r.props.children,s)),n.push(a)}),n}var D_="get",O_="application/x-www-form-urlencoded";function hS(t){return t!=null&&typeof t.tagName=="string"}function Wie(t){return hS(t)&&t.tagName.toLowerCase()==="button"}function qie(t){return hS(t)&&t.tagName.toLowerCase()==="form"}function Kie(t){return hS(t)&&t.tagName.toLowerCase()==="input"}function Xie(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Yie(t,e){return t.button===0&&(!e||e==="_self")&&!Xie(t)}var Qv=null;function Zie(){if(Qv===null)try{new FormData(document.createElement("form"),0),Qv=!1}catch{Qv=!0}return Qv}var Qie=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function sA(t){return t!=null&&!Qie.has(t)?(Do(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${O_}"`),null):t}function Jie(t,e){let n,r,i,s,a;if(qie(t)){let o=t.getAttribute("action");r=o?vc(o,e):null,n=t.getAttribute("method")||D_,i=sA(t.getAttribute("enctype"))||O_,s=new FormData(t)}else if(Wie(t)||Kie(t)&&(t.type==="submit"||t.type==="image")){let o=t.form;if(o==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=t.getAttribute("formaction")||o.getAttribute("action");if(r=l?vc(l,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||D_,i=sA(t.getAttribute("formenctype"))||sA(o.getAttribute("enctype"))||O_,s=new FormData(o,t),!Zie()){let{name:u,type:d,value:f}=t;if(d==="image"){let g=u?`${u}.`:"";s.append(`${g}x`,"0"),s.append(`${g}y`,"0")}else u&&s.append(u,f)}}else{if(hS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=D_,r=null,i=O_,a=t}return s&&i==="text/plain"&&(a=s,s=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:s,body:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function lR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function ese(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&&vc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function tse(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 nse(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 rse(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let a=await tse(s,n);return a.links?a.links():[]}return[]}));return ose(r.flat(1).filter(nse).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function c5(t,e,n,r,i,s){let a=(l,u)=>n[u]?l.route.id!==n[u].route.id:!0,o=(l,u)=>n[u].pathname!==l.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==l.params["*"];return s==="assets"?e.filter((l,u)=>a(l,u)||o(l,u)):s==="data"?e.filter((l,u)=>{let d=r.routes[l.route.id];if(!d||!d.hasLoader)return!1;if(a(l,u)||o(l,u))return!0;if(l.route.shouldRevalidate){let f=l.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function ise(t,e,{includeHydrateFallback:n}={}){return sse(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let s=[i.module];return i.clientActionModule&&(s=s.concat(i.clientActionModule)),i.clientLoaderModule&&(s=s.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(s=s.concat(i.hydrateFallbackModule)),i.imports&&(s=s.concat(i.imports)),s}).flat(1))}function sse(t){return[...new Set(t)]}function ase(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function ose(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(ase(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function dG(){let t=M.useContext(jm);return lR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function lse(){let t=M.useContext(dS);return lR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var cR=M.createContext(void 0);cR.displayName="FrameworkContext";function hG(){let t=M.useContext(cR);return lR(t,"You must render this element inside a <HydratedRouter> element"),t}function cse(t,e){let n=M.useContext(cR),[r,i]=M.useState(!1),[s,a]=M.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,g=M.useRef(null);M.useEffect(()=>{if(t==="render"&&a(!0),t==="viewport"){let y=b=>{b.forEach(E=>{a(E.isIntersecting)})},v=new IntersectionObserver(y,{threshold:.5});return g.current&&v.observe(g.current),()=>{v.disconnect()}}},[t]),M.useEffect(()=>{if(r){let y=setTimeout(()=>{a(!0)},100);return()=>{clearTimeout(y)}}},[r]);let m=()=>{i(!0)},x=()=>{i(!1),a(!1)};return n?t!=="intent"?[s,g,{}]:[s,g,{onFocus:Xg(o,m),onBlur:Xg(l,x),onMouseEnter:Xg(u,m),onMouseLeave:Xg(d,x),onTouchStart:Xg(f,m)}]:[!1,g,{}]}function Xg(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function use({page:t,...e}){let{router:n}=dG(),r=M.useMemo(()=>J9(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?M.createElement(hse,{page:t,matches:r,...e}):null}function dse(t){let{manifest:e,routeModules:n}=hG(),[r,i]=M.useState([]);return M.useEffect(()=>{let s=!1;return rse(t,e,n).then(a=>{s||i(a)}),()=>{s=!0}},[t,e,n]),r}function hse({page:t,matches:e,...n}){let r=dd(),{manifest:i,routeModules:s}=hG(),{basename:a}=dG(),{loaderData:o,matches:l}=lse(),u=M.useMemo(()=>c5(t,e,l,i,r,"data"),[t,e,l,i,r]),d=M.useMemo(()=>c5(t,e,l,i,r,"assets"),[t,e,l,i,r]),f=M.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,y=!1;if(e.forEach(b=>{let E=i.routes[b.route.id];!E||!E.hasLoader||(!u.some(S=>S.route.id===b.route.id)&&b.route.id in o&&s[b.route.id]?.shouldRevalidate||E.hasClientLoader?y=!0:x.add(b.route.id))}),x.size===0)return[];let v=ese(t,a,"data");return y&&x.size>0&&v.searchParams.set("_routes",e.filter(b=>x.has(b.route.id)).map(b=>b.route.id).join(",")),[v.pathname+v.search]},[a,o,r,i,u,e,t,s]),g=M.useMemo(()=>ise(d,i),[d,i]),m=dse(d);return M.createElement(M.Fragment,null,f.map(x=>M.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.map(x=>M.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),m.map(({key:x,link:y})=>M.createElement("link",{key:x,nonce:n.nonce,...y})))}function fse(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var fG=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{fG&&(window.__reactRouterVersion="7.9.6")}catch{}function pse({basename:t,children:e,window:n}){let r=M.useRef();r.current==null&&(r.current=Qre({window:n,v5Compat:!0}));let i=r.current,[s,a]=M.useState({action:i.action,location:i.location}),o=M.useCallback(l=>{M.startTransition(()=>a(l))},[a]);return M.useLayoutEffect(()=>i.listen(o),[i,o]),M.createElement(Vie,{basename:t,children:e,location:s.location,navigationType:s.action,navigator:i})}var pG=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,fS=M.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:a,state:o,target:l,to:u,preventScrollReset:d,viewTransition:f,...g},m){let{basename:x}=M.useContext(gl),y=typeof u=="string"&&pG.test(u),v,b=!1;if(typeof u=="string"&&y&&(v=u,fG))try{let N=new URL(window.location.href),D=u.startsWith("//")?new URL(N.protocol+u):new URL(u),F=vc(D.pathname,x);D.origin===N.origin&&F!=null?u=F+D.search+D.hash:b=!0}catch{Do(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=Aie(u,{relative:i}),[S,A,T]=cse(r,g),P=xse(u,{replace:a,state:o,target:l,preventScrollReset:d,relative:i,viewTransition:f});function C(N){e&&e(N),N.defaultPrevented||P(N)}let I=M.createElement("a",{...g,...T,href:v||E,onClick:b||s?e:C,ref:fse(m,A),target:l,"data-discover":!y&&n==="render"?"true":void 0});return S&&!y?M.createElement(M.Fragment,null,I,M.createElement(use,{page:E})):I});fS.displayName="Link";var ZN=M.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:a,viewTransition:o,children:l,...u},d){let f=nb(a,{relative:u.relative}),g=dd(),m=M.useContext(dS),{navigator:x,basename:y}=M.useContext(gl),v=m!=null&&wse(f)&&o===!0,b=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,E=g.pathname,S=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(E=E.toLowerCase(),S=S?S.toLowerCase():null,b=b.toLowerCase()),S&&y&&(S=vc(S,y)||S);const A=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let T=E===b||!i&&E.startsWith(b)&&E.charAt(A)==="/",P=S!=null&&(S===b||!i&&S.startsWith(b)&&S.charAt(b.length)==="/"),C={isActive:T,isPending:P,isTransitioning:v},I=T?e:void 0,N;typeof r=="function"?N=r(C):N=[r,T?"active":null,P?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let D=typeof s=="function"?s(C):s;return M.createElement(fS,{...u,"aria-current":I,className:N,ref:d,style:D,to:a,viewTransition:o},typeof l=="function"?l(C):l)});ZN.displayName="NavLink";var mse=M.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:a=D_,action:o,onSubmit:l,relative:u,preventScrollReset:d,viewTransition:f,...g},m)=>{let x=yse(),y=_se(o,{relative:u}),v=a.toLowerCase()==="get"?"get":"post",b=typeof o=="string"&&pG.test(o),E=S=>{if(l&&l(S),S.defaultPrevented)return;S.preventDefault();let A=S.nativeEvent.submitter,T=A?.getAttribute("formmethod")||a;x(A||S.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:i,state:s,relative:u,preventScrollReset:d,viewTransition:f})};return M.createElement("form",{ref:m,method:v,action:y,onSubmit:r?l:E,...g,"data-discover":!b&&t==="render"?"true":void 0})});mse.displayName="Form";function gse(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function mG(t){let e=M.useContext(jm);return vr(e,gse(t)),e}function xse(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:a}={}){let o=sR(),l=dd(),u=nb(t,{relative:s});return M.useCallback(d=>{if(Yie(d,e)){d.preventDefault();let f=n!==void 0?n:r0(l)===r0(u);o(t,{replace:f,state:r,preventScrollReset:i,relative:s,viewTransition:a})}},[l,o,u,n,r,e,t,i,s,a])}var bse=0,vse=()=>`__${String(++bse)}__`;function yse(){let{router:t}=mG("useSubmit"),{basename:e}=M.useContext(gl),n=Fie();return M.useCallback(async(r,i={})=>{let{action:s,method:a,encType:o,formData:l,body:u}=Jie(r,e);if(i.navigate===!1){let d=i.fetcherKey||vse();await t.fetch(d,n,i.action||s,{preventScrollReset:i.preventScrollReset,formData:l,body:u,formMethod:i.method||a,formEncType:i.encType||o,flushSync:i.flushSync})}else await t.navigate(i.action||s,{preventScrollReset:i.preventScrollReset,formData:l,body:u,formMethod:i.method||a,formEncType:i.encType||o,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function _se(t,{relative:e}={}){let{basename:n}=M.useContext(gl),r=M.useContext(Uo);vr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...nb(t||".",{relative:e})},a=dd();if(t==null){s.search=a.search;let o=new URLSearchParams(s.search),l=o.getAll("index");if(l.some(d=>d==="")){o.delete("index"),l.filter(f=>f).forEach(f=>o.append("index",f));let d=o.toString();s.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:dc([n,s.pathname])),r0(s)}function wse(t,{relative:e}={}){let n=M.useContext(sG);vr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=mG("useViewTransitionState"),i=nb(t,{relative:e});if(!n.isTransitioning)return!1;let s=vc(n.currentLocation.pathname,r)||n.currentLocation.pathname,a=vc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return i1(i.pathname,a)!=null||i1(i.pathname,s)!=null}var ic=H9();const Sse=oo(ic);var Lm=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(){}},Ese={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Mse=class{#e=Ese;#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)}},ih=new Mse;function Ase(t){setTimeout(t,0)}var Nh=typeof window>"u"||"Deno"in globalThis;function ys(){}function Tse(t,e){return typeof t=="function"?t(e):t}function QN(t){return typeof t=="number"&&t>=0&&t!==1/0}function gG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Bu(t,e){return typeof t=="function"?t(e):t}function Ba(t,e){return typeof t=="function"?t(e):t}function u5(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:a,stale:o}=t;if(a){if(r){if(e.queryHash!==uR(a,e.options))return!1}else if(!i0(e.queryKey,a))return!1}if(n!=="all"){const l=e.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||i&&i!==e.state.fetchStatus||s&&!s(e))}function d5(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(kh(e.options.mutationKey)!==kh(s))return!1}else if(!i0(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function uR(t,e){return(e?.queryKeyHashFn||kh)(t)}function kh(t){return JSON.stringify(t,(e,n)=>JN(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function i0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>i0(t[n],e[n])):!1}var Cse=Object.prototype.hasOwnProperty;function xG(t,e){if(t===e)return t;const n=h5(t)&&h5(e);if(!n&&!(JN(t)&&JN(e)))return e;const i=(n?t:Object.keys(t)).length,s=n?e:Object.keys(e),a=s.length,o=n?new Array(a):{};let l=0;for(let u=0;u<a;u++){const d=n?u:s[u],f=t[d],g=e[d];if(f===g){o[d]=f,(n?u<i:Cse.call(t,d))&&l++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){o[d]=g;continue}const m=xG(f,g);o[d]=m,m===f&&l++}return i===a&&l===i?t:o}function s1(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 h5(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function JN(t){if(!f5(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!f5(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function f5(t){return Object.prototype.toString.call(t)==="[object Object]"}function Nse(t){return new Promise(e=>{ih.setTimeout(e,t)})}function e3(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?xG(t,e):e}function kse(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 dR=Symbol();function bG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===dR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function vG(t,e){return typeof t=="function"?t(...e):!!t}var Rse=class extends Lm{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Nh&&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"}},hR=new Rse;function t3(){let t,e;const n=new Promise((i,s)=>{t=i,e=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var Dse=Ase;function Ose(){let t=[],e=0,n=o=>{o()},r=o=>{o()},i=Dse;const s=o=>{e?t.push(o):i(()=>{n(o)})},a=()=>{const o=t;t=[],o.length&&i(()=>{r(()=>{o.forEach(l=>{n(l)})})})};return{batch:o=>{let l;e++;try{l=o()}finally{e--,e||a()}return l},batchCalls:o=>(...l)=>{s(()=>{o(...l)})},schedule:s,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var di=Ose(),jse=class extends Lm{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Nh&&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 jse;function Lse(t){return Math.min(1e3*2**t,3e4)}function yG(t){return(t??"online")==="online"?a1.isOnline():!0}var n3=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function _G(t){let e=!1,n=0,r;const i=t3(),s=()=>i.status!=="pending",a=y=>{if(!s()){const v=new n3(y);g(v),t.onCancel?.(v)}},o=()=>{e=!0},l=()=>{e=!1},u=()=>hR.isFocused()&&(t.networkMode==="always"||a1.isOnline())&&t.canRun(),d=()=>yG(t.networkMode)&&t.canRun(),f=y=>{s()||(r?.(),i.resolve(y))},g=y=>{s()||(r?.(),i.reject(y))},m=()=>new Promise(y=>{r=v=>{(s()||u())&&y(v)},t.onPause?.()}).then(()=>{r=void 0,s()||t.onContinue?.()}),x=()=>{if(s())return;let y;const v=n===0?t.initialPromise:void 0;try{y=v??t.fn()}catch(b){y=Promise.reject(b)}Promise.resolve(y).then(f).catch(b=>{if(s())return;const E=t.retry??(Nh?0:3),S=t.retryDelay??Lse,A=typeof S=="function"?S(n,b):S,T=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,b);if(e||!T){g(b);return}n++,t.onFail?.(n,b),Nse(A).then(()=>u()?void 0:m()).then(()=>{e?g(b):x()})})};return{promise:i,status:()=>i.status,cancel:a,continue:()=>(r?.(),i),cancelRetry:o,continueRetry:l,canStart:d,start:()=>(d()?x():m().then(x),i)}}var wG=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),QN(this.gcTime)&&(this.#e=ih.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Nh?1/0:300*1e3))}clearGcTimeout(){this.#e&&(ih.clearTimeout(this.#e),this.#e=void 0)}},Ise=class extends wG{#e;#t;#n;#i;#r;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=m5(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#a,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=m5(this.options);e.data!==void 0&&(this.setState(p5(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=e3(this.state.data,t,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#s({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(ys).catch(ys):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Ba(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===dR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Bu(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:!gG(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(l=>l.options.queryFn);o&&this.setOptions(o.options)}const n=new AbortController,r=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const o=bG(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(o,u,this):o(u)},a=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(o),o})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:"fetch",meta:a.fetchOptions?.meta}),this.#r=_G({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o=>{o instanceof n3&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(o,l)=>{this.#s({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const o=await this.#r.start();if(o===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#n.config.onSuccess?.(o,this),this.#n.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof n3){if(o.silent)return this.#r.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#s({type:"error",error:o}),this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#s(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...SG(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...p5(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),di.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function SG(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:yG(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function p5(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function m5(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 Use=class extends Lm{constructor(t,e){super(),this.options=e,this.#e=t,this.#s=null,this.#o=t3(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#m;#h;#f;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),g5(this.#t,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return r3(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return r3(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#_(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ba(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&&!s1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&x5(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Ba(this.options.enabled,this.#t)!==Ba(e.enabled,this.#t)||Bu(this.options.staleTime,this.#t)!==Bu(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Ba(this.options.enabled,this.#t)!==Ba(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 zse(this,n)&&(this.#i=n,this.#a=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#d(t){this.#w();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(ys)),e}#g(){this.#y();const t=Bu(this.options.staleTime,this.#t);if(Nh||this.#i.isStale||!QN(t))return;const n=gG(this.#i.dataUpdatedAt,t)+1;this.#c=ih.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,!(Nh||Ba(this.options.enabled,this.#t)===!1||!QN(this.#l)||this.#l===0)&&(this.#u=ih.setInterval(()=>{(this.options.refetchIntervalInBackground||hR.isFocused())&&this.#d()},this.#l))}#v(){this.#g(),this.#b(this.#x())}#y(){this.#c&&(ih.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(ih.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#i,s=this.#r,a=this.#a,l=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,g;if(e._optimisticResults){const I=this.hasListeners(),N=!I&&g5(t,e),D=I&&x5(t,n,e,r);(N||D)&&(d={...d,...SG(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:x,status:y}=d;g=d.data;let v=!1;if(e.placeholderData!==void 0&&g===void 0&&y==="pending"){let I;i?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(I=i.data,v=!0):I=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,I!==void 0&&(y="success",g=e3(i?.data,I,e),f=!0)}if(e.select&&g!==void 0&&!v)if(i&&g===s?.data&&e.select===this.#m)g=this.#h;else try{this.#m=e.select,g=e.select(g),g=e3(i?.data,g,e),this.#h=g,this.#s=null}catch(I){this.#s=I}this.#s&&(m=this.#s,g=this.#h,x=Date.now(),y="error");const b=d.fetchStatus==="fetching",E=y==="pending",S=y==="error",A=E&&b,T=g!==void 0,C={status:y,fetchStatus:d.fetchStatus,isPending:E,isSuccess:y==="success",isError:S,isInitialLoading:A,isLoading:A,data:g,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:b,isRefetching:b&&!E,isLoadingError:S&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:S&&T,isStale:fR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Ba(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=F=>{C.status==="error"?F.reject(C.error):C.data!==void 0&&F.resolve(C.data)},N=()=>{const F=this.#o=C.promise=t3();I(F)},D=this.#o;switch(D.status){case"pending":t.queryHash===n.queryHash&&I(D);break;case"fulfilled":(C.status==="error"||C.data!==D.value)&&N();break;case"rejected":(C.status!=="error"||C.error!==D.reason)&&N();break}}return C}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#a=this.options,this.#r.data!==void 0&&(this.#f=this.#t),s1(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#p.size)return!0;const s=new Set(i??this.#p);return this.options.throwOnError&&s.add("error"),Object.keys(this.#i).some(a=>{const o=a;return this.#i[o]!==t[o]&&s.has(o)})};this.#S({listeners:n()})}#w(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#S(t){di.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Fse(t,e){return Ba(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function g5(t,e){return Fse(t,e)||t.state.data!==void 0&&r3(t,e,e.refetchOnMount)}function r3(t,e,n){if(Ba(e.enabled,t)!==!1&&Bu(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&fR(t,e)}return!1}function x5(t,e,n,r){return(t!==e||Ba(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&fR(t,n)}function fR(t,e){return Ba(e.enabled,t)!==!1&&t.isStaleByTime(Bu(e.staleTime,t))}function zse(t,e){return!s1(t.getCurrentResult(),e)}function b5(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],a=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=bG(e.options,e.fetchOptions),m=async(x,y,v)=>{if(d)return Promise.reject();if(y==null&&x.pages.length)return Promise.resolve(x);const E=(()=>{const P={client:e.client,queryKey:e.queryKey,pageParam:y,direction:v?"backward":"forward",meta:e.options.meta};return f(P),P})(),S=await g(E),{maxPages:A}=e.options,T=v?Pse:kse;return{pages:T(x.pages,S,A),pageParams:T(x.pageParams,y,A)}};if(i&&s.length){const x=i==="backward",y=x?Bse:v5,v={pages:s,pageParams:a},b=y(r,v);o=await m(v,b,x)}else{const x=t??s.length;do{const y=l===0?a[0]??r.initialPageParam:v5(r,o);if(l>0&&y==null)break;o=await m(o,y),l++}while(l<x)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function v5(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 Bse(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Hse=class extends wG{#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=_G({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,a)=>{this.#r({type:"failed",failureCount:s,error:a})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const a=await this.options.onMutate?.(t,n);a!==this.state.context&&this.#r({type:"pending",context:a,variables:t,isPaused:i})}const s=await this.#i.start();return await this.#n.config.onSuccess?.(s,t,this.state.context,this,n),await this.options.onSuccess?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(s,null,t,this.state.context,n),this.#r({type:"success",data:s}),s}catch(s){try{throw await this.#n.config.onError?.(s,t,this.state.context,this,n),await this.options.onError?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,s,t,this.state.context,n),s}finally{this.#r({type:"error",error:s})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),di.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function EG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $se=class extends Lm{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 Hse({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=Jv(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=Jv(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=Jv(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=Jv(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){di.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>d5(e,n))}findAll(t={}){return this.getAll().filter(e=>d5(t,e))}notify(t){di.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return di.batch(()=>Promise.all(t.map(e=>e.continue().catch(ys))))}};function Jv(t){return t.options.scope?.id}var Vse=class extends Lm{#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),s1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&kh(n.mutationKey)!==kh(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#a()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??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}}#a(e){di.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,n,r,i),this.#i.onSettled?.(e.data,null,n,r,i)):e?.type==="error"&&(this.#i.onError?.(e.error,n,r,i),this.#i.onSettled?.(void 0,e.error,n,r,i))}this.listeners.forEach(n=>{n(this.#t)})})}},Gse=class extends Lm{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??uR(r,e);let s=this.get(i);return s||(s=new Ise({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(s)),s}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){di.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>u5(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>u5(t,n)):e}notify(t){di.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){di.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){di.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Wse=class{#e;#t;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#e=t.queryCache||new Gse,this.#t=t.mutationCache||new $se,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=hR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=a1.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Bu(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),s=this.#e.get(r.queryHash)?.state.data,a=Tse(e,s);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(t,e,n){return di.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;di.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return di.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=di.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(ys).catch(ys)}invalidateQueries(t,e={}){return di.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=di.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(ys)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(ys)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(Bu(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ys).catch(ys)}fetchInfiniteQuery(t){return t.behavior=b5(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ys).catch(ys)}ensureInfiniteQueryData(t){return t.behavior=b5(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(kh(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{i0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(kh(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{i0(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=uR(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===dR&&(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()}},MG=M.createContext(void 0),Sn=t=>{const e=M.useContext(MG);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},qse=({client:t,children:e})=>(M.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),c.jsx(MG.Provider,{value:t,children:e})),AG=M.createContext(!1),Kse=()=>M.useContext(AG);AG.Provider;function Xse(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Yse=M.createContext(Xse()),Zse=()=>M.useContext(Yse),Qse=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Jse=t=>{M.useEffect(()=>{t.clearReset()},[t])},eae=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||vG(n,[t.error,r])),tae=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))}},nae=(t,e)=>t.isLoading&&t.isFetching&&!e,rae=(t,e)=>t?.suspense&&e.isPending,y5=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function iae(t,e,n){const r=Kse(),i=Zse(),s=Sn(),a=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=r?"isRestoring":"optimistic",tae(a),Qse(a,i),Jse(i);const o=!s.getQueryCache().get(a.queryHash),[l]=M.useState(()=>new e(s,a)),u=l.getOptimisticResult(a),d=!r&&t.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(f=>{const g=d?l.subscribe(di.batchCalls(f)):ys;return l.updateResult(),g},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),M.useEffect(()=>{l.setOptions(a)},[a,l]),rae(a,u))throw y5(a,l,i);if(eae({result:u,errorResetBoundary:i,throwOnError:a.throwOnError,query:s.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw u.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(a,u),a.experimental_prefetchInRender&&!Nh&&nae(u,r)&&(o?y5(a,l,i):s.getQueryCache().get(a.queryHash)?.promise)?.catch(ys).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?u:l.trackResult(u)}function yt(t,e){return iae(t,Use)}function _t(t,e){const n=Sn(),[r]=M.useState(()=>new Vse(n,t));M.useEffect(()=>{r.setOptions(t)},[r,t]);const i=M.useSyncExternalStore(M.useCallback(a=>r.subscribe(di.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=M.useCallback((a,o)=>{r.mutate(a,o).catch(ys)},[r]);if(i.error&&vG(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const sae=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),aae=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),_5=t=>{const e=aae(t);return e.charAt(0).toUpperCase()+e.slice(1)},TG=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),oae=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var lae={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 cae=M.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:a,...o},l)=>M.createElement("svg",{ref:l,...lae,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:TG("lucide",i),...!s&&!oae(o)&&{"aria-hidden":"true"},...o},[...a.map(([u,d])=>M.createElement(u,d)),...Array.isArray(s)?s:[s]]));const Xe=(t,e)=>{const n=M.forwardRef(({className:r,...i},s)=>M.createElement(cae,{ref:s,iconNode:e,className:TG(`lucide-${sae(_5(t))}`,`lucide-${t}`,r),...i}));return n.displayName=_5(t),n};const uae=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],pS=Xe("archive",uae);const dae=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],s0=Xe("arrow-down",dae);const hae=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],i3=Xe("arrow-right",hae);const fae=[["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"}]],pae=Xe("arrow-up-down",fae);const mae=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],nm=Xe("arrow-up",mae);const gae=[["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"}]],fh=Xe("bell",gae);const xae=[["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"}]],bae=Xe("bold",xae);const vae=[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],yae=Xe("book",vae);const _ae=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],wae=Xe("bookmark",_ae);const Sae=[["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"}]],rm=Xe("box",Sae);const Eae=[["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"}]],Mae=Xe("cable",Eae);const Aae=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["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"}]],Tae=Xe("calendar-days",Aae);const Cae=[["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"}]],qr=Xe("calendar",Cae);const Nae=[["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"}]],a0=Xe("camera",Nae);const kae=[["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"}]],Pae=Xe("chart-column",kae);const Rae=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ph=Xe("check",Rae);const Dae=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ef=Xe("chevron-down",Dae);const Oae=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],tf=Xe("chevron-right",Oae);const jae=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Rh=Xe("chevron-left",jae);const Lae=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],mS=Xe("chevron-up",Lae);const Iae=[["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"}]],Oo=Xe("circle-alert",Iae);const Uae=[["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"}]],aA=Xe("circle-arrow-up",Uae);const Fae=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ds=Xe("circle-check-big",Fae);const zae=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Bae=Xe("circle-dot",zae);const Hae=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],$ae=Xe("circle-stop",Hae);const Vae=[["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"}]],hd=Xe("circle-x",Vae);const Gae=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ti=Xe("clock",Gae);const Wae=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],gS=Xe("cloud",Wae);const qae=[["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"}]],Kae=Xe("code-xml",qae);const Xae=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],CG=Xe("code",Xae);const Yae=[["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"}]],Zae=Xe("coffee",Yae);const Qae=[["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"}]],Jae=Xe("cog",Qae);const eoe=[["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"}]],toe=Xe("compass",eoe);const noe=[["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"}]],Dh=Xe("copy",noe);const roe=[["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"}]],s3=Xe("database",roe);const ioe=[["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"}]],a3=Xe("dollar-sign",ioe);const soe=[["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"}]],ya=Xe("download",soe);const aoe=[["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"}]],pR=Xe("droplet",aoe);const ooe=[["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"}]],loe=Xe("droplets",ooe);const coe=[["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"}]],NG=Xe("ellipsis-vertical",coe);const uoe=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],oA=Xe("equal",uoe);const doe=[["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"}]],ro=Xe("external-link",doe);const hoe=[["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"}]],mR=Xe("eye-off",hoe);const foe=[["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"}]],o0=Xe("eye",foe);const poe=[["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"}]],moe=Xe("fan",poe);const goe=[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.8",key:"1kchwa"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}],["path",{d:"M3 13.1a2 2 0 0 0-.999 1.76v3.24a2 2 0 0 0 .969 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01z",key:"19flxy"}],["path",{d:"M7 17v5",key:"1yj1jh"}]],xoe=Xe("file-box",goe);const boe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],w5=Xe("file-code",boe);const voe=[["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"}]],yoe=Xe("file-exclamation-point",voe);const _oe=[["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"}]],o1=Xe("file-spreadsheet",_oe);const woe=[["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"}]],Ya=Xe("file-text",woe);const Soe=[["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"}]],kG=Xe("file",Soe);const Eoe=[["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"}]],Bp=Xe("film",Eoe);const Moe=[["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"}]],Aoe=Xe("flame",Moe);const Toe=[["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"}]],ph=Xe("folder-kanban",Toe);const Coe=[["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"}]],Noe=Xe("folder-open",Coe);const koe=[["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"}]],PG=Xe("folder",koe);const Poe=[["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"}]],gR=Xe("funnel",Poe);const Roe=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],xR=Xe("gauge",Roe);const Doe=[["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"}]],Ooe=Xe("gift",Doe);const joe=[["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"}]],Hp=Xe("git-compare",joe);const Loe=[["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"}]],S5=Xe("github",Loe);const Ioe=[["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"}]],l0=Xe("globe",Ioe);const Uoe=[["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"}]],c0=Xe("grip-vertical",Uoe);const Foe=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],RG=Xe("hard-drive",Foe);const zoe=[["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"}]],Boe=Xe("heart",zoe);const Hoe=[["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"}]],o3=Xe("history",Hoe);const $oe=[["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"}]],Voe=Xe("house",$oe);const Goe=[["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"}]],rb=Xe("image",Goe);const Woe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],DG=Xe("info",Woe);const qoe=[["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"}]],Koe=Xe("italic",qoe);const Xoe=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Op=Xe("key",Xoe);const Yoe=[["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"}]],l3=Xe("keyboard",Yoe);const Zoe=[["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"}]],Oh=Xe("layers",Zoe);const Qoe=[["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"}]],OG=Xe("layout-grid",Qoe);const Joe=[["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"}]],ele=Xe("layout-list",Joe);const tle=[["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"}]],nle=Xe("link-2-off",tle);const rle=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],c3=Xe("link-2",rle);const ile=[["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"}]],xS=Xe("link",ile);const sle=[["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"}]],jG=Xe("list-ordered",sle);const ale=[["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"}]],ole=Xe("list-todo",ale);const lle=[["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"}]],bR=Xe("list",lle);const cle=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],At=Xe("loader-circle",cle);const ule=[["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"}]],E5=Xe("log-in",ule);const dle=[["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"}]],hle=Xe("log-out",dle);const fle=[["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"}]],ple=Xe("mail",fle);const mle=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],gle=Xe("map",mle);const xle=[["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"}]],ble=Xe("maximize-2",xle);const vle=[["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"}]],yle=Xe("maximize",vle);const _le=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],wle=Xe("menu",_le);const Sle=[["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"}]],Ele=Xe("minimize-2",Sle);const Mle=[["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"}]],Ale=Xe("minimize",Mle);const Tle=[["path",{d:"M5 12h14",key:"1ays0h"}]],M5=Xe("minus",Tle);const Cle=[["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"}]],l1=Xe("moon",Cle);const Nle=[["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"}]],kle=Xe("music",Nle);const Ple=[["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"}]],u0=Xe("package",Ple);const Rle=[["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"}]],Dle=Xe("palette",Rle);const Ole=[["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"}]],jle=Xe("pause",Ole);const Lle=[["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"}]],d0=Xe("pen-line",Lle);const Ile=[["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"}]],vR=Xe("pen",Ile);const Ule=[["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"}]],Zu=Xe("pencil",Ule);const Fle=[["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"}]],zle=Xe("phone",Fle);const Ble=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],bS=Xe("play",Ble);const Hle=[["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"}]],Ox=Xe("plug",Hle);const $le=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],fr=Xe("plus",$le);const Vle=[["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"}]],yR=Xe("power-off",Vle);const Gle=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],fd=Xe("power",Gle);const Wle=[["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"}]],jo=Xe("printer",Wle);const qle=[["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"}]],Kle=Xe("qr-code",qle);const Xle=[["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"}]],qs=Xe("refresh-cw",Xle);const Yle=[["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"}]],Im=Xe("rotate-ccw",Yle);const Zle=[["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"}]],Qle=Xe("ruler",Zle);const Jle=[["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"}]],To=Xe("save",Jle);const ece=[["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"}]],tce=Xe("scan-search",ece);const nce=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Qu=Xe("search",nce);const rce=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],_R=Xe("send",rce);const ice=[["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"}]],sce=Xe("server",ice);const ace=[["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"}]],vS=Xe("settings-2",ace);const oce=[["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=Xe("settings",oce);const lce=[["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"}]],cce=Xe("shopping-cart",lce);const uce=[["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"}]],dce=Xe("signal",uce);const hce=[["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"}]],fce=Xe("skip-back",hce);const pce=[["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"}]],c1=Xe("skip-forward",pce);const mce=[["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"}]],A5=Xe("sliders-vertical",mce);const gce=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],h0=Xe("sparkles",gce);const xce=[["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"}]],jh=Xe("square-check-big",xce);const bce=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],im=Xe("square",bce);const vce=[["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"}]],sm=Xe("star",vce);const yce=[["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"}]],LG=Xe("sticky-note",yce);const _ce=[["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"}]],T5=Xe("sun",_ce);const wce=[["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"}]],f0=Xe("tag",wce);const Sce=[["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"}]],IG=Xe("target",Sce);const Ece=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],UG=Xe("terminal",Ece);const Mce=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Ace=Xe("text-align-center",Mce);const Tce=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Cce=Xe("text-align-end",Tce);const Nce=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],kce=Xe("text-align-start",Nce);const Pce=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],$p=Xe("thermometer",Pce);const Rce=[["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"}]],Ou=Xe("timer",Rce);const Dce=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],kn=Xe("trash-2",Dce);const Oce=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],jce=Xe("trending-down",Oce);const Lce=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Ice=Xe("trending-up",Lce);const Uce=[["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"}]],Qr=Xe("triangle-alert",Uce);const Fce=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],zce=Xe("underline",Fce);const Bce=[["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"}]],FG=Xe("unlink",Bce);const Hce=[["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"}]],ma=Xe("upload",Hce);const $ce=[["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"}]],u3=Xe("user",$ce);const Vce=[["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"}]],Gce=Xe("users",Vce);const Wce=[["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"}]],zG=Xe("video",Wce);const qce=[["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"}]],SR=Xe("wifi-off",qce);const Kce=[["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"}]],BG=Xe("wifi",Kce);const Xce=[["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"}]],Yce=Xe("wind",Xce);const Zce=[["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"}]],Ju=Xe("wrench",Zce);const Qce=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gt=Xe("x",Qce);const Jce=[["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"}]],eue=Xe("zoom-in",Jce);const tue=[["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"}]],am=Xe("zap",tue);const nue=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],rue=Xe("zoom-out",nue),HG=M.createContext(void 0);function iue({children:t}){const[e,n]=M.useState(()=>{const s=localStorage.getItem("theme");return s||"dark"});M.useEffect(()=>{const s=document.documentElement;e==="dark"?s.classList.add("dark"):s.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const r=()=>{n(s=>s==="dark"?"light":"dark")},i=s=>{n(s)};return c.jsx(HG.Provider,{value:{theme:e,toggleTheme:r,setTheme:i},children:t})}function yS(){const t=M.useContext(HG);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 c.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function za({children:t,className:e=""}){return c.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Dt({children:t,className:e=""}){return c.jsx("div",{className:`p-6 ${e}`,children:t})}function sue(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,s)=>({keys:[String(s+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,s)=>({keys:[String(s+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function C5({children:t}){return c.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-bambu-dark border border-bambu-dark-tertiary rounded text-white",children:t})}function aue({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=uS(),i=sue(n,e,r);return M.useEffect(()=>{const s=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t]),c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:c.jsx(Nt,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(l3,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),c.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(s=>c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:s.category}),c.jsx("div",{className:"space-y-2",children:s.items.map(a=>c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[a.description,a.isExternal&&c.jsx(ro,{className:"w-3 h-3 text-bambu-gray"})]}),c.jsx("div",{className:"flex gap-1",children:a.keys.map(o=>c.jsx(C5,{children:o},o))})]},a.description))})]},s.category))}),c.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:c.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",c.jsx(C5,{children:"Esc"})," or click outside to close"]})})]})})})}const Yn="/api/v1";async function nt(t,e={}){const n=await fetch(`${Yn}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${n.status}`)}return n.json()}const Pe={getPrinters:()=>nt("/printers/"),getPrinter:t=>nt(`/printers/${t}`),createPrinter:t=>nt("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>nt(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:t=>nt(`/printers/${t}`,{method:"DELETE"}),getPrinterStatus:t=>nt(`/printers/${t}/status`),connectPrinter:t=>nt(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>nt(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>nt(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>nt(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>nt(`/printers/${t}/logging`),clearMQTTLogs:t=>nt(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>nt(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Yn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>nt(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>nt(`/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)),nt(`/archives/?${i}`)},getArchive:t=>nt(`/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)),nt(`/archives/search?${n}`)},rebuildSearchIndex:()=>nt("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>nt(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>nt(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>nt(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>nt("/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)),nt(`/archives/analysis/failures?${e}`)},compareArchives:t=>nt(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>nt(`/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(`${Yn}/archives/export?${e}`);if(!n.ok){const a=await n.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(r){const a=r.match(/filename="?([^"]+)"?/);a&&(i=a[1])}return{blob:await n.blob(),filename:i}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=await fetch(`${Yn}/archives/stats/export?${e}`);if(!n.ok){const a=await n.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(r){const a=r.match(/filename="?([^"]+)"?/);a&&(i=a[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>nt(`/archives/${t}/duplicates`),backfillContentHashes:()=>nt("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Yn}/archives/${t}/thumbnail`,getArchiveDownload:t=>`${Yn}/archives/${t}/download`,getArchiveGcode:t=>`${Yn}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${Yn}/archives/${t}/timelapse`,scanArchiveTimelapse:t=>nt(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>nt(`/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(`${Yn}/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)=>`${Yn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Yn}/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)=>nt(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Yn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${Yn}/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(`${Yn}/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=>nt(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Yn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>nt(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>nt(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>nt(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Yn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Yn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,reprintArchive:(t,e)=>nt(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${Yn}/archives/upload?printer_id=${e}`:`${Yn}/archives/upload`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(s=>n.append("files",s));const r=e?`${Yn}/archives/upload-bulk?printer_id=${e}`:`${Yn}/archives/upload-bulk`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getSettings:()=>nt("/settings/"),updateSettings:t=>nt("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>nt("/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=`${Yn}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n),i=r.headers.get("Content-Disposition");let s="bambuddy-backup.json";if(i){const o=i.match(/filename=([^;]+)/);o&&(s=o[1].trim())}return{blob:await r.blob(),filename:s}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${Yn}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>nt("/settings/check-ffmpeg"),getCloudStatus:()=>nt("/cloud/status"),cloudLogin:(t,e,n="global")=>nt("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>nt("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>nt("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>nt("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>nt(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>nt(`/cloud/settings/${t}`),createCloudSetting:t=>nt("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>nt(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>nt(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>nt("/cloud/devices"),getCloudFields:t=>nt(`/cloud/fields/${t}`),getAllCloudFields:()=>nt("/cloud/fields"),getSmartPlugs:()=>nt("/smart-plugs/"),getSmartPlug:t=>nt(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>nt(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>nt("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>nt(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>nt(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>nt(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>nt(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>nt("/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),nt(`/queue/?${n}`)},getQueueItem:t=>nt(`/queue/${t}`),addToQueue:t=>nt("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>nt(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>nt(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>nt("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>nt(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>nt(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>nt(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>nt(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>nt(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>nt(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>nt(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>nt(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>nt(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>nt(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>nt(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>nt(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>nt(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>nt("/filaments/"),getFilament:t=>nt(`/filaments/${t}`),getFilamentsByType:t=>nt(`/filaments/by-type/${t}`),getNotificationProviders:()=>nt("/notifications/"),getNotificationProvider:t=>nt(`/notifications/${t}`),createNotificationProvider:t=>nt("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>nt(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>nt(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>nt(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>nt("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>nt("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>nt("/notification-templates"),getNotificationTemplate:t=>nt(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>nt(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>nt(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>nt("/notification-templates/variables"),previewTemplate:t=>nt("/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)),nt(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>nt(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>nt(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>nt("/spoolman/status"),connectSpoolman:()=>nt("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>nt("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>nt(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>nt("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>nt("/spoolman/spools"),getSpoolmanFilaments:()=>nt("/spoolman/filaments"),getVersion:()=>nt("/updates/version"),checkForUpdates:()=>nt("/updates/check"),applyUpdate:()=>nt("/updates/apply",{method:"POST"}),getUpdateStatus:()=>nt("/updates/status"),getMaintenanceTypes:()=>nt("/maintenance/types"),createMaintenanceType:t=>nt("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>nt(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>nt(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>nt("/maintenance/overview"),getPrinterMaintenance:t=>nt(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>nt(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>nt(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>nt(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>nt("/maintenance/summary"),setPrinterHours:(t,e)=>nt(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),getCameraStreamUrl:(t,e=10)=>`${Yn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${Yn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>nt(`/printers/${t}/camera/test`),getExternalLinks:()=>nt("/external-links/"),getExternalLink:t=>nt(`/external-links/${t}`),createExternalLink:t=>nt("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>nt(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>nt(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>nt("/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(`${Yn}/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=>nt(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${Yn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),nt(`/projects/?${e}`)},getProject:t=>nt(`/projects/${t}`),createProject:t=>nt("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>nt(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>nt(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>nt(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>nt(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>nt(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>nt(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),getAPIKeys:()=>nt("/api-keys/"),createAPIKey:t=>nt("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>nt(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>nt(`/api-keys/${t}`,{method:"DELETE"})},$G=[{name:"globe",icon:l0},{name:"link",icon:xS},{name:"external-link",icon:ro},{name:"book",icon:yae},{name:"file-text",icon:Ya},{name:"home",icon:Voe},{name:"star",icon:sm},{name:"heart",icon:Boe},{name:"bookmark",icon:wae},{name:"shopping-cart",icon:cce},{name:"music",icon:kle},{name:"video",icon:zG},{name:"image",icon:rb},{name:"camera",icon:a0},{name:"map",icon:gle},{name:"compass",icon:toe},{name:"coffee",icon:Zae},{name:"gift",icon:Ooe},{name:"wrench",icon:Ju},{name:"zap",icon:am},{name:"cloud",icon:gS},{name:"database",icon:s3},{name:"folder",icon:PG},{name:"mail",icon:ple},{name:"phone",icon:zle},{name:"user",icon:u3},{name:"users",icon:Gce},{name:"server",icon:sce},{name:"terminal",icon:UG},{name:"code",icon:CG}];function _S(t){return $G.find(n=>n.name===t)?.icon||xS}function oue({value:t,onChange:e}){const[n,r]=M.useState(!1),i=_S(t);return c.jsxs("div",{className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[c.jsx(i,{className:"w-5 h-5"}),c.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),c.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:c.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:$G.map(({name:s,icon:a})=>c.jsx("button",{type:"button",onClick:()=>{e(s),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===s?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:s,children:c.jsx(a,{className:"w-5 h-5"})},s))})})]})]})}const N5=768;function VG(){const[t,e]=M.useState(()=>typeof window<"u"?window.innerWidth<N5:!1);return M.useEffect(()=>{const n=window.matchMedia(`(max-width: ${N5-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const p0=[{id:"printers",to:"/",icon:jo,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:pS,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:qr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Pae,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:gS,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Ju,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:ph,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:wR,labelKey:"nav.settings"}];function lue(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return p0.map(e=>e.id)}return p0.map(e=>e.id)}function cue(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function lA(t){return t.startsWith("ext-")}function GG(){return localStorage.getItem("defaultView")||"/"}function uue(t){localStorage.setItem("defaultView",t)}function due(){const t=sR(),e=dd(),{theme:n,toggleTheme:r}=yS(),{t:i}=uS(),s=VG(),[a,o]=M.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[l,u]=M.useState(!1),[d,f]=M.useState(!1),[g,m]=M.useState(lue),[x,y]=M.useState(null),[v,b]=M.useState(null),E=M.useRef(!1),[S,A]=M.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:T}=yt({queryKey:["version"],queryFn:Pe.getVersion,staleTime:1/0}),{data:P}=yt({queryKey:["settings"],queryFn:Pe.getSettings,staleTime:300*1e3}),{data:C}=yt({queryKey:["updateCheck"],queryFn:Pe.checkForUpdates,enabled:P?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:I}=yt({queryKey:["external-links"],queryFn:Pe.getExternalLinks}),N=new Map(p0.map(Z=>[Z.id,Z])),D=new Map((I||[]).map(Z=>[`ext-${Z.id}`,Z])),F=(()=>{const Z=[],U=new Set;for(const $ of g)(N.has($)||D.has($))&&(Z.push($),U.add($));for(const $ of p0)U.has($.id)||(Z.push($.id),U.add($.id));for(const $ of I||[]){const ee=`ext-${$.id}`;U.has(ee)||(Z.push(ee),U.add(ee))}return Z})(),L=(Z,U)=>{y(U),Z.dataTransfer.effectAllowed="move",Z.dataTransfer.setData("text/plain",U)},q=(Z,U)=>{Z.preventDefault(),Z.dataTransfer.dropEffect="move",b(U)},R=()=>{b(null)},V=(Z,U)=>{if(Z.preventDefault(),x===null||x===U){y(null),b(null);return}const $=[...F],ee=$.indexOf(x),ae=$.indexOf(U);if(ee===-1||ae===-1){y(null),b(null);return}$.splice(ee,1),$.splice(ae,0,x),m($),cue($),y(null),b(null)},K=()=>{y(null),b(null)},W=C?.update_available&&C.latest_version&&C.latest_version!==S,ne=()=>{C?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",C.latest_version),A(C.latest_version))};M.useEffect(()=>{if(!E.current&&e.pathname==="/"){const Z=GG();Z!=="/"&&(E.current=!0,t(Z,{replace:!0}))}},[e.pathname,t]),M.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(a))},[a]),M.useEffect(()=>{s&&u(!1)},[e.pathname,s]);const Y=M.useCallback(Z=>{const U=Z.target;if(!(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable)&&!Z.metaKey&&!Z.ctrlKey&&!Z.altKey){const $=parseInt(Z.key);if($>=1&&$<=F.length&&$<=9){const ee=F[$-1];if(Z.preventDefault(),lA(ee)){const ae=ee.replace("ext-","");t(`/external/${ae}`)}else{const ae=N.get(ee);ae&&t(ae.to)}return}switch(Z.key){case"?":Z.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,F,N]);return M.useEffect(()=>(document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)),[Y]),c.jsxs("div",{className:"flex min-h-screen",children:[s&&c.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[c.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:c.jsx(wle,{className:"w-6 h-6 text-white"})}),c.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),s&&l&&c.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),c.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${s?`fixed inset-y-0 left-0 z-50 w-72 transform ${l?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${a?"w-64":"w-16"}`}`,children:[c.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s||a?"p-4":"p-2"}`,children:c.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:s||a?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),c.jsx("nav",{className:"flex-1 p-2",children:c.jsx("ul",{className:"space-y-2",children:F.map(Z=>{if(lA(Z)){const $=D.get(Z);if(!$)return null;const ee=$.custom_icon?null:_S($.icon);return c.jsx("li",{draggable:!0,onDragStart:ae=>L(ae,Z),onDragOver:ae=>q(ae,Z),onDragLeave:R,onDrop:ae=>V(ae,Z),onDragEnd:K,className:`relative ${x===Z?"opacity-50":""} ${v===Z&&x!==Z?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:c.jsxs(ZN,{to:`/external/${$.id}`,className:({isActive:ae})=>`flex items-center ${s||a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ae?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!a?$.name:void 0,children:[a&&!s&&c.jsx(c0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),$.custom_icon?c.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"}`}):ee&&c.jsx(ee,{className:"w-5 h-5 flex-shrink-0"}),(s||a)&&c.jsx("span",{children:$.name})]})},Z)}else{const $=N.get(Z);if(!$)return null;const{to:ee,icon:ae,labelKey:fe}=$;return c.jsx("li",{draggable:!0,onDragStart:ue=>L(ue,Z),onDragOver:ue=>q(ue,Z),onDragLeave:R,onDrop:ue=>V(ue,Z),onDragEnd:K,className:`relative ${x===Z?"opacity-50":""} ${v===Z&&x!==Z?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:c.jsxs(ZN,{to:ee,className:({isActive:ue})=>`flex items-center ${s||a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ue?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!a?i(fe):void 0,children:[a&&!s&&c.jsx(c0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),c.jsx(ae,{className:"w-5 h-5 flex-shrink-0"}),(s||a)&&c.jsx("span",{children:i(fe)})]})},Z)}})})}),!s&&c.jsx("button",{onClick:()=>o(!a),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(a?"nav.collapseSidebar":"nav.expandSidebar"),children:a?c.jsx(Rh,{className:"w-5 h-5"}):c.jsx(tf,{className:"w-5 h-5"})}),c.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s||a?c.jsxs("div",{className:"flex items-center justify-between px-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",T?.version||"..."]}),C?.update_available&&c.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:C.latest_version}),children:[c.jsx(aA,{className:"w-4 h-4"}),c.jsx("span",{children:i("nav.update")})]})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:c.jsx(S5,{className:"w-5 h-5"})}),c.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:c.jsx(l3,{className:"w-5 h-5"})}),c.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?c.jsx(T5,{className:"w-5 h-5"}):c.jsx(l1,{className:"w-5 h-5"})})]})]}):c.jsxs("div",{className:"flex flex-col items-center gap-1",children:[C?.update_available&&c.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:C.latest_version}),children:c.jsx(aA,{className:"w-5 h-5"})}),c.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:c.jsx(S5,{className:"w-5 h-5"})}),c.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:c.jsx(l3,{className:"w-5 h-5"})}),c.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?c.jsx(T5,{className:"w-5 h-5"}):c.jsx(l1,{className:"w-5 h-5"})})]})})]}),c.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${s?"mt-14":a?"ml-64":"ml-16"}`,children:[W&&c.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx(aA,{className:"w-4 h-4 text-bambu-green"}),c.jsx("span",{children:i("nav.updateAvailableBanner",{version:C?.latest_version,defaultValue:`Version ${C?.latest_version} is available!`})}),c.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),c.jsx("button",{onClick:ne,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:c.jsx(Gt,{className:"w-4 h-4"})})]}),c.jsx($ie,{})]}),d&&c.jsx(aue,{onClose:()=>f(!1),sidebarItems:F.map(Z=>{if(lA(Z)){const U=D.get(Z);return U?{type:"external",label:U.name}:null}else{const U=N.get(Z);return U?{type:"nav",label:U.labelKey,labelKey:U.labelKey}:null}}).filter(Boolean)})]})}function Ie({variant:t="primary",size:e="md",className:n="",children:r,...i}){const s="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",a={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},o={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return c.jsx("button",{className:`${s} ${a[t]} ${o[e]} ${n}`,...i,children:r})}function Kr({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:s,onCancel:a}){M.useEffect(()=>{const u=d=>{d.key==="Escape"&&a()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a]);const l={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:a,children:c.jsx(Nt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:c.jsxs(Dt,{className:"p-6",children:[c.jsxs("div",{className:"flex items-start gap-4",children:[c.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${l.icon}`,children:c.jsx(Qr,{className:"w-6 h-6"})}),c.jsxs("div",{className:"flex-1",children:[c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),c.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),c.jsxs("div",{className:"flex gap-3 mt-6",children:[c.jsx(Ie,{variant:"secondary",onClick:a,className:"flex-1",children:r}),c.jsx(Ie,{onClick:s,className:`flex-1 ${l.button}`,children:n})]})]})})})}const WG=M.createContext(void 0);function ri(){const t=M.useContext(WG);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const hue={success:c.jsx(ds,{className:"w-5 h-5 text-green-400"}),error:c.jsx(hd,{className:"w-5 h-5 text-red-400"}),warning:c.jsx(Oo,{className:"w-5 h-5 text-yellow-400"}),info:c.jsx(DG,{className:"w-5 h-5 text-blue-400"})},fue={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30"};function pue({children:t}){const[e,n]=M.useState([]),r=M.useCallback((s,a="success")=>{const o=Math.random().toString(36).substr(2,9);n(l=>[...l,{id:o,message:s,type:a}]),setTimeout(()=>{n(l=>l.filter(u=>u.id!==o))},3e3)},[]),i=M.useCallback(s=>{n(a=>a.filter(o=>o.id!==s))},[]);return c.jsxs(WG.Provider,{value:{showToast:r},children:[t,c.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(s=>c.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${fue[s.type]}`,children:[hue[s.type],c.jsx("span",{className:"text-white text-sm",children:s.message}),c.jsx("button",{onClick:()=>i(s.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-4 h-4"})})]},s.id))})]})}function mue(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 k5(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 gue(t,e){if(e)return PG;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return xoe;case"gcode":return Ya;case"mp4":case"avi":return Bp;case"png":case"jpg":case"jpeg":return rb;default:return kG}}function xue({printerId:t,printerName:e,onClose:n}){const{showToast:r}=ri(),i=Sn(),[s,a]=M.useState("/"),[o,l]=M.useState(null),[u,d]=M.useState(""),[f,g]=M.useState(null);M.useEffect(()=>{const C=I=>{I.key==="Escape"&&n()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[n]);const{data:m,isLoading:x,refetch:y}=yt({queryKey:["printerFiles",t,s],queryFn:()=>Pe.getPrinterFiles(t,s)}),{data:v}=yt({queryKey:["printerStorage",t],queryFn:()=>Pe.getPrinterStorage(t),staleTime:3e4}),b=_t({mutationFn:C=>Pe.deletePrinterFile(t,C),onSuccess:(C,I)=>{r(`Deleted: ${I.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),l(null)},onError:C=>{r(`Delete failed: ${C.message}`,"error")}}),E=C=>{a(C),l(null)},S=()=>{if(s==="/")return;const C=s.split("/").filter(Boolean);C.pop(),a(C.length?"/"+C.join("/"):"/"),l(null)},A=C=>{window.open(Pe.getPrinterFileDownloadUrl(t,C),"_blank")},T=C=>{g(C)},P=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return c.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[c.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:C=>C.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(RG,{className:"w-5 h-5 text-bambu-green"}),c.jsxs("div",{children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),c.jsxs("div",{className:"flex items-center gap-4",children:[v&&(v.used_bytes!=null||v.free_bytes!=null)&&c.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[v.used_bytes!=null&&c.jsxs("span",{children:["Used: ",k5(v.used_bytes)]}),v.used_bytes!=null&&v.free_bytes!=null&&c.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),v.free_bytes!=null&&c.jsxs("span",{children:["Free: ",k5(v.free_bytes)]})]}),c.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]})]}),c.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[P.map(C=>c.jsx("button",{onClick:()=>{E(C.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${s===C.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:C.label},C.path)),c.jsx("div",{className:"flex-1"}),c.jsxs("div",{className:"relative",children:[c.jsx(Qu,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:C=>d(C.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>y(),disabled:x,children:c.jsx(qs,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),c.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[c.jsx("button",{onClick:S,disabled:s==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:c.jsx(Rh,{className:"w-4 h-4"})}),c.jsx("span",{className:"text-bambu-gray font-mono",children:s})]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:x?c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?.files?.length?c.jsx("div",{className:"space-y-1",children:[...m.files].filter(C=>!u||C.name.toLowerCase().includes(u.toLowerCase())).sort((C,I)=>C.is_directory&&!I.is_directory?-1:!C.is_directory&&I.is_directory?1:C.name.localeCompare(I.name)).map(C=>{const I=gue(C.name,C.is_directory),N=o===C.path;return c.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${N?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{C.is_directory?E(C.path):l(N?null:C.path)},children:[c.jsx(I,{className:`w-5 h-5 flex-shrink-0 ${C.is_directory?"text-bambu-green":"text-bambu-gray"}`}),c.jsx("span",{className:"flex-1 text-white truncate",children:C.name}),!C.is_directory&&c.jsx("span",{className:"text-sm text-bambu-gray",children:mue(C.size)}),C.is_directory&&c.jsx(Rh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},C.path)})}):c.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),c.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[c.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${m?.files?.filter(C=>C.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${m?.files?.length||0} items`:`${m?.files?.length||0} items`}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ie,{variant:"secondary",disabled:!o,onClick:()=>o&&A(o),children:[c.jsx(ya,{className:"w-4 h-4"}),"Download"]}),c.jsxs(Ie,{variant:"secondary",disabled:!o||b.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[b.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&c.jsx(Kr,{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 bue({printerId:t,printerName:e,onClose:n}){const r=Sn(),[i,s]=M.useState(!0),[a,o]=M.useState(new Set),[l,u]=M.useState(""),[d,f]=M.useState("all"),g=M.useRef(null),{data:m,isLoading:x,refetch:y}=yt({queryKey:["mqtt-logs",t],queryFn:()=>Pe.getMQTTLogs(t),refetchInterval:1e3}),v=_t({mutationFn:()=>Pe.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),b=_t({mutationFn:()=>Pe.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=_t({mutationFn:()=>Pe.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});M.useEffect(()=>{const N=D=>{D.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]),M.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[m?.logs,i]);const S=N=>{o(D=>{const F=new Set(D);return F.has(N)?F.delete(N):F.add(N),F})},A=N=>new Date(N).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(N,D)=>{if(N==null)return"<empty>";const F=typeof N=="string"?JSON.parse(N):N,L=JSON.stringify(F,null,D?2:0);return!D&&L.length>100?L.substring(0,100)+"...":L},P=m?.logging_enabled??!1,C=m?.logs??[],I=M.useMemo(()=>C.filter(N=>{if(d!=="all"&&N.direction!==d)return!1;if(l.trim()){const D=l.toLowerCase(),F=N.topic.toLowerCase().includes(D),q=JSON.stringify(N.payload).toLowerCase().includes(D);return F||q}return!0}),[C,l,d]);return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),c.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[P?c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,children:[c.jsx(im,{className:"w-4 h-4"}),"Stop"]}):c.jsxs(Ie,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[c.jsx(bS,{className:"w-4 h-4"}),"Start Logging"]}),c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||C.length===0,children:[c.jsx(kn,{className:"w-4 h-4"}),"Clear"]}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:x,children:c.jsx(qs,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),c.jsx("div",{className:"flex-1"}),c.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:i,onChange:N=>s(N.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),c.jsxs("span",{className:"text-sm text-bambu-gray",children:[I.length,"/",C.length]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(Qu,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:l,onChange:N=>u(N.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),l&&c.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:c.jsx(Gt,{className:"w-4 h-4"})})]}),c.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[c.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),c.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[c.jsx(s0,{className:"w-3 h-3"}),"In"]}),c.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[c.jsx(nm,{className:"w-3 h-3"}),"Out"]})]})]})]}),c.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:C.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[c.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!P&&c.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):I.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[c.jsx("p",{className:"mb-2",children:"No messages match your filter"}),c.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):c.jsx("div",{className:"space-y-1",children:I.map((N,D)=>{const F=a.has(D),L=N.direction==="in";return c.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>S(D),children:[c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx("span",{className:"text-bambu-gray shrink-0",children:A(N.timestamp)}),c.jsx("span",{className:`shrink-0 ${L?"text-blue-400":"text-green-400"}`,title:L?"Incoming":"Outgoing",children:L?c.jsx(s0,{className:"w-3 h-3"}):c.jsx(nm,{className:"w-3 h-3"})}),c.jsx("span",{className:"text-purple-400 shrink-0",children:N.topic})]}),F?c.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:T(N.payload,!0)}):c.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(N.payload,!1)})]},D)})})}),c.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[c.jsx("div",{className:"text-sm text-bambu-gray",children:P?c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):c.jsx("span",{children:"Logging stopped"})}),c.jsx(Ie,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const vue={"0700_5500_0002_0001":"A binding error occurred between AMS and the extruder. Please perform AMS initialization again.","0500_0300_0002_000E":"Some modules are incompatible with the printer firmware version. Please update firmware.","0300_0100_0002_0054":"The heatbed temperature is abnormal. The sensor may be disconnected or damaged.","0500_0100_0005_0005":"Motor driver overheated. Let the printer cool down.","0500_0100_0005_0006":"Motor driver communication error.","0700_0100_0007_0001":"AMS communication error.","0700_0100_0007_0002":"AMS filament runout.","0700_0100_0007_0003":"AMS filament not detected.","0C00_0100_000C_0003":"First layer inspection failed.","0C00_0100_000C_0004":"Nozzle clog detected.","0C00_0100_000C_8000":"Foreign object detected on print bed.","0500_0100_0005_0000":"Motor X axis lost steps.","0500_0100_0005_0001":"Motor Y axis lost steps.","0500_0100_0005_0002":"Motor Z axis lost steps."};function yue(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Qr};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Qr};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Oo};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:DG}}}function qG(t,e){const n=(t>>24&255).toString(16).padStart(2,"0").toUpperCase(),r=(t>>16&255).toString(16).padStart(2,"0").toUpperCase(),i=(t>>8&255).toString(16).padStart(2,"0").toUpperCase(),s=(t&255).toString(16).padStart(2,"0").toUpperCase(),a=(e>>24&255).toString(16).padStart(2,"0").toUpperCase(),o=(e>>16&255).toString(16).padStart(2,"0").toUpperCase(),l=(e>>8&255).toString(16).padStart(2,"0").toUpperCase(),u=(e&255).toString(16).padStart(2,"0").toUpperCase();return`${n}${r}_${i}${s}_${a}${o}_${l}${u}`}function _ue(t,e,n){const r=qG(t,e);return`https://wiki.bambulab.com/en/${n.toLowerCase().includes("h2")?"h2":"x1"}/troubleshooting/hmscode/${r}`}function wue({printerName:t,errors:e,onClose:n}){return console.log("HMSErrorModal errors:",JSON.stringify(e,null,2)),M.useEffect(()=>{const r=i=>{i.key==="Escape"&&n()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Qr,{className:"w-5 h-5 text-orange-400"}),c.jsxs("h2",{className:"text-lg font-semibold text-white",children:["HMS Errors - ",t]})]}),c.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.length===0?c.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[c.jsx(Oo,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),c.jsx("p",{children:"No HMS errors"})]}):c.jsx("div",{className:"space-y-3",children:e.map((r,i)=>{const{label:s,color:a,bgColor:o,Icon:l}=yue(r.severity),u=parseInt(r.code.replace("0x",""),16)||0,d=qG(r.attr,u),f=vue[d]||"Unknown error. Click the link below for details.",g=_ue(r.attr,u,t),m=`HMS_${d.replace(/_/g,"-")}`;return c.jsx("div",{className:`p-4 rounded-lg ${o} border border-white/10`,children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx(l,{className:`w-5 h-5 ${a} flex-shrink-0 mt-0.5`}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx("span",{className:`font-mono text-sm ${a}`,children:m}),c.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${o} ${a}`,children:s})]}),c.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:f}),c.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[c.jsx(ro,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${r.code}-${i}`)})})}),c.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:c.jsx("p",{className:"text-xs text-bambu-gray",children:"HMS (Health Management System) monitors printer health. Clear errors on the printer to dismiss them here."})})]})})}function Sue(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 Eue({printerId:t}){const{data:e}=yt({queryKey:["queue",t,"pending"],queryFn:()=>Pe.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:c.jsx(fS,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[c.jsx(qr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),c.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[c.jsx(ti,{className:"w-3 h-3"}),Sue(n?.scheduled_time||null)]}),r>1&&c.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),c.jsx(tf,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function Mue({side:t}){const{theme:e}=yS(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return c.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function Aue({colors:t,className:e}){const n=[{x:9.5,cx:12.5},{x:18.5,cx:21.5},{x:27.5,cx:30.5},{x:36.5,cx:39.5}];return c.jsxs("svg",{className:e,width:"56",height:"34",viewBox:"0 0 52 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 0C1.79086 0 0 1.79086 0 4V28C0 30.2091 1.79086 32 4 32H48C50.2091 32 52 30.2091 52 28V4C52 1.79086 50.2091 0 48 0H4ZM44 8H8V24H44V8Z",fill:"#2F2E33"}),n.map((r,i)=>t[i]?c.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:t[i]},i):c.jsxs("g",{children:[c.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:"#ffffff"}),c.jsx("line",{x1:r.x,y1:"8",x2:r.x+6,y2:"24",stroke:"#555555",strokeWidth:"1.5"})]},i)),c.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M36.5 16H33.5V18.2617C33.5 19.9186 32.1569 21.2617 30.5 21.2617C28.8431 21.2617 27.5 19.9186 27.5 18.2617V16H24.5V18.2617C24.5 19.9186 23.1569 21.2617 21.5 21.2617C19.8431 21.2617 18.5 19.9186 18.5 18.2617V16H15.5V18.2617C15.5 19.9186 14.1569 21.2617 12.5 21.2617C10.8432 21.2617 9.5 19.9186 9.5 18.2617V16H4V28H48V16H42.5V18.2617C42.5 19.9186 41.1569 21.2617 39.5 21.2617C37.8431 21.2617 36.5 19.9186 36.5 18.2617V16Z",fill:"#767676"}),c.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 9.18382C6 6.32088 8.32088 4 11.1838 4H40.8162C43.6791 4 46 6.32088 46 9.18382V16H42.5V12.2617C42.5 10.6049 41.1569 9.26172 39.5 9.26172C37.8431 9.26172 36.5 10.6049 36.5 12.2617V16H33.5V12.2617C33.5 10.6049 32.1569 9.26172 30.5 9.26172C28.8431 9.26172 27.5 10.6049 27.5 12.2617V16H24.5V12.2617C24.5 10.6049 23.1569 9.26172 21.5 9.26172C19.8431 9.26172 18.5 10.6049 18.5 12.2617V16H15.5V12.2617C15.5 10.6049 14.1569 9.26172 12.5 9.26172C10.8432 9.26172 9.5 10.6049 9.5 12.2617V16H6V9.18382Z",fill:"#BFBFBF"})]})}function Tue({color:t,className:e}){return c.jsxs("svg",{className:e,width:"56",height:"56",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t?c.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:t,rx:"0.3"}):c.jsxs("g",{children:[c.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:"#ffffff",rx:"0.3"}),c.jsx("line",{x1:"8.3",y1:"5.2",x2:"12.1",y2:"10.3",stroke:"#555555",strokeWidth:"0.8"})]}),c.jsx("path",{d:"M5.88312 4.68555C5.88312 4.13326 6.33083 3.68555 6.88312 3.68555H13.5059C14.0582 3.68555 14.5059 4.13326 14.5059 4.68555V10.3887H5.88312V4.68555Z",stroke:"#6B6B6B"}),c.jsx("rect",{x:"3.8725",y:"10.3887",width:"12.7037",height:"7.55371",rx:"1.2",stroke:"#6B6B6B"}),c.jsx("path",{d:"M8.21991 5.65234C8.21991 5.3762 8.44377 5.15234 8.71991 5.15234H11.7288C12.005 5.15234 12.2288 5.3762 12.2288 5.65234V10.3887H8.21991V5.65234Z",stroke:"#6B6B6B"})]})}function P5({className:t}){return c.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:c.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function Cue({className:t}){return c.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),c.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function Nue({className:t}){return c.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),c.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function kue({className:t}){return c.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),c.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function Pue({className:t}){return c.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),c.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),c.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function Rue({className:t}){return c.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),c.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),c.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function Due({humidity:t,goodThreshold:e=40,fairThreshold:n=60}){const r=typeof t=="string"?parseInt(t,10):t,i=typeof e=="number"?e:40,s=typeof n=="number"?n:60;let a,o;isNaN(r)?(a="#C3C2C1",o="Unknown"):r<=i?(a="#22a352",o="Good"):r<=s?(a="#d4a017",o="Fair"):(a="#c62828",o="Bad");let l;return isNaN(r)||r<=i?l=P5:r<=s?l=Cue:l=Nue,c.jsxs("div",{className:"flex items-center justify-end gap-1",title:`Humidity: ${r}% - ${o}`,children:[c.jsx(l,{className:"w-3 h-4"}),c.jsxs("span",{className:"text-xs font-medium tabular-nums w-8 text-right",style:{color:a},children:[r,"%"]})]})}function Oue({temp:t,goodThreshold:e=28,fairThreshold:n=35}){const r=typeof e=="number"?e:28,i=typeof n=="number"?n:35;let s,a;return t<=r?(s="#22a352",a=kue):t<=i?(s="#d4a017",a=Pue):(s="#c62828",a=Rue),c.jsxs("span",{className:"flex items-center gap-1",title:"Temperature",children:[c.jsx(a,{className:"w-3 h-4"}),c.jsxs("span",{className:"tabular-nums w-12 text-right",style:{color:s},children:[t,"°C"]})]})}function jue(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,s=r>=128?r-128:r,a=String.fromCharCode(65+s);return i?`HT-${a}`:`AMS-${a}`}function Lue(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Iue(t){const e=new Date,n=new Date(e.getTime()+t*60*1e3),r=new Date;r.setHours(0,0,0,0);const i=new Date(n);i.setHours(0,0,0,0);const s=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),a=Math.floor((i.getTime()-r.getTime())/(1e3*60*60*24));return a===0?s:a===1?`Tomorrow ${s}`:n.toLocaleDateString([],{weekday:"short"})+" "+s}function Uue(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 Fue(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 zue({url:t,printName:e}){const[n,r]=M.useState(!1),[i,s]=M.useState(!1),[a,o]=M.useState(!1);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&o(!0),children:t&&!i?c.jsxs(c.Fragment,{children:[c.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>s(!0)}),!n&&c.jsx(rm,{className:"w-8 h-8 text-bambu-gray"})]}):c.jsx(rm,{className:"w-8 h-8 text-bambu-gray"})}),a&&t&&c.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:c.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[c.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&c.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function Bue({printers:t}){const e=Sn(),n=M.useMemo(()=>{let i=0,s=0,a=0,o=0;return t?.forEach(l=>{const u=e.getQueryData(["printerStatus",l.id]);u===void 0?o++:u.connected?u.state==="RUNNING"?i++:s++:a++}),{printing:i,idle:s,offline:a,loading:o,total:t?.length||0}},[t,e]),[,r]=M.useState(0);return M.useEffect(()=>{const i=e.getQueryCache().subscribe(()=>{r(s=>s+1)});return()=>i()},[e]),t?.length?c.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),c.jsxs("span",{className:"text-bambu-gray",children:[c.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),c.jsxs("span",{className:"text-bambu-gray",children:[c.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),c.jsxs("span",{className:"text-bambu-gray",children:[c.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function R5({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i}){const s=Sn(),a=sR(),[o,l]=M.useState(!1),[u,d]=M.useState(!1),[f,g]=M.useState(!1),[m,x]=M.useState(!1),[y,v]=M.useState(!1),[b,E]=M.useState(!1),[S,A]=M.useState(!1),[T,P]=M.useState(!1),{data:C}=yt({queryKey:["printerStatus",t.id],queryFn:()=>Pe.getPrinterStatus(t.id),refetchInterval:3e4}),[I,N]=M.useState(null);M.useEffect(()=>{C?.wifi_signal!=null&&N(C.wifi_signal)},[C?.wifi_signal]);const D=C?.wifi_signal??I,F=M.useRef({});M.useEffect(()=>{C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0&&(F.current=C.ams_extruder_map)},[C?.ams_extruder_map]);const L=C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0?C.ams_extruder_map:F.current,q=M.useRef([]);M.useEffect(()=>{C?.ams&&C.ams.length>0&&(q.current=C.ams)},[C?.ams]);const R=C?.ams&&C.ams.length>0?C.ams:q.current,{data:V}=yt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>Pe.getSmartPlugByPrinter(t.id)}),{data:K}=yt({queryKey:["smartPlugStatus",V?.id],queryFn:()=>V?Pe.getSmartPlugStatus(V.id):null,enabled:!!V,refetchInterval:1e4}),{data:W}=yt({queryKey:["queue",t.id,"pending"],queryFn:()=>Pe.getQueue(t.id,"pending")}),ne=W?.length||0,{data:Y}=yt({queryKey:["archives",t.id,"last"],queryFn:()=>Pe.getArchives(t.id,1,0),enabled:C?.connected&&C?.state!=="RUNNING"}),Z=Y?.[0],U=e&&C&&!C.connected,$=_t({mutationFn:()=>Pe.deletePrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printers"]})}}),ee=_t({mutationFn:()=>Pe.connectPrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printerStatus",t.id]})}}),ae=_t({mutationFn:ue=>V?Pe.controlSmartPlug(V.id,ue):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugStatus",V?.id]})}}),fe=_t({mutationFn:ue=>V?Pe.updateSmartPlug(V.id,{auto_off:ue}):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),s.invalidateQueries({queryKey:["smart-plugs"]})}});return U?null:c.jsxs(Nt,{className:"relative",children:[c.jsxs(Dt,{children:[c.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[c.jsx("img",{src:Uue(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${r==="compact"?"w-10 h-10":"w-14 h-14"}`}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&c.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${C?.connected?"bg-bambu-green":"bg-red-500"}`,title:C?.connected?"Connected":"Offline"})]}),c.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&C?.nozzles&&C.nozzles[0]?.nozzle_diameter&&c.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:C.nozzles[0].nozzle_type||"Nozzle",children:["• ",C.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&c.jsxs("span",{className:"ml-2 text-bambu-gray",children:[c.jsx(ti,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),c.jsxs("div",{className:"relative flex-shrink-0",children:[c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>l(!o),children:c.jsx(NG,{className:"w-4 h-4"})}),o&&c.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10",children:[c.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{g(!0),l(!1)},children:[c.jsx(Zu,{className:"w-4 h-4"}),"Edit"]}),c.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{ee.mutate(),l(!1)},children:[c.jsx(qs,{className:"w-4 h-4"}),"Reconnect"]}),c.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{v(!0),l(!1)},children:[c.jsx(UG,{className:"w-4 h-4"}),"MQTT Debug"]}),c.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{d(!0),l(!1)},children:[c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&c.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[c.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${C?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[C?.connected?c.jsx(xS,{className:"w-3 h-3"}):c.jsx(FG,{className:"w-3 h-3"}),C?.connected?"Connected":"Offline"]}),C?.connected&&D!=null&&c.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${D>=-50||D>=-60?"bg-bambu-green/20 text-bambu-green":D>=-70?"bg-amber-500/20 text-amber-600":D>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${D} dBm - ${Fue(D).label}`,children:[c.jsx(dce,{className:"w-3 h-3"}),D,"dBm"]}),C?.connected&&c.jsxs("button",{onClick:()=>P(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${C.hms_errors&&C.hms_errors.length>0?C.hms_errors.some(ue=>ue.severity<=2)?"bg-red-500/20 text-red-400":"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:"Click to view HMS errors",children:[c.jsx(Qr,{className:"w-3 h-3"}),C.hms_errors&&C.hms_errors.length>0?C.hms_errors.length:"OK"]}),n&&c.jsxs("button",{onClick:()=>a("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-red-500/20 text-red-400":n.warning_count>0?"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:"All maintenance up to date - Click to view",children:[c.jsx(Ju,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),ne>0&&c.jsxs("button",{onClick:()=>a("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:`${ne} print${ne>1?"s":""} in queue`,children:[c.jsx(Oh,{className:"w-3 h-3"}),ne]})]})]}),u&&c.jsx(Kr,{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:()=>{$.mutate(),d(!1)},onCancel:()=>d(!1)}),C?.connected&&c.jsxs(c.Fragment,{children:[r==="compact"?c.jsx("div",{className:"mt-2",children:C.state==="RUNNING"?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:c.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),c.jsxs("span",{className:"text-xs text-white",children:[Math.round(C.progress||0),"%"]})]}):c.jsx("p",{className:"text-xs text-bambu-gray capitalize",children:C.state?.toLowerCase()||"Idle"})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:c.jsxs("div",{className:"flex gap-3",children:[c.jsx(zue,{url:C.state==="RUNNING"?C.cover_url:null,printName:C.state==="RUNNING"&&(C.subtask_name||C.current_print)||void 0}),c.jsx("div",{className:"flex-1 min-w-0",children:C.current_print&&C.state==="RUNNING"?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Printing"}),c.jsx("p",{className:"text-white text-sm mb-2 truncate",children:C.subtask_name||C.current_print}),c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:c.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),c.jsxs("span",{className:"text-white",children:[Math.round(C.progress||0),"%"]})]}),c.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[C.remaining_time!=null&&C.remaining_time>0&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(ti,{className:"w-3 h-3"}),Lue(C.remaining_time*60)]}),c.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",Iue(C.remaining_time)]})]}),C.layer_num!=null&&C.total_layers!=null&&C.total_layers>0&&c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(Oh,{className:"w-3 h-3"}),C.layer_num,"/",C.total_layers]})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),c.jsx("p",{className:"text-white text-sm mb-2 capitalize",children:C.state?.toLowerCase()||"Idle"}),c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:c.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),c.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Z?c.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Z.print_name||Z.filename,children:["Last: ",Z.print_name||Z.filename,Z.completed_at&&c.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(Z.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):c.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),C.state!=="RUNNING"&&c.jsx(Eue,{printerId:t.id})]}),C.temperatures&&r==="expanded"&&c.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[c.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[c.jsx($p,{className:"w-4 h-4 mx-auto mb-1 text-orange-400"}),C.temperatures.nozzle_2!==void 0?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Left / Right"}),c.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C / ",Math.round(C.temperatures.nozzle_2||0),"°C"]})]}):c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),c.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C"]})]})]}),c.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[c.jsx($p,{className:"w-4 h-4 mx-auto mb-1 text-blue-400"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),c.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.bed||0),"°C"]})]}),C.temperatures.chamber!==void 0&&c.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[c.jsx($p,{className:"w-4 h-4 mx-auto mb-1 text-green-400"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),c.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.chamber||0),"°C"]})]})]}),R&&R.length>0&&r==="expanded"&&c.jsxs("div",{className:"mt-3 space-y-2",children:[R.map(ue=>{const xe=L[String(ue.id)],Me=ue.id>=128?ue.id-128:ue.id,se=xe!==void 0?xe:Me,ve=t.nozzle_count===2||C?.temperatures?.nozzle_2!==void 0,je=se===1,de=se===0,ut=ue.tray.map(z=>z.tray_color?`#${z.tray_color}`:z.tray_type?"#333":null),H=ue.tray.length===1;return c.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[ve&&(je||de)&&c.jsx(Mue,{side:je?"L":"R"}),H?c.jsx(Tue,{color:ut[0],className:"flex-shrink-0"}):c.jsx(Aue,{colors:ut,className:"flex-shrink-0"})]}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:jue(ue.id,ue.tray.length)}),c.jsx("div",{className:"mt-0.5 text-[10px] flex items-start",children:ue.tray.map((z,re)=>c.jsxs("div",{className:"flex items-start",children:[c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:"text-bambu-gray/70 truncate",children:z.tray_type?z.tray_sub_brands||z.tray_type:"—"}),c.jsx("span",{className:"text-bambu-gray/50 truncate",children:z.tray_type&&z.remain>=0?`${z.remain}%`:"—"})]}),re<ue.tray.length-1&&c.jsxs("span",{className:"text-bambu-gray/50 mx-1 flex flex-col",children:[c.jsx("span",{children:"·"}),c.jsx("span",{children:"·"})]})]},re))})]}),(ue.humidity!=null||ue.temp!=null)&&c.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[ue.humidity!=null&&c.jsx(Due,{humidity:ue.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair}),ue.temp!=null&&c.jsx(Oue,{temp:ue.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair})]})]})},ue.id)}),C.vt_tray&&C.vt_tray.tray_type&&c.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-white/20 flex-shrink-0",style:{backgroundColor:C.vt_tray.tray_color?`#${C.vt_tray.tray_color}`:"#333"}}),c.jsxs("div",{children:[c.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:"External"}),c.jsx("p",{className:"text-[10px] text-bambu-gray/70",children:C.vt_tray.tray_sub_brands||C.vt_tray.tray_type||"Spool"})]})]})})]})]}),V&&r==="expanded"&&c.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.jsx(am,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),c.jsx("span",{className:"text-sm text-white truncate",children:V.name}),K&&c.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${K.state==="ON"?"bg-bambu-green/20 text-bambu-green":K.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:K.state||"?"}),K?.energy?.power!=null&&K.state==="ON"&&c.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[K.energy.power,"W"]})]}),c.jsx("div",{className:"flex-1"}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs("button",{onClick:()=>E(!0),disabled:ae.isPending||K?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${K?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[c.jsx(fd,{className:"w-3 h-3"}),"On"]}),c.jsxs("button",{onClick:()=>A(!0),disabled:ae.isPending||K?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${K?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[c.jsx(yR,{className:"w-3 h-3"}),"Off"]})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx("span",{className:`text-xs hidden sm:inline ${V.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:V.auto_off_executed?"Auto-off done":"Auto-off"}),c.jsx("button",{onClick:()=>fe.mutate(!V.auto_off),disabled:fe.isPending||V.auto_off_executed,title:V.auto_off_executed?"Auto-off was executed - turn printer on to reset":"Auto power-off after print",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${V.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":V.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:c.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${V.auto_off||V.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&c.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[c.jsxs("div",{className:"text-xs text-bambu-gray",children:[c.jsx("p",{children:t.ip_address}),c.jsx("p",{className:"truncate",children:t.serial_number})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>{window.open(`/camera/${t.id}`,`camera-${t.id}`,"width=640,height=400,menubar=no,toolbar=no,location=no,status=no")},disabled:!C?.connected,title:"Open camera in new window",children:c.jsx(zG,{className:"w-4 h-4"})}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>x(!0),title:"Browse printer files",children:[c.jsx(RG,{className:"w-4 h-4"}),"Files"]})]})]})]}),m&&c.jsx(xue,{printerId:t.id,printerName:t.name,onClose:()=>x(!1)}),y&&c.jsx(bue,{printerId:t.id,printerName:t.name,onClose:()=>v(!1)}),b&&V&&c.jsx(Kr,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{ae.mutate("on"),E(!1)},onCancel:()=>E(!1)}),S&&V&&c.jsx(Kr,{title:"Power Off Printer",message:C?.state==="RUNNING"?`WARNING: "${t.name}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.`:`Are you sure you want to turn OFF the power for "${t.name}"?`,confirmText:"Power Off",variant:"danger",onConfirm:()=>{ae.mutate("off"),A(!1)},onCancel:()=>A(!1)}),T&&c.jsx(wue,{printerName:t.name,errors:C?.hms_errors||[],onClose:()=>P(!1)}),f&&c.jsx($ue,{printer:t,onClose:()=>g(!1)})]})}function Hue({onClose:t,onAdd:e}){const[n,r]=M.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0});return M.useEffect(()=>{const i=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:c.jsx(Nt,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:c.jsxs(Dt,{children:[c.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),c.jsxs("form",{onSubmit:i=>{i.preventDefault(),e(n)},className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),c.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.name,onChange:i=>r({...n,name:i.target.value}),placeholder:"My Printer"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),c.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.ip_address,onChange:i=>r({...n,ip_address:i.target.value}),placeholder:"192.168.1.100"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),c.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.serial_number,onChange:i=>r({...n,serial_number:i.target.value}),placeholder:"01P00A000000000"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),c.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.access_code,onChange:i=>r({...n,access_code:i.target.value}),placeholder:"From printer settings"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),c.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.model||"",onChange:i=>r({...n,model:i.target.value}),children:[c.jsx("option",{value:"",children:"Select model..."}),c.jsxs("optgroup",{label:"H2 Series",children:[c.jsx("option",{value:"H2C",children:"H2C"}),c.jsx("option",{value:"H2D",children:"H2D"}),c.jsx("option",{value:"H2S",children:"H2S"})]}),c.jsxs("optgroup",{label:"X1 Series",children:[c.jsx("option",{value:"X1E",children:"X1E"}),c.jsx("option",{value:"X1C",children:"X1 Carbon"}),c.jsx("option",{value:"X1",children:"X1"})]}),c.jsxs("optgroup",{label:"P Series",children:[c.jsx("option",{value:"P2S",children:"P2S"}),c.jsx("option",{value:"P1S",children:"P1S"}),c.jsx("option",{value:"P1P",children:"P1P"})]}),c.jsxs("optgroup",{label:"A1 Series",children:[c.jsx("option",{value:"A1",children:"A1"}),c.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"auto_archive",checked:n.auto_archive,onChange:i=>r({...n,auto_archive:i.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),c.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),c.jsxs("div",{className:"flex gap-3 pt-4",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function $ue({printer:t,onClose:e}){const n=Sn(),[r,i]=M.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),s=_t({mutationFn:o=>Pe.updatePrinter(t.id,o),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});M.useEffect(()=>{const o=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]);const a=o=>{o.preventDefault();const l={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(l.access_code=r.access_code),s.mutate(l)};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:c.jsx(Nt,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:c.jsxs(Dt,{children:[c.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),c.jsxs("form",{onSubmit:a,className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),c.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:o=>i({...r,name:o.target.value}),placeholder:"My Printer"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),c.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:o=>i({...r,ip_address:o.target.value}),placeholder:"192.168.1.100"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),c.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),c.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:o=>i({...r,access_code:o.target.value}),placeholder:"Leave empty to keep current"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),c.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model,onChange:o=>i({...r,model:o.target.value}),children:[c.jsx("option",{value:"",children:"Select model..."}),c.jsxs("optgroup",{label:"H2 Series",children:[c.jsx("option",{value:"H2C",children:"H2C"}),c.jsx("option",{value:"H2D",children:"H2D"}),c.jsx("option",{value:"H2S",children:"H2S"})]}),c.jsxs("optgroup",{label:"X1 Series",children:[c.jsx("option",{value:"X1E",children:"X1E"}),c.jsx("option",{value:"X1C",children:"X1 Carbon"}),c.jsx("option",{value:"X1",children:"X1"})]}),c.jsxs("optgroup",{label:"P Series",children:[c.jsx("option",{value:"P2S",children:"P2S"}),c.jsx("option",{value:"P1S",children:"P1S"}),c.jsx("option",{value:"P1P",children:"P1P"})]}),c.jsxs("optgroup",{label:"A1 Series",children:[c.jsx("option",{value:"A1",children:"A1"}),c.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),c.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.location,onChange:o=>i({...r,location:o.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:o=>i({...r,auto_archive:o.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),c.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),c.jsxs("div",{className:"flex gap-3 pt-4",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{type:"submit",className:"flex-1",disabled:s.isPending,children:s.isPending?"Saving...":"Save Changes"})]})]})]})})})}function Vue(t){const{data:e}=yt({queryKey:["printerStatus",t],queryFn:()=>Pe.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function Gue({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=Vue(t.id),{data:s}=yt({queryKey:["smartPlugStatus",e.id],queryFn:()=>Pe.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?c.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),s&&c.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${s.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:s.state||"?"})]}),c.jsxs("button",{onClick:()=>n(e.id),disabled:r||s?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${s?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[c.jsx(fd,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function Wue(){const[t,e]=M.useState(!1),[n,r]=M.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,s]=M.useState(!1),[a,o]=M.useState(null),[l,u]=M.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=M.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,m]=M.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),x=Sn(),{data:y,isLoading:v}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:b}=yt({queryKey:["settings"],queryFn:Pe.getSettings}),{data:E}=yt({queryKey:["smart-plugs"],queryFn:Pe.getSmartPlugs}),{data:S}=yt({queryKey:["maintenanceOverview"],queryFn:Pe.getMaintenanceOverview,staleTime:60*1e3}),A=S?.reduce((R,V)=>(R[V.printer_id]={due_count:V.due_count,warning_count:V.warning_count,total_print_hours:V.total_print_hours},R),{})||{},T=E?.reduce((R,V)=>(V.printer_id&&(R[V.printer_id]=V),R),{})||{},P=_t({mutationFn:Pe.createPrinter,onSuccess:()=>{x.invalidateQueries({queryKey:["printers"]}),e(!1)}}),C=_t({mutationFn:R=>Pe.controlSmartPlug(R,"on"),onSuccess:()=>{x.invalidateQueries({queryKey:["smart-plugs"]}),o(null)},onError:()=>{o(null)}}),I=()=>{const R=!n;r(R),localStorage.setItem("hideDisconnectedPrinters",String(R))},N=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)},L=M.useMemo(()=>{if(!y)return[];const R=[...y];switch(l){case"name":R.sort((V,K)=>V.name.localeCompare(K.name));break;case"model":R.sort((V,K)=>(V.model||"").localeCompare(K.model||""));break;case"location":R.sort((V,K)=>{const W=V.location||"",ne=K.location||"";return!W&&ne?1:W&&!ne?-1:W.localeCompare(ne)||V.name.localeCompare(K.name)});break;case"status":R.sort((V,K)=>{const W=x.getQueryData(["printerStatus",V.id]),ne=x.getQueryData(["printerStatus",K.id]),Y=Z=>Z?.connected?Z.state==="RUNNING"?0:1:2;return Y(W)-Y(ne)});break}return d||R.reverse(),R},[y,l,d,x]),q=M.useMemo(()=>{if(l!=="location")return null;const R={};return L.forEach(V=>{const K=V.location||"Ungrouped";R[K]||(R[K]=[]),R[K].push(V)}),R},[l,L]);return c.jsxs("div",{className:"p-4 md:p-8",children:[c.jsxs("div",{className:"flex items-center justify-between mb-6",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),c.jsx(Bue,{printers:y})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs("select",{value:l,onChange:R=>N(R.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"name",children:"Name"}),c.jsx("option",{value:"status",children:"Status"}),c.jsx("option",{value:"model",children:"Model"}),c.jsx("option",{value:"location",children:"Location"})]}),c.jsx("button",{onClick:D,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?c.jsx(nm,{className:"w-4 h-4 text-bambu-gray"}):c.jsx(s0,{className:"w-4 h-4 text-bambu-gray"})})]}),c.jsx("button",{onClick:F,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:g==="expanded"?"Switch to compact view":"Switch to expanded view",children:g==="expanded"?c.jsx(ele,{className:"w-5 h-5 text-bambu-gray"}):c.jsx(OG,{className:"w-5 h-5 text-bambu-gray"})}),c.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),c.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:n,onChange:I,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(T).length>0&&c.jsxs("div",{className:"relative",children:[c.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[c.jsx(fd,{className:"w-4 h-4"}),"Power On",c.jsx(ef,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),c.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[c.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),y?.filter(R=>T[R.id]).map(R=>c.jsx(Gue,{printer:R,plug:T[R.id],onPowerOn:V=>{o(V),C.mutate(V)},isPowering:a===T[R.id]?.id},R.id)),y?.filter(R=>T[R.id]).length===0&&c.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),c.jsxs(Ie,{onClick:()=>e(!0),children:[c.jsx(fr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),v?c.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):y?.length===0?c.jsx(Nt,{children:c.jsxs(Dt,{className:"text-center py-12",children:[c.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),c.jsxs(Ie,{onClick:()=>e(!0),children:[c.jsx(fr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):q?c.jsx("div",{className:"space-y-6",children:Object.entries(q).map(([R,V])=>c.jsxs("div",{children:[c.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[c.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),R,c.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",V.length,")"]})]}),c.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:V.map(K=>c.jsx(R5,{printer:K,hideIfDisconnected:n,maintenanceInfo:A[K.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},K.id))})]},R))}):c.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:L.map(R=>c.jsx(R5,{printer:R,hideIfDisconnected:n,maintenanceInfo:A[R.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},R.id))}),t&&c.jsx(Hue,{onClose:()=>e(!1),onAdd:R=>P.mutate(R)})]})}const ER="181",Vp={ROTATE:0,DOLLY:1,PAN:2},jp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},que=0,D5=1,Kue=2,KG=1,Xue=2,Yl=3,ed=0,$s=1,Jo=2,hc=0,Gp=1,O5=2,j5=3,L5=4,Yue=5,Qd=100,Zue=101,Que=102,Jue=103,ede=104,tde=200,nde=201,rde=202,ide=203,d3=204,h3=205,sde=206,ade=207,ode=208,lde=209,cde=210,ude=211,dde=212,hde=213,fde=214,f3=0,p3=1,m3=2,om=3,g3=4,x3=5,b3=6,v3=7,MR=0,pde=1,mde=2,Hu=0,gde=1,xde=2,bde=3,vde=4,yde=5,_de=6,wde=7,XG=300,lm=301,cm=302,y3=303,_3=304,wS=306,w3=1e3,sc=1001,S3=1002,ga=1003,Sde=1004,ey=1005,Za=1006,cA=1007,sh=1008,ll=1009,YG=1010,ZG=1011,m0=1012,AR=1013,Lh=1014,ac=1015,Um=1016,TR=1017,CR=1018,g0=1020,QG=35902,JG=35899,e7=1021,t7=1022,Co=1023,x0=1026,b0=1027,n7=1028,NR=1029,kR=1030,PR=1031,RR=1033,j_=33776,L_=33777,I_=33778,U_=33779,E3=35840,M3=35841,A3=35842,T3=35843,C3=36196,N3=37492,k3=37496,P3=37808,R3=37809,D3=37810,O3=37811,j3=37812,L3=37813,I3=37814,U3=37815,F3=37816,z3=37817,B3=37818,H3=37819,$3=37820,V3=37821,G3=36492,W3=36494,q3=36495,K3=36283,X3=36284,Y3=36285,Z3=36286,Ede=3200,Mde=3201,r7=0,Ade=1,ku="",Ha="srgb",um="srgb-linear",u1="linear",Hn="srgb",Hf=7680,I5=519,Tde=512,Cde=513,Nde=514,i7=515,kde=516,Pde=517,Rde=518,Dde=519,U5=35044,F5="300 es",nl=2e3,d1=2001;function s7(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function h1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Ode(){const t=h1("canvas");return t.style.display="block",t}const z5={};function B5(...t){const e="THREE."+t.shift();console.log(e,...t)}function Xt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function jr(...t){const e="THREE."+t.shift();console.error(e,...t)}function v0(...t){const e=t.join(" ");e in z5||(z5[e]=!0,Xt(...t))}function jde(t,e,n){return new Promise(function(r,i){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}setTimeout(s,n)})}let nf=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}};const ts=["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"],F_=Math.PI/180,Q3=180/Math.PI;function ib(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ts[t&255]+ts[t>>8&255]+ts[t>>16&255]+ts[t>>24&255]+"-"+ts[e&255]+ts[e>>8&255]+"-"+ts[e>>16&15|64]+ts[e>>24&255]+"-"+ts[n&63|128]+ts[n>>8&255]+"-"+ts[n>>16&255]+ts[n>>24&255]+ts[r&255]+ts[r>>8&255]+ts[r>>16&255]+ts[r>>24&255]).toLowerCase()}function mn(t,e,n){return Math.max(e,Math.min(n,t))}function Lde(t,e){return(t%e+e)%e}function uA(t,e,n){return(1-n)*t+n*e}function Yg(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 Is(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 Ide={DEG2RAD:F_};let on=class a7{constructor(e=0,n=0){a7.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(mn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ih=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,s,a,o){let l=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],g=s[a+0],m=s[a+1],x=s[a+2],y=s[a+3];if(o<=0){e[n+0]=l,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(o>=1){e[n+0]=g,e[n+1]=m,e[n+2]=x,e[n+3]=y;return}if(f!==y||l!==g||u!==m||d!==x){let v=l*g+u*m+d*x+f*y;v<0&&(g=-g,m=-m,x=-x,y=-y,v=-v);let b=1-o;if(v<.9995){const E=Math.acos(v),S=Math.sin(E);b=Math.sin(b*E)/S,o=Math.sin(o*E)/S,l=l*b+g*o,u=u*b+m*o,d=d*b+x*o,f=f*b+y*o}else{l=l*b+g*o,u=u*b+m*o,d=d*b+x*o,f=f*b+y*o;const E=1/Math.sqrt(l*l+u*u+d*d+f*f);l*=E,u*=E,d*=E,f*=E}}e[n]=l,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],l=r[i+1],u=r[i+2],d=r[i+3],f=s[a],g=s[a+1],m=s[a+2],x=s[a+3];return e[n]=o*x+d*f+l*m-u*g,e[n+1]=l*x+d*g+u*f-o*m,e[n+2]=u*x+d*m+o*g-l*f,e[n+3]=d*x-o*f-l*g-u*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,u=o(r/2),d=o(i/2),f=o(s/2),g=l(r/2),m=l(i/2),x=l(s/2);switch(a){case"XYZ":this._x=g*d*f+u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f-g*m*x;break;case"YXZ":this._x=g*d*f+u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f+g*m*x;break;case"ZXY":this._x=g*d*f-u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f-g*m*x;break;case"ZYX":this._x=g*d*f-u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f+g*m*x;break;case"YZX":this._x=g*d*f+u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f-g*m*x;break;case"XZY":this._x=g*d*f-u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f+g*m*x;break;default:Xt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],a=n[1],o=n[5],l=n[9],u=n[2],d=n[6],f=n[10],g=r+o+f;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(d-l)*m,this._y=(s-u)*m,this._z=(a-i)*m}else if(r>o&&r>f){const m=2*Math.sqrt(1+r-o-f);this._w=(d-l)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+u)/m}else if(o>f){const m=2*Math.sqrt(1+o-r-f);this._w=(s-u)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(l+d)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(a-i)/m,this._x=(s+u)/m,this._y=(l+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(mn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,a=e._w,o=n._x,l=n._y,u=n._z,d=n._w;return this._x=r*d+a*o+i*u-s*l,this._y=i*d+a*l+s*o-r*u,this._z=s*d+a*u+r*l-i*o,this._w=a*d-r*o-i*l-s*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,s=-s,a=-a,o=-o);let l=1-n;if(o<.9995){const u=Math.acos(o),d=Math.sin(u);l=Math.sin(l*u)/d,n=Math.sin(n*u)/d,this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+s*n,this._w=this._w*l+a*n,this._onChangeCallback()}else this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+s*n,this._w=this._w*l+a*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Je=class o7{constructor(e=0,n=0,r=0){o7.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(H5.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(H5.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*a,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*a,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*a,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,u=2*(a*i-o*r),d=2*(o*n-s*i),f=2*(s*r-a*n);return this.x=n+l*u+a*f-o*d,this.y=r+l*d+o*u-s*f,this.z=i+l*f+s*d-a*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this.z=mn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this.z=mn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,a=n.x,o=n.y,l=n.z;return this.x=i*l-s*o,this.y=s*a-r*l,this.z=r*o-i*a,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return dA.copy(this).projectOnVector(e),this.sub(dA)}reflect(e){return this.sub(dA.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(mn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const dA=new Je,H5=new Ih;let un=class l7{constructor(e,n,r,i,s,a,o,l,u){l7.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,l,u)}set(e,n,r,i,s,a,o,l,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=s,d[5]=l,d[6]=r,d[7]=a,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[3],l=r[6],u=r[1],d=r[4],f=r[7],g=r[2],m=r[5],x=r[8],y=i[0],v=i[3],b=i[6],E=i[1],S=i[4],A=i[7],T=i[2],P=i[5],C=i[8];return s[0]=a*y+o*E+l*T,s[3]=a*v+o*S+l*P,s[6]=a*b+o*A+l*C,s[1]=u*y+d*E+f*T,s[4]=u*v+d*S+f*P,s[7]=u*b+d*A+f*C,s[2]=g*y+m*E+x*T,s[5]=g*v+m*S+x*P,s[8]=g*b+m*A+x*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],d=e[8];return n*a*d-n*o*u-r*s*d+r*o*l+i*s*u-i*a*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],d=e[8],f=d*a-o*u,g=o*l-d*s,m=u*s-a*l,x=n*f+r*g+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(o*r-i*a)*y,e[3]=g*y,e[4]=(d*n-i*l)*y,e[5]=(i*s-o*n)*y,e[6]=m*y,e[7]=(r*l-u*n)*y,e[8]=(a*n-r*s)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,a,o){const l=Math.cos(s),u=Math.sin(s);return this.set(r*l,r*u,-r*(l*a+u*o)+a+e,-i*u,i*l,-i*(-u*a+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(hA.makeScale(e,n)),this}rotate(e){return this.premultiply(hA.makeRotation(-e)),this}translate(e,n){return this.premultiply(hA.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 hA=new un,$5=new un().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),V5=new un().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ude(){const t={enabled:!0,workingColorSpace:um,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Hn&&(i.r=fc(i.r),i.g=fc(i.g),i.b=fc(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Hn&&(i.r=Wp(i.r),i.g=Wp(i.g),i.b=Wp(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===ku?u1:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return v0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return v0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[um]:{primaries:e,whitePoint:r,transfer:u1,toXYZ:$5,fromXYZ:V5,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ha},outputColorSpaceConfig:{drawingBufferColorSpace:Ha}},[Ha]:{primaries:e,whitePoint:r,transfer:Hn,toXYZ:$5,fromXYZ:V5,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ha}}}),t}const An=Ude();function fc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Wp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let $f,Fde=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{$f===void 0&&($f=h1("canvas")),$f.width=e.width,$f.height=e.height;const i=$f.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=$f}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=h1("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=fc(s[a]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(fc(n[r]/255)*255):n[r]=fc(n[r]);return{data:n,width:e.width,height:e.height}}else return Xt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},zde=0,DR=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:zde++}),this.uuid=ib(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(fA(i[a].image)):s.push(fA(i[a]))}else s=fA(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function fA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Fde.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Xt("Texture: Unable to serialize Texture."),{})}let Bde=0;const pA=new Je;let Fo=class z_ extends nf{constructor(e=z_.DEFAULT_IMAGE,n=z_.DEFAULT_MAPPING,r=sc,i=sc,s=Za,a=sh,o=Co,l=ll,u=z_.DEFAULT_ANISOTROPY,d=ku){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Bde++}),this.uuid=ib(),this.name="",this.source=new DR(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=l,this.offset=new on(0,0),this.repeat=new on(1,1),this.center=new on(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new un,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(pA).x}get height(){return this.source.getSize(pA).y}get depth(){return this.source.getSize(pA).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){Xt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Xt(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==XG)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case w3:e.x=e.x-Math.floor(e.x);break;case sc:e.x=e.x<0?0:1;break;case S3: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 w3:e.y=e.y-Math.floor(e.y);break;case sc:e.y=e.y<0?0:1;break;case S3: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++}};Fo.DEFAULT_IMAGE=null;Fo.DEFAULT_MAPPING=XG;Fo.DEFAULT_ANISOTROPY=1;let Wr=class c7{constructor(e=0,n=0,r=0,i=1){c7.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*n+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*n+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*n+a[7]*r+a[11]*i+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const l=e.elements,u=l[0],d=l[4],f=l[8],g=l[1],m=l[5],x=l[9],y=l[2],v=l[6],b=l[10];if(Math.abs(d-g)<.01&&Math.abs(f-y)<.01&&Math.abs(x-v)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+y)<.1&&Math.abs(x+v)<.1&&Math.abs(u+m+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(m+1)/2,T=(b+1)/2,P=(d+g)/4,C=(f+y)/4,I=(x+v)/4;return S>A&&S>T?S<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(S),i=P/r,s=C/r):A>T?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=P/i,s=I/i):T<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(T),r=C/s,i=I/s),this.set(r,i,s,n),this}let E=Math.sqrt((v-x)*(v-x)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(v-x)/E,this.y=(f-y)/E,this.z=(g-d)/E,this.w=Math.acos((u+m+b-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this.z=mn(this.z,e.z,n.z),this.w=mn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this.z=mn(this.z,e,n),this.w=mn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Hde=class extends nf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Za,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 Wr(0,0,e,n),this.scissorTest=!1,this.viewport=new Wr(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new Fo(i);this.textures=[];const a=r.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:Za,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new DR(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"})}},Uh=class extends Hde{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},u7=class extends Fo{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=ga,this.minFilter=ga,this.wrapR=sc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},$de=class extends Fo{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=ga,this.minFilter=ga,this.wrapR=sc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Fh=class{constructor(e=new Je(1/0,1/0,1/0),n=new Je(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(mo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(mo.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=mo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,mo):mo.fromBufferAttribute(s,a),mo.applyMatrix4(e.matrixWorld),this.expandByPoint(mo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ty.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),ty.copy(r.boundingBox)),ty.applyMatrix4(e.matrixWorld),this.union(ty)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,mo),mo.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(Zg),ny.subVectors(this.max,Zg),Vf.subVectors(e.a,Zg),Gf.subVectors(e.b,Zg),Wf.subVectors(e.c,Zg),ou.subVectors(Gf,Vf),lu.subVectors(Wf,Gf),Ld.subVectors(Vf,Wf);let n=[0,-ou.z,ou.y,0,-lu.z,lu.y,0,-Ld.z,Ld.y,ou.z,0,-ou.x,lu.z,0,-lu.x,Ld.z,0,-Ld.x,-ou.y,ou.x,0,-lu.y,lu.x,0,-Ld.y,Ld.x,0];return!mA(n,Vf,Gf,Wf,ny)||(n=[1,0,0,0,1,0,0,0,1],!mA(n,Vf,Gf,Wf,ny))?!1:(ry.crossVectors(ou,lu),n=[ry.x,ry.y,ry.z],mA(n,Vf,Gf,Wf,ny))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,mo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(mo).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:(Ll[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ll[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ll[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ll[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ll[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ll[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ll[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ll[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ll),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 Ll=[new Je,new Je,new Je,new Je,new Je,new Je,new Je,new Je],mo=new Je,ty=new Fh,Vf=new Je,Gf=new Je,Wf=new Je,ou=new Je,lu=new Je,Ld=new Je,Zg=new Je,ny=new Je,ry=new Je,Id=new Je;function mA(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){Id.fromArray(t,s);const o=i.x*Math.abs(Id.x)+i.y*Math.abs(Id.y)+i.z*Math.abs(Id.z),l=e.dot(Id),u=n.dot(Id),d=r.dot(Id);if(Math.max(-Math.max(l,u,d),Math.min(l,u,d))>o)return!1}return!0}const Vde=new Fh,Qg=new Je,gA=new Je;let SS=class{constructor(e=new Je,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):Vde.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Qg.subVectors(e,this.center);const n=Qg.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Qg,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):(gA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Qg.copy(e.center).add(gA)),this.expandByPoint(Qg.copy(e.center).sub(gA))),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 Il=new Je,xA=new Je,iy=new Je,cu=new Je,bA=new Je,sy=new Je,vA=new Je;let OR=class{constructor(e=new Je,n=new Je(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Il)),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=Il.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Il.copy(this.origin).addScaledVector(this.direction,n),Il.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){xA.copy(e).add(n).multiplyScalar(.5),iy.copy(n).sub(e).normalize(),cu.copy(this.origin).sub(xA);const s=e.distanceTo(n)*.5,a=-this.direction.dot(iy),o=cu.dot(this.direction),l=-cu.dot(iy),u=cu.lengthSq(),d=Math.abs(1-a*a);let f,g,m,x;if(d>0)if(f=a*l-o,g=a*o-l,x=s*d,f>=0)if(g>=-x)if(g<=x){const y=1/d;f*=y,g*=y,m=f*(f+a*g+2*o)+g*(a*f+g+2*l)+u}else g=s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;else g=-s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;else g<=-x?(f=Math.max(0,-(-a*s+o)),g=f>0?-s:Math.min(Math.max(-s,-l),s),m=-f*f+g*(g+2*l)+u):g<=x?(f=0,g=Math.min(Math.max(-s,-l),s),m=g*(g+2*l)+u):(f=Math.max(0,-(a*s+o)),g=f>0?s:Math.min(Math.max(-s,-l),s),m=-f*f+g*(g+2*l)+u);else g=a>0?-s:s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(xA).addScaledVector(iy,g),m}intersectSphere(e,n){Il.subVectors(e.center,this.origin);const r=Il.dot(this.direction),i=Il.dot(Il)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,l=r+a;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,a,o,l;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(s=(e.min.y-g.y)*d,a=(e.max.y-g.y)*d):(s=(e.max.y-g.y)*d,a=(e.min.y-g.y)*d),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),f>=0?(o=(e.min.z-g.z)*f,l=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,l=(e.min.z-g.z)*f),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Il)!==null}intersectTriangle(e,n,r,i,s){bA.subVectors(n,e),sy.subVectors(r,e),vA.crossVectors(bA,sy);let a=this.direction.dot(vA),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;cu.subVectors(this.origin,e);const l=o*this.direction.dot(sy.crossVectors(cu,sy));if(l<0)return null;const u=o*this.direction.dot(bA.cross(cu));if(u<0||l+u>a)return null;const d=-o*cu.dot(vA);return d<0?null:this.at(d/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Jr=class J3{constructor(e,n,r,i,s,a,o,l,u,d,f,g,m,x,y,v){J3.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,l,u,d,f,g,m,x,y,v)}set(e,n,r,i,s,a,o,l,u,d,f,g,m,x,y,v){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=s,b[5]=a,b[9]=o,b[13]=l,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=m,b[7]=x,b[11]=y,b[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new J3().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/qf.setFromMatrixColumn(e,0).length(),s=1/qf.setFromMatrixColumn(e,1).length(),a=1/qf.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,a=Math.cos(r),o=Math.sin(r),l=Math.cos(i),u=Math.sin(i),d=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const g=a*d,m=a*f,x=o*d,y=o*f;n[0]=l*d,n[4]=-l*f,n[8]=u,n[1]=m+x*u,n[5]=g-y*u,n[9]=-o*l,n[2]=y-g*u,n[6]=x+m*u,n[10]=a*l}else if(e.order==="YXZ"){const g=l*d,m=l*f,x=u*d,y=u*f;n[0]=g+y*o,n[4]=x*o-m,n[8]=a*u,n[1]=a*f,n[5]=a*d,n[9]=-o,n[2]=m*o-x,n[6]=y+g*o,n[10]=a*l}else if(e.order==="ZXY"){const g=l*d,m=l*f,x=u*d,y=u*f;n[0]=g-y*o,n[4]=-a*f,n[8]=x+m*o,n[1]=m+x*o,n[5]=a*d,n[9]=y-g*o,n[2]=-a*u,n[6]=o,n[10]=a*l}else if(e.order==="ZYX"){const g=a*d,m=a*f,x=o*d,y=o*f;n[0]=l*d,n[4]=x*u-m,n[8]=g*u+y,n[1]=l*f,n[5]=y*u+g,n[9]=m*u-x,n[2]=-u,n[6]=o*l,n[10]=a*l}else if(e.order==="YZX"){const g=a*l,m=a*u,x=o*l,y=o*u;n[0]=l*d,n[4]=y-g*f,n[8]=x*f+m,n[1]=f,n[5]=a*d,n[9]=-o*d,n[2]=-u*d,n[6]=m*f+x,n[10]=g-y*f}else if(e.order==="XZY"){const g=a*l,m=a*u,x=o*l,y=o*u;n[0]=l*d,n[4]=-f,n[8]=u*d,n[1]=g*f+y,n[5]=a*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=o*d,n[10]=y*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Gde,e,Wde)}lookAt(e,n,r){const i=this.elements;return aa.subVectors(e,n),aa.lengthSq()===0&&(aa.z=1),aa.normalize(),uu.crossVectors(r,aa),uu.lengthSq()===0&&(Math.abs(r.z)===1?aa.x+=1e-4:aa.z+=1e-4,aa.normalize(),uu.crossVectors(r,aa)),uu.normalize(),ay.crossVectors(aa,uu),i[0]=uu.x,i[4]=ay.x,i[8]=aa.x,i[1]=uu.y,i[5]=ay.y,i[9]=aa.y,i[2]=uu.z,i[6]=ay.z,i[10]=aa.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[4],l=r[8],u=r[12],d=r[1],f=r[5],g=r[9],m=r[13],x=r[2],y=r[6],v=r[10],b=r[14],E=r[3],S=r[7],A=r[11],T=r[15],P=i[0],C=i[4],I=i[8],N=i[12],D=i[1],F=i[5],L=i[9],q=i[13],R=i[2],V=i[6],K=i[10],W=i[14],ne=i[3],Y=i[7],Z=i[11],U=i[15];return s[0]=a*P+o*D+l*R+u*ne,s[4]=a*C+o*F+l*V+u*Y,s[8]=a*I+o*L+l*K+u*Z,s[12]=a*N+o*q+l*W+u*U,s[1]=d*P+f*D+g*R+m*ne,s[5]=d*C+f*F+g*V+m*Y,s[9]=d*I+f*L+g*K+m*Z,s[13]=d*N+f*q+g*W+m*U,s[2]=x*P+y*D+v*R+b*ne,s[6]=x*C+y*F+v*V+b*Y,s[10]=x*I+y*L+v*K+b*Z,s[14]=x*N+y*q+v*W+b*U,s[3]=E*P+S*D+A*R+T*ne,s[7]=E*C+S*F+A*V+T*Y,s[11]=E*I+S*L+A*K+T*Z,s[15]=E*N+S*q+A*W+T*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],u=e[13],d=e[2],f=e[6],g=e[10],m=e[14],x=e[3],y=e[7],v=e[11],b=e[15];return x*(+s*l*f-i*u*f-s*o*g+r*u*g+i*o*m-r*l*m)+y*(+n*l*m-n*u*g+s*a*g-i*a*m+i*u*d-s*l*d)+v*(+n*u*f-n*o*m-s*a*f+r*a*m+s*o*d-r*u*d)+b*(-i*o*d-n*l*f+n*o*g+i*a*f-r*a*g+r*l*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],d=e[8],f=e[9],g=e[10],m=e[11],x=e[12],y=e[13],v=e[14],b=e[15],E=f*v*u-y*g*u+y*l*m-o*v*m-f*l*b+o*g*b,S=x*g*u-d*v*u-x*l*m+a*v*m+d*l*b-a*g*b,A=d*y*u-x*f*u+x*o*m-a*y*m-d*o*b+a*f*b,T=x*f*l-d*y*l-x*o*g+a*y*g+d*o*v-a*f*v,P=n*E+r*S+i*A+s*T;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/P;return e[0]=E*C,e[1]=(y*g*s-f*v*s-y*i*m+r*v*m+f*i*b-r*g*b)*C,e[2]=(o*v*s-y*l*s+y*i*u-r*v*u-o*i*b+r*l*b)*C,e[3]=(f*l*s-o*g*s-f*i*u+r*g*u+o*i*m-r*l*m)*C,e[4]=S*C,e[5]=(d*v*s-x*g*s+x*i*m-n*v*m-d*i*b+n*g*b)*C,e[6]=(x*l*s-a*v*s-x*i*u+n*v*u+a*i*b-n*l*b)*C,e[7]=(a*g*s-d*l*s+d*i*u-n*g*u-a*i*m+n*l*m)*C,e[8]=A*C,e[9]=(x*f*s-d*y*s-x*r*m+n*y*m+d*r*b-n*f*b)*C,e[10]=(a*y*s-x*o*s+x*r*u-n*y*u-a*r*b+n*o*b)*C,e[11]=(d*o*s-a*f*s-d*r*u+n*f*u+a*r*m-n*o*m)*C,e[12]=T*C,e[13]=(d*y*i-x*f*i+x*r*g-n*y*g-d*r*v+n*f*v)*C,e[14]=(x*o*i-a*y*i-x*r*l+n*y*l+a*r*v-n*o*v)*C,e[15]=(a*f*i-d*o*i+d*r*l-n*f*l-a*r*g+n*o*g)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,a=e.x,o=e.y,l=e.z,u=s*a,d=s*o;return this.set(u*a+r,u*o-i*l,u*l+i*o,0,u*o+i*l,d*o+r,d*l-i*a,0,u*l-i*o,d*l+i*a,s*l*l+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,a=n._y,o=n._z,l=n._w,u=s+s,d=a+a,f=o+o,g=s*u,m=s*d,x=s*f,y=a*d,v=a*f,b=o*f,E=l*u,S=l*d,A=l*f,T=r.x,P=r.y,C=r.z;return i[0]=(1-(y+b))*T,i[1]=(m+A)*T,i[2]=(x-S)*T,i[3]=0,i[4]=(m-A)*P,i[5]=(1-(g+b))*P,i[6]=(v+E)*P,i[7]=0,i[8]=(x+S)*C,i[9]=(v-E)*C,i[10]=(1-(g+y))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=qf.set(i[0],i[1],i[2]).length();const a=qf.set(i[4],i[5],i[6]).length(),o=qf.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],go.copy(this);const u=1/s,d=1/a,f=1/o;return go.elements[0]*=u,go.elements[1]*=u,go.elements[2]*=u,go.elements[4]*=d,go.elements[5]*=d,go.elements[6]*=d,go.elements[8]*=f,go.elements[9]*=f,go.elements[10]*=f,n.setFromRotationMatrix(go),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=nl,l=!1){const u=this.elements,d=2*s/(n-e),f=2*s/(r-i),g=(n+e)/(n-e),m=(r+i)/(r-i);let x,y;if(l)x=s/(a-s),y=a*s/(a-s);else if(o===nl)x=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===d1)x=-a/(a-s),y=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return u[0]=d,u[4]=0,u[8]=g,u[12]=0,u[1]=0,u[5]=f,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=nl,l=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),g=-(n+e)/(n-e),m=-(r+i)/(r-i);let x,y;if(l)x=1/(a-s),y=a/(a-s);else if(o===nl)x=-2/(a-s),y=-(a+s)/(a-s);else if(o===d1)x=-1/(a-s),y=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return u[0]=d,u[4]=0,u[8]=0,u[12]=g,u[1]=0,u[5]=f,u[9]=0,u[13]=m,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const qf=new Je,go=new Jr,Gde=new Je(0,0,0),Wde=new Je(1,1,1),uu=new Je,ay=new Je,aa=new Je,G5=new Jr,W5=new Ih;let td=class d7{constructor(e=0,n=0,r=0,i=d7.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],u=i[5],d=i[9],f=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(mn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-mn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(mn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-mn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(mn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-mn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:Xt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return G5.makeRotationFromQuaternion(e),this.setFromRotationMatrix(G5,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return W5.setFromEuler(this),this.setFromQuaternion(W5,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}};td.DEFAULT_ORDER="XYZ";let h7=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}},qde=0;const q5=new Je,Kf=new Ih,Ul=new Jr,oy=new Je,Jg=new Je,Kde=new Je,Xde=new Ih,K5=new Je(1,0,0),X5=new Je(0,1,0),Y5=new Je(0,0,1),Z5={type:"added"},Yde={type:"removed"},Xf={type:"childadded",child:null},yA={type:"childremoved",child:null};let _a=class B_ extends nf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:qde++}),this.uuid=ib(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=B_.DEFAULT_UP.clone();const e=new Je,n=new td,r=new Ih,i=new Je(1,1,1);function s(){r.setFromEuler(n,!1)}function a(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Jr},normalMatrix:{value:new un}}),this.matrix=new Jr,this.matrixWorld=new Jr,this.matrixAutoUpdate=B_.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=B_.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new h7,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 Kf.setFromAxisAngle(e,n),this.quaternion.multiply(Kf),this}rotateOnWorldAxis(e,n){return Kf.setFromAxisAngle(e,n),this.quaternion.premultiply(Kf),this}rotateX(e){return this.rotateOnAxis(K5,e)}rotateY(e){return this.rotateOnAxis(X5,e)}rotateZ(e){return this.rotateOnAxis(Y5,e)}translateOnAxis(e,n){return q5.copy(e).applyQuaternion(this.quaternion),this.position.add(q5.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(K5,e)}translateY(e){return this.translateOnAxis(X5,e)}translateZ(e){return this.translateOnAxis(Y5,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ul.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?oy.copy(e):oy.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Jg.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ul.lookAt(Jg,oy,this.up):Ul.lookAt(oy,Jg,this.up),this.quaternion.setFromRotationMatrix(Ul),i&&(Ul.extractRotation(i.matrixWorld),Kf.setFromRotationMatrix(Ul),this.quaternion.premultiply(Kf.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(jr("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(Z5),Xf.child=e,this.dispatchEvent(Xf),Xf.child=null):jr("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(Yde),yA.child=e,this.dispatchEvent(yA),yA.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),Ul.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ul.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ul),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Z5),Xf.child=e,this.dispatchEvent(Xf),Xf.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const a=this.children[r].getObjectByProperty(e,n);if(a!==void 0)return a}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Jg,e,Kde),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Jg,Xde,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let u=0,d=l.length;u<d;u++){const f=l[u];s(e.shapes,f)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,u=this.material.length;l<u;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(n){const o=a(e.geometries),l=a(e.materials),u=a(e.textures),d=a(e.images),f=a(e.shapes),g=a(e.skeletons),m=a(e.animations),x=a(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),x.length>0&&(r.nodes=x)}return r.object=i,r;function a(o){const l=[];for(const u in o){const d=o[u];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};_a.DEFAULT_UP=new Je(0,1,0);_a.DEFAULT_MATRIX_AUTO_UPDATE=!0;_a.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const xo=new Je,Fl=new Je,_A=new Je,zl=new Je,Yf=new Je,Zf=new Je,Q5=new Je,wA=new Je,SA=new Je,EA=new Je,MA=new Wr,AA=new Wr,TA=new Wr;let ex=class Cp{constructor(e=new Je,n=new Je,r=new Je){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),xo.subVectors(e,n),i.cross(xo);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){xo.subVectors(i,n),Fl.subVectors(r,n),_A.subVectors(e,n);const a=xo.dot(xo),o=xo.dot(Fl),l=xo.dot(_A),u=Fl.dot(Fl),d=Fl.dot(_A),f=a*u-o*o;if(f===0)return s.set(0,0,0),null;const g=1/f,m=(u*l-o*d)*g,x=(a*d-o*l)*g;return s.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,zl)===null?!1:zl.x>=0&&zl.y>=0&&zl.x+zl.y<=1}static getInterpolation(e,n,r,i,s,a,o,l){return this.getBarycoord(e,n,r,i,zl)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,zl.x),l.addScaledVector(a,zl.y),l.addScaledVector(o,zl.z),l)}static getInterpolatedAttribute(e,n,r,i,s,a){return MA.setScalar(0),AA.setScalar(0),TA.setScalar(0),MA.fromBufferAttribute(e,n),AA.fromBufferAttribute(e,r),TA.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(MA,s.x),a.addScaledVector(AA,s.y),a.addScaledVector(TA,s.z),a}static isFrontFacing(e,n,r,i){return xo.subVectors(r,n),Fl.subVectors(e,n),xo.cross(Fl).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 xo.subVectors(this.c,this.b),Fl.subVectors(this.a,this.b),xo.cross(Fl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Cp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Cp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return Cp.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Cp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Cp.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let a,o;Yf.subVectors(i,r),Zf.subVectors(s,r),wA.subVectors(e,r);const l=Yf.dot(wA),u=Zf.dot(wA);if(l<=0&&u<=0)return n.copy(r);SA.subVectors(e,i);const d=Yf.dot(SA),f=Zf.dot(SA);if(d>=0&&f<=d)return n.copy(i);const g=l*f-d*u;if(g<=0&&l>=0&&d<=0)return a=l/(l-d),n.copy(r).addScaledVector(Yf,a);EA.subVectors(e,s);const m=Yf.dot(EA),x=Zf.dot(EA);if(x>=0&&m<=x)return n.copy(s);const y=m*u-l*x;if(y<=0&&u>=0&&x<=0)return o=u/(u-x),n.copy(r).addScaledVector(Zf,o);const v=d*x-m*f;if(v<=0&&f-d>=0&&m-x>=0)return Q5.subVectors(s,i),o=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(Q5,o);const b=1/(v+y+g);return a=y*b,o=g*b,n.copy(r).addScaledVector(Yf,a).addScaledVector(Zf,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const f7={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},du={h:0,s:0,l:0},ly={h:0,s:0,l:0};function CA(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 vn=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=Ha){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,An.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=An.workingColorSpace){return this.r=e,this.g=n,this.b=r,An.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=An.workingColorSpace){if(e=Lde(e,1),n=mn(n,0,1),r=mn(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,a=2*r-s;this.r=CA(a,s,e+1/3),this.g=CA(a,s,e),this.b=CA(a,s,e-1/3)}return An.colorSpaceToWorking(this,i),this}setStyle(e,n=Ha){function r(s){s!==void 0&&parseFloat(s)<1&&Xt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:Xt("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(a===6)return this.setHex(parseInt(s,16),n);Xt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Ha){const r=f7[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Xt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=fc(e.r),this.g=fc(e.g),this.b=fc(e.b),this}copyLinearToSRGB(e){return this.r=Wp(e.r),this.g=Wp(e.g),this.b=Wp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ha){return An.workingToColorSpace(ns.copy(this),e),Math.round(mn(ns.r*255,0,255))*65536+Math.round(mn(ns.g*255,0,255))*256+Math.round(mn(ns.b*255,0,255))}getHexString(e=Ha){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=An.workingColorSpace){An.workingToColorSpace(ns.copy(this),n);const r=ns.r,i=ns.g,s=ns.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,u;const d=(o+a)/2;if(o===a)l=0,u=0;else{const f=a-o;switch(u=d<=.5?f/(a+o):f/(2-a-o),a){case r:l=(i-s)/f+(i<s?6:0);break;case i:l=(s-r)/f+2;break;case s:l=(r-i)/f+4;break}l/=6}return e.h=l,e.s=u,e.l=d,e}getRGB(e,n=An.workingColorSpace){return An.workingToColorSpace(ns.copy(this),n),e.r=ns.r,e.g=ns.g,e.b=ns.b,e}getStyle(e=Ha){An.workingToColorSpace(ns.copy(this),e);const n=ns.r,r=ns.g,i=ns.b;return e!==Ha?`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(du),this.setHSL(du.h+e,du.s+n,du.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(du),e.getHSL(ly);const r=uA(du.h,ly.h,n),i=uA(du.s,ly.s,n),s=uA(du.l,ly.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const ns=new vn;vn.NAMES=f7;let Zde=0,Fm=class extends nf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Zde++}),this.uuid=ib(),this.name="",this.type="Material",this.blending=Gp,this.side=ed,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=d3,this.blendDst=h3,this.blendEquation=Qd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new vn(0,0,0),this.blendAlpha=0,this.depthFunc=om,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=I5,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Hf,this.stencilZFail=Hf,this.stencilZPass=Hf,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){Xt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Xt(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Gp&&(r.blending=this.blending),this.side!==ed&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==d3&&(r.blendSrc=this.blendSrc),this.blendDst!==h3&&(r.blendDst=this.blendDst),this.blendEquation!==Qd&&(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!==om&&(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!==I5&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Hf&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Hf&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Hf&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(n){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},jR=class extends Fm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new vn(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 td,this.combine=MR,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 $r=new Je,cy=new on;let Qde=0,Ja=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:Qde++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=U5,this.updateRanges=[],this.gpuType=ac,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)cy.fromBufferAttribute(this,n),cy.applyMatrix3(e),this.setXY(n,cy.x,cy.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.applyMatrix3(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.applyMatrix4(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.applyNormalMatrix(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.transformDirection(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=Yg(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Is(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Yg(n,this.array)),n}setX(e,n){return this.normalized&&(n=Is(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Yg(n,this.array)),n}setY(e,n){return this.normalized&&(n=Is(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=Yg(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Is(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=Yg(n,this.array)),n}setW(e,n){return this.normalized&&(n=Is(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Is(n,this.array),r=Is(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=Is(n,this.array),r=Is(r,this.array),i=Is(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=Is(n,this.array),r=Is(r,this.array),i=Is(i,this.array),s=Is(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==U5&&(e.usage=this.usage),e}},p7=class extends Ja{constructor(e,n,r){super(new Uint16Array(e),n,r)}},m7=class extends Ja{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Po=class extends Ja{constructor(e,n,r){super(new Float32Array(e),n,r)}},Jde=0;const Pa=new Jr,NA=new _a,Qf=new Je,oa=new Fh,tx=new Fh,Ai=new Je;let xl=class g7 extends nf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Jde++}),this.uuid=ib(),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(s7(e)?m7:p7)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new un().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Pa.makeRotationFromQuaternion(e),this.applyMatrix4(Pa),this}rotateX(e){return Pa.makeRotationX(e),this.applyMatrix4(Pa),this}rotateY(e){return Pa.makeRotationY(e),this.applyMatrix4(Pa),this}rotateZ(e){return Pa.makeRotationZ(e),this.applyMatrix4(Pa),this}translate(e,n,r){return Pa.makeTranslation(e,n,r),this.applyMatrix4(Pa),this}scale(e,n,r){return Pa.makeScale(e,n,r),this.applyMatrix4(Pa),this}lookAt(e){return NA.lookAt(e),NA.updateMatrix(),this.applyMatrix4(NA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Qf).negate(),this.translate(Qf.x,Qf.y,Qf.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const a=e[i];r.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Po(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const s=e[i];n.setXYZ(i,s.x,s.y,s.z||0)}e.length>n.count&&Xt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Fh);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){jr("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Je(-1/0,-1/0,-1/0),new Je(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];oa.setFromBufferAttribute(s),this.morphTargetsRelative?(Ai.addVectors(this.boundingBox.min,oa.min),this.boundingBox.expandByPoint(Ai),Ai.addVectors(this.boundingBox.max,oa.max),this.boundingBox.expandByPoint(Ai)):(this.boundingBox.expandByPoint(oa.min),this.boundingBox.expandByPoint(oa.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&jr('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 SS);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){jr("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Je,1/0);return}if(e){const r=this.boundingSphere.center;if(oa.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];tx.setFromBufferAttribute(o),this.morphTargetsRelative?(Ai.addVectors(oa.min,tx.min),oa.expandByPoint(Ai),Ai.addVectors(oa.max,tx.max),oa.expandByPoint(Ai)):(oa.expandByPoint(tx.min),oa.expandByPoint(tx.max))}oa.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Ai.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Ai));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],l=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)Ai.fromBufferAttribute(o,u),l&&(Qf.fromBufferAttribute(e,u),Ai.add(Qf)),i=Math.max(i,r.distanceToSquared(Ai))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&jr('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){jr("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ja(new Float32Array(4*r.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let I=0;I<r.count;I++)o[I]=new Je,l[I]=new Je;const u=new Je,d=new Je,f=new Je,g=new on,m=new on,x=new on,y=new Je,v=new Je;function b(I,N,D){u.fromBufferAttribute(r,I),d.fromBufferAttribute(r,N),f.fromBufferAttribute(r,D),g.fromBufferAttribute(s,I),m.fromBufferAttribute(s,N),x.fromBufferAttribute(s,D),d.sub(u),f.sub(u),m.sub(g),x.sub(g);const F=1/(m.x*x.y-x.x*m.y);isFinite(F)&&(y.copy(d).multiplyScalar(x.y).addScaledVector(f,-m.y).multiplyScalar(F),v.copy(f).multiplyScalar(m.x).addScaledVector(d,-x.x).multiplyScalar(F),o[I].add(y),o[N].add(y),o[D].add(y),l[I].add(v),l[N].add(v),l[D].add(v))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let I=0,N=E.length;I<N;++I){const D=E[I],F=D.start,L=D.count;for(let q=F,R=F+L;q<R;q+=3)b(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const S=new Je,A=new Je,T=new Je,P=new Je;function C(I){T.fromBufferAttribute(i,I),P.copy(T);const N=o[I];S.copy(N),S.sub(T.multiplyScalar(T.dot(N))).normalize(),A.crossVectors(P,N);const F=A.dot(l[I])<0?-1:1;a.setXYZW(I,S.x,S.y,S.z,F)}for(let I=0,N=E.length;I<N;++I){const D=E[I],F=D.start,L=D.count;for(let q=F,R=F+L;q<R;q+=3)C(e.getX(q+0)),C(e.getX(q+1)),C(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 Ja(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new Je,s=new Je,a=new Je,o=new Je,l=new Je,u=new Je,d=new Je,f=new Je;if(e)for(let g=0,m=e.count;g<m;g+=3){const x=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),a.fromBufferAttribute(n,v),d.subVectors(a,s),f.subVectors(i,s),d.cross(f),o.fromBufferAttribute(r,x),l.fromBufferAttribute(r,y),u.fromBufferAttribute(r,v),o.add(d),l.add(d),u.add(d),r.setXYZ(x,o.x,o.y,o.z),r.setXYZ(y,l.x,l.y,l.z),r.setXYZ(v,u.x,u.y,u.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),s.fromBufferAttribute(n,g+1),a.fromBufferAttribute(n,g+2),d.subVectors(a,s),f.subVectors(i,s),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Ai.fromBufferAttribute(e,n),Ai.normalize(),e.setXYZ(n,Ai.x,Ai.y,Ai.z)}toNonIndexed(){function e(o,l){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(l.length*d);let m=0,x=0;for(let y=0,v=l.length;y<v;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*d;for(let b=0;b<d;b++)g[x++]=u[m++]}return new Ja(g,d,f)}if(this.index===null)return Xt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new g7,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],u=e(l,r);n.setAttribute(o,u)}const s=this.morphAttributes;for(const o in s){const l=[],u=s[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const u=a[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const u in l)l[u]!==void 0&&(e[u]=l[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const l in r){const u=r[l];e.data.attributes[l]=u.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const u=this.morphAttributes[l],d=[];for(let f=0,g=u.length;f<g;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[l]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const s=e.morphAttributes;for(const u in s){const d=[],f=s[u];for(let g=0,m=f.length;g<m;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let u=0,d=a.length;u<d;u++){const f=a[u];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const J5=new Jr,Ud=new OR,uy=new SS,eF=new Je,dy=new Je,hy=new Je,fy=new Je,kA=new Je,py=new Je,tF=new Je,my=new Je;let cl=class extends _a{constructor(e=new xl,n=new jR){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){py.set(0,0,0);for(let l=0,u=s.length;l<u;l++){const d=o[l],f=s[l];d!==0&&(kA.fromBufferAttribute(f,e),a?py.addScaledVector(kA,d):py.addScaledVector(kA.sub(n),d))}n.add(py)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),uy.copy(r.boundingSphere),uy.applyMatrix4(s),Ud.copy(e.ray).recast(e.near),!(uy.containsPoint(Ud.origin)===!1&&(Ud.intersectSphere(uy,eF)===null||Ud.origin.distanceToSquared(eF)>(e.far-e.near)**2))&&(J5.copy(s).invert(),Ud.copy(e.ray).applyMatrix4(J5),!(r.boundingBox!==null&&Ud.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Ud)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,f=s.attributes.normal,g=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let x=0,y=g.length;x<y;x++){const v=g[x],b=a[v.materialIndex],E=Math.max(v.start,m.start),S=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=S;A<T;A+=3){const P=o.getX(A),C=o.getX(A+1),I=o.getX(A+2);i=gy(this,b,e,r,u,d,f,P,C,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const E=o.getX(v),S=o.getX(v+1),A=o.getX(v+2);i=gy(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let x=0,y=g.length;x<y;x++){const v=g[x],b=a[v.materialIndex],E=Math.max(v.start,m.start),S=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=S;A<T;A+=3){const P=A,C=A+1,I=A+2;i=gy(this,b,e,r,u,d,f,P,C,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const E=v,S=v+1,A=v+2;i=gy(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}};function ehe(t,e,n,r,i,s,a,o){let l;if(e.side===$s?l=r.intersectTriangle(a,s,i,!0,o):l=r.intersectTriangle(i,s,a,e.side===ed,o),l===null)return null;my.copy(o),my.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(my);return u<n.near||u>n.far?null:{distance:u,point:my.clone(),object:t}}function gy(t,e,n,r,i,s,a,o,l,u){t.getVertexPosition(o,dy),t.getVertexPosition(l,hy),t.getVertexPosition(u,fy);const d=ehe(t,e,n,r,dy,hy,fy,tF);if(d){const f=new Je;ex.getBarycoord(tF,dy,hy,fy,f),i&&(d.uv=ex.getInterpolatedAttribute(i,o,l,u,f,new on)),s&&(d.uv1=ex.getInterpolatedAttribute(s,o,l,u,f,new on)),a&&(d.normal=ex.getInterpolatedAttribute(a,o,l,u,f,new Je),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:o,b:l,c:u,normal:new Je,materialIndex:0};ex.getNormal(dy,hy,fy,g.normal),d.face=g,d.barycoord=f}return d}let LR=class x7 extends xl{constructor(e=1,n=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],u=[],d=[],f=[];let g=0,m=0;x("z","y","x",-1,-1,r,n,e,a,s,0),x("z","y","x",1,-1,r,n,-e,a,s,1),x("x","z","y",1,1,e,r,n,i,a,2),x("x","z","y",1,-1,e,r,-n,i,a,3),x("x","y","z",1,-1,e,n,r,i,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Po(u,3)),this.setAttribute("normal",new Po(d,3)),this.setAttribute("uv",new Po(f,2));function x(y,v,b,E,S,A,T,P,C,I,N){const D=A/C,F=T/I,L=A/2,q=T/2,R=P/2,V=C+1,K=I+1;let W=0,ne=0;const Y=new Je;for(let Z=0;Z<K;Z++){const U=Z*F-q;for(let $=0;$<V;$++){const ee=$*D-L;Y[y]=ee*E,Y[v]=U*S,Y[b]=R,u.push(Y.x,Y.y,Y.z),Y[y]=0,Y[v]=0,Y[b]=P>0?1:-1,d.push(Y.x,Y.y,Y.z),f.push($/C),f.push(1-Z/I),W+=1}}for(let Z=0;Z<I;Z++)for(let U=0;U<C;U++){const $=g+U+V*Z,ee=g+U+V*(Z+1),ae=g+(U+1)+V*(Z+1),fe=g+(U+1)+V*Z;l.push($,ee,fe),l.push(ee,ae,fe),ne+=6}o.addGroup(m,ne,N),m+=ne,g+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new x7(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function dm(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(Xt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function bs(t){const e={};for(let n=0;n<t.length;n++){const r=dm(t[n]);for(const i in r)e[i]=r[i]}return e}function the(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function b7(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:An.workingColorSpace}const nhe={clone:dm,merge:bs};var rhe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,ihe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let yc=class extends Fm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rhe,this.fragmentShader=ihe,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=dm(e.uniforms),this.uniformsGroups=the(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?n.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?n.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?n.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?n.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?n.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?n.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?n.uniforms[i]={type:"m4",value:a.toArray()}:n.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}},v7=class extends _a{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Jr,this.projectionMatrix=new Jr,this.projectionMatrixInverse=new Jr,this.coordinateSystem=nl,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 hu=new Je,nF=new on,rF=new on;let Ga=class extends v7{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=Q3*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(F_*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Q3*2*Math.atan(Math.tan(F_*.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){hu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(hu.x,hu.y).multiplyScalar(-e/hu.z),hu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(hu.x,hu.y).multiplyScalar(-e/hu.z)}getViewSize(e,n){return this.getViewBounds(e,nF,rF),n.subVectors(rF,nF)}setViewOffset(e,n,r,i,s,a){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(F_*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,u=a.fullHeight;s+=a.offsetX*i/l,n-=a.offsetY*r/u,i*=a.width/l,r*=a.height/u}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const Jf=-90,ep=1;let she=class extends _a{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ga(Jf,ep,e,n);i.layers=this.layers,this.add(i);const s=new Ga(Jf,ep,e,n);s.layers=this.layers,this.add(s);const a=new Ga(Jf,ep,e,n);a.layers=this.layers,this.add(a);const o=new Ga(Jf,ep,e,n);o.layers=this.layers,this.add(o);const l=new Ga(Jf,ep,e,n);l.layers=this.layers,this.add(l);const u=new Ga(Jf,ep,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,a,o,l]=n;for(const u of n)this.remove(u);if(e===nl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===d1)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,a),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,l),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},y7=class extends Fo{constructor(e=[],n=lm,r,i,s,a,o,l,u,d){super(e,n,r,i,s,a,o,l,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},ahe=class extends Uh{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 y7(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 LR(5,5,5),s=new yc({name:"CubemapFromEquirect",uniforms:dm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:$s,blending:hc});s.uniforms.tEquirect.value=n;const a=new cl(i,s),o=n.minFilter;return n.minFilter===sh&&(n.minFilter=Za),new she(1,10,this).update(e,a),n.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(n,r,i);e.setRenderTarget(s)}},_x=class extends _a{constructor(){super(),this.isGroup=!0,this.type="Group"}};const ohe={type:"move"};let PA=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new _x,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 _x,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Je,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Je),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new _x,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Je,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Je),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){a=!0;for(const y of e.hand.values()){const v=n.getJointPose(y,r),b=this._getHandJoint(u,y);v!==null&&(b.matrix.fromArray(v.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=v.radius),b.visible=v!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),m=.02,x=.005;u.inputState.pinching&&g>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=m-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(ohe)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new _x;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},lhe=class extends _a{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 td,this.environmentIntensity=1,this.environmentRotation=new td,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}},che=class extends Fo{constructor(e=null,n=1,r=1,i,s,a,o,l,u=ga,d=ga,f,g){super(null,a,o,l,u,d,i,s,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const RA=new Je,uhe=new Je,dhe=new un;let wu=class{constructor(e=new Je(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=RA.subVectors(r,n).cross(uhe.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(RA),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||dhe.getNormalMatrix(e),i=this.coplanarPoint(RA).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const Fd=new SS,hhe=new on(.5,.5),xy=new Je;let IR=class{constructor(e=new wu,n=new wu,r=new wu,i=new wu,s=new wu,a=new wu){this.planes=[e,n,r,i,s,a]}set(e,n,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=nl,r=!1){const i=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],u=s[3],d=s[4],f=s[5],g=s[6],m=s[7],x=s[8],y=s[9],v=s[10],b=s[11],E=s[12],S=s[13],A=s[14],T=s[15];if(i[0].setComponents(u-a,m-d,b-x,T-E).normalize(),i[1].setComponents(u+a,m+d,b+x,T+E).normalize(),i[2].setComponents(u+o,m+f,b+y,T+S).normalize(),i[3].setComponents(u-o,m-f,b-y,T-S).normalize(),r)i[4].setComponents(l,g,v,A).normalize(),i[5].setComponents(u-l,m-g,b-v,T-A).normalize();else if(i[4].setComponents(u-l,m-g,b-v,T-A).normalize(),n===nl)i[5].setComponents(u+l,m+g,b+v,T+A).normalize();else if(n===d1)i[5].setComponents(l,g,v,A).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Fd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Fd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Fd)}intersectsSprite(e){Fd.center.set(0,0,0);const n=hhe.distanceTo(e.center);return Fd.radius=.7071067811865476+n,Fd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Fd)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(xy.x=i.normal.x>0?e.max.x:e.min.x,xy.y=i.normal.y>0?e.max.y:e.min.y,xy.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(xy)<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)}},_7=class extends Fm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new vn(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 f1=new Je,p1=new Je,iF=new Jr,nx=new OR,by=new SS,DA=new Je,sF=new Je;let fhe=class extends _a{constructor(e=new xl,n=new _7){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,s=n.count;i<s;i++)f1.fromBufferAttribute(n,i-1),p1.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=f1.distanceTo(p1);e.setAttribute("lineDistance",new Po(r,1))}else Xt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),by.copy(r.boundingSphere),by.applyMatrix4(i),by.radius+=s,e.ray.intersectsSphere(by)===!1)return;iF.copy(i).invert(),nx.copy(e.ray).applyMatrix4(iF);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,u=this.isLineSegments?2:1,d=r.index,g=r.attributes.position;if(d!==null){const m=Math.max(0,a.start),x=Math.min(d.count,a.start+a.count);for(let y=m,v=x-1;y<v;y+=u){const b=d.getX(y),E=d.getX(y+1),S=vy(this,e,nx,l,b,E,y);S&&n.push(S)}if(this.isLineLoop){const y=d.getX(x-1),v=d.getX(m),b=vy(this,e,nx,l,y,v,x-1);b&&n.push(b)}}else{const m=Math.max(0,a.start),x=Math.min(g.count,a.start+a.count);for(let y=m,v=x-1;y<v;y+=u){const b=vy(this,e,nx,l,y,y+1,y);b&&n.push(b)}if(this.isLineLoop){const y=vy(this,e,nx,l,x-1,m,x-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};function vy(t,e,n,r,i,s,a){const o=t.geometry.attributes.position;if(f1.fromBufferAttribute(o,i),p1.fromBufferAttribute(o,s),n.distanceSqToSegment(f1,p1,DA,sF)>r)return;DA.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(DA);if(!(u<e.near||u>e.far))return{distance:u,point:sF.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const aF=new Je,oF=new Je;let phe=class extends fhe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,s=n.count;i<s;i+=2)aF.fromBufferAttribute(n,i),oF.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+aF.distanceTo(oF);e.setAttribute("lineDistance",new Po(r,1))}else Xt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},w7=class extends Fo{constructor(e,n,r=Lh,i,s,a,o=ga,l=ga,u,d=x0,f=1){if(d!==x0&&d!==b0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:f};super(g,i,s,a,o,l,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new DR(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 S7 extends Fo{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let UR=class E7 extends xl{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,a=n/2,o=Math.floor(r),l=Math.floor(i),u=o+1,d=l+1,f=e/o,g=n/l,m=[],x=[],y=[],v=[];for(let b=0;b<d;b++){const E=b*g-a;for(let S=0;S<u;S++){const A=S*f-s;x.push(A,-E,0),y.push(0,0,1),v.push(S/o),v.push(1-b/l)}}for(let b=0;b<l;b++)for(let E=0;E<o;E++){const S=E+u*b,A=E+u*(b+1),T=E+1+u*(b+1),P=E+1+u*b;m.push(S,A,P),m.push(A,T,P)}this.setIndex(m),this.setAttribute("position",new Po(x,3)),this.setAttribute("normal",new Po(y,3)),this.setAttribute("uv",new Po(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new E7(e.width,e.height,e.widthSegments,e.heightSegments)}};class mhe extends Fm{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new vn(16777215),this.specular=new vn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new vn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=r7,this.normalScale=new on(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new td,this.combine=MR,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 ghe=class extends Fm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ede,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}},xhe=class extends Fm{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}},M7=class extends _a{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new vn(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 OA=new Jr,lF=new Je,cF=new Je;let bhe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new on(512,512),this.mapType=ll,this.map=null,this.mapPass=null,this.matrix=new Jr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new IR,this._frameExtents=new on(1,1),this._viewportCount=1,this._viewports=[new Wr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;lF.setFromMatrixPosition(e.matrixWorld),n.position.copy(lF),cF.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(cF),n.updateMatrixWorld(),OA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(OA,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(OA)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},A7=class extends v7{constructor(e=-1,n=1,r=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,a=r+e,o=i+n,l=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,a=s+u*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class vhe extends bhe{constructor(){super(new A7(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class uF extends M7{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_a.DEFAULT_UP),this.updateMatrix(),this.target=new _a,this.shadow=new vhe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let yhe=class extends M7{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},_he=class extends Ga{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},dF=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=mn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(mn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class whe extends phe{constructor(e=10,n=10,r=4473924,i=8947848){r=new vn(r),i=new vn(i);const s=n/2,a=e/n,o=e/2,l=[],u=[];for(let g=0,m=0,x=-o;g<=n;g++,x+=a){l.push(-o,0,x,o,0,x),l.push(x,0,-o,x,0,o);const y=g===s?r:i;y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3}const d=new xl;d.setAttribute("position",new Po(l,3)),d.setAttribute("color",new Po(u,3));const f=new _7({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class She extends nf{constructor(e,n=null){super(),this.object=e,this.domElement=n,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Xt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function hF(t,e,n,r){const i=Ehe(r);switch(n){case e7:return t*e;case n7:return t*e/i.components*i.byteLength;case NR:return t*e/i.components*i.byteLength;case kR:return t*e*2/i.components*i.byteLength;case PR:return t*e*2/i.components*i.byteLength;case t7:return t*e*3/i.components*i.byteLength;case Co:return t*e*4/i.components*i.byteLength;case RR:return t*e*4/i.components*i.byteLength;case j_:case L_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case I_:case U_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case M3:case T3:return Math.max(t,16)*Math.max(e,8)/4;case E3:case A3:return Math.max(t,8)*Math.max(e,8)/2;case C3:case N3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case k3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case P3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case R3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case D3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case O3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case j3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case L3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case I3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case U3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case F3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case z3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case B3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case H3:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case $3:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case V3:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case G3:case W3:case q3:return Math.ceil(t/4)*Math.ceil(e/4)*16;case K3:case X3:return Math.ceil(t/4)*Math.ceil(e/4)*8;case Y3:case Z3:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Ehe(t){switch(t){case ll:case YG:return{byteLength:1,components:1};case m0:case ZG:case Um:return{byteLength:2,components:1};case TR:case CR:return{byteLength:2,components:4};case Lh:case AR:case ac:return{byteLength:4,components:1};case QG:case JG:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ER}}));typeof window<"u"&&(window.__THREE__?Xt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ER);function T7(){let t=null,e=!1,n=null,r=null;function i(s,a){n(s,a),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){n=s},setContext:function(s){t=s}}}function Mhe(t){const e=new WeakMap;function n(o,l){const u=o.array,d=o.usage,f=u.byteLength,g=t.createBuffer();t.bindBuffer(l,g),t.bufferData(l,u,d),o.onUploadCallback();let m;if(u instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)m=t.HALF_FLOAT;else if(u instanceof Uint16Array)o.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)m=t.SHORT;else if(u instanceof Uint32Array)m=t.UNSIGNED_INT;else if(u instanceof Int32Array)m=t.INT;else if(u instanceof Int8Array)m=t.BYTE;else if(u instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:g,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:o.version,size:f}}function r(o,l,u){const d=l.array,f=l.updateRanges;if(t.bindBuffer(u,o),f.length===0)t.bufferSubData(u,0,d);else{f.sort((m,x)=>m.start-x.start);let g=0;for(let m=1;m<f.length;m++){const x=f[g],y=f[m];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++g,f[g]=y)}f.length=g+1;for(let m=0,x=f.length;m<x;m++){const y=f[m];t.bufferSubData(u,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(t.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const u=e.get(o);if(u===void 0)e.set(o,n(o,l));else if(u.version<o.version){if(u.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,o,l),u.version=o.version}}return{get:i,remove:s,update:a}}var Ahe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,The=`#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`,Che=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,Nhe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,khe=`#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`,Phe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Rhe=`#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`,Dhe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,Ohe=`#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`,jhe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,Lhe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,Ihe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,Uhe=`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`,Fhe=`#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`,zhe=`#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`,Bhe=`#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`,Hhe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,$he=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,Vhe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,Ghe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,Whe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,qhe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,Khe=`#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`,Xhe=`#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`,Yhe=`#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`,Zhe=`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`,Qhe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,Jhe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,efe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,tfe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,nfe="gl_FragColor = linearToOutputTexel( gl_FragColor );",rfe=`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 );
- }`,ife=`#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`,sfe=`#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`,afe=`#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`,ofe=`#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`,lfe=`#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`,cfe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,ufe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,dfe=`#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`,hfe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,ffe=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,pfe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,mfe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,gfe=`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`,xfe=`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`,bfe=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,vfe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,yfe=`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`,_fe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,wfe=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Sfe=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,Efe=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,Mfe=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,Afe=`#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`,Tfe=`#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`,Cfe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,Nfe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,kfe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,Pfe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,Rfe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,Dfe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,Ofe=`#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`,jfe=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Lfe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,Ife=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,Ufe=`#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`,Ffe=`#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`,zfe=`#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`,Bfe=`#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`,Hfe=`#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`,$fe=`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;`,Vfe=`#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`,Gfe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Wfe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,qfe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,Kfe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,Xfe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Yfe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Zfe=`#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`,Qfe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Jfe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,epe=`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 );
- }`,tpe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,npe=`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;`,rpe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,ipe=`#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`,spe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,ape=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,ope=`#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`,lpe=`#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`,cpe=`#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`,upe=`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;
- }`,dpe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,hpe=`#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`,fpe=`#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`,ppe=`#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`,mpe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,gpe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,xpe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,bpe=`#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; }`,vpe=`#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`,ype=`#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`,_pe=`#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`,wpe=`#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`,Spe=`#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 Mpe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,Ape=`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>
- }`,Tpe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Cpe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Npe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,kpe=`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>
- }`,Ppe=`#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;
- }`,Rpe=`#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
- }`,Dpe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,Ope=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,jpe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,Lpe=`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>
- }`,Ipe=`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>
- }`,Upe=`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>
- }`,Fpe=`#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>
- }`,zpe=`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>
- }`,Bpe=`#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>
- }`,Hpe=`#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>
- }`,$pe=`#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>
- }`,Gpe=`#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
- }`,qpe=`#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>
- }`,Kpe=`#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>
- }`,Xpe=`#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
- }`,Ype=`#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>
- }`,Zpe=`#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>
- }`,Qpe=`#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>
- }`,Jpe=`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>
- }`,eme=`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>
- }`,tme=`#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>
- }`,nme=`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>
- }`,rme=`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>
- }`,ime=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,sn={alphahash_fragment:Ahe,alphahash_pars_fragment:The,alphamap_fragment:Che,alphamap_pars_fragment:Nhe,alphatest_fragment:khe,alphatest_pars_fragment:Phe,aomap_fragment:Rhe,aomap_pars_fragment:Dhe,batching_pars_vertex:Ohe,batching_vertex:jhe,begin_vertex:Lhe,beginnormal_vertex:Ihe,bsdfs:Uhe,iridescence_fragment:Fhe,bumpmap_pars_fragment:zhe,clipping_planes_fragment:Bhe,clipping_planes_pars_fragment:Hhe,clipping_planes_pars_vertex:$he,clipping_planes_vertex:Vhe,color_fragment:Ghe,color_pars_fragment:Whe,color_pars_vertex:qhe,color_vertex:Khe,common:Xhe,cube_uv_reflection_fragment:Yhe,defaultnormal_vertex:Zhe,displacementmap_pars_vertex:Qhe,displacementmap_vertex:Jhe,emissivemap_fragment:efe,emissivemap_pars_fragment:tfe,colorspace_fragment:nfe,colorspace_pars_fragment:rfe,envmap_fragment:ife,envmap_common_pars_fragment:sfe,envmap_pars_fragment:afe,envmap_pars_vertex:ofe,envmap_physical_pars_fragment:bfe,envmap_vertex:lfe,fog_vertex:cfe,fog_pars_vertex:ufe,fog_fragment:dfe,fog_pars_fragment:hfe,gradientmap_pars_fragment:ffe,lightmap_pars_fragment:pfe,lights_lambert_fragment:mfe,lights_lambert_pars_fragment:gfe,lights_pars_begin:xfe,lights_toon_fragment:vfe,lights_toon_pars_fragment:yfe,lights_phong_fragment:_fe,lights_phong_pars_fragment:wfe,lights_physical_fragment:Sfe,lights_physical_pars_fragment:Efe,lights_fragment_begin:Mfe,lights_fragment_maps:Afe,lights_fragment_end:Tfe,logdepthbuf_fragment:Cfe,logdepthbuf_pars_fragment:Nfe,logdepthbuf_pars_vertex:kfe,logdepthbuf_vertex:Pfe,map_fragment:Rfe,map_pars_fragment:Dfe,map_particle_fragment:Ofe,map_particle_pars_fragment:jfe,metalnessmap_fragment:Lfe,metalnessmap_pars_fragment:Ife,morphinstance_vertex:Ufe,morphcolor_vertex:Ffe,morphnormal_vertex:zfe,morphtarget_pars_vertex:Bfe,morphtarget_vertex:Hfe,normal_fragment_begin:$fe,normal_fragment_maps:Vfe,normal_pars_fragment:Gfe,normal_pars_vertex:Wfe,normal_vertex:qfe,normalmap_pars_fragment:Kfe,clearcoat_normal_fragment_begin:Xfe,clearcoat_normal_fragment_maps:Yfe,clearcoat_pars_fragment:Zfe,iridescence_pars_fragment:Qfe,opaque_fragment:Jfe,packing:epe,premultiplied_alpha_fragment:tpe,project_vertex:npe,dithering_fragment:rpe,dithering_pars_fragment:ipe,roughnessmap_fragment:spe,roughnessmap_pars_fragment:ape,shadowmap_pars_fragment:ope,shadowmap_pars_vertex:lpe,shadowmap_vertex:cpe,shadowmask_pars_fragment:upe,skinbase_vertex:dpe,skinning_pars_vertex:hpe,skinning_vertex:fpe,skinnormal_vertex:ppe,specularmap_fragment:mpe,specularmap_pars_fragment:gpe,tonemapping_fragment:xpe,tonemapping_pars_fragment:bpe,transmission_fragment:vpe,transmission_pars_fragment:ype,uv_pars_fragment:_pe,uv_pars_vertex:wpe,uv_vertex:Spe,worldpos_vertex:Epe,background_vert:Mpe,background_frag:Ape,backgroundCube_vert:Tpe,backgroundCube_frag:Cpe,cube_vert:Npe,cube_frag:kpe,depth_vert:Ppe,depth_frag:Rpe,distanceRGBA_vert:Dpe,distanceRGBA_frag:Ope,equirect_vert:jpe,equirect_frag:Lpe,linedashed_vert:Ipe,linedashed_frag:Upe,meshbasic_vert:Fpe,meshbasic_frag:zpe,meshlambert_vert:Bpe,meshlambert_frag:Hpe,meshmatcap_vert:$pe,meshmatcap_frag:Vpe,meshnormal_vert:Gpe,meshnormal_frag:Wpe,meshphong_vert:qpe,meshphong_frag:Kpe,meshphysical_vert:Xpe,meshphysical_frag:Ype,meshtoon_vert:Zpe,meshtoon_frag:Qpe,points_vert:Jpe,points_frag:eme,shadow_vert:tme,shadow_frag:nme,sprite_vert:rme,sprite_frag:ime},Et={common:{diffuse:{value:new vn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new un}},envmap:{envMap:{value:null},envMapRotation:{value:new un},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new un}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new un}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new un},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new un},normalScale:{value:new on(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new un},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new un}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new un}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new un}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new vn(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 vn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0},uvTransform:{value:new un}},sprite:{diffuse:{value:new vn(16777215)},opacity:{value:1},center:{value:new on(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}}},Qo={basic:{uniforms:bs([Et.common,Et.specularmap,Et.envmap,Et.aomap,Et.lightmap,Et.fog]),vertexShader:sn.meshbasic_vert,fragmentShader:sn.meshbasic_frag},lambert:{uniforms:bs([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 vn(0)}}]),vertexShader:sn.meshlambert_vert,fragmentShader:sn.meshlambert_frag},phong:{uniforms:bs([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 vn(0)},specular:{value:new vn(1118481)},shininess:{value:30}}]),vertexShader:sn.meshphong_vert,fragmentShader:sn.meshphong_frag},standard:{uniforms:bs([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 vn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag},toon:{uniforms:bs([Et.common,Et.aomap,Et.lightmap,Et.emissivemap,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.gradientmap,Et.fog,Et.lights,{emissive:{value:new vn(0)}}]),vertexShader:sn.meshtoon_vert,fragmentShader:sn.meshtoon_frag},matcap:{uniforms:bs([Et.common,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.fog,{matcap:{value:null}}]),vertexShader:sn.meshmatcap_vert,fragmentShader:sn.meshmatcap_frag},points:{uniforms:bs([Et.points,Et.fog]),vertexShader:sn.points_vert,fragmentShader:sn.points_frag},dashed:{uniforms:bs([Et.common,Et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:sn.linedashed_vert,fragmentShader:sn.linedashed_frag},depth:{uniforms:bs([Et.common,Et.displacementmap]),vertexShader:sn.depth_vert,fragmentShader:sn.depth_frag},normal:{uniforms:bs([Et.common,Et.bumpmap,Et.normalmap,Et.displacementmap,{opacity:{value:1}}]),vertexShader:sn.meshnormal_vert,fragmentShader:sn.meshnormal_frag},sprite:{uniforms:bs([Et.sprite,Et.fog]),vertexShader:sn.sprite_vert,fragmentShader:sn.sprite_frag},background:{uniforms:{uvTransform:{value:new un},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:sn.background_vert,fragmentShader:sn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new un}},vertexShader:sn.backgroundCube_vert,fragmentShader:sn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:sn.cube_vert,fragmentShader:sn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:sn.equirect_vert,fragmentShader:sn.equirect_frag},distanceRGBA:{uniforms:bs([Et.common,Et.displacementmap,{referencePosition:{value:new Je},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:sn.distanceRGBA_vert,fragmentShader:sn.distanceRGBA_frag},shadow:{uniforms:bs([Et.lights,Et.fog,{color:{value:new vn(0)},opacity:{value:1}}]),vertexShader:sn.shadow_vert,fragmentShader:sn.shadow_frag}};Qo.physical={uniforms:bs([Qo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new un},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new un},clearcoatNormalScale:{value:new on(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new un},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new un},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new un},sheen:{value:0},sheenColor:{value:new vn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new un},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new un},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new un},transmissionSamplerSize:{value:new on},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new un},attenuationDistance:{value:0},attenuationColor:{value:new vn(0)},specularColor:{value:new vn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new un},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new un},anisotropyVector:{value:new on},anisotropyMap:{value:null},anisotropyMapTransform:{value:new un}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag};const yy={r:0,b:0,g:0},zd=new td,sme=new Jr;function ame(t,e,n,r,i,s,a){const o=new vn(0);let l=s===!0?0:1,u,d,f=null,g=0,m=null;function x(S){let A=S.isScene===!0?S.background:null;return A&&A.isTexture&&(A=(S.backgroundBlurriness>0?n:e).get(A)),A}function y(S){let A=!1;const T=x(S);T===null?b(o,l):T&&T.isColor&&(b(T,1),A=!0);const P=t.xr.getEnvironmentBlendMode();P==="additive"?r.buffers.color.setClear(0,0,0,1,a):P==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,a),(t.autoClear||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function v(S,A){const T=x(A);T&&(T.isCubeTexture||T.mapping===wS)?(d===void 0&&(d=new cl(new LR(1,1,1),new yc({name:"BackgroundCubeMaterial",uniforms:dm(Qo.backgroundCube.uniforms),vertexShader:Qo.backgroundCube.vertexShader,fragmentShader:Qo.backgroundCube.fragmentShader,side:$s,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(P,C,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),zd.copy(A.backgroundRotation),zd.x*=-1,zd.y*=-1,zd.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(zd.y*=-1,zd.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(sme.makeRotationFromEuler(zd)),d.material.toneMapped=An.getTransfer(T.colorSpace)!==Hn,(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 cl(new UR(2,2),new yc({name:"BackgroundMaterial",uniforms:dm(Qo.background.uniforms),vertexShader:Qo.background.vertexShader,fragmentShader:Qo.background.fragmentShader,side:ed,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=An.getTransfer(T.colorSpace)!==Hn,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(yy,b7(t)),r.buffers.color.setClear(yy.r,yy.g,yy.b,A,a)}function E(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return o},setClearColor:function(S,A=1){o.set(S),l=A,b(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(S){l=S,b(o,l)},render:y,addToRenderList:v,dispose:E}}function ome(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let s=i,a=!1;function o(D,F,L,q,R){let V=!1;const K=f(q,L,F);s!==K&&(s=K,u(s.object)),V=m(D,q,L,R),V&&x(D,q,L,R),R!==null&&e.update(R,t.ELEMENT_ARRAY_BUFFER),(V||a)&&(a=!1,A(D,F,L,q),R!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(R).buffer))}function l(){return t.createVertexArray()}function u(D){return t.bindVertexArray(D)}function d(D){return t.deleteVertexArray(D)}function f(D,F,L){const q=L.wireframe===!0;let R=r[D.id];R===void 0&&(R={},r[D.id]=R);let V=R[F.id];V===void 0&&(V={},R[F.id]=V);let K=V[q];return K===void 0&&(K=g(l()),V[q]=K),K}function g(D){const F=[],L=[],q=[];for(let R=0;R<n;R++)F[R]=0,L[R]=0,q[R]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:L,attributeDivisors:q,object:D,attributes:{},index:null}}function m(D,F,L,q){const R=s.attributes,V=F.attributes;let K=0;const W=L.getAttributes();for(const ne in W)if(W[ne].location>=0){const Z=R[ne];let U=V[ne];if(U===void 0&&(ne==="instanceMatrix"&&D.instanceMatrix&&(U=D.instanceMatrix),ne==="instanceColor"&&D.instanceColor&&(U=D.instanceColor)),Z===void 0||Z.attribute!==U||U&&Z.data!==U.data)return!0;K++}return s.attributesNum!==K||s.index!==q}function x(D,F,L,q){const R={},V=F.attributes;let K=0;const W=L.getAttributes();for(const ne in W)if(W[ne].location>=0){let Z=V[ne];Z===void 0&&(ne==="instanceMatrix"&&D.instanceMatrix&&(Z=D.instanceMatrix),ne==="instanceColor"&&D.instanceColor&&(Z=D.instanceColor));const U={};U.attribute=Z,Z&&Z.data&&(U.data=Z.data),R[ne]=U,K++}s.attributes=R,s.attributesNum=K,s.index=q}function y(){const D=s.newAttributes;for(let F=0,L=D.length;F<L;F++)D[F]=0}function v(D){b(D,0)}function b(D,F){const L=s.newAttributes,q=s.enabledAttributes,R=s.attributeDivisors;L[D]=1,q[D]===0&&(t.enableVertexAttribArray(D),q[D]=1),R[D]!==F&&(t.vertexAttribDivisor(D,F),R[D]=F)}function E(){const D=s.newAttributes,F=s.enabledAttributes;for(let L=0,q=F.length;L<q;L++)F[L]!==D[L]&&(t.disableVertexAttribArray(L),F[L]=0)}function S(D,F,L,q,R,V,K){K===!0?t.vertexAttribIPointer(D,F,L,R,V):t.vertexAttribPointer(D,F,L,q,R,V)}function A(D,F,L,q){y();const R=q.attributes,V=L.getAttributes(),K=F.defaultAttributeValues;for(const W in V){const ne=V[W];if(ne.location>=0){let Y=R[W];if(Y===void 0&&(W==="instanceMatrix"&&D.instanceMatrix&&(Y=D.instanceMatrix),W==="instanceColor"&&D.instanceColor&&(Y=D.instanceColor)),Y!==void 0){const Z=Y.normalized,U=Y.itemSize,$=e.get(Y);if($===void 0)continue;const ee=$.buffer,ae=$.type,fe=$.bytesPerElement,ue=ae===t.INT||ae===t.UNSIGNED_INT||Y.gpuType===AR;if(Y.isInterleavedBufferAttribute){const xe=Y.data,Me=xe.stride,se=Y.offset;if(xe.isInstancedInterleavedBuffer){for(let ve=0;ve<ne.locationSize;ve++)b(ne.location+ve,xe.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let ve=0;ve<ne.locationSize;ve++)v(ne.location+ve);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let ve=0;ve<ne.locationSize;ve++)S(ne.location+ve,U/ne.locationSize,ae,Z,Me*fe,(se+U/ne.locationSize*ve)*fe,ue)}else{if(Y.isInstancedBufferAttribute){for(let xe=0;xe<ne.locationSize;xe++)b(ne.location+xe,Y.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let xe=0;xe<ne.locationSize;xe++)v(ne.location+xe);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let xe=0;xe<ne.locationSize;xe++)S(ne.location+xe,U/ne.locationSize,ae,Z,U*fe,U/ne.locationSize*xe*fe,ue)}}else if(K!==void 0){const Z=K[W];if(Z!==void 0)switch(Z.length){case 2:t.vertexAttrib2fv(ne.location,Z);break;case 3:t.vertexAttrib3fv(ne.location,Z);break;case 4:t.vertexAttrib4fv(ne.location,Z);break;default:t.vertexAttrib1fv(ne.location,Z)}}}}E()}function T(){I();for(const D in r){const F=r[D];for(const L in F){const q=F[L];for(const R in q)d(q[R].object),delete q[R];delete F[L]}delete r[D]}}function P(D){if(r[D.id]===void 0)return;const F=r[D.id];for(const L in F){const q=F[L];for(const R in q)d(q[R].object),delete q[R];delete F[L]}delete r[D.id]}function C(D){for(const F in r){const L=r[F];if(L[D.id]===void 0)continue;const q=L[D.id];for(const R in q)d(q[R].object),delete q[R];delete L[D.id]}}function I(){N(),a=!0,s!==i&&(s=i,u(s.object))}function N(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:I,resetDefaultState:N,dispose:T,releaseStatesOfGeometry:P,releaseStatesOfProgram:C,initAttributes:y,enableAttribute:v,disableUnusedAttributes:E}}function lme(t,e,n){let r;function i(u){r=u}function s(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function a(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function o(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let m=0;for(let x=0;x<f;x++)m+=d[x];n.update(m,r,1)}function l(u,d,f,g){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<u.length;x++)a(u[x],d[x],g[x]);else{m.multiDrawArraysInstancedWEBGL(r,u,0,d,0,g,0,f);let x=0;for(let y=0;y<f;y++)x+=d[y]*g[y];n.update(x,r,1)}}this.setMode=i,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function cme(t,e,n,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(C){return!(C!==Co&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){const I=C===Um&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==ll&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==ac&&!I)}function l(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=l(u);d!==u&&(Xt("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),v=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),E=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),S=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=x>0,P=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:g,maxTextures:m,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:v,maxAttributes:b,maxVertexUniforms:E,maxVaryings:S,maxFragmentUniforms:A,vertexTextures:T,maxSamples:P}}function ume(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new wu,o=new un,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const m=f.length!==0||g||r!==0||i;return i=g,r=f.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,m){const x=f.clippingPlanes,y=f.clipIntersection,v=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||s&&!v)s?d(null):u();else{const E=s?0:r,S=E*4;let A=b.clippingState||null;l.value=A,A=d(x,g,S,m);for(let T=0;T!==S;++T)A[T]=n[T];b.clippingState=A,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=E}};function u(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,m,x){const y=f!==null?f.length:0;let v=null;if(y!==0){if(v=l.value,x!==!0||v===null){const b=m+y*4,E=g.matrixWorldInverse;o.getNormalMatrix(E),(v===null||v.length<b)&&(v=new Float32Array(b));for(let S=0,A=m;S!==y;++S,A+=4)a.copy(f[S]).applyMatrix4(E,o),a.normal.toArray(v,A),v[A+3]=a.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function dme(t){let e=new WeakMap;function n(a,o){return o===y3?a.mapping=lm:o===_3&&(a.mapping=cm),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===y3||o===_3)if(e.has(a)){const l=e.get(a).texture;return n(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const u=new ahe(l.height);return u.fromEquirectangularTexture(t,a),e.set(a,u),a.addEventListener("dispose",i),n(u.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const ju=4,fF=[.125,.215,.35,.446,.526,.582],Jd=20,hme=256,rx=new A7,pF=new vn;let jA=null,LA=0,IA=0,UA=!1;const fme=new Je;let mF=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,s={}){const{size:a=256,position:o=fme}=s;jA=this._renderer.getRenderTarget(),LA=this._renderer.getActiveCubeFace(),IA=this._renderer.getActiveMipmapLevel(),UA=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,r,i,l,o),n>0&&this._blur(l,0,0,n),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=bF(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=xF(),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(jA,LA,IA),this._renderer.xr.enabled=UA,e.scissorTest=!1,tp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===lm||e.mapping===cm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),jA=this._renderer.getRenderTarget(),LA=this._renderer.getActiveCubeFace(),IA=this._renderer.getActiveMipmapLevel(),UA=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:Za,minFilter:Za,generateMipmaps:!1,type:Um,format:Co,colorSpace:um,depthBuffer:!1},i=gF(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=gF(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=pme(s)),this._blurMaterial=gme(s,e,n),this._ggxMaterial=mme(s,e,n)}return i}_compileMaterial(e){const n=new cl(new xl,e);this._renderer.compile(n,rx)}_sceneToCubeUV(e,n,r,i,s){const l=new Ga(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(pF),f.toneMapping=Hu,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new cl(new LR,new jR({name:"PMREM.Background",side:$s,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,v=y.material;let b=!1;const E=e.background;E?E.isColor&&(v.color.copy(E),e.background=null,b=!0):(v.color.copy(pF),b=!0);for(let S=0;S<6;S++){const A=S%3;A===0?(l.up.set(0,u[S],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+d[S],s.y,s.z)):A===1?(l.up.set(0,0,u[S]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+d[S],s.z)):(l.up.set(0,u[S],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+d[S]));const T=this._cubeSize;tp(i,A*T,S>2?T:0,T,T),f.setRenderTarget(i),b&&f.render(y,l),f.render(e,l)}f.toneMapping=m,f.autoClear=g,e.background=E}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===lm||e.mapping===cm;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=bF()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=xF());const s=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;tp(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(a,rx)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(e,s-1,s);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[r];o.material=a;const l=a.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),g=.05+u*.95,m=f*g,{_lodMax:x}=this,y=this._sizeLods[r],v=3*y*(r>x-ju?r-x+ju:0),b=4*(this._cubeSize-y);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=x-n,tp(s,v,b,3*y,2*y),i.setRenderTarget(s),i.render(o,rx),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=x-r,tp(e,v,b,3*y,2*y),i.setRenderTarget(e),i.render(o,rx)}_blur(e,n,r,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,n,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,a,o){const l=this._renderer,u=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&jr("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const g=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Jd-1),y=s/x,v=isFinite(s)?1+Math.floor(d*y):Jd;v>Jd&&Xt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Jd}`);const b=[];let E=0;for(let C=0;C<Jd;++C){const I=C/y,N=Math.exp(-I*I/2);b.push(N),C===0?E+=N:C<v&&(E+=2*N)}for(let C=0;C<b.length;C++)b[C]=b[C]/E;g.envMap.value=e.texture,g.samples.value=v,g.weights.value=b,g.latitudinal.value=a==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:S}=this;g.dTheta.value=x,g.mipInt.value=S-r;const A=this._sizeLods[i],T=3*A*(i>S-ju?i-S+ju:0),P=4*(this._cubeSize-A);tp(n,T,P,3*A,2*A),l.setRenderTarget(n),l.render(f,rx)}};function pme(t){const e=[],n=[],r=[];let i=t;const s=t-ju+1+fF.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>t-ju?l=fF[a-t+ju-1]:a===0&&(l=0),n.push(l);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,y=3,v=2,b=1,E=new Float32Array(y*x*m),S=new Float32Array(v*x*m),A=new Float32Array(b*x*m);for(let P=0;P<m;P++){const C=P%3*2/3-1,I=P>2?0:-1,N=[C,I,0,C+2/3,I,0,C+2/3,I+1,0,C,I,0,C+2/3,I+1,0,C,I+1,0];E.set(N,y*x*P),S.set(g,v*x*P);const D=[P,P,P,P,P,P];A.set(D,b*x*P)}const T=new xl;T.setAttribute("position",new Ja(E,y)),T.setAttribute("uv",new Ja(S,v)),T.setAttribute("faceIndex",new Ja(A,b)),r.push(new cl(T,null)),i>ju&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function gF(t,e,n){const r=new Uh(t,e,n);return r.texture.mapping=wS,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function tp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function mme(t,e,n){return new yc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:hme,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:ES(),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:hc,depthTest:!1,depthWrite:!1})}function gme(t,e,n){const r=new Float32Array(Jd),i=new Je(0,1,0);return new yc({name:"SphericalGaussianBlur",defines:{n:Jd,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:ES(),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:hc,depthTest:!1,depthWrite:!1})}function xF(){return new yc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ES(),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:hc,depthTest:!1,depthWrite:!1})}function bF(){return new yc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ES(),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:hc,depthTest:!1,depthWrite:!1})}function ES(){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 xme(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,u=l===y3||l===_3,d=l===lm||l===cm;if(u||d){let f=e.get(o);const g=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==g)return n===null&&(n=new mF(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 mF(t)),f=u?n.fromEquirectangular(o):n.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",s),f.texture):null}}}return o}function i(o){let l=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&l++;return l===u}function s(o){const l=o.target;l.removeEventListener("dispose",s);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function a(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:a}}function bme(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&&v0("WebGLRenderer: "+r+" extension not supported."),i}}}function vme(t,e,n,r){const i={},s=new WeakMap;function a(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);g.removeEventListener("dispose",a),delete i[g.id];const m=s.get(g);m&&(e.remove(m),s.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(f,g){return i[g.id]===!0||(g.addEventListener("dispose",a),i[g.id]=!0,n.memory.geometries++),g}function l(f){const g=f.attributes;for(const m in g)e.update(g[m],t.ARRAY_BUFFER)}function u(f){const g=[],m=f.index,x=f.attributes.position;let y=0;if(m!==null){const E=m.array;y=m.version;for(let S=0,A=E.length;S<A;S+=3){const T=E[S+0],P=E[S+1],C=E[S+2];g.push(T,P,P,C,C,T)}}else if(x!==void 0){const E=x.array;y=x.version;for(let S=0,A=E.length/3-1;S<A;S+=3){const T=S+0,P=S+1,C=S+2;g.push(T,P,P,C,C,T)}}else return;const v=new(s7(g)?m7:p7)(g,1);v.version=y;const b=s.get(f);b&&e.remove(b),s.set(f,v)}function d(f){const g=s.get(f);if(g){const m=f.index;m!==null&&g.version<m.version&&u(f)}else u(f);return s.get(f)}return{get:o,update:l,getWireframeAttribute:d}}function yme(t,e,n){let r;function i(g){r=g}let s,a;function o(g){s=g.type,a=g.bytesPerElement}function l(g,m){t.drawElements(r,m,s,g*a),n.update(m,r,1)}function u(g,m,x){x!==0&&(t.drawElementsInstanced(r,m,s,g*a,x),n.update(m,r,x))}function d(g,m,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,s,g,0,x);let v=0;for(let b=0;b<x;b++)v+=m[b];n.update(v,r,1)}function f(g,m,x,y){if(x===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let b=0;b<g.length;b++)u(g[b]/a,m[b],y[b]);else{v.multiDrawElementsInstancedWEBGL(r,m,0,s,g,0,y,0,x);let b=0;for(let E=0;E<x;E++)b+=m[E]*y[E];n.update(b,r,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function _me(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,a,o){switch(n.calls++,a){case t.TRIANGLES:n.triangles+=o*(s/3);break;case t.LINES:n.lines+=o*(s/2);break;case t.LINE_STRIP:n.lines+=o*(s-1);break;case t.LINE_LOOP:n.lines+=o*s;break;case t.POINTS:n.points+=o*s;break;default:jr("WebGLInfo: Unknown draw mode:",a);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function wme(t,e,n){const r=new WeakMap,i=new Wr;function s(a,o,l){const u=a.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=d!==void 0?d.length:0;let g=r.get(o);if(g===void 0||g.count!==f){let D=function(){I.dispose(),r.delete(o),o.removeEventListener("dispose",D)};var m=D;g!==void 0&&g.texture.dispose();const x=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,b=o.morphAttributes.position||[],E=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let A=0;x===!0&&(A=1),y===!0&&(A=2),v===!0&&(A=3);let T=o.attributes.position.count*A,P=1;T>e.maxTextureSize&&(P=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const C=new Float32Array(T*P*4*f),I=new u7(C,T,P,f);I.type=ac,I.needsUpdate=!0;const N=A*4;for(let F=0;F<f;F++){const L=b[F],q=E[F],R=S[F],V=T*P*4*F;for(let K=0;K<L.count;K++){const W=K*N;x===!0&&(i.fromBufferAttribute(L,K),C[V+W+0]=i.x,C[V+W+1]=i.y,C[V+W+2]=i.z,C[V+W+3]=0),y===!0&&(i.fromBufferAttribute(q,K),C[V+W+4]=i.x,C[V+W+5]=i.y,C[V+W+6]=i.z,C[V+W+7]=0),v===!0&&(i.fromBufferAttribute(R,K),C[V+W+8]=i.x,C[V+W+9]=i.y,C[V+W+10]=i.z,C[V+W+11]=R.itemSize===4?i.w:1)}}g={count:f,texture:I,size:new on(T,P)},r.set(o,g),o.addEventListener("dispose",D)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",a.morphTexture,n);else{let x=0;for(let v=0;v<u.length;v++)x+=u[v];const y=o.morphTargetsRelative?1:1-x;l.getUniforms().setValue(t,"morphTargetBaseInfluence",y),l.getUniforms().setValue(t,"morphTargetInfluences",u)}l.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:s}}function Sme(t,e,n,r){let i=new WeakMap;function s(l){const u=r.render.frame,d=l.geometry,f=e.get(l,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==u&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,u))),l.isSkinnedMesh){const g=l.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function a(){i=new WeakMap}function o(l){const u=l.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:a}}const C7=new Fo,vF=new w7(1,1),N7=new u7,k7=new $de,P7=new y7,yF=[],_F=[],wF=new Float32Array(16),SF=new Float32Array(9),EF=new Float32Array(4);function zm(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=yF[i];if(s===void 0&&(s=new Float32Array(i),yF[i]=s),e!==0){r.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=n,t[a].toArray(s,o)}return s}function hi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function fi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function MS(t,e){let n=_F[e];n===void 0&&(n=new Int32Array(e),_F[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Eme(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Mme(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(hi(n,e))return;t.uniform2fv(this.addr,e),fi(n,e)}}function Ame(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(hi(n,e))return;t.uniform3fv(this.addr,e),fi(n,e)}}function Tme(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(hi(n,e))return;t.uniform4fv(this.addr,e),fi(n,e)}}function Cme(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(hi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),fi(n,e)}else{if(hi(n,r))return;EF.set(r),t.uniformMatrix2fv(this.addr,!1,EF),fi(n,r)}}function Nme(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(hi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),fi(n,e)}else{if(hi(n,r))return;SF.set(r),t.uniformMatrix3fv(this.addr,!1,SF),fi(n,r)}}function kme(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(hi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),fi(n,e)}else{if(hi(n,r))return;wF.set(r),t.uniformMatrix4fv(this.addr,!1,wF),fi(n,r)}}function Pme(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Rme(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(hi(n,e))return;t.uniform2iv(this.addr,e),fi(n,e)}}function Dme(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(hi(n,e))return;t.uniform3iv(this.addr,e),fi(n,e)}}function Ome(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(hi(n,e))return;t.uniform4iv(this.addr,e),fi(n,e)}}function jme(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Lme(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(hi(n,e))return;t.uniform2uiv(this.addr,e),fi(n,e)}}function Ime(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(hi(n,e))return;t.uniform3uiv(this.addr,e),fi(n,e)}}function Ume(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(hi(n,e))return;t.uniform4uiv(this.addr,e),fi(n,e)}}function Fme(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let s;this.type===t.SAMPLER_2D_SHADOW?(vF.compareFunction=i7,s=vF):s=C7,n.setTexture2D(e||s,i)}function zme(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||k7,i)}function Bme(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||P7,i)}function Hme(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||N7,i)}function $me(t){switch(t){case 5126:return Eme;case 35664:return Mme;case 35665:return Ame;case 35666:return Tme;case 35674:return Cme;case 35675:return Nme;case 35676:return kme;case 5124:case 35670:return Pme;case 35667:case 35671:return Rme;case 35668:case 35672:return Dme;case 35669:case 35673:return Ome;case 5125:return jme;case 36294:return Lme;case 36295:return Ime;case 36296:return Ume;case 35678:case 36198:case 36298:case 36306:case 35682:return Fme;case 35679:case 36299:case 36307:return zme;case 35680:case 36300:case 36308:case 36293:return Bme;case 36289:case 36303:case 36311:case 36292:return Hme}}function Vme(t,e){t.uniform1fv(this.addr,e)}function Gme(t,e){const n=zm(e,this.size,2);t.uniform2fv(this.addr,n)}function Wme(t,e){const n=zm(e,this.size,3);t.uniform3fv(this.addr,n)}function qme(t,e){const n=zm(e,this.size,4);t.uniform4fv(this.addr,n)}function Kme(t,e){const n=zm(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Xme(t,e){const n=zm(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Yme(t,e){const n=zm(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Zme(t,e){t.uniform1iv(this.addr,e)}function Qme(t,e){t.uniform2iv(this.addr,e)}function Jme(t,e){t.uniform3iv(this.addr,e)}function ege(t,e){t.uniform4iv(this.addr,e)}function tge(t,e){t.uniform1uiv(this.addr,e)}function nge(t,e){t.uniform2uiv(this.addr,e)}function rge(t,e){t.uniform3uiv(this.addr,e)}function ige(t,e){t.uniform4uiv(this.addr,e)}function sge(t,e,n){const r=this.cache,i=e.length,s=MS(n,i);hi(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||C7,s[a])}function age(t,e,n){const r=this.cache,i=e.length,s=MS(n,i);hi(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||k7,s[a])}function oge(t,e,n){const r=this.cache,i=e.length,s=MS(n,i);hi(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||P7,s[a])}function lge(t,e,n){const r=this.cache,i=e.length,s=MS(n,i);hi(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||N7,s[a])}function cge(t){switch(t){case 5126:return Vme;case 35664:return Gme;case 35665:return Wme;case 35666:return qme;case 35674:return Kme;case 35675:return Xme;case 35676:return Yme;case 5124:case 35670:return Zme;case 35667:case 35671:return Qme;case 35668:case 35672:return Jme;case 35669:case 35673:return ege;case 5125:return tge;case 36294:return nge;case 36295:return rge;case 36296:return ige;case 35678:case 36198:case 36298:case 36306:case 35682:return sge;case 35679:case 36299:case 36307:return age;case 35680:case 36300:case 36308:case 36293:return oge;case 36289:case 36303:case 36311:case 36292:return lge}}let uge=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=$me(n.type)}},dge=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=cge(n.type)}},hge=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,n[o.id],r)}}};const FA=/(\w+)(\])?(\[|\.)?/g;function MF(t,e){t.seq.push(e),t.map[e.id]=e}function fge(t,e,n){const r=t.name,i=r.length;for(FA.lastIndex=0;;){const s=FA.exec(r),a=FA.lastIndex;let o=s[1];const l=s[2]==="]",u=s[3];if(l&&(o=o|0),u===void 0||u==="["&&a+2===i){MF(n,u===void 0?new uge(o,t,e):new dge(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new hge(o),MF(n,f)),n=f}}}let H_=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),a=e.getUniformLocation(n,s.name);fge(s,a,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let s=0,a=n.length;s!==a;++s){const o=n[s],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in n&&r.push(a)}return r}};function AF(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const pge=37297;let mge=0;function gge(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let a=i;a<s;a++){const o=a+1;r.push(`${o===e?">":" "} ${o}: ${n[a]}`)}return r.join(`
- `)}const TF=new un;function xge(t){An._getMatrix(TF,An.workingColorSpace,t);const e=`mat3( ${TF.elements.map(n=>n.toFixed(4))} )`;switch(An.getTransfer(t)){case u1:return[e,"LinearTransferOETF"];case Hn:return[e,"sRGBTransferOETF"];default:return Xt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function CF(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
- `+s+`
- `+gge(t.getShaderSource(e),o)}else return s}function bge(t,e){const n=xge(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function vge(t,e){let n;switch(e){case gde:n="Linear";break;case xde:n="Reinhard";break;case bde:n="Cineon";break;case vde:n="ACESFilmic";break;case _de:n="AgX";break;case wde:n="Neutral";break;case yde:n="Custom";break;default:Xt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const _y=new Je;function yge(){An.getLuminanceCoefficients(_y);const t=_y.x.toFixed(4),e=_y.y.toFixed(4),n=_y.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function _ge(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(wx).join(`
- `)}function wge(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function Sge(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),a=s.name;let o=1;s.type===t.FLOAT_MAT2&&(o=2),s.type===t.FLOAT_MAT3&&(o=3),s.type===t.FLOAT_MAT4&&(o=4),n[a]={type:s.type,location:t.getAttribLocation(e,a),locationSize:o}}return n}function wx(t){return t!==""}function NF(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 kF(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Ege=/^[ \t]*#include +<([\w\d./]+)>/gm;function ek(t){return t.replace(Ege,Age)}const Mge=new Map;function Age(t,e){let n=sn[e];if(n===void 0){const r=Mge.get(e);if(r!==void 0)n=sn[r],Xt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return ek(n)}const Tge=/#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 PF(t){return t.replace(Tge,Cge)}function Cge(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function RF(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 Nge(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===KG?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Xue?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Yl&&(e="SHADOWMAP_TYPE_VSM"),e}function kge(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case lm:case cm:e="ENVMAP_TYPE_CUBE";break;case wS:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Pge(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case cm:e="ENVMAP_MODE_REFRACTION";break}return e}function Rge(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case MR:e="ENVMAP_BLENDING_MULTIPLY";break;case pde:e="ENVMAP_BLENDING_MIX";break;case mde:e="ENVMAP_BLENDING_ADD";break}return e}function Dge(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 Oge(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=Nge(n),u=kge(n),d=Pge(n),f=Rge(n),g=Dge(n),m=_ge(n),x=wge(s),y=i.createProgram();let v,b,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(wx).join(`
- `),v.length>0&&(v+=`
- `),b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(wx).join(`
- `),b.length>0&&(b+=`
- `)):(v=[RF(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(wx).join(`
- `),b=[RF(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Hu?"#define TONE_MAPPING":"",n.toneMapping!==Hu?sn.tonemapping_pars_fragment:"",n.toneMapping!==Hu?vge("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",sn.colorspace_pars_fragment,bge("linearToOutputTexel",n.outputColorSpace),yge(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(wx).join(`
- `)),a=ek(a),a=NF(a,n),a=kF(a,n),o=ek(o),o=NF(o,n),o=kF(o,n),a=PF(a),o=PF(o),n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,v=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,b=["#define varying in",n.glslVersion===F5?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===F5?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+b);const S=E+v+a,A=E+b+o,T=AF(i,i.VERTEX_SHADER,S),P=AF(i,i.FRAGMENT_SHADER,A);i.attachShader(y,T),i.attachShader(y,P),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(F){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(y)||"",q=i.getShaderInfoLog(T)||"",R=i.getShaderInfoLog(P)||"",V=L.trim(),K=q.trim(),W=R.trim();let ne=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(ne=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,P);else{const Z=CF(i,T,"vertex"),U=CF(i,P,"fragment");jr("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Material Name: `+F.name+`
- Material Type: `+F.type+`
- Program Info Log: `+V+`
- `+Z+`
- `+U)}else V!==""?Xt("WebGLProgram: Program Info Log:",V):(K===""||W==="")&&(Y=!1);Y&&(F.diagnostics={runnable:ne,programLog:V,vertexShader:{log:K,prefix:v},fragmentShader:{log:W,prefix:b}})}i.deleteShader(T),i.deleteShader(P),I=new H_(i,y),N=Sge(i,y)}let I;this.getUniforms=function(){return I===void 0&&C(this),I};let N;this.getAttributes=function(){return N===void 0&&C(this),N};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,pge)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=mge++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=P,this}let jge=0,Lge=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new Ige(e),n.set(e,r)),r}},Ige=class{constructor(e){this.id=jge++,this.code=e,this.usedTimes=0}};function Uge(t,e,n,r,i,s,a){const o=new h7,l=new Lge,u=new Set,d=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(N){return u.add(N),N===0?"uv":`uv${N}`}function v(N,D,F,L,q){const R=L.fog,V=q.geometry,K=N.isMeshStandardMaterial?L.environment:null,W=(N.isMeshStandardMaterial?n:e).get(N.envMap||K),ne=W&&W.mapping===wS?W.image.height:null,Y=x[N.type];N.precision!==null&&(m=i.getMaxPrecision(N.precision),m!==N.precision&&Xt("WebGLProgram.getParameters:",N.precision,"not supported, using",m,"instead."));const Z=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,U=Z!==void 0?Z.length:0;let $=0;V.morphAttributes.position!==void 0&&($=1),V.morphAttributes.normal!==void 0&&($=2),V.morphAttributes.color!==void 0&&($=3);let ee,ae,fe,ue;if(Y){const Ot=Qo[Y];ee=Ot.vertexShader,ae=Ot.fragmentShader}else ee=N.vertexShader,ae=N.fragmentShader,l.update(N),fe=l.getVertexShaderID(N),ue=l.getFragmentShaderID(N);const xe=t.getRenderTarget(),Me=t.state.buffers.depth.getReversed(),se=q.isInstancedMesh===!0,ve=q.isBatchedMesh===!0,je=!!N.map,de=!!N.matcap,ut=!!W,H=!!N.aoMap,z=!!N.lightMap,re=!!N.bumpMap,G=!!N.normalMap,J=!!N.displacementMap,le=!!N.emissiveMap,ke=!!N.metalnessMap,Ne=!!N.roughnessMap,we=N.anisotropy>0,B=N.clearcoat>0,j=N.dispersion>0,te=N.iridescence>0,be=N.sheen>0,_e=N.transmission>0,ge=we&&!!N.anisotropyMap,me=B&&!!N.clearcoatMap,Ae=B&&!!N.clearcoatNormalMap,ze=B&&!!N.clearcoatRoughnessMap,st=te&&!!N.iridescenceMap,Ve=te&&!!N.iridescenceThicknessMap,ce=be&&!!N.sheenColorMap,Ye=be&&!!N.sheenRoughnessMap,$e=!!N.specularMap,Ze=!!N.specularColorMap,at=!!N.specularIntensityMap,Q=_e&&!!N.transmissionMap,Fe=_e&&!!N.thicknessMap,pe=!!N.gradientMap,Ue=!!N.alphaMap,Ce=N.alphaTest>0,ye=!!N.alphaHash,He=!!N.extensions;let ht=Hu;N.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(ht=t.toneMapping);const wt={shaderID:Y,shaderType:N.type,shaderName:N.name,vertexShader:ee,fragmentShader:ae,defines:N.defines,customVertexShaderID:fe,customFragmentShaderID:ue,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:m,batching:ve,batchingColor:ve&&q._colorsTexture!==null,instancing:se,instancingColor:se&&q.instanceColor!==null,instancingMorph:se&&q.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:um,alphaToCoverage:!!N.alphaToCoverage,map:je,matcap:de,envMap:ut,envMapMode:ut&&W.mapping,envMapCubeUVHeight:ne,aoMap:H,lightMap:z,bumpMap:re,normalMap:G,displacementMap:g&&J,emissiveMap:le,normalMapObjectSpace:G&&N.normalMapType===Ade,normalMapTangentSpace:G&&N.normalMapType===r7,metalnessMap:ke,roughnessMap:Ne,anisotropy:we,anisotropyMap:ge,clearcoat:B,clearcoatMap:me,clearcoatNormalMap:Ae,clearcoatRoughnessMap:ze,dispersion:j,iridescence:te,iridescenceMap:st,iridescenceThicknessMap:Ve,sheen:be,sheenColorMap:ce,sheenRoughnessMap:Ye,specularMap:$e,specularColorMap:Ze,specularIntensityMap:at,transmission:_e,transmissionMap:Q,thicknessMap:Fe,gradientMap:pe,opaque:N.transparent===!1&&N.blending===Gp&&N.alphaToCoverage===!1,alphaMap:Ue,alphaTest:Ce,alphaHash:ye,combine:N.combine,mapUv:je&&y(N.map.channel),aoMapUv:H&&y(N.aoMap.channel),lightMapUv:z&&y(N.lightMap.channel),bumpMapUv:re&&y(N.bumpMap.channel),normalMapUv:G&&y(N.normalMap.channel),displacementMapUv:J&&y(N.displacementMap.channel),emissiveMapUv:le&&y(N.emissiveMap.channel),metalnessMapUv:ke&&y(N.metalnessMap.channel),roughnessMapUv:Ne&&y(N.roughnessMap.channel),anisotropyMapUv:ge&&y(N.anisotropyMap.channel),clearcoatMapUv:me&&y(N.clearcoatMap.channel),clearcoatNormalMapUv:Ae&&y(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ze&&y(N.clearcoatRoughnessMap.channel),iridescenceMapUv:st&&y(N.iridescenceMap.channel),iridescenceThicknessMapUv:Ve&&y(N.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&y(N.sheenColorMap.channel),sheenRoughnessMapUv:Ye&&y(N.sheenRoughnessMap.channel),specularMapUv:$e&&y(N.specularMap.channel),specularColorMapUv:Ze&&y(N.specularColorMap.channel),specularIntensityMapUv:at&&y(N.specularIntensityMap.channel),transmissionMapUv:Q&&y(N.transmissionMap.channel),thicknessMapUv:Fe&&y(N.thicknessMap.channel),alphaMapUv:Ue&&y(N.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(G||we),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!V.attributes.uv&&(je||Ue),fog:!!R,useFog:N.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:N.flatShading===!0&&N.wireframe===!1,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Me,skinning:q.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.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:a.numPlanes,numClipIntersection:a.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:ht,decodeVideoTexture:je&&N.map.isVideoTexture===!0&&An.getTransfer(N.map.colorSpace)===Hn,decodeVideoTextureEmissive:le&&N.emissiveMap.isVideoTexture===!0&&An.getTransfer(N.emissiveMap.colorSpace)===Hn,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===Jo,flipSided:N.side===$s,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionClipCullDistance:He&&N.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(He&&N.extensions.multiDraw===!0||ve)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()};return wt.vertexUv1s=u.has(1),wt.vertexUv2s=u.has(2),wt.vertexUv3s=u.has(3),u.clear(),wt}function b(N){const D=[];if(N.shaderID?D.push(N.shaderID):(D.push(N.customVertexShaderID),D.push(N.customFragmentShaderID)),N.defines!==void 0)for(const F in N.defines)D.push(F),D.push(N.defines[F]);return N.isRawShaderMaterial===!1&&(E(D,N),S(D,N),D.push(t.outputColorSpace)),D.push(N.customProgramCacheKey),D.join()}function E(N,D){N.push(D.precision),N.push(D.outputColorSpace),N.push(D.envMapMode),N.push(D.envMapCubeUVHeight),N.push(D.mapUv),N.push(D.alphaMapUv),N.push(D.lightMapUv),N.push(D.aoMapUv),N.push(D.bumpMapUv),N.push(D.normalMapUv),N.push(D.displacementMapUv),N.push(D.emissiveMapUv),N.push(D.metalnessMapUv),N.push(D.roughnessMapUv),N.push(D.anisotropyMapUv),N.push(D.clearcoatMapUv),N.push(D.clearcoatNormalMapUv),N.push(D.clearcoatRoughnessMapUv),N.push(D.iridescenceMapUv),N.push(D.iridescenceThicknessMapUv),N.push(D.sheenColorMapUv),N.push(D.sheenRoughnessMapUv),N.push(D.specularMapUv),N.push(D.specularColorMapUv),N.push(D.specularIntensityMapUv),N.push(D.transmissionMapUv),N.push(D.thicknessMapUv),N.push(D.combine),N.push(D.fogExp2),N.push(D.sizeAttenuation),N.push(D.morphTargetsCount),N.push(D.morphAttributeCount),N.push(D.numDirLights),N.push(D.numPointLights),N.push(D.numSpotLights),N.push(D.numSpotLightMaps),N.push(D.numHemiLights),N.push(D.numRectAreaLights),N.push(D.numDirLightShadows),N.push(D.numPointLightShadows),N.push(D.numSpotLightShadows),N.push(D.numSpotLightShadowsWithMaps),N.push(D.numLightProbes),N.push(D.shadowMapType),N.push(D.toneMapping),N.push(D.numClippingPlanes),N.push(D.numClipIntersection),N.push(D.depthPacking)}function S(N,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),N.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),N.push(o.mask)}function A(N){const D=x[N.type];let F;if(D){const L=Qo[D];F=nhe.clone(L.uniforms)}else F=N.uniforms;return F}function T(N,D){let F;for(let L=0,q=d.length;L<q;L++){const R=d[L];if(R.cacheKey===D){F=R,++F.usedTimes;break}}return F===void 0&&(F=new Oge(t,D,N,s),d.push(F)),F}function P(N){if(--N.usedTimes===0){const D=d.indexOf(N);d[D]=d[d.length-1],d.pop(),N.destroy()}}function C(N){l.remove(N)}function I(){l.dispose()}return{getParameters:v,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:P,releaseShaderCache:C,programs:d,dispose:I}}function Fge(){let t=new WeakMap;function e(a){return t.has(a)}function n(a){let o=t.get(a);return o===void 0&&(o={},t.set(a,o)),o}function r(a){t.delete(a)}function i(a,o,l){t.get(a)[o]=l}function s(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:s}}function zge(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 DF(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 OF(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function a(f,g,m,x,y,v){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:m,groupOrder:x,renderOrder:f.renderOrder,z:y,group:v},t[e]=b):(b.id=f.id,b.object=f,b.geometry=g,b.material=m,b.groupOrder=x,b.renderOrder=f.renderOrder,b.z=y,b.group=v),e++,b}function o(f,g,m,x,y,v){const b=a(f,g,m,x,y,v);m.transmission>0?r.push(b):m.transparent===!0?i.push(b):n.push(b)}function l(f,g,m,x,y,v){const b=a(f,g,m,x,y,v);m.transmission>0?r.unshift(b):m.transparent===!0?i.unshift(b):n.unshift(b)}function u(f,g){n.length>1&&n.sort(f||zge),r.length>1&&r.sort(g||DF),i.length>1&&i.sort(g||DF)}function d(){for(let f=e,g=t.length;f<g;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:o,unshift:l,finish:d,sort:u}}function Bge(){let t=new WeakMap;function e(r,i){const s=t.get(r);let a;return s===void 0?(a=new OF,t.set(r,[a])):i>=s.length?(a=new OF,s.push(a)):a=s[i],a}function n(){t=new WeakMap}return{get:e,dispose:n}}function Hge(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Je,color:new vn};break;case"SpotLight":n={position:new Je,direction:new Je,color:new vn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Je,color:new vn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Je,skyColor:new vn,groundColor:new vn};break;case"RectAreaLight":n={color:new vn,position:new Je,halfWidth:new Je,halfHeight:new Je};break}return t[e.id]=n,n}}}function $ge(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Vge=0;function Gge(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Wge(t){const e=new Hge,n=$ge(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new Je);const i=new Je,s=new Jr,a=new Jr;function o(u){let d=0,f=0,g=0;for(let N=0;N<9;N++)r.probe[N].set(0,0,0);let m=0,x=0,y=0,v=0,b=0,E=0,S=0,A=0,T=0,P=0,C=0;u.sort(Gge);for(let N=0,D=u.length;N<D;N++){const F=u[N],L=F.color,q=F.intensity,R=F.distance,V=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=L.r*q,f+=L.g*q,g+=L.b*q;else if(F.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(F.sh.coefficients[K],q);C++}else if(F.isDirectionalLight){const K=e.get(F);if(K.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const W=F.shadow,ne=n.get(F);ne.shadowIntensity=W.intensity,ne.shadowBias=W.bias,ne.shadowNormalBias=W.normalBias,ne.shadowRadius=W.radius,ne.shadowMapSize=W.mapSize,r.directionalShadow[m]=ne,r.directionalShadowMap[m]=V,r.directionalShadowMatrix[m]=F.shadow.matrix,E++}r.directional[m]=K,m++}else if(F.isSpotLight){const K=e.get(F);K.position.setFromMatrixPosition(F.matrixWorld),K.color.copy(L).multiplyScalar(q),K.distance=R,K.coneCos=Math.cos(F.angle),K.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),K.decay=F.decay,r.spot[y]=K;const W=F.shadow;if(F.map&&(r.spotLightMap[T]=F.map,T++,W.updateMatrices(F),F.castShadow&&P++),r.spotLightMatrix[y]=W.matrix,F.castShadow){const ne=n.get(F);ne.shadowIntensity=W.intensity,ne.shadowBias=W.bias,ne.shadowNormalBias=W.normalBias,ne.shadowRadius=W.radius,ne.shadowMapSize=W.mapSize,r.spotShadow[y]=ne,r.spotShadowMap[y]=V,A++}y++}else if(F.isRectAreaLight){const K=e.get(F);K.color.copy(L).multiplyScalar(q),K.halfWidth.set(F.width*.5,0,0),K.halfHeight.set(0,F.height*.5,0),r.rectArea[v]=K,v++}else if(F.isPointLight){const K=e.get(F);if(K.color.copy(F.color).multiplyScalar(F.intensity),K.distance=F.distance,K.decay=F.decay,F.castShadow){const W=F.shadow,ne=n.get(F);ne.shadowIntensity=W.intensity,ne.shadowBias=W.bias,ne.shadowNormalBias=W.normalBias,ne.shadowRadius=W.radius,ne.shadowMapSize=W.mapSize,ne.shadowCameraNear=W.camera.near,ne.shadowCameraFar=W.camera.far,r.pointShadow[x]=ne,r.pointShadowMap[x]=V,r.pointShadowMatrix[x]=F.shadow.matrix,S++}r.point[x]=K,x++}else if(F.isHemisphereLight){const K=e.get(F);K.skyColor.copy(F.color).multiplyScalar(q),K.groundColor.copy(F.groundColor).multiplyScalar(q),r.hemi[b]=K,b++}}v>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Et.LTC_FLOAT_1,r.rectAreaLTC2=Et.LTC_FLOAT_2):(r.rectAreaLTC1=Et.LTC_HALF_1,r.rectAreaLTC2=Et.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=g;const I=r.hash;(I.directionalLength!==m||I.pointLength!==x||I.spotLength!==y||I.rectAreaLength!==v||I.hemiLength!==b||I.numDirectionalShadows!==E||I.numPointShadows!==S||I.numSpotShadows!==A||I.numSpotMaps!==T||I.numLightProbes!==C)&&(r.directional.length=m,r.spot.length=y,r.rectArea.length=v,r.point.length=x,r.hemi.length=b,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=S,r.pointShadowMap.length=S,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=S,r.spotLightMatrix.length=A+T-P,r.spotLightMap.length=T,r.numSpotLightShadowsWithMaps=P,r.numLightProbes=C,I.directionalLength=m,I.pointLength=x,I.spotLength=y,I.rectAreaLength=v,I.hemiLength=b,I.numDirectionalShadows=E,I.numPointShadows=S,I.numSpotShadows=A,I.numSpotMaps=T,I.numLightProbes=C,r.version=Vge++)}function l(u,d){let f=0,g=0,m=0,x=0,y=0;const v=d.matrixWorldInverse;for(let b=0,E=u.length;b<E;b++){const S=u[b];if(S.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(v),f++}else if(S.isSpotLight){const A=r.spot[m];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(v),m++}else if(S.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),a.identity(),s.copy(S.matrixWorld),s.premultiply(v),a.extractRotation(s),A.halfWidth.set(S.width*.5,0,0),A.halfHeight.set(0,S.height*.5,0),A.halfWidth.applyMatrix4(a),A.halfHeight.applyMatrix4(a),x++}else if(S.isPointLight){const A=r.point[g];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),g++}else if(S.isHemisphereLight){const A=r.hemi[y];A.direction.setFromMatrixPosition(S.matrixWorld),A.direction.transformDirection(v),y++}}}return{setup:o,setupView:l,state:r}}function jF(t){const e=new Wge(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function s(d){n.push(d)}function a(d){r.push(d)}function o(){e.setup(n)}function l(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function qge(t){let e=new WeakMap;function n(i,s=0){const a=e.get(i);let o;return a===void 0?(o=new jF(t),e.set(i,[o])):s>=a.length?(o=new jF(t),a.push(o)):o=a[s],o}function r(){e=new WeakMap}return{get:n,dispose:r}}const Kge=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,Xge=`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 Yge(t,e,n){let r=new IR;const i=new on,s=new on,a=new Wr,o=new ghe({depthPacking:Mde}),l=new xhe,u={},d=n.maxTextureSize,f={[ed]:$s,[$s]:ed,[Jo]:Jo},g=new yc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new on},radius:{value:4}},vertexShader:Kge,fragmentShader:Xge}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const x=new xl;x.setAttribute("position",new Ja(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new cl(x,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=KG;let b=this.type;this.render=function(P,C,I){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||P.length===0)return;const N=t.getRenderTarget(),D=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),L=t.state;L.setBlending(hc),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const q=b!==Yl&&this.type===Yl,R=b===Yl&&this.type!==Yl;for(let V=0,K=P.length;V<K;V++){const W=P[V],ne=W.shadow;if(ne===void 0){Xt("WebGLShadowMap:",W,"has no shadow.");continue}if(ne.autoUpdate===!1&&ne.needsUpdate===!1)continue;i.copy(ne.mapSize);const Y=ne.getFrameExtents();if(i.multiply(Y),s.copy(ne.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Y.x),i.x=s.x*Y.x,ne.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Y.y),i.y=s.y*Y.y,ne.mapSize.y=s.y)),ne.map===null||q===!0||R===!0){const U=this.type!==Yl?{minFilter:ga,magFilter:ga}:{};ne.map!==null&&ne.map.dispose(),ne.map=new Uh(i.x,i.y,U),ne.map.texture.name=W.name+".shadowMap",ne.camera.updateProjectionMatrix()}t.setRenderTarget(ne.map),t.clear();const Z=ne.getViewportCount();for(let U=0;U<Z;U++){const $=ne.getViewport(U);a.set(s.x*$.x,s.y*$.y,s.x*$.z,s.y*$.w),L.viewport(a),ne.updateMatrices(W,U),r=ne.getFrustum(),A(C,I,ne.camera,W,this.type)}ne.isPointLightShadow!==!0&&this.type===Yl&&E(ne,I),ne.needsUpdate=!1}b=this.type,v.needsUpdate=!1,t.setRenderTarget(N,D,F)};function E(P,C){const I=e.update(y);g.defines.VSM_SAMPLES!==P.blurSamples&&(g.defines.VSM_SAMPLES=P.blurSamples,m.defines.VSM_SAMPLES=P.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new Uh(i.x,i.y)),g.uniforms.shadow_pass.value=P.map.texture,g.uniforms.resolution.value=P.mapSize,g.uniforms.radius.value=P.radius,t.setRenderTarget(P.mapPass),t.clear(),t.renderBufferDirect(C,null,I,g,y,null),m.uniforms.shadow_pass.value=P.mapPass.texture,m.uniforms.resolution.value=P.mapSize,m.uniforms.radius.value=P.radius,t.setRenderTarget(P.map),t.clear(),t.renderBufferDirect(C,null,I,m,y,null)}function S(P,C,I,N){let D=null;const F=I.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(F!==void 0)D=F;else if(D=I.isPointLight===!0?l:o,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const L=D.uuid,q=C.uuid;let R=u[L];R===void 0&&(R={},u[L]=R);let V=R[q];V===void 0&&(V=D.clone(),R[q]=V,C.addEventListener("dispose",T)),D=V}if(D.visible=C.visible,D.wireframe=C.wireframe,N===Yl?D.side=C.shadowSide!==null?C.shadowSide:C.side:D.side=C.shadowSide!==null?C.shadowSide:f[C.side],D.alphaMap=C.alphaMap,D.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,D.map=C.map,D.clipShadows=C.clipShadows,D.clippingPlanes=C.clippingPlanes,D.clipIntersection=C.clipIntersection,D.displacementMap=C.displacementMap,D.displacementScale=C.displacementScale,D.displacementBias=C.displacementBias,D.wireframeLinewidth=C.wireframeLinewidth,D.linewidth=C.linewidth,I.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const L=t.properties.get(D);L.light=I}return D}function A(P,C,I,N,D){if(P.visible===!1)return;if(P.layers.test(C.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&D===Yl)&&(!P.frustumCulled||r.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,P.matrixWorld);const q=e.update(P),R=P.material;if(Array.isArray(R)){const V=q.groups;for(let K=0,W=V.length;K<W;K++){const ne=V[K],Y=R[ne.materialIndex];if(Y&&Y.visible){const Z=S(P,Y,N,D);P.onBeforeShadow(t,P,C,I,q,Z,ne),t.renderBufferDirect(I,null,q,Z,P,ne),P.onAfterShadow(t,P,C,I,q,Z,ne)}}}else if(R.visible){const V=S(P,R,N,D);P.onBeforeShadow(t,P,C,I,q,V,null),t.renderBufferDirect(I,null,q,V,P,null),P.onAfterShadow(t,P,C,I,q,V,null)}}const L=P.children;for(let q=0,R=L.length;q<R;q++)A(L[q],C,I,N,D)}function T(P){P.target.removeEventListener("dispose",T);for(const I in u){const N=u[I],D=P.target.uuid;D in N&&(N[D].dispose(),delete N[D])}}}const Zge={[f3]:p3,[m3]:b3,[g3]:v3,[om]:x3,[p3]:f3,[b3]:m3,[v3]:g3,[x3]:om};function Qge(t,e){function n(){let Q=!1;const Fe=new Wr;let pe=null;const Ue=new Wr(0,0,0,0);return{setMask:function(Ce){pe!==Ce&&!Q&&(t.colorMask(Ce,Ce,Ce,Ce),pe=Ce)},setLocked:function(Ce){Q=Ce},setClear:function(Ce,ye,He,ht,wt){wt===!0&&(Ce*=ht,ye*=ht,He*=ht),Fe.set(Ce,ye,He,ht),Ue.equals(Fe)===!1&&(t.clearColor(Ce,ye,He,ht),Ue.copy(Fe))},reset:function(){Q=!1,pe=null,Ue.set(-1,0,0,0)}}}function r(){let Q=!1,Fe=!1,pe=null,Ue=null,Ce=null;return{setReversed:function(ye){if(Fe!==ye){const He=e.get("EXT_clip_control");ye?He.clipControlEXT(He.LOWER_LEFT_EXT,He.ZERO_TO_ONE_EXT):He.clipControlEXT(He.LOWER_LEFT_EXT,He.NEGATIVE_ONE_TO_ONE_EXT),Fe=ye;const ht=Ce;Ce=null,this.setClear(ht)}},getReversed:function(){return Fe},setTest:function(ye){ye?xe(t.DEPTH_TEST):Me(t.DEPTH_TEST)},setMask:function(ye){pe!==ye&&!Q&&(t.depthMask(ye),pe=ye)},setFunc:function(ye){if(Fe&&(ye=Zge[ye]),Ue!==ye){switch(ye){case f3:t.depthFunc(t.NEVER);break;case p3:t.depthFunc(t.ALWAYS);break;case m3:t.depthFunc(t.LESS);break;case om:t.depthFunc(t.LEQUAL);break;case g3:t.depthFunc(t.EQUAL);break;case x3:t.depthFunc(t.GEQUAL);break;case b3:t.depthFunc(t.GREATER);break;case v3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ue=ye}},setLocked:function(ye){Q=ye},setClear:function(ye){Ce!==ye&&(Fe&&(ye=1-ye),t.clearDepth(ye),Ce=ye)},reset:function(){Q=!1,pe=null,Ue=null,Ce=null,Fe=!1}}}function i(){let Q=!1,Fe=null,pe=null,Ue=null,Ce=null,ye=null,He=null,ht=null,wt=null;return{setTest:function(Ot){Q||(Ot?xe(t.STENCIL_TEST):Me(t.STENCIL_TEST))},setMask:function(Ot){Fe!==Ot&&!Q&&(t.stencilMask(Ot),Fe=Ot)},setFunc:function(Ot,cn,It){(pe!==Ot||Ue!==cn||Ce!==It)&&(t.stencilFunc(Ot,cn,It),pe=Ot,Ue=cn,Ce=It)},setOp:function(Ot,cn,It){(ye!==Ot||He!==cn||ht!==It)&&(t.stencilOp(Ot,cn,It),ye=Ot,He=cn,ht=It)},setLocked:function(Ot){Q=Ot},setClear:function(Ot){wt!==Ot&&(t.clearStencil(Ot),wt=Ot)},reset:function(){Q=!1,Fe=null,pe=null,Ue=null,Ce=null,ye=null,He=null,ht=null,wt=null}}}const s=new n,a=new r,o=new i,l=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,m=[],x=null,y=!1,v=null,b=null,E=null,S=null,A=null,T=null,P=null,C=new vn(0,0,0),I=0,N=!1,D=null,F=null,L=null,q=null,R=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,W=0;const ne=t.getParameter(t.VERSION);ne.indexOf("WebGL")!==-1?(W=parseFloat(/^WebGL (\d)/.exec(ne)[1]),K=W>=1):ne.indexOf("OpenGL ES")!==-1&&(W=parseFloat(/^OpenGL ES (\d)/.exec(ne)[1]),K=W>=2);let Y=null,Z={};const U=t.getParameter(t.SCISSOR_BOX),$=t.getParameter(t.VIEWPORT),ee=new Wr().fromArray(U),ae=new Wr().fromArray($);function fe(Q,Fe,pe,Ue){const Ce=new Uint8Array(4),ye=t.createTexture();t.bindTexture(Q,ye),t.texParameteri(Q,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Q,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let He=0;He<pe;He++)Q===t.TEXTURE_3D||Q===t.TEXTURE_2D_ARRAY?t.texImage3D(Fe,0,t.RGBA,1,1,Ue,0,t.RGBA,t.UNSIGNED_BYTE,Ce):t.texImage2D(Fe+He,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ce);return ye}const ue={};ue[t.TEXTURE_2D]=fe(t.TEXTURE_2D,t.TEXTURE_2D,1),ue[t.TEXTURE_CUBE_MAP]=fe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),ue[t.TEXTURE_2D_ARRAY]=fe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),ue[t.TEXTURE_3D]=fe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),xe(t.DEPTH_TEST),a.setFunc(om),re(!1),G(D5),xe(t.CULL_FACE),H(hc);function xe(Q){d[Q]!==!0&&(t.enable(Q),d[Q]=!0)}function Me(Q){d[Q]!==!1&&(t.disable(Q),d[Q]=!1)}function se(Q,Fe){return f[Q]!==Fe?(t.bindFramebuffer(Q,Fe),f[Q]=Fe,Q===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Fe),Q===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Fe),!0):!1}function ve(Q,Fe){let pe=m,Ue=!1;if(Q){pe=g.get(Fe),pe===void 0&&(pe=[],g.set(Fe,pe));const Ce=Q.textures;if(pe.length!==Ce.length||pe[0]!==t.COLOR_ATTACHMENT0){for(let ye=0,He=Ce.length;ye<He;ye++)pe[ye]=t.COLOR_ATTACHMENT0+ye;pe.length=Ce.length,Ue=!0}}else pe[0]!==t.BACK&&(pe[0]=t.BACK,Ue=!0);Ue&&t.drawBuffers(pe)}function je(Q){return x!==Q?(t.useProgram(Q),x=Q,!0):!1}const de={[Qd]:t.FUNC_ADD,[Zue]:t.FUNC_SUBTRACT,[Que]:t.FUNC_REVERSE_SUBTRACT};de[Jue]=t.MIN,de[ede]=t.MAX;const ut={[tde]:t.ZERO,[nde]:t.ONE,[rde]:t.SRC_COLOR,[d3]:t.SRC_ALPHA,[cde]:t.SRC_ALPHA_SATURATE,[ode]:t.DST_COLOR,[sde]:t.DST_ALPHA,[ide]:t.ONE_MINUS_SRC_COLOR,[h3]:t.ONE_MINUS_SRC_ALPHA,[lde]:t.ONE_MINUS_DST_COLOR,[ade]:t.ONE_MINUS_DST_ALPHA,[ude]:t.CONSTANT_COLOR,[dde]:t.ONE_MINUS_CONSTANT_COLOR,[hde]:t.CONSTANT_ALPHA,[fde]:t.ONE_MINUS_CONSTANT_ALPHA};function H(Q,Fe,pe,Ue,Ce,ye,He,ht,wt,Ot){if(Q===hc){y===!0&&(Me(t.BLEND),y=!1);return}if(y===!1&&(xe(t.BLEND),y=!0),Q!==Yue){if(Q!==v||Ot!==N){if((b!==Qd||A!==Qd)&&(t.blendEquation(t.FUNC_ADD),b=Qd,A=Qd),Ot)switch(Q){case Gp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case O5:t.blendFunc(t.ONE,t.ONE);break;case j5:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case L5:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:jr("WebGLState: Invalid blending: ",Q);break}else switch(Q){case Gp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case O5:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case j5:jr("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case L5:jr("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:jr("WebGLState: Invalid blending: ",Q);break}E=null,S=null,T=null,P=null,C.set(0,0,0),I=0,v=Q,N=Ot}return}Ce=Ce||Fe,ye=ye||pe,He=He||Ue,(Fe!==b||Ce!==A)&&(t.blendEquationSeparate(de[Fe],de[Ce]),b=Fe,A=Ce),(pe!==E||Ue!==S||ye!==T||He!==P)&&(t.blendFuncSeparate(ut[pe],ut[Ue],ut[ye],ut[He]),E=pe,S=Ue,T=ye,P=He),(ht.equals(C)===!1||wt!==I)&&(t.blendColor(ht.r,ht.g,ht.b,wt),C.copy(ht),I=wt),v=Q,N=!1}function z(Q,Fe){Q.side===Jo?Me(t.CULL_FACE):xe(t.CULL_FACE);let pe=Q.side===$s;Fe&&(pe=!pe),re(pe),Q.blending===Gp&&Q.transparent===!1?H(hc):H(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.blendColor,Q.blendAlpha,Q.premultipliedAlpha),a.setFunc(Q.depthFunc),a.setTest(Q.depthTest),a.setMask(Q.depthWrite),s.setMask(Q.colorWrite);const Ue=Q.stencilWrite;o.setTest(Ue),Ue&&(o.setMask(Q.stencilWriteMask),o.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),o.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),le(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?xe(t.SAMPLE_ALPHA_TO_COVERAGE):Me(t.SAMPLE_ALPHA_TO_COVERAGE)}function re(Q){D!==Q&&(Q?t.frontFace(t.CW):t.frontFace(t.CCW),D=Q)}function G(Q){Q!==que?(xe(t.CULL_FACE),Q!==F&&(Q===D5?t.cullFace(t.BACK):Q===Kue?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Me(t.CULL_FACE),F=Q}function J(Q){Q!==L&&(K&&t.lineWidth(Q),L=Q)}function le(Q,Fe,pe){Q?(xe(t.POLYGON_OFFSET_FILL),(q!==Fe||R!==pe)&&(t.polygonOffset(Fe,pe),q=Fe,R=pe)):Me(t.POLYGON_OFFSET_FILL)}function ke(Q){Q?xe(t.SCISSOR_TEST):Me(t.SCISSOR_TEST)}function Ne(Q){Q===void 0&&(Q=t.TEXTURE0+V-1),Y!==Q&&(t.activeTexture(Q),Y=Q)}function we(Q,Fe,pe){pe===void 0&&(Y===null?pe=t.TEXTURE0+V-1:pe=Y);let Ue=Z[pe];Ue===void 0&&(Ue={type:void 0,texture:void 0},Z[pe]=Ue),(Ue.type!==Q||Ue.texture!==Fe)&&(Y!==pe&&(t.activeTexture(pe),Y=pe),t.bindTexture(Q,Fe||ue[Q]),Ue.type=Q,Ue.texture=Fe)}function B(){const Q=Z[Y];Q!==void 0&&Q.type!==void 0&&(t.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function j(){try{t.compressedTexImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function te(){try{t.compressedTexImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function be(){try{t.texSubImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function _e(){try{t.texSubImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ge(){try{t.compressedTexSubImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function me(){try{t.compressedTexSubImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function Ae(){try{t.texStorage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ze(){try{t.texStorage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function st(){try{t.texImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function Ve(){try{t.texImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ce(Q){ee.equals(Q)===!1&&(t.scissor(Q.x,Q.y,Q.z,Q.w),ee.copy(Q))}function Ye(Q){ae.equals(Q)===!1&&(t.viewport(Q.x,Q.y,Q.z,Q.w),ae.copy(Q))}function $e(Q,Fe){let pe=u.get(Fe);pe===void 0&&(pe=new WeakMap,u.set(Fe,pe));let Ue=pe.get(Q);Ue===void 0&&(Ue=t.getUniformBlockIndex(Fe,Q.name),pe.set(Q,Ue))}function Ze(Q,Fe){const Ue=u.get(Fe).get(Q);l.get(Fe)!==Ue&&(t.uniformBlockBinding(Fe,Ue,Q.__bindingPointIndex),l.set(Fe,Ue))}function at(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),a.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Y=null,Z={},f={},g=new WeakMap,m=[],x=null,y=!1,v=null,b=null,E=null,S=null,A=null,T=null,P=null,C=new vn(0,0,0),I=0,N=!1,D=null,F=null,L=null,q=null,R=null,ee.set(0,0,t.canvas.width,t.canvas.height),ae.set(0,0,t.canvas.width,t.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:xe,disable:Me,bindFramebuffer:se,drawBuffers:ve,useProgram:je,setBlending:H,setMaterial:z,setFlipSided:re,setCullFace:G,setLineWidth:J,setPolygonOffset:le,setScissorTest:ke,activeTexture:Ne,bindTexture:we,unbindTexture:B,compressedTexImage2D:j,compressedTexImage3D:te,texImage2D:st,texImage3D:Ve,updateUBOMapping:$e,uniformBlockBinding:Ze,texStorage2D:Ae,texStorage3D:ze,texSubImage2D:be,texSubImage3D:_e,compressedTexSubImage2D:ge,compressedTexSubImage3D:me,scissor:ce,viewport:Ye,reset:at}}function Jge(t,e,n,r,i,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new on,d=new WeakMap;let f;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(B,j){return m?new OffscreenCanvas(B,j):h1("canvas")}function y(B,j,te){let be=1;const _e=we(B);if((_e.width>te||_e.height>te)&&(be=te/Math.max(_e.width,_e.height)),be<1)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap||typeof VideoFrame<"u"&&B instanceof VideoFrame){const ge=Math.floor(be*_e.width),me=Math.floor(be*_e.height);f===void 0&&(f=x(ge,me));const Ae=j?x(ge,me):f;return Ae.width=ge,Ae.height=me,Ae.getContext("2d").drawImage(B,0,0,ge,me),Xt("WebGLRenderer: Texture has been resized from ("+_e.width+"x"+_e.height+") to ("+ge+"x"+me+")."),Ae}else return"data"in B&&Xt("WebGLRenderer: Image in DataTexture is too big ("+_e.width+"x"+_e.height+")."),B;return B}function v(B){return B.generateMipmaps}function b(B){t.generateMipmap(B)}function E(B){return B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:B.isWebGL3DRenderTarget?t.TEXTURE_3D:B.isWebGLArrayRenderTarget||B.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function S(B,j,te,be,_e=!1){if(B!==null){if(t[B]!==void 0)return t[B];Xt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ge=j;if(j===t.RED&&(te===t.FLOAT&&(ge=t.R32F),te===t.HALF_FLOAT&&(ge=t.R16F),te===t.UNSIGNED_BYTE&&(ge=t.R8)),j===t.RED_INTEGER&&(te===t.UNSIGNED_BYTE&&(ge=t.R8UI),te===t.UNSIGNED_SHORT&&(ge=t.R16UI),te===t.UNSIGNED_INT&&(ge=t.R32UI),te===t.BYTE&&(ge=t.R8I),te===t.SHORT&&(ge=t.R16I),te===t.INT&&(ge=t.R32I)),j===t.RG&&(te===t.FLOAT&&(ge=t.RG32F),te===t.HALF_FLOAT&&(ge=t.RG16F),te===t.UNSIGNED_BYTE&&(ge=t.RG8)),j===t.RG_INTEGER&&(te===t.UNSIGNED_BYTE&&(ge=t.RG8UI),te===t.UNSIGNED_SHORT&&(ge=t.RG16UI),te===t.UNSIGNED_INT&&(ge=t.RG32UI),te===t.BYTE&&(ge=t.RG8I),te===t.SHORT&&(ge=t.RG16I),te===t.INT&&(ge=t.RG32I)),j===t.RGB_INTEGER&&(te===t.UNSIGNED_BYTE&&(ge=t.RGB8UI),te===t.UNSIGNED_SHORT&&(ge=t.RGB16UI),te===t.UNSIGNED_INT&&(ge=t.RGB32UI),te===t.BYTE&&(ge=t.RGB8I),te===t.SHORT&&(ge=t.RGB16I),te===t.INT&&(ge=t.RGB32I)),j===t.RGBA_INTEGER&&(te===t.UNSIGNED_BYTE&&(ge=t.RGBA8UI),te===t.UNSIGNED_SHORT&&(ge=t.RGBA16UI),te===t.UNSIGNED_INT&&(ge=t.RGBA32UI),te===t.BYTE&&(ge=t.RGBA8I),te===t.SHORT&&(ge=t.RGBA16I),te===t.INT&&(ge=t.RGBA32I)),j===t.RGB&&(te===t.UNSIGNED_INT_5_9_9_9_REV&&(ge=t.RGB9_E5),te===t.UNSIGNED_INT_10F_11F_11F_REV&&(ge=t.R11F_G11F_B10F)),j===t.RGBA){const me=_e?u1:An.getTransfer(be);te===t.FLOAT&&(ge=t.RGBA32F),te===t.HALF_FLOAT&&(ge=t.RGBA16F),te===t.UNSIGNED_BYTE&&(ge=me===Hn?t.SRGB8_ALPHA8:t.RGBA8),te===t.UNSIGNED_SHORT_4_4_4_4&&(ge=t.RGBA4),te===t.UNSIGNED_SHORT_5_5_5_1&&(ge=t.RGB5_A1)}return(ge===t.R16F||ge===t.R32F||ge===t.RG16F||ge===t.RG32F||ge===t.RGBA16F||ge===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function A(B,j){let te;return B?j===null||j===Lh||j===g0?te=t.DEPTH24_STENCIL8:j===ac?te=t.DEPTH32F_STENCIL8:j===m0&&(te=t.DEPTH24_STENCIL8,Xt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):j===null||j===Lh||j===g0?te=t.DEPTH_COMPONENT24:j===ac?te=t.DEPTH_COMPONENT32F:j===m0&&(te=t.DEPTH_COMPONENT16),te}function T(B,j){return v(B)===!0||B.isFramebufferTexture&&B.minFilter!==ga&&B.minFilter!==Za?Math.log2(Math.max(j.width,j.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?j.mipmaps.length:1}function P(B){const j=B.target;j.removeEventListener("dispose",P),I(j),j.isVideoTexture&&d.delete(j)}function C(B){const j=B.target;j.removeEventListener("dispose",C),D(j)}function I(B){const j=r.get(B);if(j.__webglInit===void 0)return;const te=B.source,be=g.get(te);if(be){const _e=be[j.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&N(B),Object.keys(be).length===0&&g.delete(te)}r.remove(B)}function N(B){const j=r.get(B);t.deleteTexture(j.__webglTexture);const te=B.source,be=g.get(te);delete be[j.__cacheKey],a.memory.textures--}function D(B){const j=r.get(B);if(B.depthTexture&&(B.depthTexture.dispose(),r.remove(B.depthTexture)),B.isWebGLCubeRenderTarget)for(let be=0;be<6;be++){if(Array.isArray(j.__webglFramebuffer[be]))for(let _e=0;_e<j.__webglFramebuffer[be].length;_e++)t.deleteFramebuffer(j.__webglFramebuffer[be][_e]);else t.deleteFramebuffer(j.__webglFramebuffer[be]);j.__webglDepthbuffer&&t.deleteRenderbuffer(j.__webglDepthbuffer[be])}else{if(Array.isArray(j.__webglFramebuffer))for(let be=0;be<j.__webglFramebuffer.length;be++)t.deleteFramebuffer(j.__webglFramebuffer[be]);else t.deleteFramebuffer(j.__webglFramebuffer);if(j.__webglDepthbuffer&&t.deleteRenderbuffer(j.__webglDepthbuffer),j.__webglMultisampledFramebuffer&&t.deleteFramebuffer(j.__webglMultisampledFramebuffer),j.__webglColorRenderbuffer)for(let be=0;be<j.__webglColorRenderbuffer.length;be++)j.__webglColorRenderbuffer[be]&&t.deleteRenderbuffer(j.__webglColorRenderbuffer[be]);j.__webglDepthRenderbuffer&&t.deleteRenderbuffer(j.__webglDepthRenderbuffer)}const te=B.textures;for(let be=0,_e=te.length;be<_e;be++){const ge=r.get(te[be]);ge.__webglTexture&&(t.deleteTexture(ge.__webglTexture),a.memory.textures--),r.remove(te[be])}r.remove(B)}let F=0;function L(){F=0}function q(){const B=F;return B>=i.maxTextures&&Xt("WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+i.maxTextures),F+=1,B}function R(B){const j=[];return j.push(B.wrapS),j.push(B.wrapT),j.push(B.wrapR||0),j.push(B.magFilter),j.push(B.minFilter),j.push(B.anisotropy),j.push(B.internalFormat),j.push(B.format),j.push(B.type),j.push(B.generateMipmaps),j.push(B.premultiplyAlpha),j.push(B.flipY),j.push(B.unpackAlignment),j.push(B.colorSpace),j.join()}function V(B,j){const te=r.get(B);if(B.isVideoTexture&&ke(B),B.isRenderTargetTexture===!1&&B.isExternalTexture!==!0&&B.version>0&&te.__version!==B.version){const be=B.image;if(be===null)Xt("WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)Xt("WebGLRenderer: Texture marked for update but image is incomplete");else{ue(te,B,j);return}}else B.isExternalTexture&&(te.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,te.__webglTexture,t.TEXTURE0+j)}function K(B,j){const te=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&te.__version!==B.version){ue(te,B,j);return}else B.isExternalTexture&&(te.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,te.__webglTexture,t.TEXTURE0+j)}function W(B,j){const te=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&te.__version!==B.version){ue(te,B,j);return}n.bindTexture(t.TEXTURE_3D,te.__webglTexture,t.TEXTURE0+j)}function ne(B,j){const te=r.get(B);if(B.version>0&&te.__version!==B.version){xe(te,B,j);return}n.bindTexture(t.TEXTURE_CUBE_MAP,te.__webglTexture,t.TEXTURE0+j)}const Y={[w3]:t.REPEAT,[sc]:t.CLAMP_TO_EDGE,[S3]:t.MIRRORED_REPEAT},Z={[ga]:t.NEAREST,[Sde]:t.NEAREST_MIPMAP_NEAREST,[ey]:t.NEAREST_MIPMAP_LINEAR,[Za]:t.LINEAR,[cA]:t.LINEAR_MIPMAP_NEAREST,[sh]:t.LINEAR_MIPMAP_LINEAR},U={[Tde]:t.NEVER,[Dde]:t.ALWAYS,[Cde]:t.LESS,[i7]:t.LEQUAL,[Nde]:t.EQUAL,[Rde]:t.GEQUAL,[kde]:t.GREATER,[Pde]:t.NOTEQUAL};function $(B,j){if(j.type===ac&&e.has("OES_texture_float_linear")===!1&&(j.magFilter===Za||j.magFilter===cA||j.magFilter===ey||j.magFilter===sh||j.minFilter===Za||j.minFilter===cA||j.minFilter===ey||j.minFilter===sh)&&Xt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(B,t.TEXTURE_WRAP_S,Y[j.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,Y[j.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,Y[j.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,Z[j.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,Z[j.minFilter]),j.compareFunction&&(t.texParameteri(B,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(B,t.TEXTURE_COMPARE_FUNC,U[j.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(j.magFilter===ga||j.minFilter!==ey&&j.minFilter!==sh||j.type===ac&&e.has("OES_texture_float_linear")===!1)return;if(j.anisotropy>1||r.get(j).__currentAnisotropy){const te=e.get("EXT_texture_filter_anisotropic");t.texParameterf(B,te.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(j.anisotropy,i.getMaxAnisotropy())),r.get(j).__currentAnisotropy=j.anisotropy}}}function ee(B,j){let te=!1;B.__webglInit===void 0&&(B.__webglInit=!0,j.addEventListener("dispose",P));const be=j.source;let _e=g.get(be);_e===void 0&&(_e={},g.set(be,_e));const ge=R(j);if(ge!==B.__cacheKey){_e[ge]===void 0&&(_e[ge]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,te=!0),_e[ge].usedTimes++;const me=_e[B.__cacheKey];me!==void 0&&(_e[B.__cacheKey].usedTimes--,me.usedTimes===0&&N(j)),B.__cacheKey=ge,B.__webglTexture=_e[ge].texture}return te}function ae(B,j,te){return Math.floor(Math.floor(B/te)/j)}function fe(B,j,te,be){const ge=B.updateRanges;if(ge.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,j.width,j.height,te,be,j.data);else{ge.sort((Ve,ce)=>Ve.start-ce.start);let me=0;for(let Ve=1;Ve<ge.length;Ve++){const ce=ge[me],Ye=ge[Ve],$e=ce.start+ce.count,Ze=ae(Ye.start,j.width,4),at=ae(ce.start,j.width,4);Ye.start<=$e+1&&Ze===at&&ae(Ye.start+Ye.count-1,j.width,4)===Ze?ce.count=Math.max(ce.count,Ye.start+Ye.count-ce.start):(++me,ge[me]=Ye)}ge.length=me+1;const Ae=t.getParameter(t.UNPACK_ROW_LENGTH),ze=t.getParameter(t.UNPACK_SKIP_PIXELS),st=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,j.width);for(let Ve=0,ce=ge.length;Ve<ce;Ve++){const Ye=ge[Ve],$e=Math.floor(Ye.start/4),Ze=Math.ceil(Ye.count/4),at=$e%j.width,Q=Math.floor($e/j.width),Fe=Ze,pe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,at),t.pixelStorei(t.UNPACK_SKIP_ROWS,Q),n.texSubImage2D(t.TEXTURE_2D,0,at,Q,Fe,pe,te,be,j.data)}B.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ae),t.pixelStorei(t.UNPACK_SKIP_PIXELS,ze),t.pixelStorei(t.UNPACK_SKIP_ROWS,st)}}function ue(B,j,te){let be=t.TEXTURE_2D;(j.isDataArrayTexture||j.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),j.isData3DTexture&&(be=t.TEXTURE_3D);const _e=ee(B,j),ge=j.source;n.bindTexture(be,B.__webglTexture,t.TEXTURE0+te);const me=r.get(ge);if(ge.version!==me.__version||_e===!0){n.activeTexture(t.TEXTURE0+te);const Ae=An.getPrimaries(An.workingColorSpace),ze=j.colorSpace===ku?null:An.getPrimaries(j.colorSpace),st=j.colorSpace===ku||Ae===ze?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,st);let Ve=y(j.image,!1,i.maxTextureSize);Ve=Ne(j,Ve);const ce=s.convert(j.format,j.colorSpace),Ye=s.convert(j.type);let $e=S(j.internalFormat,ce,Ye,j.colorSpace,j.isVideoTexture);$(be,j);let Ze;const at=j.mipmaps,Q=j.isVideoTexture!==!0,Fe=me.__version===void 0||_e===!0,pe=ge.dataReady,Ue=T(j,Ve);if(j.isDepthTexture)$e=A(j.format===b0,j.type),Fe&&(Q?n.texStorage2D(t.TEXTURE_2D,1,$e,Ve.width,Ve.height):n.texImage2D(t.TEXTURE_2D,0,$e,Ve.width,Ve.height,0,ce,Ye,null));else if(j.isDataTexture)if(at.length>0){Q&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,$e,at[0].width,at[0].height);for(let Ce=0,ye=at.length;Ce<ye;Ce++)Ze=at[Ce],Q?pe&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ze.width,Ze.height,ce,Ye,Ze.data):n.texImage2D(t.TEXTURE_2D,Ce,$e,Ze.width,Ze.height,0,ce,Ye,Ze.data);j.generateMipmaps=!1}else Q?(Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ve.width,Ve.height),pe&&fe(j,Ve,ce,Ye)):n.texImage2D(t.TEXTURE_2D,0,$e,Ve.width,Ve.height,0,ce,Ye,Ve.data);else if(j.isCompressedTexture)if(j.isCompressedArrayTexture){Q&&Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,$e,at[0].width,at[0].height,Ve.depth);for(let Ce=0,ye=at.length;Ce<ye;Ce++)if(Ze=at[Ce],j.format!==Co)if(ce!==null)if(Q){if(pe)if(j.layerUpdates.size>0){const He=hF(Ze.width,Ze.height,j.format,j.type);for(const ht of j.layerUpdates){const wt=Ze.data.subarray(ht*He/Ze.data.BYTES_PER_ELEMENT,(ht+1)*He/Ze.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,ht,Ze.width,Ze.height,1,ce,wt)}j.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ze.width,Ze.height,Ve.depth,ce,Ze.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ce,$e,Ze.width,Ze.height,Ve.depth,0,Ze.data,0,0);else Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Q?pe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ze.width,Ze.height,Ve.depth,ce,Ye,Ze.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ce,$e,Ze.width,Ze.height,Ve.depth,0,ce,Ye,Ze.data)}else{Q&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,$e,at[0].width,at[0].height);for(let Ce=0,ye=at.length;Ce<ye;Ce++)Ze=at[Ce],j.format!==Co?ce!==null?Q?pe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ce,0,0,Ze.width,Ze.height,ce,Ze.data):n.compressedTexImage2D(t.TEXTURE_2D,Ce,$e,Ze.width,Ze.height,0,Ze.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Q?pe&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ze.width,Ze.height,ce,Ye,Ze.data):n.texImage2D(t.TEXTURE_2D,Ce,$e,Ze.width,Ze.height,0,ce,Ye,Ze.data)}else if(j.isDataArrayTexture)if(Q){if(Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,$e,Ve.width,Ve.height,Ve.depth),pe)if(j.layerUpdates.size>0){const Ce=hF(Ve.width,Ve.height,j.format,j.type);for(const ye of j.layerUpdates){const He=Ve.data.subarray(ye*Ce/Ve.data.BYTES_PER_ELEMENT,(ye+1)*Ce/Ve.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,ye,Ve.width,Ve.height,1,ce,Ye,He)}j.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ve.width,Ve.height,Ve.depth,ce,Ye,Ve.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,$e,Ve.width,Ve.height,Ve.depth,0,ce,Ye,Ve.data);else if(j.isData3DTexture)Q?(Fe&&n.texStorage3D(t.TEXTURE_3D,Ue,$e,Ve.width,Ve.height,Ve.depth),pe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ve.width,Ve.height,Ve.depth,ce,Ye,Ve.data)):n.texImage3D(t.TEXTURE_3D,0,$e,Ve.width,Ve.height,Ve.depth,0,ce,Ye,Ve.data);else if(j.isFramebufferTexture){if(Fe)if(Q)n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ve.width,Ve.height);else{let Ce=Ve.width,ye=Ve.height;for(let He=0;He<Ue;He++)n.texImage2D(t.TEXTURE_2D,He,$e,Ce,ye,0,ce,Ye,null),Ce>>=1,ye>>=1}}else if(at.length>0){if(Q&&Fe){const Ce=we(at[0]);n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ce.width,Ce.height)}for(let Ce=0,ye=at.length;Ce<ye;Ce++)Ze=at[Ce],Q?pe&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,ce,Ye,Ze):n.texImage2D(t.TEXTURE_2D,Ce,$e,ce,Ye,Ze);j.generateMipmaps=!1}else if(Q){if(Fe){const Ce=we(Ve);n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ce.width,Ce.height)}pe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ce,Ye,Ve)}else n.texImage2D(t.TEXTURE_2D,0,$e,ce,Ye,Ve);v(j)&&b(be),me.__version=ge.version,j.onUpdate&&j.onUpdate(j)}B.__version=j.version}function xe(B,j,te){if(j.image.length!==6)return;const be=ee(B,j),_e=j.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+te);const ge=r.get(_e);if(_e.version!==ge.__version||be===!0){n.activeTexture(t.TEXTURE0+te);const me=An.getPrimaries(An.workingColorSpace),Ae=j.colorSpace===ku?null:An.getPrimaries(j.colorSpace),ze=j.colorSpace===ku||me===Ae?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ze);const st=j.isCompressedTexture||j.image[0].isCompressedTexture,Ve=j.image[0]&&j.image[0].isDataTexture,ce=[];for(let ye=0;ye<6;ye++)!st&&!Ve?ce[ye]=y(j.image[ye],!0,i.maxCubemapSize):ce[ye]=Ve?j.image[ye].image:j.image[ye],ce[ye]=Ne(j,ce[ye]);const Ye=ce[0],$e=s.convert(j.format,j.colorSpace),Ze=s.convert(j.type),at=S(j.internalFormat,$e,Ze,j.colorSpace),Q=j.isVideoTexture!==!0,Fe=ge.__version===void 0||be===!0,pe=_e.dataReady;let Ue=T(j,Ye);$(t.TEXTURE_CUBE_MAP,j);let Ce;if(st){Q&&Fe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,at,Ye.width,Ye.height);for(let ye=0;ye<6;ye++){Ce=ce[ye].mipmaps;for(let He=0;He<Ce.length;He++){const ht=Ce[He];j.format!==Co?$e!==null?Q?pe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He,0,0,ht.width,ht.height,$e,ht.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He,at,ht.width,ht.height,0,ht.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He,0,0,ht.width,ht.height,$e,Ze,ht.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He,at,ht.width,ht.height,0,$e,Ze,ht.data)}}}else{if(Ce=j.mipmaps,Q&&Fe){Ce.length>0&&Ue++;const ye=we(ce[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,at,ye.width,ye.height)}for(let ye=0;ye<6;ye++)if(Ve){Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,ce[ye].width,ce[ye].height,$e,Ze,ce[ye].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,at,ce[ye].width,ce[ye].height,0,$e,Ze,ce[ye].data);for(let He=0;He<Ce.length;He++){const wt=Ce[He].image[ye].image;Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He+1,0,0,wt.width,wt.height,$e,Ze,wt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He+1,at,wt.width,wt.height,0,$e,Ze,wt.data)}}else{Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,$e,Ze,ce[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,at,$e,Ze,ce[ye]);for(let He=0;He<Ce.length;He++){const ht=Ce[He];Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He+1,0,0,$e,Ze,ht.image[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He+1,at,$e,Ze,ht.image[ye])}}}v(j)&&b(t.TEXTURE_CUBE_MAP),ge.__version=_e.version,j.onUpdate&&j.onUpdate(j)}B.__version=j.version}function Me(B,j,te,be,_e,ge){const me=s.convert(te.format,te.colorSpace),Ae=s.convert(te.type),ze=S(te.internalFormat,me,Ae,te.colorSpace),st=r.get(j),Ve=r.get(te);if(Ve.__renderTarget=j,!st.__hasExternalTextures){const ce=Math.max(1,j.width>>ge),Ye=Math.max(1,j.height>>ge);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,ge,ze,ce,Ye,j.depth,0,me,Ae,null):n.texImage2D(_e,ge,ze,ce,Ye,0,me,Ae,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),le(j)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,_e,Ve.__webglTexture,0,J(j)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,_e,Ve.__webglTexture,ge),n.bindFramebuffer(t.FRAMEBUFFER,null)}function se(B,j,te){if(t.bindRenderbuffer(t.RENDERBUFFER,B),j.depthBuffer){const be=j.depthTexture,_e=be&&be.isDepthTexture?be.type:null,ge=A(j.stencilBuffer,_e),me=j.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ae=J(j);le(j)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ae,ge,j.width,j.height):te?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ae,ge,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,ge,j.width,j.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,me,t.RENDERBUFFER,B)}else{const be=j.textures;for(let _e=0;_e<be.length;_e++){const ge=be[_e],me=s.convert(ge.format,ge.colorSpace),Ae=s.convert(ge.type),ze=S(ge.internalFormat,me,Ae,ge.colorSpace),st=J(j);te&&le(j)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,st,ze,j.width,j.height):le(j)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,st,ze,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,ze,j.width,j.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ve(B,j){if(j&&j.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,B),!(j.depthTexture&&j.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const be=r.get(j.depthTexture);be.__renderTarget=j,(!be.__webglTexture||j.depthTexture.image.width!==j.width||j.depthTexture.image.height!==j.height)&&(j.depthTexture.image.width=j.width,j.depthTexture.image.height=j.height,j.depthTexture.needsUpdate=!0),V(j.depthTexture,0);const _e=be.__webglTexture,ge=J(j);if(j.depthTexture.format===x0)le(j)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0,ge):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0);else if(j.depthTexture.format===b0)le(j)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0,ge):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0);else throw new Error("Unknown depthTexture format")}function je(B){const j=r.get(B),te=B.isWebGLCubeRenderTarget===!0;if(j.__boundDepthTexture!==B.depthTexture){const be=B.depthTexture;if(j.__depthDisposeCallback&&j.__depthDisposeCallback(),be){const _e=()=>{delete j.__boundDepthTexture,delete j.__depthDisposeCallback,be.removeEventListener("dispose",_e)};be.addEventListener("dispose",_e),j.__depthDisposeCallback=_e}j.__boundDepthTexture=be}if(B.depthTexture&&!j.__autoAllocateDepthBuffer){if(te)throw new Error("target.depthTexture not supported in Cube render targets");const be=B.texture.mipmaps;be&&be.length>0?ve(j.__webglFramebuffer[0],B):ve(j.__webglFramebuffer,B)}else if(te){j.__webglDepthbuffer=[];for(let be=0;be<6;be++)if(n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer[be]),j.__webglDepthbuffer[be]===void 0)j.__webglDepthbuffer[be]=t.createRenderbuffer(),se(j.__webglDepthbuffer[be],B,!1);else{const _e=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ge=j.__webglDepthbuffer[be];t.bindRenderbuffer(t.RENDERBUFFER,ge),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,ge)}}else{const be=B.texture.mipmaps;if(be&&be.length>0?n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer),j.__webglDepthbuffer===void 0)j.__webglDepthbuffer=t.createRenderbuffer(),se(j.__webglDepthbuffer,B,!1);else{const _e=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ge=j.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ge),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,ge)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function de(B,j,te){const be=r.get(B);j!==void 0&&Me(be.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),te!==void 0&&je(B)}function ut(B){const j=B.texture,te=r.get(B),be=r.get(j);B.addEventListener("dispose",C);const _e=B.textures,ge=B.isWebGLCubeRenderTarget===!0,me=_e.length>1;if(me||(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=j.version,a.memory.textures++),ge){te.__webglFramebuffer=[];for(let Ae=0;Ae<6;Ae++)if(j.mipmaps&&j.mipmaps.length>0){te.__webglFramebuffer[Ae]=[];for(let ze=0;ze<j.mipmaps.length;ze++)te.__webglFramebuffer[Ae][ze]=t.createFramebuffer()}else te.__webglFramebuffer[Ae]=t.createFramebuffer()}else{if(j.mipmaps&&j.mipmaps.length>0){te.__webglFramebuffer=[];for(let Ae=0;Ae<j.mipmaps.length;Ae++)te.__webglFramebuffer[Ae]=t.createFramebuffer()}else te.__webglFramebuffer=t.createFramebuffer();if(me)for(let Ae=0,ze=_e.length;Ae<ze;Ae++){const st=r.get(_e[Ae]);st.__webglTexture===void 0&&(st.__webglTexture=t.createTexture(),a.memory.textures++)}if(B.samples>0&&le(B)===!1){te.__webglMultisampledFramebuffer=t.createFramebuffer(),te.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,te.__webglMultisampledFramebuffer);for(let Ae=0;Ae<_e.length;Ae++){const ze=_e[Ae];te.__webglColorRenderbuffer[Ae]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,te.__webglColorRenderbuffer[Ae]);const st=s.convert(ze.format,ze.colorSpace),Ve=s.convert(ze.type),ce=S(ze.internalFormat,st,Ve,ze.colorSpace,B.isXRRenderTarget===!0),Ye=J(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ye,ce,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ae,t.RENDERBUFFER,te.__webglColorRenderbuffer[Ae])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(te.__webglDepthRenderbuffer=t.createRenderbuffer(),se(te.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ge){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),$(t.TEXTURE_CUBE_MAP,j);for(let Ae=0;Ae<6;Ae++)if(j.mipmaps&&j.mipmaps.length>0)for(let ze=0;ze<j.mipmaps.length;ze++)Me(te.__webglFramebuffer[Ae][ze],B,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,ze);else Me(te.__webglFramebuffer[Ae],B,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0);v(j)&&b(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(me){for(let Ae=0,ze=_e.length;Ae<ze;Ae++){const st=_e[Ae],Ve=r.get(st);let ce=t.TEXTURE_2D;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(ce=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ce,Ve.__webglTexture),$(ce,st),Me(te.__webglFramebuffer,B,st,t.COLOR_ATTACHMENT0+Ae,ce,0),v(st)&&b(ce)}n.unbindTexture()}else{let Ae=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(Ae=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ae,be.__webglTexture),$(Ae,j),j.mipmaps&&j.mipmaps.length>0)for(let ze=0;ze<j.mipmaps.length;ze++)Me(te.__webglFramebuffer[ze],B,j,t.COLOR_ATTACHMENT0,Ae,ze);else Me(te.__webglFramebuffer,B,j,t.COLOR_ATTACHMENT0,Ae,0);v(j)&&b(Ae),n.unbindTexture()}B.depthBuffer&&je(B)}function H(B){const j=B.textures;for(let te=0,be=j.length;te<be;te++){const _e=j[te];if(v(_e)){const ge=E(B),me=r.get(_e).__webglTexture;n.bindTexture(ge,me),b(ge),n.unbindTexture()}}}const z=[],re=[];function G(B){if(B.samples>0){if(le(B)===!1){const j=B.textures,te=B.width,be=B.height;let _e=t.COLOR_BUFFER_BIT;const ge=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,me=r.get(B),Ae=j.length>1;if(Ae)for(let st=0;st<j.length;st++)n.bindFramebuffer(t.FRAMEBUFFER,me.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,me.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,me.__webglMultisampledFramebuffer);const ze=B.texture.mipmaps;ze&&ze.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,me.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,me.__webglFramebuffer);for(let st=0;st<j.length;st++){if(B.resolveDepthBuffer&&(B.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&B.resolveStencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Ae){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,me.__webglColorRenderbuffer[st]);const Ve=r.get(j[st]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ve,0)}t.blitFramebuffer(0,0,te,be,0,0,te,be,_e,t.NEAREST),l===!0&&(z.length=0,re.length=0,z.push(t.COLOR_ATTACHMENT0+st),B.depthBuffer&&B.resolveDepthBuffer===!1&&(z.push(ge),re.push(ge),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,re)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,z))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ae)for(let st=0;st<j.length;st++){n.bindFramebuffer(t.FRAMEBUFFER,me.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,me.__webglColorRenderbuffer[st]);const Ve=r.get(j[st]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,me.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,Ve,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,me.__webglMultisampledFramebuffer)}else if(B.depthBuffer&&B.resolveDepthBuffer===!1&&l){const j=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[j])}}}function J(B){return Math.min(i.maxSamples,B.samples)}function le(B){const j=r.get(B);return B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&j.__useRenderToTexture!==!1}function ke(B){const j=a.render.frame;d.get(B)!==j&&(d.set(B,j),B.update())}function Ne(B,j){const te=B.colorSpace,be=B.format,_e=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||te!==um&&te!==ku&&(An.getTransfer(te)===Hn?(be!==Co||_e!==ll)&&Xt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):jr("WebGLTextures: Unsupported texture color space:",te)),j}function we(B){return typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement?(u.width=B.naturalWidth||B.width,u.height=B.naturalHeight||B.height):typeof VideoFrame<"u"&&B instanceof VideoFrame?(u.width=B.displayWidth,u.height=B.displayHeight):(u.width=B.width,u.height=B.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=L,this.setTexture2D=V,this.setTexture2DArray=K,this.setTexture3D=W,this.setTextureCube=ne,this.rebindTextures=de,this.setupRenderTarget=ut,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=G,this.setupDepthRenderbuffer=je,this.setupFrameBufferTexture=Me,this.useMultisampledRTT=le}function exe(t,e){function n(r,i=ku){let s;const a=An.getTransfer(i);if(r===ll)return t.UNSIGNED_BYTE;if(r===TR)return t.UNSIGNED_SHORT_4_4_4_4;if(r===CR)return t.UNSIGNED_SHORT_5_5_5_1;if(r===QG)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===JG)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===YG)return t.BYTE;if(r===ZG)return t.SHORT;if(r===m0)return t.UNSIGNED_SHORT;if(r===AR)return t.INT;if(r===Lh)return t.UNSIGNED_INT;if(r===ac)return t.FLOAT;if(r===Um)return t.HALF_FLOAT;if(r===e7)return t.ALPHA;if(r===t7)return t.RGB;if(r===Co)return t.RGBA;if(r===x0)return t.DEPTH_COMPONENT;if(r===b0)return t.DEPTH_STENCIL;if(r===n7)return t.RED;if(r===NR)return t.RED_INTEGER;if(r===kR)return t.RG;if(r===PR)return t.RG_INTEGER;if(r===RR)return t.RGBA_INTEGER;if(r===j_||r===L_||r===I_||r===U_)if(a===Hn)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===j_)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===L_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===I_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===U_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===j_)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===L_)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===I_)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===U_)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===E3||r===M3||r===A3||r===T3)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===E3)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===M3)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===A3)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===T3)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===C3||r===N3||r===k3)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===C3||r===N3)return a===Hn?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===k3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===P3||r===R3||r===D3||r===O3||r===j3||r===L3||r===I3||r===U3||r===F3||r===z3||r===B3||r===H3||r===$3||r===V3)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===P3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===R3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===D3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===O3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===j3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===L3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===I3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===U3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===F3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===z3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===B3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===H3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===$3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===V3)return a===Hn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===G3||r===W3||r===q3)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===G3)return a===Hn?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===W3)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===q3)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===K3||r===X3||r===Y3||r===Z3)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===K3)return s.COMPRESSED_RED_RGTC1_EXT;if(r===X3)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===Y3)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===Z3)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===g0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const txe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,nxe=`
- 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 rxe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new S7(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 yc({vertexShader:txe,fragmentShader:nxe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new cl(new UR(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let ixe=class extends nf{constructor(e,n){super();const r=this;let i=null,s=1,a=null,o="local-floor",l=1,u=null,d=null,f=null,g=null,m=null,x=null;const y=typeof XRWebGLBinding<"u",v=new rxe,b={},E=n.getContextAttributes();let S=null,A=null;const T=[],P=[],C=new on;let I=null;const N=new Ga;N.viewport=new Wr;const D=new Ga;D.viewport=new Wr;const F=[N,D],L=new _he;let q=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ue){let xe=T[ue];return xe===void 0&&(xe=new PA,T[ue]=xe),xe.getTargetRaySpace()},this.getControllerGrip=function(ue){let xe=T[ue];return xe===void 0&&(xe=new PA,T[ue]=xe),xe.getGripSpace()},this.getHand=function(ue){let xe=T[ue];return xe===void 0&&(xe=new PA,T[ue]=xe),xe.getHandSpace()};function V(ue){const xe=P.indexOf(ue.inputSource);if(xe===-1)return;const Me=T[xe];Me!==void 0&&(Me.update(ue.inputSource,ue.frame,u||a),Me.dispatchEvent({type:ue.type,data:ue.inputSource}))}function K(){i.removeEventListener("select",V),i.removeEventListener("selectstart",V),i.removeEventListener("selectend",V),i.removeEventListener("squeeze",V),i.removeEventListener("squeezestart",V),i.removeEventListener("squeezeend",V),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",W);for(let ue=0;ue<T.length;ue++){const xe=P[ue];xe!==null&&(P[ue]=null,T[ue].disconnect(xe))}q=null,R=null,v.reset();for(const ue in b)delete b[ue];e.setRenderTarget(S),m=null,g=null,f=null,i=null,A=null,fe.stop(),r.isPresenting=!1,e.setPixelRatio(I),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ue){s=ue,r.isPresenting===!0&&Xt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ue){o=ue,r.isPresenting===!0&&Xt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||a},this.setReferenceSpace=function(ue){u=ue},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ue){if(i=ue,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",V),i.addEventListener("selectstart",V),i.addEventListener("selectend",V),i.addEventListener("squeeze",V),i.addEventListener("squeezestart",V),i.addEventListener("squeezeend",V),i.addEventListener("end",K),i.addEventListener("inputsourceschange",W),E.xrCompatible!==!0&&await n.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(C),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Me=null,se=null,ve=null;E.depth&&(ve=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Me=E.stencil?b0:x0,se=E.stencil?g0:Lh);const je={colorFormat:n.RGBA8,depthFormat:ve,scaleFactor:s};f=this.getBinding(),g=f.createProjectionLayer(je),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),A=new Uh(g.textureWidth,g.textureHeight,{format:Co,type:ll,depthTexture:new w7(g.textureWidth,g.textureHeight,se,void 0,void 0,void 0,void 0,void 0,void 0,Me),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Me={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,Me),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),A=new Uh(m.framebufferWidth,m.framebufferHeight,{format:Co,type:ll,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(l),u=null,a=await i.requestReferenceSpace(o),fe.setContext(i),fe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function W(ue){for(let xe=0;xe<ue.removed.length;xe++){const Me=ue.removed[xe],se=P.indexOf(Me);se>=0&&(P[se]=null,T[se].disconnect(Me))}for(let xe=0;xe<ue.added.length;xe++){const Me=ue.added[xe];let se=P.indexOf(Me);if(se===-1){for(let je=0;je<T.length;je++)if(je>=P.length){P.push(Me),se=je;break}else if(P[je]===null){P[je]=Me,se=je;break}if(se===-1)break}const ve=T[se];ve&&ve.connect(Me)}}const ne=new Je,Y=new Je;function Z(ue,xe,Me){ne.setFromMatrixPosition(xe.matrixWorld),Y.setFromMatrixPosition(Me.matrixWorld);const se=ne.distanceTo(Y),ve=xe.projectionMatrix.elements,je=Me.projectionMatrix.elements,de=ve[14]/(ve[10]-1),ut=ve[14]/(ve[10]+1),H=(ve[9]+1)/ve[5],z=(ve[9]-1)/ve[5],re=(ve[8]-1)/ve[0],G=(je[8]+1)/je[0],J=de*re,le=de*G,ke=se/(-re+G),Ne=ke*-re;if(xe.matrixWorld.decompose(ue.position,ue.quaternion,ue.scale),ue.translateX(Ne),ue.translateZ(ke),ue.matrixWorld.compose(ue.position,ue.quaternion,ue.scale),ue.matrixWorldInverse.copy(ue.matrixWorld).invert(),ve[10]===-1)ue.projectionMatrix.copy(xe.projectionMatrix),ue.projectionMatrixInverse.copy(xe.projectionMatrixInverse);else{const we=de+ke,B=ut+ke,j=J-Ne,te=le+(se-Ne),be=H*ut/B*we,_e=z*ut/B*we;ue.projectionMatrix.makePerspective(j,te,be,_e,we,B),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert()}}function U(ue,xe){xe===null?ue.matrixWorld.copy(ue.matrix):ue.matrixWorld.multiplyMatrices(xe.matrixWorld,ue.matrix),ue.matrixWorldInverse.copy(ue.matrixWorld).invert()}this.updateCamera=function(ue){if(i===null)return;let xe=ue.near,Me=ue.far;v.texture!==null&&(v.depthNear>0&&(xe=v.depthNear),v.depthFar>0&&(Me=v.depthFar)),L.near=D.near=N.near=xe,L.far=D.far=N.far=Me,(q!==L.near||R!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),q=L.near,R=L.far),L.layers.mask=ue.layers.mask|6,N.layers.mask=L.layers.mask&3,D.layers.mask=L.layers.mask&5;const se=ue.parent,ve=L.cameras;U(L,se);for(let je=0;je<ve.length;je++)U(ve[je],se);ve.length===2?Z(L,N,D):L.projectionMatrix.copy(N.projectionMatrix),$(ue,L,se)};function $(ue,xe,Me){Me===null?ue.matrix.copy(xe.matrixWorld):(ue.matrix.copy(Me.matrixWorld),ue.matrix.invert(),ue.matrix.multiply(xe.matrixWorld)),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.updateMatrixWorld(!0),ue.projectionMatrix.copy(xe.projectionMatrix),ue.projectionMatrixInverse.copy(xe.projectionMatrixInverse),ue.isPerspectiveCamera&&(ue.fov=Q3*2*Math.atan(1/ue.projectionMatrix.elements[5]),ue.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(ue){l=ue,g!==null&&(g.fixedFoveation=ue),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ue)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(L)},this.getCameraTexture=function(ue){return b[ue]};let ee=null;function ae(ue,xe){if(d=xe.getViewerPose(u||a),x=xe,d!==null){const Me=d.views;m!==null&&(e.setRenderTargetFramebuffer(A,m.framebuffer),e.setRenderTarget(A));let se=!1;Me.length!==L.cameras.length&&(L.cameras.length=0,se=!0);for(let ut=0;ut<Me.length;ut++){const H=Me[ut];let z=null;if(m!==null)z=m.getViewport(H);else{const G=f.getViewSubImage(g,H);z=G.viewport,ut===0&&(e.setRenderTargetTextures(A,G.colorTexture,G.depthStencilTexture),e.setRenderTarget(A))}let re=F[ut];re===void 0&&(re=new Ga,re.layers.enable(ut),re.viewport=new Wr,F[ut]=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(z.x,z.y,z.width,z.height),ut===0&&(L.matrix.copy(re.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),se===!0&&L.cameras.push(re)}const ve=i.enabledFeatures;if(ve&&ve.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const ut=f.getDepthInformation(Me[0]);ut&&ut.isValid&&ut.texture&&v.init(ut,i.renderState)}if(ve&&ve.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let ut=0;ut<Me.length;ut++){const H=Me[ut].camera;if(H){let z=b[H];z||(z=new S7,b[H]=z);const re=f.getCameraImage(H);z.sourceTexture=re}}}}for(let Me=0;Me<T.length;Me++){const se=P[Me],ve=T[Me];se!==null&&ve!==void 0&&ve.update(se,xe,u||a)}ee&&ee(ue,xe),xe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:xe}),x=null}const fe=new T7;fe.setAnimationLoop(ae),this.setAnimationLoop=function(ue){ee=ue},this.dispose=function(){}}};const Bd=new td,sxe=new Jr;function axe(t,e){function n(v,b){v.matrixAutoUpdate===!0&&v.updateMatrix(),b.value.copy(v.matrix)}function r(v,b){b.color.getRGB(v.fogColor.value,b7(t)),b.isFog?(v.fogNear.value=b.near,v.fogFar.value=b.far):b.isFogExp2&&(v.fogDensity.value=b.density)}function i(v,b,E,S,A){b.isMeshBasicMaterial||b.isMeshLambertMaterial?s(v,b):b.isMeshToonMaterial?(s(v,b),f(v,b)):b.isMeshPhongMaterial?(s(v,b),d(v,b)):b.isMeshStandardMaterial?(s(v,b),g(v,b),b.isMeshPhysicalMaterial&&m(v,b,A)):b.isMeshMatcapMaterial?(s(v,b),x(v,b)):b.isMeshDepthMaterial?s(v,b):b.isMeshDistanceMaterial?(s(v,b),y(v,b)):b.isMeshNormalMaterial?s(v,b):b.isLineBasicMaterial?(a(v,b),b.isLineDashedMaterial&&o(v,b)):b.isPointsMaterial?l(v,b,E,S):b.isSpriteMaterial?u(v,b):b.isShadowMaterial?(v.color.value.copy(b.color),v.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function s(v,b){v.opacity.value=b.opacity,b.color&&v.diffuse.value.copy(b.color),b.emissive&&v.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.bumpMap&&(v.bumpMap.value=b.bumpMap,n(b.bumpMap,v.bumpMapTransform),v.bumpScale.value=b.bumpScale,b.side===$s&&(v.bumpScale.value*=-1)),b.normalMap&&(v.normalMap.value=b.normalMap,n(b.normalMap,v.normalMapTransform),v.normalScale.value.copy(b.normalScale),b.side===$s&&v.normalScale.value.negate()),b.displacementMap&&(v.displacementMap.value=b.displacementMap,n(b.displacementMap,v.displacementMapTransform),v.displacementScale.value=b.displacementScale,v.displacementBias.value=b.displacementBias),b.emissiveMap&&(v.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,v.emissiveMapTransform)),b.specularMap&&(v.specularMap.value=b.specularMap,n(b.specularMap,v.specularMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest);const E=e.get(b),S=E.envMap,A=E.envMapRotation;S&&(v.envMap.value=S,Bd.copy(A),Bd.x*=-1,Bd.y*=-1,Bd.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Bd.y*=-1,Bd.z*=-1),v.envMapRotation.value.setFromMatrix4(sxe.makeRotationFromEuler(Bd)),v.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=b.reflectivity,v.ior.value=b.ior,v.refractionRatio.value=b.refractionRatio),b.lightMap&&(v.lightMap.value=b.lightMap,v.lightMapIntensity.value=b.lightMapIntensity,n(b.lightMap,v.lightMapTransform)),b.aoMap&&(v.aoMap.value=b.aoMap,v.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,v.aoMapTransform))}function a(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform))}function o(v,b){v.dashSize.value=b.dashSize,v.totalSize.value=b.dashSize+b.gapSize,v.scale.value=b.scale}function l(v,b,E,S){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.size.value=b.size*E,v.scale.value=S*.5,b.map&&(v.map.value=b.map,n(b.map,v.uvTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function u(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.rotation.value=b.rotation,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function d(v,b){v.specular.value.copy(b.specular),v.shininess.value=Math.max(b.shininess,1e-4)}function f(v,b){b.gradientMap&&(v.gradientMap.value=b.gradientMap)}function g(v,b){v.metalness.value=b.metalness,b.metalnessMap&&(v.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,v.metalnessMapTransform)),v.roughness.value=b.roughness,b.roughnessMap&&(v.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,v.roughnessMapTransform)),b.envMap&&(v.envMapIntensity.value=b.envMapIntensity)}function m(v,b,E){v.ior.value=b.ior,b.sheen>0&&(v.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),v.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(v.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,v.sheenColorMapTransform)),b.sheenRoughnessMap&&(v.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,v.sheenRoughnessMapTransform))),b.clearcoat>0&&(v.clearcoat.value=b.clearcoat,v.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(v.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,v.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(v.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===$s&&v.clearcoatNormalScale.value.negate())),b.dispersion>0&&(v.dispersion.value=b.dispersion),b.iridescence>0&&(v.iridescence.value=b.iridescence,v.iridescenceIOR.value=b.iridescenceIOR,v.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(v.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,v.iridescenceMapTransform)),b.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),b.transmission>0&&(v.transmission.value=b.transmission,v.transmissionSamplerMap.value=E.texture,v.transmissionSamplerSize.value.set(E.width,E.height),b.transmissionMap&&(v.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,v.transmissionMapTransform)),v.thickness.value=b.thickness,b.thicknessMap&&(v.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=b.attenuationDistance,v.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(v.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(v.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=b.specularIntensity,v.specularColor.value.copy(b.specularColor),b.specularColorMap&&(v.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,v.specularColorMapTransform)),b.specularIntensityMap&&(v.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,v.specularIntensityMapTransform))}function x(v,b){b.matcap&&(v.matcap.value=b.matcap)}function y(v,b){const E=e.get(b).light;v.referencePosition.value.setFromMatrixPosition(E.matrixWorld),v.nearDistance.value=E.shadow.camera.near,v.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function oxe(t,e,n,r){let i={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(E,S){const A=S.program;r.uniformBlockBinding(E,A)}function u(E,S){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",v));const T=S.program;r.updateUBOMapping(E,T);const P=e.render.frame;s[E.id]!==P&&(g(E),s[E.id]=P)}function d(E){const S=f();E.__bindingPointIndex=S;const A=t.createBuffer(),T=E.__size,P=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,P),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let E=0;E<o;E++)if(a.indexOf(E)===-1)return a.push(E),E;return jr("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const S=i[E.id],A=E.uniforms,T=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let P=0,C=A.length;P<C;P++){const I=Array.isArray(A[P])?A[P]:[A[P]];for(let N=0,D=I.length;N<D;N++){const F=I[N];if(m(F,P,N,T)===!0){const L=F.__offset,q=Array.isArray(F.value)?F.value:[F.value];let R=0;for(let V=0;V<q.length;V++){const K=q[V],W=y(K);typeof K=="number"||typeof K=="boolean"?(F.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,L+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+=W.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,L,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(E,S,A,T){const P=E.value,C=S+"_"+A;if(T[C]===void 0)return typeof P=="number"||typeof P=="boolean"?T[C]=P:T[C]=P.clone(),!0;{const I=T[C];if(typeof P=="number"||typeof P=="boolean"){if(I!==P)return T[C]=P,!0}else if(I.equals(P)===!1)return I.copy(P),!0}return!1}function x(E){const S=E.uniforms;let A=0;const T=16;for(let C=0,I=S.length;C<I;C++){const N=Array.isArray(S[C])?S[C]:[S[C]];for(let D=0,F=N.length;D<F;D++){const L=N[D],q=Array.isArray(L.value)?L.value:[L.value];for(let R=0,V=q.length;R<V;R++){const K=q[R],W=y(K),ne=A%T,Y=ne%W.boundary,Z=ne+Y;A+=Y,Z!==0&&T-Z<W.storage&&(A+=T-Z),L.__data=new Float32Array(W.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=A,A+=W.storage}}}const P=A%T;return P>0&&(A+=T-P),E.__size=A,E.__cache={},this}function y(E){const S={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(S.boundary=4,S.storage=4):E.isVector2?(S.boundary=8,S.storage=8):E.isVector3||E.isColor?(S.boundary=16,S.storage=12):E.isVector4?(S.boundary=16,S.storage=16):E.isMatrix3?(S.boundary=48,S.storage=48):E.isMatrix4?(S.boundary=64,S.storage=64):E.isTexture?Xt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Xt("WebGLRenderer: Unsupported uniform value type.",E),S}function v(E){const S=E.target;S.removeEventListener("dispose",v);const A=a.indexOf(S.__bindingPointIndex);a.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete s[S.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);a=[],i={},s={}}return{bind:l,update:u,dispose:b}}const lxe=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 Bl=null;function cxe(){return Bl===null&&(Bl=new che(lxe,32,32,kR,Um),Bl.minFilter=Za,Bl.magFilter=Za,Bl.wrapS=sc,Bl.wrapT=sc,Bl.generateMipmaps=!1,Bl.needsUpdate=!0),Bl}let uxe=class{constructor(e={}){const{canvas:n=Ode(),context:r=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let m;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=r.getContextAttributes().alpha}else m=a;const x=new Set([RR,PR,NR]),y=new Set([ll,Lh,m0,g0,TR,CR]),v=new Uint32Array(4),b=new Int32Array(4);let E=null,S=null;const A=[],T=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Hu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let C=!1;this._outputColorSpace=Ha;let I=0,N=0,D=null,F=-1,L=null;const q=new Wr,R=new Wr;let V=null;const K=new vn(0);let W=0,ne=n.width,Y=n.height,Z=1,U=null,$=null;const ee=new Wr(0,0,ne,Y),ae=new Wr(0,0,ne,Y);let fe=!1;const ue=new IR;let xe=!1,Me=!1;const se=new Jr,ve=new Je,je=new Wr,de={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ut=!1;function H(){return D===null?Z:1}let z=r;function re(ie,Se){return n.getContext(ie,Se)}try{const ie={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${ER}`),n.addEventListener("webglcontextlost",Ce,!1),n.addEventListener("webglcontextrestored",ye,!1),n.addEventListener("webglcontextcreationerror",He,!1),z===null){const Se="webgl2";if(z=re(Se,ie),z===null)throw re(Se)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ie){throw ie("WebGLRenderer: "+ie.message),ie}let G,J,le,ke,Ne,we,B,j,te,be,_e,ge,me,Ae,ze,st,Ve,ce,Ye,$e,Ze,at,Q,Fe;function pe(){G=new bme(z),G.init(),at=new exe(z,G),J=new cme(z,G,e,at),le=new Qge(z,G),J.reversedDepthBuffer&&g&&le.buffers.depth.setReversed(!0),ke=new _me(z),Ne=new Fge,we=new Jge(z,G,le,Ne,J,at,ke),B=new dme(P),j=new xme(P),te=new Mhe(z),Q=new ome(z,te),be=new vme(z,te,ke,Q),_e=new Sme(z,be,te,ke),Ye=new wme(z,J,we),st=new ume(Ne),ge=new Uge(P,B,j,G,J,Q,st),me=new axe(P,Ne),Ae=new Bge,ze=new qge(G),ce=new ame(P,B,j,le,_e,m,l),Ve=new Yge(P,_e,J),Fe=new oxe(z,ke,J,le),$e=new lme(z,G,ke),Ze=new yme(z,G,ke),ke.programs=ge.programs,P.capabilities=J,P.extensions=G,P.properties=Ne,P.renderLists=Ae,P.shadowMap=Ve,P.state=le,P.info=ke}pe();const Ue=new ixe(P,z);this.xr=Ue,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const ie=G.get("WEBGL_lose_context");ie&&ie.loseContext()},this.forceContextRestore=function(){const ie=G.get("WEBGL_lose_context");ie&&ie.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(ie){ie!==void 0&&(Z=ie,this.setSize(ne,Y,!1))},this.getSize=function(ie){return ie.set(ne,Y)},this.setSize=function(ie,Se,Le=!0){if(Ue.isPresenting){Xt("WebGLRenderer: Can't change size while VR device is presenting.");return}ne=ie,Y=Se,n.width=Math.floor(ie*Z),n.height=Math.floor(Se*Z),Le===!0&&(n.style.width=ie+"px",n.style.height=Se+"px"),this.setViewport(0,0,ie,Se)},this.getDrawingBufferSize=function(ie){return ie.set(ne*Z,Y*Z).floor()},this.setDrawingBufferSize=function(ie,Se,Le){ne=ie,Y=Se,Z=Le,n.width=Math.floor(ie*Le),n.height=Math.floor(Se*Le),this.setViewport(0,0,ie,Se)},this.getCurrentViewport=function(ie){return ie.copy(q)},this.getViewport=function(ie){return ie.copy(ee)},this.setViewport=function(ie,Se,Le,Oe){ie.isVector4?ee.set(ie.x,ie.y,ie.z,ie.w):ee.set(ie,Se,Le,Oe),le.viewport(q.copy(ee).multiplyScalar(Z).round())},this.getScissor=function(ie){return ie.copy(ae)},this.setScissor=function(ie,Se,Le,Oe){ie.isVector4?ae.set(ie.x,ie.y,ie.z,ie.w):ae.set(ie,Se,Le,Oe),le.scissor(R.copy(ae).multiplyScalar(Z).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(ie){le.setScissorTest(fe=ie)},this.setOpaqueSort=function(ie){U=ie},this.setTransparentSort=function(ie){$=ie},this.getClearColor=function(ie){return ie.copy(ce.getClearColor())},this.setClearColor=function(){ce.setClearColor(...arguments)},this.getClearAlpha=function(){return ce.getClearAlpha()},this.setClearAlpha=function(){ce.setClearAlpha(...arguments)},this.clear=function(ie=!0,Se=!0,Le=!0){let Oe=0;if(ie){let Te=!1;if(D!==null){const ot=D.texture.format;Te=x.has(ot)}if(Te){const ot=D.texture.type,ft=y.has(ot),bt=ce.getClearColor(),xt=ce.getClearAlpha(),jt=bt.r,Mt=bt.g,mt=bt.b;ft?(v[0]=jt,v[1]=Mt,v[2]=mt,v[3]=xt,z.clearBufferuiv(z.COLOR,0,v)):(b[0]=jt,b[1]=Mt,b[2]=mt,b[3]=xt,z.clearBufferiv(z.COLOR,0,b))}else Oe|=z.COLOR_BUFFER_BIT}Se&&(Oe|=z.DEPTH_BUFFER_BIT),Le&&(Oe|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z.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",ye,!1),n.removeEventListener("webglcontextcreationerror",He,!1),ce.dispose(),Ae.dispose(),ze.dispose(),Ne.dispose(),B.dispose(),j.dispose(),_e.dispose(),Q.dispose(),Fe.dispose(),ge.dispose(),Ue.dispose(),Ue.removeEventListener("sessionstart",Kn),Ue.removeEventListener("sessionend",_i),si.stop()};function Ce(ie){ie.preventDefault(),B5("WebGLRenderer: Context Lost."),C=!0}function ye(){B5("WebGLRenderer: Context Restored."),C=!1;const ie=ke.autoReset,Se=Ve.enabled,Le=Ve.autoUpdate,Oe=Ve.needsUpdate,Te=Ve.type;pe(),ke.autoReset=ie,Ve.enabled=Se,Ve.autoUpdate=Le,Ve.needsUpdate=Oe,Ve.type=Te}function He(ie){jr("WebGLRenderer: A WebGL context could not be created. Reason: ",ie.statusMessage)}function ht(ie){const Se=ie.target;Se.removeEventListener("dispose",ht),wt(Se)}function wt(ie){Ot(ie),Ne.remove(ie)}function Ot(ie){const Se=Ne.get(ie).programs;Se!==void 0&&(Se.forEach(function(Le){ge.releaseProgram(Le)}),ie.isShaderMaterial&&ge.releaseShaderCache(ie))}this.renderBufferDirect=function(ie,Se,Le,Oe,Te,ot){Se===null&&(Se=de);const ft=Te.isMesh&&Te.matrixWorld.determinant()<0,bt=he(ie,Se,Le,Oe,Te);le.setMaterial(Oe,ft);let xt=Le.index,jt=1;if(Oe.wireframe===!0){if(xt=be.getWireframeAttribute(Le),xt===void 0)return;jt=2}const Mt=Le.drawRange,mt=Le.attributes.position;let Kt=Mt.start*jt,Ft=(Mt.start+Mt.count)*jt;ot!==null&&(Kt=Math.max(Kt,ot.start*jt),Ft=Math.min(Ft,(ot.start+ot.count)*jt)),xt!==null?(Kt=Math.max(Kt,0),Ft=Math.min(Ft,xt.count)):mt!=null&&(Kt=Math.max(Kt,0),Ft=Math.min(Ft,mt.count));const nn=Ft-Kt;if(nn<0||nn===1/0)return;Q.setup(Te,Oe,bt,Le,xt);let dn,gn=$e;if(xt!==null&&(dn=te.get(xt),gn=Ze,gn.setIndex(dn)),Te.isMesh)Oe.wireframe===!0?(le.setLineWidth(Oe.wireframeLinewidth*H()),gn.setMode(z.LINES)):gn.setMode(z.TRIANGLES);else if(Te.isLine){let Ut=Oe.linewidth;Ut===void 0&&(Ut=1),le.setLineWidth(Ut*H()),Te.isLineSegments?gn.setMode(z.LINES):Te.isLineLoop?gn.setMode(z.LINE_LOOP):gn.setMode(z.LINE_STRIP)}else Te.isPoints?gn.setMode(z.POINTS):Te.isSprite&&gn.setMode(z.TRIANGLES);if(Te.isBatchedMesh)if(Te._multiDrawInstances!==null)v0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),gn.renderMultiDrawInstances(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount,Te._multiDrawInstances);else if(G.get("WEBGL_multi_draw"))gn.renderMultiDraw(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount);else{const Ut=Te._multiDrawStarts,Zt=Te._multiDrawCounts,Jt=Te._multiDrawCount,Sr=xt?te.get(xt).bytesPerElement:1,Pr=Ne.get(Oe).currentProgram.getUniforms();for(let Pn=0;Pn<Jt;Pn++)Pr.setValue(z,"_gl_DrawID",Pn),gn.render(Ut[Pn]/Sr,Zt[Pn])}else if(Te.isInstancedMesh)gn.renderInstances(Kt,nn,Te.count);else if(Le.isInstancedBufferGeometry){const Ut=Le._maxInstanceCount!==void 0?Le._maxInstanceCount:1/0,Zt=Math.min(Le.instanceCount,Ut);gn.renderInstances(Kt,nn,Zt)}else gn.render(Kt,nn)};function cn(ie,Se,Le){ie.transparent===!0&&ie.side===Jo&&ie.forceSinglePass===!1?(ie.side=$s,ie.needsUpdate=!0,kr(ie,Se,Le),ie.side=ed,ie.needsUpdate=!0,kr(ie,Se,Le),ie.side=Jo):kr(ie,Se,Le)}this.compile=function(ie,Se,Le=null){Le===null&&(Le=ie),S=ze.get(Le),S.init(Se),T.push(S),Le.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Se.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),ie!==Le&&ie.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Se.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),S.setupLights();const Oe=new Set;return ie.traverse(function(Te){if(!(Te.isMesh||Te.isPoints||Te.isLine||Te.isSprite))return;const ot=Te.material;if(ot)if(Array.isArray(ot))for(let ft=0;ft<ot.length;ft++){const bt=ot[ft];cn(bt,Le,Te),Oe.add(bt)}else cn(ot,Le,Te),Oe.add(ot)}),S=T.pop(),Oe},this.compileAsync=function(ie,Se,Le=null){const Oe=this.compile(ie,Se,Le);return new Promise(Te=>{function ot(){if(Oe.forEach(function(ft){Ne.get(ft).currentProgram.isReady()&&Oe.delete(ft)}),Oe.size===0){Te(ie);return}setTimeout(ot,10)}G.get("KHR_parallel_shader_compile")!==null?ot():setTimeout(ot,10)})};let It=null;function Rn(ie){It&&It(ie)}function Kn(){si.stop()}function _i(){si.start()}const si=new T7;si.setAnimationLoop(Rn),typeof self<"u"&&si.setContext(self),this.setAnimationLoop=function(ie){It=ie,Ue.setAnimationLoop(ie),ie===null?si.stop():si.start()},Ue.addEventListener("sessionstart",Kn),Ue.addEventListener("sessionend",_i),this.render=function(ie,Se){if(Se!==void 0&&Se.isCamera!==!0){jr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;if(ie.matrixWorldAutoUpdate===!0&&ie.updateMatrixWorld(),Se.parent===null&&Se.matrixWorldAutoUpdate===!0&&Se.updateMatrixWorld(),Ue.enabled===!0&&Ue.isPresenting===!0&&(Ue.cameraAutoUpdate===!0&&Ue.updateCamera(Se),Se=Ue.getCamera()),ie.isScene===!0&&ie.onBeforeRender(P,ie,Se,D),S=ze.get(ie,T.length),S.init(Se),T.push(S),se.multiplyMatrices(Se.projectionMatrix,Se.matrixWorldInverse),ue.setFromProjectionMatrix(se,nl,Se.reversedDepth),Me=this.localClippingEnabled,xe=st.init(this.clippingPlanes,Me),E=Ae.get(ie,A.length),E.init(),A.push(E),Ue.enabled===!0&&Ue.isPresenting===!0){const ot=P.xr.getDepthSensingMesh();ot!==null&&wi(ot,Se,-1/0,P.sortObjects)}wi(ie,Se,0,P.sortObjects),E.finish(),P.sortObjects===!0&&E.sort(U,$),ut=Ue.enabled===!1||Ue.isPresenting===!1||Ue.hasDepthSensing()===!1,ut&&ce.addToRenderList(E,ie),this.info.render.frame++,xe===!0&&st.beginShadows();const Le=S.state.shadowsArray;Ve.render(Le,ie,Se),xe===!0&&st.endShadows(),this.info.autoReset===!0&&this.info.reset();const Oe=E.opaque,Te=E.transmissive;if(S.setupLights(),Se.isArrayCamera){const ot=Se.cameras;if(Te.length>0)for(let ft=0,bt=ot.length;ft<bt;ft++){const xt=ot[ft];Ji(Oe,Te,ie,xt)}ut&&ce.render(ie);for(let ft=0,bt=ot.length;ft<bt;ft++){const xt=ot[ft];Ii(E,ie,xt,xt.viewport)}}else Te.length>0&&Ji(Oe,Te,ie,Se),ut&&ce.render(ie),Ii(E,ie,Se);D!==null&&N===0&&(we.updateMultisampleRenderTarget(D),we.updateRenderTargetMipmap(D)),ie.isScene===!0&&ie.onAfterRender(P,ie,Se),Q.resetDefaultState(),F=-1,L=null,T.pop(),T.length>0?(S=T[T.length-1],xe===!0&&st.setGlobalState(P.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function wi(ie,Se,Le,Oe){if(ie.visible===!1)return;if(ie.layers.test(Se.layers)){if(ie.isGroup)Le=ie.renderOrder;else if(ie.isLOD)ie.autoUpdate===!0&&ie.update(Se);else if(ie.isLight)S.pushLight(ie),ie.castShadow&&S.pushShadow(ie);else if(ie.isSprite){if(!ie.frustumCulled||ue.intersectsSprite(ie)){Oe&&je.setFromMatrixPosition(ie.matrixWorld).applyMatrix4(se);const ft=_e.update(ie),bt=ie.material;bt.visible&&E.push(ie,ft,bt,Le,je.z,null)}}else if((ie.isMesh||ie.isLine||ie.isPoints)&&(!ie.frustumCulled||ue.intersectsObject(ie))){const ft=_e.update(ie),bt=ie.material;if(Oe&&(ie.boundingSphere!==void 0?(ie.boundingSphere===null&&ie.computeBoundingSphere(),je.copy(ie.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),je.copy(ft.boundingSphere.center)),je.applyMatrix4(ie.matrixWorld).applyMatrix4(se)),Array.isArray(bt)){const xt=ft.groups;for(let jt=0,Mt=xt.length;jt<Mt;jt++){const mt=xt[jt],Kt=bt[mt.materialIndex];Kt&&Kt.visible&&E.push(ie,ft,Kt,Le,je.z,mt)}}else bt.visible&&E.push(ie,ft,bt,Le,je.z,null)}}const ot=ie.children;for(let ft=0,bt=ot.length;ft<bt;ft++)wi(ot[ft],Se,Le,Oe)}function Ii(ie,Se,Le,Oe){const{opaque:Te,transmissive:ot,transparent:ft}=ie;S.setupLightsView(Le),xe===!0&&st.setGlobalState(P.clippingPlanes,Le),Oe&&le.viewport(q.copy(Oe)),Te.length>0&&Ur(Te,Se,Le),ot.length>0&&Ur(ot,Se,Le),ft.length>0&&Ur(ft,Se,Le),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function Ji(ie,Se,Le,Oe){if((Le.isScene===!0?Le.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[Oe.id]===void 0&&(S.state.transmissionRenderTarget[Oe.id]=new Uh(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")||G.has("EXT_color_buffer_float")?Um:ll,minFilter:sh,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:An.workingColorSpace}));const ot=S.state.transmissionRenderTarget[Oe.id],ft=Oe.viewport||q;ot.setSize(ft.z*P.transmissionResolutionScale,ft.w*P.transmissionResolutionScale);const bt=P.getRenderTarget(),xt=P.getActiveCubeFace(),jt=P.getActiveMipmapLevel();P.setRenderTarget(ot),P.getClearColor(K),W=P.getClearAlpha(),W<1&&P.setClearColor(16777215,.5),P.clear(),ut&&ce.render(Le);const Mt=P.toneMapping;P.toneMapping=Hu;const mt=Oe.viewport;if(Oe.viewport!==void 0&&(Oe.viewport=void 0),S.setupLightsView(Oe),xe===!0&&st.setGlobalState(P.clippingPlanes,Oe),Ur(ie,Le,Oe),we.updateMultisampleRenderTarget(ot),we.updateRenderTargetMipmap(ot),G.has("WEBGL_multisampled_render_to_texture")===!1){let Kt=!1;for(let Ft=0,nn=Se.length;Ft<nn;Ft++){const dn=Se[Ft],{object:gn,geometry:Ut,material:Zt,group:Jt}=dn;if(Zt.side===Jo&&gn.layers.test(Oe.layers)){const Sr=Zt.side;Zt.side=$s,Zt.needsUpdate=!0,xr(gn,Le,Oe,Ut,Zt,Jt),Zt.side=Sr,Zt.needsUpdate=!0,Kt=!0}}Kt===!0&&(we.updateMultisampleRenderTarget(ot),we.updateRenderTargetMipmap(ot))}P.setRenderTarget(bt,xt,jt),P.setClearColor(K,W),mt!==void 0&&(Oe.viewport=mt),P.toneMapping=Mt}function Ur(ie,Se,Le){const Oe=Se.isScene===!0?Se.overrideMaterial:null;for(let Te=0,ot=ie.length;Te<ot;Te++){const ft=ie[Te],{object:bt,geometry:xt,group:jt}=ft;let Mt=ft.material;Mt.allowOverride===!0&&Oe!==null&&(Mt=Oe),bt.layers.test(Le.layers)&&xr(bt,Se,Le,xt,Mt,jt)}}function xr(ie,Se,Le,Oe,Te,ot){ie.onBeforeRender(P,Se,Le,Oe,Te,ot),ie.modelViewMatrix.multiplyMatrices(Le.matrixWorldInverse,ie.matrixWorld),ie.normalMatrix.getNormalMatrix(ie.modelViewMatrix),Te.onBeforeRender(P,Se,Le,Oe,ie,ot),Te.transparent===!0&&Te.side===Jo&&Te.forceSinglePass===!1?(Te.side=$s,Te.needsUpdate=!0,P.renderBufferDirect(Le,Se,Oe,Te,ie,ot),Te.side=ed,Te.needsUpdate=!0,P.renderBufferDirect(Le,Se,Oe,Te,ie,ot),Te.side=Jo):P.renderBufferDirect(Le,Se,Oe,Te,ie,ot),ie.onAfterRender(P,Se,Le,Oe,Te,ot)}function kr(ie,Se,Le){Se.isScene!==!0&&(Se=de);const Oe=Ne.get(ie),Te=S.state.lights,ot=S.state.shadowsArray,ft=Te.state.version,bt=ge.getParameters(ie,Te.state,ot,Se,Le),xt=ge.getProgramCacheKey(bt);let jt=Oe.programs;Oe.environment=ie.isMeshStandardMaterial?Se.environment:null,Oe.fog=Se.fog,Oe.envMap=(ie.isMeshStandardMaterial?j:B).get(ie.envMap||Oe.environment),Oe.envMapRotation=Oe.environment!==null&&ie.envMap===null?Se.environmentRotation:ie.envMapRotation,jt===void 0&&(ie.addEventListener("dispose",ht),jt=new Map,Oe.programs=jt);let Mt=jt.get(xt);if(Mt!==void 0){if(Oe.currentProgram===Mt&&Oe.lightsStateVersion===ft)return Ic(ie,bt),Mt}else bt.uniforms=ge.getUniforms(ie),ie.onBeforeCompile(bt,P),Mt=ge.acquireProgram(bt,xt),jt.set(xt,Mt),Oe.uniforms=bt.uniforms;const mt=Oe.uniforms;return(!ie.isShaderMaterial&&!ie.isRawShaderMaterial||ie.clipping===!0)&&(mt.clippingPlanes=st.uniform),Ic(ie,bt),Oe.needsLights=tt(ie),Oe.lightsStateVersion=ft,Oe.needsLights&&(mt.ambientLightColor.value=Te.state.ambient,mt.lightProbe.value=Te.state.probe,mt.directionalLights.value=Te.state.directional,mt.directionalLightShadows.value=Te.state.directionalShadow,mt.spotLights.value=Te.state.spot,mt.spotLightShadows.value=Te.state.spotShadow,mt.rectAreaLights.value=Te.state.rectArea,mt.ltc_1.value=Te.state.rectAreaLTC1,mt.ltc_2.value=Te.state.rectAreaLTC2,mt.pointLights.value=Te.state.point,mt.pointLightShadows.value=Te.state.pointShadow,mt.hemisphereLights.value=Te.state.hemi,mt.directionalShadowMap.value=Te.state.directionalShadowMap,mt.directionalShadowMatrix.value=Te.state.directionalShadowMatrix,mt.spotShadowMap.value=Te.state.spotShadowMap,mt.spotLightMatrix.value=Te.state.spotLightMatrix,mt.spotLightMap.value=Te.state.spotLightMap,mt.pointShadowMap.value=Te.state.pointShadowMap,mt.pointShadowMatrix.value=Te.state.pointShadowMatrix),Oe.currentProgram=Mt,Oe.uniformsList=null,Mt}function co(ie){if(ie.uniformsList===null){const Se=ie.currentProgram.getUniforms();ie.uniformsList=H_.seqWithValue(Se.seq,ie.uniforms)}return ie.uniformsList}function Ic(ie,Se){const Le=Ne.get(ie);Le.outputColorSpace=Se.outputColorSpace,Le.batching=Se.batching,Le.batchingColor=Se.batchingColor,Le.instancing=Se.instancing,Le.instancingColor=Se.instancingColor,Le.instancingMorph=Se.instancingMorph,Le.skinning=Se.skinning,Le.morphTargets=Se.morphTargets,Le.morphNormals=Se.morphNormals,Le.morphColors=Se.morphColors,Le.morphTargetsCount=Se.morphTargetsCount,Le.numClippingPlanes=Se.numClippingPlanes,Le.numIntersection=Se.numClipIntersection,Le.vertexAlphas=Se.vertexAlphas,Le.vertexTangents=Se.vertexTangents,Le.toneMapping=Se.toneMapping}function he(ie,Se,Le,Oe,Te){Se.isScene!==!0&&(Se=de),we.resetTextureUnits();const ot=Se.fog,ft=Oe.isMeshStandardMaterial?Se.environment:null,bt=D===null?P.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:um,xt=(Oe.isMeshStandardMaterial?j:B).get(Oe.envMap||ft),jt=Oe.vertexColors===!0&&!!Le.attributes.color&&Le.attributes.color.itemSize===4,Mt=!!Le.attributes.tangent&&(!!Oe.normalMap||Oe.anisotropy>0),mt=!!Le.morphAttributes.position,Kt=!!Le.morphAttributes.normal,Ft=!!Le.morphAttributes.color;let nn=Hu;Oe.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(nn=P.toneMapping);const dn=Le.morphAttributes.position||Le.morphAttributes.normal||Le.morphAttributes.color,gn=dn!==void 0?dn.length:0,Ut=Ne.get(Oe),Zt=S.state.lights;if(xe===!0&&(Me===!0||ie!==L)){const Ei=ie===L&&Oe.id===F;st.setState(Oe,ie,Ei)}let Jt=!1;Oe.version===Ut.__version?(Ut.needsLights&&Ut.lightsStateVersion!==Zt.state.version||Ut.outputColorSpace!==bt||Te.isBatchedMesh&&Ut.batching===!1||!Te.isBatchedMesh&&Ut.batching===!0||Te.isBatchedMesh&&Ut.batchingColor===!0&&Te.colorTexture===null||Te.isBatchedMesh&&Ut.batchingColor===!1&&Te.colorTexture!==null||Te.isInstancedMesh&&Ut.instancing===!1||!Te.isInstancedMesh&&Ut.instancing===!0||Te.isSkinnedMesh&&Ut.skinning===!1||!Te.isSkinnedMesh&&Ut.skinning===!0||Te.isInstancedMesh&&Ut.instancingColor===!0&&Te.instanceColor===null||Te.isInstancedMesh&&Ut.instancingColor===!1&&Te.instanceColor!==null||Te.isInstancedMesh&&Ut.instancingMorph===!0&&Te.morphTexture===null||Te.isInstancedMesh&&Ut.instancingMorph===!1&&Te.morphTexture!==null||Ut.envMap!==xt||Oe.fog===!0&&Ut.fog!==ot||Ut.numClippingPlanes!==void 0&&(Ut.numClippingPlanes!==st.numPlanes||Ut.numIntersection!==st.numIntersection)||Ut.vertexAlphas!==jt||Ut.vertexTangents!==Mt||Ut.morphTargets!==mt||Ut.morphNormals!==Kt||Ut.morphColors!==Ft||Ut.toneMapping!==nn||Ut.morphTargetsCount!==gn)&&(Jt=!0):(Jt=!0,Ut.__version=Oe.version);let Sr=Ut.currentProgram;Jt===!0&&(Sr=kr(Oe,Se,Te));let Pr=!1,Pn=!1,uo=!1;const Dn=Sr.getUniforms(),Si=Ut.uniforms;if(le.useProgram(Sr.program)&&(Pr=!0,Pn=!0,uo=!0),Oe.id!==F&&(F=Oe.id,Pn=!0),Pr||L!==ie){le.buffers.depth.getReversed()&&ie.reversedDepth!==!0&&(ie._reversedDepth=!0,ie.updateProjectionMatrix()),Dn.setValue(z,"projectionMatrix",ie.projectionMatrix),Dn.setValue(z,"viewMatrix",ie.matrixWorldInverse);const Ui=Dn.map.cameraPosition;Ui!==void 0&&Ui.setValue(z,ve.setFromMatrixPosition(ie.matrixWorld)),J.logarithmicDepthBuffer&&Dn.setValue(z,"logDepthBufFC",2/(Math.log(ie.far+1)/Math.LN2)),(Oe.isMeshPhongMaterial||Oe.isMeshToonMaterial||Oe.isMeshLambertMaterial||Oe.isMeshBasicMaterial||Oe.isMeshStandardMaterial||Oe.isShaderMaterial)&&Dn.setValue(z,"isOrthographic",ie.isOrthographicCamera===!0),L!==ie&&(L=ie,Pn=!0,uo=!0)}if(Te.isSkinnedMesh){Dn.setOptional(z,Te,"bindMatrix"),Dn.setOptional(z,Te,"bindMatrixInverse");const Ei=Te.skeleton;Ei&&(Ei.boneTexture===null&&Ei.computeBoneTexture(),Dn.setValue(z,"boneTexture",Ei.boneTexture,we))}Te.isBatchedMesh&&(Dn.setOptional(z,Te,"batchingTexture"),Dn.setValue(z,"batchingTexture",Te._matricesTexture,we),Dn.setOptional(z,Te,"batchingIdTexture"),Dn.setValue(z,"batchingIdTexture",Te._indirectTexture,we),Dn.setOptional(z,Te,"batchingColorTexture"),Te._colorsTexture!==null&&Dn.setValue(z,"batchingColorTexture",Te._colorsTexture,we));const ai=Le.morphAttributes;if((ai.position!==void 0||ai.normal!==void 0||ai.color!==void 0)&&Ye.update(Te,Le,Sr),(Pn||Ut.receiveShadow!==Te.receiveShadow)&&(Ut.receiveShadow=Te.receiveShadow,Dn.setValue(z,"receiveShadow",Te.receiveShadow)),Oe.isMeshGouraudMaterial&&Oe.envMap!==null&&(Si.envMap.value=xt,Si.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),Oe.isMeshStandardMaterial&&Oe.envMap===null&&Se.environment!==null&&(Si.envMapIntensity.value=Se.environmentIntensity),Si.dfgLUT!==void 0&&(Si.dfgLUT.value=cxe()),Pn&&(Dn.setValue(z,"toneMappingExposure",P.toneMappingExposure),Ut.needsLights&&Ge(Si,uo),ot&&Oe.fog===!0&&me.refreshFogUniforms(Si,ot),me.refreshMaterialUniforms(Si,Oe,Z,Y,S.state.transmissionRenderTarget[ie.id]),H_.upload(z,co(Ut),Si,we)),Oe.isShaderMaterial&&Oe.uniformsNeedUpdate===!0&&(H_.upload(z,co(Ut),Si,we),Oe.uniformsNeedUpdate=!1),Oe.isSpriteMaterial&&Dn.setValue(z,"center",Te.center),Dn.setValue(z,"modelViewMatrix",Te.modelViewMatrix),Dn.setValue(z,"normalMatrix",Te.normalMatrix),Dn.setValue(z,"modelMatrix",Te.matrixWorld),Oe.isShaderMaterial||Oe.isRawShaderMaterial){const Ei=Oe.uniformsGroups;for(let Ui=0,Bo=Ei.length;Ui<Bo;Ui++){const bl=Ei[Ui];Fe.update(bl,Sr),Fe.bind(bl,Sr)}}return Sr}function Ge(ie,Se){ie.ambientLightColor.needsUpdate=Se,ie.lightProbe.needsUpdate=Se,ie.directionalLights.needsUpdate=Se,ie.directionalLightShadows.needsUpdate=Se,ie.pointLights.needsUpdate=Se,ie.pointLightShadows.needsUpdate=Se,ie.spotLights.needsUpdate=Se,ie.spotLightShadows.needsUpdate=Se,ie.rectAreaLights.needsUpdate=Se,ie.hemisphereLights.needsUpdate=Se}function tt(ie){return ie.isMeshLambertMaterial||ie.isMeshToonMaterial||ie.isMeshPhongMaterial||ie.isMeshStandardMaterial||ie.isShadowMaterial||ie.isShaderMaterial&&ie.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return N},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(ie,Se,Le){const Oe=Ne.get(ie);Oe.__autoAllocateDepthBuffer=ie.resolveDepthBuffer===!1,Oe.__autoAllocateDepthBuffer===!1&&(Oe.__useRenderToTexture=!1),Ne.get(ie.texture).__webglTexture=Se,Ne.get(ie.depthTexture).__webglTexture=Oe.__autoAllocateDepthBuffer?void 0:Le,Oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ie,Se){const Le=Ne.get(ie);Le.__webglFramebuffer=Se,Le.__useDefaultFramebuffer=Se===void 0};const rt=z.createFramebuffer();this.setRenderTarget=function(ie,Se=0,Le=0){D=ie,I=Se,N=Le;let Oe=!0,Te=null,ot=!1,ft=!1;if(ie){const xt=Ne.get(ie);if(xt.__useDefaultFramebuffer!==void 0)le.bindFramebuffer(z.FRAMEBUFFER,null),Oe=!1;else if(xt.__webglFramebuffer===void 0)we.setupRenderTarget(ie);else if(xt.__hasExternalTextures)we.rebindTextures(ie,Ne.get(ie.texture).__webglTexture,Ne.get(ie.depthTexture).__webglTexture);else if(ie.depthBuffer){const mt=ie.depthTexture;if(xt.__boundDepthTexture!==mt){if(mt!==null&&Ne.has(mt)&&(ie.width!==mt.image.width||ie.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");we.setupDepthRenderbuffer(ie)}}const jt=ie.texture;(jt.isData3DTexture||jt.isDataArrayTexture||jt.isCompressedArrayTexture)&&(ft=!0);const Mt=Ne.get(ie).__webglFramebuffer;ie.isWebGLCubeRenderTarget?(Array.isArray(Mt[Se])?Te=Mt[Se][Le]:Te=Mt[Se],ot=!0):ie.samples>0&&we.useMultisampledRTT(ie)===!1?Te=Ne.get(ie).__webglMultisampledFramebuffer:Array.isArray(Mt)?Te=Mt[Le]:Te=Mt,q.copy(ie.viewport),R.copy(ie.scissor),V=ie.scissorTest}else q.copy(ee).multiplyScalar(Z).floor(),R.copy(ae).multiplyScalar(Z).floor(),V=fe;if(Le!==0&&(Te=rt),le.bindFramebuffer(z.FRAMEBUFFER,Te)&&Oe&&le.drawBuffers(ie,Te),le.viewport(q),le.scissor(R),le.setScissorTest(V),ot){const xt=Ne.get(ie.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+Se,xt.__webglTexture,Le)}else if(ft){const xt=Se;for(let jt=0;jt<ie.textures.length;jt++){const Mt=Ne.get(ie.textures[jt]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+jt,Mt.__webglTexture,Le,xt)}}else if(ie!==null&&Le!==0){const xt=Ne.get(ie.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,xt.__webglTexture,Le)}F=-1},this.readRenderTargetPixels=function(ie,Se,Le,Oe,Te,ot,ft,bt=0){if(!(ie&&ie.isWebGLRenderTarget)){jr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xt=Ne.get(ie).__webglFramebuffer;if(ie.isWebGLCubeRenderTarget&&ft!==void 0&&(xt=xt[ft]),xt){le.bindFramebuffer(z.FRAMEBUFFER,xt);try{const jt=ie.textures[bt],Mt=jt.format,mt=jt.type;if(!J.textureFormatReadable(Mt)){jr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!J.textureTypeReadable(mt)){jr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Se>=0&&Se<=ie.width-Oe&&Le>=0&&Le<=ie.height-Te&&(ie.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+bt),z.readPixels(Se,Le,Oe,Te,at.convert(Mt),at.convert(mt),ot))}finally{const jt=D!==null?Ne.get(D).__webglFramebuffer:null;le.bindFramebuffer(z.FRAMEBUFFER,jt)}}},this.readRenderTargetPixelsAsync=async function(ie,Se,Le,Oe,Te,ot,ft,bt=0){if(!(ie&&ie.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xt=Ne.get(ie).__webglFramebuffer;if(ie.isWebGLCubeRenderTarget&&ft!==void 0&&(xt=xt[ft]),xt)if(Se>=0&&Se<=ie.width-Oe&&Le>=0&&Le<=ie.height-Te){le.bindFramebuffer(z.FRAMEBUFFER,xt);const jt=ie.textures[bt],Mt=jt.format,mt=jt.type;if(!J.textureFormatReadable(Mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!J.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Kt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,Kt),z.bufferData(z.PIXEL_PACK_BUFFER,ot.byteLength,z.STREAM_READ),ie.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+bt),z.readPixels(Se,Le,Oe,Te,at.convert(Mt),at.convert(mt),0);const Ft=D!==null?Ne.get(D).__webglFramebuffer:null;le.bindFramebuffer(z.FRAMEBUFFER,Ft);const nn=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await jde(z,nn,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,Kt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,ot),z.deleteBuffer(Kt),z.deleteSync(nn),ot}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ie,Se=null,Le=0){const Oe=Math.pow(2,-Le),Te=Math.floor(ie.image.width*Oe),ot=Math.floor(ie.image.height*Oe),ft=Se!==null?Se.x:0,bt=Se!==null?Se.y:0;we.setTexture2D(ie,0),z.copyTexSubImage2D(z.TEXTURE_2D,Le,0,0,ft,bt,Te,ot),le.unbindTexture()};const et=z.createFramebuffer(),St=z.createFramebuffer();this.copyTextureToTexture=function(ie,Se,Le=null,Oe=null,Te=0,ot=null){ot===null&&(Te!==0?(v0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ot=Te,Te=0):ot=0);let ft,bt,xt,jt,Mt,mt,Kt,Ft,nn;const dn=ie.isCompressedTexture?ie.mipmaps[ot]:ie.image;if(Le!==null)ft=Le.max.x-Le.min.x,bt=Le.max.y-Le.min.y,xt=Le.isBox3?Le.max.z-Le.min.z:1,jt=Le.min.x,Mt=Le.min.y,mt=Le.isBox3?Le.min.z:0;else{const ai=Math.pow(2,-Te);ft=Math.floor(dn.width*ai),bt=Math.floor(dn.height*ai),ie.isDataArrayTexture?xt=dn.depth:ie.isData3DTexture?xt=Math.floor(dn.depth*ai):xt=1,jt=0,Mt=0,mt=0}Oe!==null?(Kt=Oe.x,Ft=Oe.y,nn=Oe.z):(Kt=0,Ft=0,nn=0);const gn=at.convert(Se.format),Ut=at.convert(Se.type);let Zt;Se.isData3DTexture?(we.setTexture3D(Se,0),Zt=z.TEXTURE_3D):Se.isDataArrayTexture||Se.isCompressedArrayTexture?(we.setTexture2DArray(Se,0),Zt=z.TEXTURE_2D_ARRAY):(we.setTexture2D(Se,0),Zt=z.TEXTURE_2D),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,Se.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Se.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,Se.unpackAlignment);const Jt=z.getParameter(z.UNPACK_ROW_LENGTH),Sr=z.getParameter(z.UNPACK_IMAGE_HEIGHT),Pr=z.getParameter(z.UNPACK_SKIP_PIXELS),Pn=z.getParameter(z.UNPACK_SKIP_ROWS),uo=z.getParameter(z.UNPACK_SKIP_IMAGES);z.pixelStorei(z.UNPACK_ROW_LENGTH,dn.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,dn.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,jt),z.pixelStorei(z.UNPACK_SKIP_ROWS,Mt),z.pixelStorei(z.UNPACK_SKIP_IMAGES,mt);const Dn=ie.isDataArrayTexture||ie.isData3DTexture,Si=Se.isDataArrayTexture||Se.isData3DTexture;if(ie.isDepthTexture){const ai=Ne.get(ie),Ei=Ne.get(Se),Ui=Ne.get(ai.__renderTarget),Bo=Ne.get(Ei.__renderTarget);le.bindFramebuffer(z.READ_FRAMEBUFFER,Ui.__webglFramebuffer),le.bindFramebuffer(z.DRAW_FRAMEBUFFER,Bo.__webglFramebuffer);for(let bl=0;bl<xt;bl++)Dn&&(z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Ne.get(ie).__webglTexture,Te,mt+bl),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Ne.get(Se).__webglTexture,ot,nn+bl)),z.blitFramebuffer(jt,Mt,ft,bt,Kt,Ft,ft,bt,z.DEPTH_BUFFER_BIT,z.NEAREST);le.bindFramebuffer(z.READ_FRAMEBUFFER,null),le.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Te!==0||ie.isRenderTargetTexture||Ne.has(ie)){const ai=Ne.get(ie),Ei=Ne.get(Se);le.bindFramebuffer(z.READ_FRAMEBUFFER,et),le.bindFramebuffer(z.DRAW_FRAMEBUFFER,St);for(let Ui=0;Ui<xt;Ui++)Dn?z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,ai.__webglTexture,Te,mt+Ui):z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,ai.__webglTexture,Te),Si?z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Ei.__webglTexture,ot,nn+Ui):z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Ei.__webglTexture,ot),Te!==0?z.blitFramebuffer(jt,Mt,ft,bt,Kt,Ft,ft,bt,z.COLOR_BUFFER_BIT,z.NEAREST):Si?z.copyTexSubImage3D(Zt,ot,Kt,Ft,nn+Ui,jt,Mt,ft,bt):z.copyTexSubImage2D(Zt,ot,Kt,Ft,jt,Mt,ft,bt);le.bindFramebuffer(z.READ_FRAMEBUFFER,null),le.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else Si?ie.isDataTexture||ie.isData3DTexture?z.texSubImage3D(Zt,ot,Kt,Ft,nn,ft,bt,xt,gn,Ut,dn.data):Se.isCompressedArrayTexture?z.compressedTexSubImage3D(Zt,ot,Kt,Ft,nn,ft,bt,xt,gn,dn.data):z.texSubImage3D(Zt,ot,Kt,Ft,nn,ft,bt,xt,gn,Ut,dn):ie.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,ot,Kt,Ft,ft,bt,gn,Ut,dn.data):ie.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,ot,Kt,Ft,dn.width,dn.height,gn,dn.data):z.texSubImage2D(z.TEXTURE_2D,ot,Kt,Ft,ft,bt,gn,Ut,dn);z.pixelStorei(z.UNPACK_ROW_LENGTH,Jt),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Sr),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Pr),z.pixelStorei(z.UNPACK_SKIP_ROWS,Pn),z.pixelStorei(z.UNPACK_SKIP_IMAGES,uo),ot===0&&Se.generateMipmaps&&z.generateMipmap(Zt),le.unbindTexture()},this.initRenderTarget=function(ie){Ne.get(ie).__webglFramebuffer===void 0&&we.setupRenderTarget(ie)},this.initTexture=function(ie){ie.isCubeTexture?we.setTextureCube(ie,0):ie.isData3DTexture?we.setTexture3D(ie,0):ie.isDataArrayTexture||ie.isCompressedArrayTexture?we.setTexture2DArray(ie,0):we.setTexture2D(ie,0),le.unbindTexture()},this.resetState=function(){I=0,N=0,D=null,le.reset(),Q.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return nl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=An._getDrawingBufferColorSpace(e),n.unpackColorSpace=An._getUnpackColorSpace()}};const LF={type:"change"},FR={type:"start"},R7={type:"end"},wy=new OR,IF=new wu,dxe=Math.cos(70*Ide.DEG2RAD),li=new Je,Us=2*Math.PI,Gn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},zA=1e-6;class hxe extends She{constructor(e,n=null){super(e,n),this.state=Gn.NONE,this.target=new Je,this.cursor=new Je,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Vp.ROTATE,MIDDLE:Vp.DOLLY,RIGHT:Vp.PAN},this.touches={ONE:jp.ROTATE,TWO:jp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Je,this._lastQuaternion=new Ih,this._lastTargetPosition=new Je,this._quat=new Ih().setFromUnitVectors(e.up,new Je(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new dF,this._sphericalDelta=new dF,this._scale=1,this._panOffset=new Je,this._rotateStart=new on,this._rotateEnd=new on,this._rotateDelta=new on,this._panStart=new on,this._panEnd=new on,this._panDelta=new on,this._dollyStart=new on,this._dollyEnd=new on,this._dollyDelta=new on,this._dollyDirection=new Je,this._mouse=new on,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=pxe.bind(this),this._onPointerDown=fxe.bind(this),this._onPointerUp=mxe.bind(this),this._onContextMenu=wxe.bind(this),this._onMouseWheel=bxe.bind(this),this._onKeyDown=vxe.bind(this),this._onTouchStart=yxe.bind(this),this._onTouchMove=_xe.bind(this),this._onMouseDown=gxe.bind(this),this._onMouseMove=xxe.bind(this),this._interceptControlDown=Sxe.bind(this),this._interceptControlUp=Exe.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(LF),this.update(),this.state=Gn.NONE}update(e=null){const n=this.object.position;li.copy(n).sub(this.target),li.applyQuaternion(this._quat),this._spherical.setFromVector3(li),this.autoRotate&&this.state===Gn.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+=Us:r>Math.PI&&(r-=Us),i<-Math.PI?i+=Us:i>Math.PI&&(i-=Us),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(li.setFromSpherical(this._spherical),li.applyQuaternion(this._quatInverse),n.copy(this.target).add(li),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=li.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new Je(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const u=new Je(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(o),this.object.updateMatrixWorld(),a=li.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(wy.origin.copy(this.object.position),wy.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(wy.direction))<dxe?this.object.lookAt(this.target):(IF.setFromNormalAndCoplanarPoint(this.object.up,this.target),wy.intersectPlane(IF,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>zA||8*(1-this._lastQuaternion.dot(this.object.quaternion))>zA||this._lastTargetPosition.distanceToSquared(this.target)>zA?(this.dispatchEvent(LF),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Us/60*this.autoRotateSpeed*e:Us/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){li.setFromMatrixColumn(n,0),li.multiplyScalar(-e),this._panOffset.add(li)}_panUp(e,n){this.screenSpacePanning===!0?li.setFromMatrixColumn(n,1):(li.setFromMatrixColumn(n,0),li.crossVectors(this.object.up,li)),li.multiplyScalar(e),this._panOffset.add(li)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;li.copy(i).sub(this.target);let s=li.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*n*s/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,s=n-r.top,a=r.width,o=r.height;this._mouse.x=i/a*2-1,this._mouse.y=-(s/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Us*this._rotateDelta.x/n.clientHeight),this._rotateUp(Us*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(Us*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(-Us*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(Us*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(-Us*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,s=Math.sqrt(r*r+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),s=.5*(e.pageY+r.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Us*this._rotateDelta.x/n.clientHeight),this._rotateUp(Us*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,s=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+n.x)*.5,o=(e.pageY+n.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new on,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function fxe(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 pxe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function mxe(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(R7),this.state=Gn.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 gxe(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 Vp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Gn.DOLLY;break;case Vp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Gn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Gn.ROTATE}break;case Vp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Gn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Gn.PAN}break;default:this.state=Gn.NONE}this.state!==Gn.NONE&&this.dispatchEvent(FR)}function xxe(t){switch(this.state){case Gn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Gn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Gn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function bxe(t){this.enabled===!1||this.enableZoom===!1||this.state!==Gn.NONE||(t.preventDefault(),this.dispatchEvent(FR),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(R7))}function vxe(t){this.enabled!==!1&&this._handleKeyDown(t)}function yxe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case jp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Gn.TOUCH_ROTATE;break;case jp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Gn.TOUCH_PAN;break;default:this.state=Gn.NONE}break;case 2:switch(this.touches.TWO){case jp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Gn.TOUCH_DOLLY_PAN;break;case jp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Gn.TOUCH_DOLLY_ROTATE;break;default:this.state=Gn.NONE}break;default:this.state=Gn.NONE}this.state!==Gn.NONE&&this.dispatchEvent(FR)}function _xe(t){switch(this._trackPointer(t),this.state){case Gn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Gn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Gn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Gn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Gn.NONE}}function wxe(t){this.enabled!==!1&&t.preventDefault()}function Sxe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Exe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Mxe(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,l=new xl;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let g=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in f.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;s[m]===void 0&&(s[m]=[]),s[m].push(f.attributes[m]),g++}if(g!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in f.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;a[m]===void 0&&(a[m]=[]),a[m].push(f.morphAttributes[m])}if(e){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,m,d),u+=m}}if(n){let d=0;const f=[];for(let g=0;g<t.length;++g){const m=t[g].index;for(let x=0;x<m.count;++x)f.push(m.getX(x)+d);d+=t[g].attributes.position.count}l.setIndex(f)}for(const d in s){const f=UF(s[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;l.setAttribute(d,f)}for(const d in a){const f=a[d][0].length;if(f===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(let g=0;g<f;++g){const m=[];for(let y=0;y<a[d].length;++y)m.push(a[d][y][g]);const x=UF(m);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;l.morphAttributes[d].push(x)}}return l}function UF(t){let e,n,r,i=-1,s=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=d.count*n}const a=new e(s),o=new Ja(a,n,r);let l=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=l/n;for(let g=0,m=d.count;g<m;g++)for(let x=0;x<n;x++){const y=d.getComponent(g,x);o.setComponent(g+f,x,y)}}else a.set(d.array,l);l+=d.count*n}return i!==void 0&&(o.gpuType=i),o}function Sy(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 BA={exports:{}};var FF;function Axe(){return FF||(FF=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,s){function a(u,d){if(!i[u]){if(!r[u]){var f=typeof Sy=="function"&&Sy;if(!d&&f)return f(u,!0);if(o)return o(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var m=i[u]={exports:{}};r[u][0].call(m.exports,function(x){var y=r[u][1][x];return a(y||x)},m,m.exports,n,r,i,s)}return i[u].exports}for(var o=typeof Sy=="function"&&Sy,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(n,r,i){var s=n("./utils"),a=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var u,d,f,g,m,x,y,v=[],b=0,E=l.length,S=E,A=s.getTypeOf(l)!=="string";b<l.length;)S=E-b,f=A?(u=l[b++],d=b<E?l[b++]:0,b<E?l[b++]:0):(u=l.charCodeAt(b++),d=b<E?l.charCodeAt(b++):0,b<E?l.charCodeAt(b++):0),g=u>>2,m=(3&u)<<4|d>>4,x=1<S?(15&d)<<2|f>>6:64,y=2<S?63&f:64,v.push(o.charAt(g)+o.charAt(m)+o.charAt(x)+o.charAt(y));return v.join("")},i.decode=function(l){var u,d,f,g,m,x,y=0,v=0,b="data:";if(l.substr(0,b.length)===b)throw new Error("Invalid base64 input, it looks like a data url.");var E,S=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&S--,l.charAt(l.length-2)===o.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(E=a.uint8array?new Uint8Array(0|S):new Array(0|S);y<l.length;)u=o.indexOf(l.charAt(y++))<<2|(g=o.indexOf(l.charAt(y++)))>>4,d=(15&g)<<4|(m=o.indexOf(l.charAt(y++)))>>2,f=(3&m)<<6|(x=o.indexOf(l.charAt(y++))),E[v++]=u,m!==64&&(E[v++]=d),x!==64&&(E[v++]=f);return E}},{"./support":30,"./utils":32}],2:[function(n,r,i){var s=n("./external"),a=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function u(d,f,g,m,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=g,this.compression=m,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,g){return d.pipe(new o).pipe(new l("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var s=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var s=n("./utils"),a=(function(){for(var o,l=[],u=0;u<256;u++){o=u;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;l[u]=o}return l})();r.exports=function(o,l){return o!==void 0&&o.length?s.getTypeOf(o)!=="string"?(function(u,d,f,g){var m=a,x=g+f;u^=-1;for(var y=g;y<x;y++)u=u>>>8^m[255&(u^d[y])];return-1^u})(0|l,o,o.length,0):(function(u,d,f,g){var m=a,x=g+f;u^=-1;for(var y=g;y<x;y++)u=u>>>8^m[255&(u^d.charCodeAt(y))];return-1^u})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=n("pako"),o=n("./utils"),l=n("./stream/GenericWorker"),u=s?"uint8array":"array";function d(f,g){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",o.inherits(d,l),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(u,f.data),!1)},d.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function s(m,x){var y,v="";for(y=0;y<x;y++)v+=String.fromCharCode(255&m),m>>>=8;return v}function a(m,x,y,v,b,E){var S,A,T=m.file,P=m.compression,C=E!==u.utf8encode,I=o.transformTo("string",E(T.name)),N=o.transformTo("string",u.utf8encode(T.name)),D=T.comment,F=o.transformTo("string",E(D)),L=o.transformTo("string",u.utf8encode(D)),q=N.length!==T.name.length,R=L.length!==D.length,V="",K="",W="",ne=T.dir,Y=T.date,Z={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(Z.crc32=m.crc32,Z.compressedSize=m.compressedSize,Z.uncompressedSize=m.uncompressedSize);var U=0;x&&(U|=8),C||!q&&!R||(U|=2048);var $=0,ee=0;ne&&($|=16),b==="UNIX"?(ee=798,$|=(function(fe,ue){var xe=fe;return fe||(xe=ue?16893:33204),(65535&xe)<<16})(T.unixPermissions,ne)):(ee=20,$|=(function(fe){return 63&(fe||0)})(T.dosPermissions)),S=Y.getUTCHours(),S<<=6,S|=Y.getUTCMinutes(),S<<=5,S|=Y.getUTCSeconds()/2,A=Y.getUTCFullYear()-1980,A<<=4,A|=Y.getUTCMonth()+1,A<<=5,A|=Y.getUTCDate(),q&&(K=s(1,1)+s(d(I),4)+N,V+="up"+s(K.length,2)+K),R&&(W=s(1,1)+s(d(F),4)+L,V+="uc"+s(W.length,2)+W);var ae="";return ae+=`
- \0`,ae+=s(U,2),ae+=P.magic,ae+=s(S,2),ae+=s(A,2),ae+=s(Z.crc32,4),ae+=s(Z.compressedSize,4),ae+=s(Z.uncompressedSize,4),ae+=s(I.length,2),ae+=s(V.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ae+I+V,dirRecord:f.CENTRAL_FILE_HEADER+s(ee,2)+ae+s(F.length,2)+"\0\0\0\0"+s($,4)+s(v,4)+I+V+F}}var o=n("../utils"),l=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function g(m,x,y,v){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=y,this.encodeFileName=v,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(g,l),g.prototype.push=function(m){var x=m.meta.percent||0,y=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,l.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:y?(x+100*(y-v-1))/y:100}}))},g.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var x=this.streamFiles&&!m.file.dir;if(x){var y=a(m,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(m){this.accumulate=!1;var x=this.streamFiles&&!m.file.dir,y=a(m,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),x)this.push({data:(function(v){return f.DATA_DESCRIPTOR+s(v.crc32,4)+s(v.compressedSize,4)+s(v.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var m=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var y=this.bytesWritten-m,v=(function(b,E,S,A,T){var P=o.transformTo("string",T(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(b,2)+s(b,2)+s(E,4)+s(S,4)+s(P.length,2)+P})(this.dirRecords.length,y,m,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(m){this._sources.push(m);var x=this;return m.on("data",function(y){x.processChunk(y)}),m.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),m.on("error",function(y){x.error(y)}),this},g.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(m){var x=this._sources;if(!l.prototype.error.call(this,m))return!1;for(var y=0;y<x.length;y++)try{x[y].error(m)}catch{}return!0},g.prototype.lock=function(){l.prototype.lock.call(this);for(var m=this._sources,x=0;x<m.length;x++)m[x].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var s=n("../compressions"),a=n("./ZipFileWorker");i.generateWorker=function(o,l,u){var d=new a(l.streamFiles,u,l.platform,l.encodeFileName),f=0;try{o.forEach(function(g,m){f++;var x=(function(E,S){var A=E||S,T=s[A];if(!T)throw new Error(A+" is not a valid compression method !");return T})(m.options.compression,l.compression),y=m.options.compressionOptions||l.compressionOptions||{},v=m.dir,b=m.date;m._compressWorker(x,y).withStreamInfo("file",{name:g,dir:v,date:b,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(g){d.error(g)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(a,o){return new s().loadAsync(a,o)},s.external=n("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var s=n("./utils"),a=n("./external"),o=n("./utf8"),l=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(g){return new a.Promise(function(m,x){var y=g.decompressed.getContentWorker().pipe(new u);y.on("error",function(v){x(v)}).on("end",function(){y.streamInfo.crc32!==g.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(g,m){var x=this;return m=s.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),d.isNode&&d.isStream(g)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",g,!0,m.optimizedBinaryString,m.base64).then(function(y){var v=new l(m);return v.load(y),v}).then(function(y){var v=[a.Promise.resolve(y)],b=y.files;if(m.checkCRC32)for(var E=0;E<b.length;E++)v.push(f(b[E]));return a.Promise.all(v)}).then(function(y){for(var v=y.shift(),b=v.files,E=0;E<b.length;E++){var S=b[E],A=S.fileNameStr,T=s.resolve(S.fileNameStr);x.file(T,S.decompressed,{binary:!0,optimizedBinaryString:!0,date:S.date,dir:S.dir,comment:S.fileCommentStr.length?S.fileCommentStr:null,unixPermissions:S.unixPermissions,dosPermissions:S.dosPermissions,createFolders:m.createFolders}),S.dir||(x.file(T).unsafeOriginalName=A)}return v.zipComment.length&&(x.comment=v.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var s=n("../utils"),a=n("../stream/GenericWorker");function o(l,u){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(o,a),o.prototype._bindStream=function(l){var u=this;(this._stream=l).pause(),l.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var s=n("readable-stream").Readable;function a(o,l,u){s.call(this,l),this._helper=o;var d=this;o.on("data",function(f,g){d.push(f)||d._helper.pause(),u&&u(g)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},r.exports=a},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,i){function s(T,P,C){var I,N=o.getTypeOf(P),D=o.extend(C||{},d);D.date=D.date||new Date,D.compression!==null&&(D.compression=D.compression.toUpperCase()),typeof D.unixPermissions=="string"&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(T=b(T)),D.createFolders&&(I=v(T))&&E.call(this,I,!0);var F=N==="string"&&D.binary===!1&&D.base64===!1;C&&C.binary!==void 0||(D.binary=!F),(P instanceof f&&P.uncompressedSize===0||D.dir||!P||P.length===0)&&(D.base64=!1,D.binary=!0,P="",D.compression="STORE",N="string");var L=null;L=P instanceof f||P instanceof l?P:x.isNode&&x.isStream(P)?new y(T,P):o.prepareContent(T,P,D.binary,D.optimizedBinaryString,D.base64);var q=new g(T,L,D);this.files[T]=q}var a=n("./utf8"),o=n("./utils"),l=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),g=n("./zipObject"),m=n("./generate"),x=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),v=function(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var P=T.lastIndexOf("/");return 0<P?T.substring(0,P):""},b=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},E=function(T,P){return P=P!==void 0?P:d.createFolders,T=b(T),this.files[T]||s.call(this,T,null,{dir:!0,createFolders:P}),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 P,C,I;for(P in this.files)I=this.files[P],(C=P.slice(this.root.length,P.length))&&P.slice(0,this.root.length)===this.root&&T(C,I)},filter:function(T){var P=[];return this.forEach(function(C,I){T(C,I)&&P.push(I)}),P},file:function(T,P,C){if(arguments.length!==1)return T=this.root+T,s.call(this,T,P,C),this;if(S(T)){var I=T;return this.filter(function(D,F){return!F.dir&&I.test(D)})}var N=this.files[this.root+T];return N&&!N.dir?N:null},folder:function(T){if(!T)return this;if(S(T))return this.filter(function(N,D){return D.dir&&T.test(N)});var P=this.root+T,C=E.call(this,P),I=this.clone();return I.root=C.name,I},remove:function(T){T=this.root+T;var P=this.files[T];if(P||(T.slice(-1)!=="/"&&(T+="/"),P=this.files[T]),P&&!P.dir)delete this.files[T];else for(var C=this.filter(function(N,D){return D.name.slice(0,T.length)===T}),I=0;I<C.length;I++)delete this.files[C[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 P,C={};try{if((C=o.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");o.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var I=C.comment||this.comment||"";P=m.generateWorker(this,C,I)}catch(N){(P=new l("error")).error(N)}return new u(P,C.type||"string",C.mimeType)},generateAsync:function(T,P){return this.generateInternalStream(T).accumulate(P)},generateNodeStream:function(T,P){return(T=T||{}).type||(T.type="nodebuffer"),this.generateInternalStream(T).toNodejsStream(P)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var s=n("./DataReader");function a(o){s.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}n("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===l&&this.data[g+1]===u&&this.data[g+2]===d&&this.data[g+3]===f)return g-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.readData(4);return l===g[0]&&u===g[1]&&d===g[2]&&f===g[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var s=n("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,u=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=o,u},readString:function(o){return s.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},r.exports=a},{"../utils":32}],19:[function(n,r,i){var s=n("./Uint8ArrayReader");function a(o){s.call(this,o)}n("../utils").inherits(a,s),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var s=n("./DataReader");function a(o){s.call(this,o)}n("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var s=n("./ArrayReader");function a(o){s.call(this,o)}n("../utils").inherits(a,s),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var s=n("../utils"),a=n("../support"),o=n("./ArrayReader"),l=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var g=s.getTypeOf(f);return s.checkSupport(g),g!=="string"||a.uint8array?g==="nodebuffer"?new u(f):a.uint8array?new d(s.transformTo("uint8array",f)):new o(s.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var s=n("./GenericWorker"),a=n("../utils");function o(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,s),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},r.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var s=n("./GenericWorker"),a=n("../crc32");function o(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,s),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var s=n("../utils"),a=n("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(o,a),o.prototype.processChunk=function(l){if(l){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+l.data.length}a.prototype.processChunk.call(this,l)},r.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var s=n("../utils"),a=n("./GenericWorker");function o(l){a.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=s.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}s.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(l){o.processChunk(l)}),a.on("end",function(){o.end()}),a.on("error",function(l){o.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},r.exports=s},{}],29:[function(n,r,i){var s=n("../utils"),a=n("./ConvertWorker"),o=n("./GenericWorker"),l=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(x,y){return new d.Promise(function(v,b){var E=[],S=x._internalType,A=x._outputType,T=x._mimeType;x.on("data",function(P,C){E.push(P),y&&y(C)}).on("error",function(P){E=[],b(P)}).on("end",function(){try{var P=(function(C,I,N){switch(C){case"blob":return s.newBlob(s.transformTo("arraybuffer",I),N);case"base64":return l.encode(I);default:return s.transformTo(C,I)}})(A,(function(C,I){var N,D=0,F=null,L=0;for(N=0;N<I.length;N++)L+=I[N].length;switch(C){case"string":return I.join("");case"array":return Array.prototype.concat.apply([],I);case"uint8array":for(F=new Uint8Array(L),N=0;N<I.length;N++)F.set(I[N],D),D+=I[N].length;return F;case"nodebuffer":return Buffer.concat(I);default:throw new Error("concat : unsupported type '"+C+"'")}})(S,E),T);v(P)}catch(C){b(C)}E=[]}).resume()})}function m(x,y,v){var b=y;switch(y){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=y,this._mimeType=v,s.checkSupport(b),this._worker=x.pipe(new a(b)),x.lock()}catch(E){this._worker=new o("error"),this._worker.error(E)}}m.prototype={accumulate:function(x){return g(this,x)},on:function(x,y){var v=this;return x==="data"?this._worker.on(x,function(b){y.call(v,b.data,b.meta)}):this._worker.on(x,function(){s.delay(y,arguments,v)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),i.blob=a.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var s=n("./utils"),a=n("./support"),o=n("./nodejsUtils"),l=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function g(){l.call(this,"utf-8 encode")}i.utf8encode=function(m){return a.nodebuffer?o.newBufferFrom(m,"utf-8"):(function(x){var y,v,b,E,S,A=x.length,T=0;for(E=0;E<A;E++)(64512&(v=x.charCodeAt(E)))==55296&&E+1<A&&(64512&(b=x.charCodeAt(E+1)))==56320&&(v=65536+(v-55296<<10)+(b-56320),E++),T+=v<128?1:v<2048?2:v<65536?3:4;for(y=a.uint8array?new Uint8Array(T):new Array(T),E=S=0;S<T;E++)(64512&(v=x.charCodeAt(E)))==55296&&E+1<A&&(64512&(b=x.charCodeAt(E+1)))==56320&&(v=65536+(v-55296<<10)+(b-56320),E++),v<128?y[S++]=v:(v<2048?y[S++]=192|v>>>6:(v<65536?y[S++]=224|v>>>12:(y[S++]=240|v>>>18,y[S++]=128|v>>>12&63),y[S++]=128|v>>>6&63),y[S++]=128|63&v);return y})(m)},i.utf8decode=function(m){return a.nodebuffer?s.transformTo("nodebuffer",m).toString("utf-8"):(function(x){var y,v,b,E,S=x.length,A=new Array(2*S);for(y=v=0;y<S;)if((b=x[y++])<128)A[v++]=b;else if(4<(E=u[b]))A[v++]=65533,y+=E-1;else{for(b&=E===2?31:E===3?15:7;1<E&&y<S;)b=b<<6|63&x[y++],E--;1<E?A[v++]=65533:b<65536?A[v++]=b:(b-=65536,A[v++]=55296|b>>10&1023,A[v++]=56320|1023&b)}return A.length!==v&&(A.subarray?A=A.subarray(0,v):A.length=v),s.applyFromCharCode(A)})(m=s.transformTo(a.uint8array?"uint8array":"array",m))},s.inherits(f,l),f.prototype.processChunk=function(m){var x=s.transformTo(a.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var y=x;(x=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),x.set(y,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var v=(function(E,S){var A;for((S=S||E.length)>E.length&&(S=E.length),A=S-1;0<=A&&(192&E[A])==128;)A--;return A<0||A===0?S:A+u[E[A]]>S?A:S})(x),b=x;v!==x.length&&(a.uint8array?(b=x.subarray(0,v),this.leftOver=x.subarray(v,x.length)):(b=x.slice(0,v),this.leftOver=x.slice(v,x.length))),this.push({data:i.utf8decode(b),meta:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,s.inherits(g,l),g.prototype.processChunk=function(m){this.push({data:i.utf8encode(m.data),meta:m.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var s=n("./support"),a=n("./base64"),o=n("./nodejsUtils"),l=n("./external");function u(y){return y}function d(y,v){for(var b=0;b<y.length;++b)v[b]=255&y.charCodeAt(b);return v}n("setimmediate"),i.newBlob=function(y,v){i.checkSupport("blob");try{return new Blob([y],{type:v})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(y),b.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(y,v,b){var E=[],S=0,A=y.length;if(A<=b)return String.fromCharCode.apply(null,y);for(;S<A;)v==="array"||v==="nodebuffer"?E.push(String.fromCharCode.apply(null,y.slice(S,Math.min(S+b,A)))):E.push(String.fromCharCode.apply(null,y.subarray(S,Math.min(S+b,A)))),S+=b;return E.join("")},stringifyByChar:function(y){for(var v="",b=0;b<y.length;b++)v+=String.fromCharCode(y[b]);return v},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function g(y){var v=65536,b=i.getTypeOf(y),E=!0;if(b==="uint8array"?E=f.applyCanBeUsed.uint8array:b==="nodebuffer"&&(E=f.applyCanBeUsed.nodebuffer),E)for(;1<v;)try{return f.stringifyByChunk(y,b,v)}catch{v=Math.floor(v/2)}return f.stringifyByChar(y)}function m(y,v){for(var b=0;b<y.length;b++)v[b]=y[b];return v}i.applyFromCharCode=g;var x={};x.string={string:u,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return x.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,o.allocBuffer(y.length))}},x.array={string:g,array:u,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(y)}},x.arraybuffer={string:function(y){return g(new Uint8Array(y))},array:function(y){return m(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(new Uint8Array(y))}},x.uint8array={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return o.newBufferFrom(y)}},x.nodebuffer={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return x.nodebuffer.uint8array(y).buffer},uint8array:function(y){return m(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,v){if(v=v||"",!y)return v;i.checkSupport(y);var b=i.getTypeOf(v);return x[b][y](v)},i.resolve=function(y){for(var v=y.split("/"),b=[],E=0;E<v.length;E++){var S=v[E];S==="."||S===""&&E!==0&&E!==v.length-1||(S===".."?b.pop():b.push(S))}return b.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":s.nodebuffer&&o.isBuffer(y)?"nodebuffer":s.uint8array&&y instanceof Uint8Array?"uint8array":s.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!s[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var v,b,E="";for(b=0;b<(y||"").length;b++)E+="\\x"+((v=y.charCodeAt(b))<16?"0":"")+v.toString(16).toUpperCase();return E},i.delay=function(y,v,b){setImmediate(function(){y.apply(b||null,v||[])})},i.inherits=function(y,v){function b(){}b.prototype=v.prototype,y.prototype=new b},i.extend=function(){var y,v,b={};for(y=0;y<arguments.length;y++)for(v in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],v)&&b[v]===void 0&&(b[v]=arguments[y][v]);return b},i.prepareContent=function(y,v,b,E,S){return l.Promise.resolve(v).then(function(A){return s.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new l.Promise(function(T,P){var C=new FileReader;C.onload=function(I){T(I.target.result)},C.onerror=function(I){P(I.target.error)},C.readAsArrayBuffer(A)}):A}).then(function(A){var T=i.getTypeOf(A);return T?(T==="arraybuffer"?A=i.transformTo("uint8array",A):T==="string"&&(S?A=a.decode(A):b&&E!==!0&&(A=(function(P){return d(P,s.uint8array?new Uint8Array(P.length):new Array(P.length))})(A))),A):l.Promise.reject(new Error("Can't read the data of '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var s=n("./reader/readerFor"),a=n("./utils"),o=n("./signature"),l=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(g)+", expected "+a.pretty(f)+")")}},isSignature:function(f,g){var m=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===g;return this.reader.setIndex(m),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),g=u.uint8array?"uint8array":"array",m=a.transformTo(g,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,g,m,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),g=this.reader.readInt(4),m=this.reader.readData(g),this.zip64ExtensibleData[f]={id:f,length:g,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,g;for(f=0;f<this.files.length;f++)g=this.files[f],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(f=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var g=f;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var x=g-m;if(0<x)this.isSignature(g,o.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=s(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var s=n("./reader/readerFor"),a=n("./utils"),o=n("./compressedObject"),l=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function g(m,x){this.options=m,this.loadOptions=x}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var x,y;if(m.skip(22),this.fileNameLength=m.readInt(2),y=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(v){for(var b in d)if(Object.prototype.hasOwnProperty.call(d,b)&&d[b].magic===v)return d[b];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,x,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var x=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(x),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var x,y,v,b=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<b;)x=m.readInt(2),y=m.readInt(2),v=m.readData(y),this.extraFields[x]={id:x,length:y,value:v};m.setIndex(b)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var y=a.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var b=a.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var x=s(m.value);return x.readInt(1)!==1||l(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var x=s(m.value);return x.readInt(1)!==1||l(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null}},r.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function s(x,y,v){this.name=x,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=y,this._dataBinary=v.binary,this.options={compression:v.compression,compressionOptions:v.compressionOptions}}var a=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),l=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");s.prototype={internalStream:function(x){var y=null,v="string";try{if(!x)throw new Error("No output type specified.");var b=(v=x.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),y=this._decompressWorker();var E=!this._dataBinary;E&&!b&&(y=y.pipe(new l.Utf8EncodeWorker)),!E&&b&&(y=y.pipe(new l.Utf8DecodeWorker))}catch(S){(y=new d("error")).error(S)}return new a(y,v,"")},async:function(x,y){return this.internalStream(x).accumulate(y)},nodeStream:function(x,y){return this.internalStream(x||"nodebuffer").toNodejsStream(y)},_compressWorker:function(x,y){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new l.Utf8EncodeWorker)),u.createWorkerFrom(v,x,y)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new o(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)s.prototype[f[m]]=g;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(s){var a,o,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var u=0,d=new l(x),f=s.document.createTextNode("");d.observe(f,{characterData:!0}),a=function(){f.data=u=++u%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var y=s.document.createElement("script");y.onreadystatechange=function(){x(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},s.document.documentElement.appendChild(y)}:function(){setTimeout(x,0)};else{var g=new s.MessageChannel;g.port1.onmessage=x,a=function(){g.port2.postMessage(0)}}var m=[];function x(){var y,v;o=!0;for(var b=m.length;b;){for(v=m,m=[],y=-1;++y<b;)v[y]();b=m.length}o=!1}r.exports=function(y){m.push(y)!==1||o||a()}}).call(this,typeof Yv<"u"?Yv:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function a(){}var o={},l=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==a&&y(this,b)}function g(b,E,S){this.promise=b,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function m(b,E,S){s(function(){var A;try{A=E(S)}catch(T){return o.reject(b,T)}A===b?o.reject(b,new TypeError("Cannot resolve promise with itself")):o.resolve(b,A)})}function x(b){var E=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof E=="function")return function(){E.apply(b,arguments)}}function y(b,E){var S=!1;function A(C){S||(S=!0,o.reject(b,C))}function T(C){S||(S=!0,o.resolve(b,C))}var P=v(function(){E(T,A)});P.status==="error"&&A(P.value)}function v(b,E){var S={};try{S.value=b(E),S.status="success"}catch(A){S.status="error",S.value=A}return S}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var E=this.constructor;return this.then(function(S){return E.resolve(b()).then(function(){return S})},function(S){return E.resolve(b()).then(function(){throw S})})},f.prototype.catch=function(b){return this.then(null,b)},f.prototype.then=function(b,E){if(typeof b!="function"&&this.state===u||typeof E!="function"&&this.state===l)return this;var S=new this.constructor(a);return this.state!==d?m(S,this.state===u?b:E,this.outcome):this.queue.push(new g(S,b,E)),S},g.prototype.callFulfilled=function(b){o.resolve(this.promise,b)},g.prototype.otherCallFulfilled=function(b){m(this.promise,this.onFulfilled,b)},g.prototype.callRejected=function(b){o.reject(this.promise,b)},g.prototype.otherCallRejected=function(b){m(this.promise,this.onRejected,b)},o.resolve=function(b,E){var S=v(x,E);if(S.status==="error")return o.reject(b,S.value);var A=S.value;if(A)y(b,A);else{b.state=u,b.outcome=E;for(var T=-1,P=b.queue.length;++T<P;)b.queue[T].callFulfilled(E)}return b},o.reject=function(b,E){b.state=l,b.outcome=E;for(var S=-1,A=b.queue.length;++S<A;)b.queue[S].callRejected(E);return b},f.resolve=function(b){return b instanceof this?b:o.resolve(new this(a),b)},f.reject=function(b){var E=new this(a);return o.reject(E,b)},f.all=function(b){var E=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=b.length,A=!1;if(!S)return this.resolve([]);for(var T=new Array(S),P=0,C=-1,I=new this(a);++C<S;)N(b[C],C);return I;function N(D,F){E.resolve(D).then(function(L){T[F]=L,++P!==S||A||(A=!0,o.resolve(I,T))},function(L){A||(A=!0,o.reject(I,L))})}},f.race=function(b){var E=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=b.length,A=!1;if(!S)return this.resolve([]);for(var T=-1,P=new this(a);++T<S;)C=b[T],E.resolve(C).then(function(I){A||(A=!0,o.resolve(P,I))},function(I){A||(A=!0,o.reject(P,I))});var C;return P}},{immediate:36}],38:[function(n,r,i){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var s=n("./zlib/deflate"),a=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,g=-1,m=0,x=8;function y(b){if(!(this instanceof y))return new y(b);this.options=a.assign({level:g,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},b||{});var E=this.options;E.raw&&0<E.windowBits?E.windowBits=-E.windowBits:E.gzip&&0<E.windowBits&&E.windowBits<16&&(E.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var S=s.deflateInit2(this.strm,E.level,E.method,E.windowBits,E.memLevel,E.strategy);if(S!==f)throw new Error(l[S]);if(E.header&&s.deflateSetHeader(this.strm,E.header),E.dictionary){var A;if(A=typeof E.dictionary=="string"?o.string2buf(E.dictionary):d.call(E.dictionary)==="[object ArrayBuffer]"?new Uint8Array(E.dictionary):E.dictionary,(S=s.deflateSetDictionary(this.strm,A))!==f)throw new Error(l[S]);this._dict_set=!0}}function v(b,E){var S=new y(E);if(S.push(b,!0),S.err)throw S.msg||l[S.err];return S.result}y.prototype.push=function(b,E){var S,A,T=this.strm,P=this.options.chunkSize;if(this.ended)return!1;A=E===~~E?E:E===!0?4:0,typeof b=="string"?T.input=o.string2buf(b):d.call(b)==="[object ArrayBuffer]"?T.input=new Uint8Array(b):T.input=b,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new a.Buf8(P),T.next_out=0,T.avail_out=P),(S=s.deflate(T,A))!==1&&S!==f)return this.onEnd(S),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(T.output,T.next_out))):this.onData(a.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&S!==1);return A===4?(S=s.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===f):A!==2||(this.onEnd(f),!(T.avail_out=0))},y.prototype.onData=function(b){this.chunks.push(b)},y.prototype.onEnd=function(b){b===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},i.Deflate=y,i.deflate=v,i.deflateRaw=function(b,E){return(E=E||{}).raw=!0,v(b,E)},i.gzip=function(b,E){return(E=E||{}).gzip=!0,v(b,E)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var s=n("./zlib/inflate"),a=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),g=Object.prototype.toString;function m(y){if(!(this instanceof m))return new m(y);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},y||{});var v=this.options;v.raw&&0<=v.windowBits&&v.windowBits<16&&(v.windowBits=-v.windowBits,v.windowBits===0&&(v.windowBits=-15)),!(0<=v.windowBits&&v.windowBits<16)||y&&y.windowBits||(v.windowBits+=32),15<v.windowBits&&v.windowBits<48&&(15&v.windowBits)==0&&(v.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var b=s.inflateInit2(this.strm,v.windowBits);if(b!==l.Z_OK)throw new Error(u[b]);this.header=new f,s.inflateGetHeader(this.strm,this.header)}function x(y,v){var b=new m(v);if(b.push(y,!0),b.err)throw b.msg||u[b.err];return b.result}m.prototype.push=function(y,v){var b,E,S,A,T,P,C=this.strm,I=this.options.chunkSize,N=this.options.dictionary,D=!1;if(this.ended)return!1;E=v===~~v?v:v===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof y=="string"?C.input=o.binstring2buf(y):g.call(y)==="[object ArrayBuffer]"?C.input=new Uint8Array(y):C.input=y,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new a.Buf8(I),C.next_out=0,C.avail_out=I),(b=s.inflate(C,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&N&&(P=typeof N=="string"?o.string2buf(N):g.call(N)==="[object ArrayBuffer]"?new Uint8Array(N):N,b=s.inflateSetDictionary(this.strm,P)),b===l.Z_BUF_ERROR&&D===!0&&(b=l.Z_OK,D=!1),b!==l.Z_STREAM_END&&b!==l.Z_OK)return this.onEnd(b),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&b!==l.Z_STREAM_END&&(C.avail_in!==0||E!==l.Z_FINISH&&E!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=o.utf8border(C.output,C.next_out),A=C.next_out-S,T=o.buf2string(C.output,S),C.next_out=A,C.avail_out=I-A,A&&a.arraySet(C.output,C.output,S,A,0),this.onData(T)):this.onData(a.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(D=!0)}while((0<C.avail_in||C.avail_out===0)&&b!==l.Z_STREAM_END);return b===l.Z_STREAM_END&&(E=l.Z_FINISH),E===l.Z_FINISH?(b=s.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===l.Z_OK):E!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(C.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=m,i.inflate=x,i.inflateRaw=function(y,v){return(v=v||{}).raw=!0,x(y,v)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(l[f]=d[f])}}return l},i.shrinkBuf=function(l,u){return l.length===u?l:l.subarray?l.subarray(0,u):(l.length=u,l)};var a={arraySet:function(l,u,d,f,g){if(u.subarray&&l.subarray)l.set(u.subarray(d,d+f),g);else for(var m=0;m<f;m++)l[g+m]=u[d+m]},flattenChunks:function(l){var u,d,f,g,m,x;for(u=f=0,d=l.length;u<d;u++)f+=l[u].length;for(x=new Uint8Array(f),u=g=0,d=l.length;u<d;u++)m=l[u],x.set(m,g),g+=m.length;return x}},o={arraySet:function(l,u,d,f,g){for(var m=0;m<f;m++)l[g+m]=u[d+m]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,a)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(s)},{}],42:[function(n,r,i){var s=n("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new s.Buf8(256),u=0;u<256;u++)l[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,g){if(g<65537&&(f.subarray&&o||!f.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(f,g));for(var m="",x=0;x<g;x++)m+=String.fromCharCode(f[x]);return m}l[254]=l[254]=1,i.string2buf=function(f){var g,m,x,y,v,b=f.length,E=0;for(y=0;y<b;y++)(64512&(m=f.charCodeAt(y)))==55296&&y+1<b&&(64512&(x=f.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),y++),E+=m<128?1:m<2048?2:m<65536?3:4;for(g=new s.Buf8(E),y=v=0;v<E;y++)(64512&(m=f.charCodeAt(y)))==55296&&y+1<b&&(64512&(x=f.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),y++),m<128?g[v++]=m:(m<2048?g[v++]=192|m>>>6:(m<65536?g[v++]=224|m>>>12:(g[v++]=240|m>>>18,g[v++]=128|m>>>12&63),g[v++]=128|m>>>6&63),g[v++]=128|63&m);return g},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var g=new s.Buf8(f.length),m=0,x=g.length;m<x;m++)g[m]=f.charCodeAt(m);return g},i.buf2string=function(f,g){var m,x,y,v,b=g||f.length,E=new Array(2*b);for(m=x=0;m<b;)if((y=f[m++])<128)E[x++]=y;else if(4<(v=l[y]))E[x++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<b;)y=y<<6|63&f[m++],v--;1<v?E[x++]=65533:y<65536?E[x++]=y:(y-=65536,E[x++]=55296|y>>10&1023,E[x++]=56320|1023&y)}return d(E,x)},i.utf8border=function(f,g){var m;for((g=g||f.length)>f.length&&(g=f.length),m=g-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?g:m+l[f[m]]>g?m:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(s,a,o,l){for(var u=65535&s|0,d=s>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3<o?2e3:o;d=d+(u=u+a[l++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var s=(function(){for(var a,o=[],l=0;l<256;l++){a=l;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;o[l]=a}return o})();r.exports=function(a,o,l,u){var d=s,f=u+l;a^=-1;for(var g=u;g<f;g++)a=a>>>8^d[255&(a^o[g])];return-1^a}},{}],46:[function(n,r,i){var s,a=n("../utils/common"),o=n("./trees"),l=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,g=4,m=0,x=-2,y=-1,v=4,b=2,E=8,S=9,A=286,T=30,P=19,C=2*A+1,I=15,N=3,D=258,F=D+N+1,L=42,q=113,R=1,V=2,K=3,W=4;function ne(H,z){return H.msg=d[z],z}function Y(H){return(H<<1)-(4<H?9:0)}function Z(H){for(var z=H.length;0<=--z;)H[z]=0}function U(H){var z=H.state,re=z.pending;re>H.avail_out&&(re=H.avail_out),re!==0&&(a.arraySet(H.output,z.pending_buf,z.pending_out,re,H.next_out),H.next_out+=re,z.pending_out+=re,H.total_out+=re,H.avail_out-=re,z.pending-=re,z.pending===0&&(z.pending_out=0))}function $(H,z){o._tr_flush_block(H,0<=H.block_start?H.block_start:-1,H.strstart-H.block_start,z),H.block_start=H.strstart,U(H.strm)}function ee(H,z){H.pending_buf[H.pending++]=z}function ae(H,z){H.pending_buf[H.pending++]=z>>>8&255,H.pending_buf[H.pending++]=255&z}function fe(H,z){var re,G,J=H.max_chain_length,le=H.strstart,ke=H.prev_length,Ne=H.nice_match,we=H.strstart>H.w_size-F?H.strstart-(H.w_size-F):0,B=H.window,j=H.w_mask,te=H.prev,be=H.strstart+D,_e=B[le+ke-1],ge=B[le+ke];H.prev_length>=H.good_match&&(J>>=2),Ne>H.lookahead&&(Ne=H.lookahead);do if(B[(re=z)+ke]===ge&&B[re+ke-1]===_e&&B[re]===B[le]&&B[++re]===B[le+1]){le+=2,re++;do;while(B[++le]===B[++re]&&B[++le]===B[++re]&&B[++le]===B[++re]&&B[++le]===B[++re]&&B[++le]===B[++re]&&B[++le]===B[++re]&&B[++le]===B[++re]&&B[++le]===B[++re]&&le<be);if(G=D-(be-le),le=be-D,ke<G){if(H.match_start=z,Ne<=(ke=G))break;_e=B[le+ke-1],ge=B[le+ke]}}while((z=te[z&j])>we&&--J!=0);return ke<=H.lookahead?ke:H.lookahead}function ue(H){var z,re,G,J,le,ke,Ne,we,B,j,te=H.w_size;do{if(J=H.window_size-H.lookahead-H.strstart,H.strstart>=te+(te-F)){for(a.arraySet(H.window,H.window,te,te,0),H.match_start-=te,H.strstart-=te,H.block_start-=te,z=re=H.hash_size;G=H.head[--z],H.head[z]=te<=G?G-te:0,--re;);for(z=re=te;G=H.prev[--z],H.prev[z]=te<=G?G-te:0,--re;);J+=te}if(H.strm.avail_in===0)break;if(ke=H.strm,Ne=H.window,we=H.strstart+H.lookahead,B=J,j=void 0,j=ke.avail_in,B<j&&(j=B),re=j===0?0:(ke.avail_in-=j,a.arraySet(Ne,ke.input,ke.next_in,j,we),ke.state.wrap===1?ke.adler=l(ke.adler,Ne,j,we):ke.state.wrap===2&&(ke.adler=u(ke.adler,Ne,j,we)),ke.next_in+=j,ke.total_in+=j,j),H.lookahead+=re,H.lookahead+H.insert>=N)for(le=H.strstart-H.insert,H.ins_h=H.window[le],H.ins_h=(H.ins_h<<H.hash_shift^H.window[le+1])&H.hash_mask;H.insert&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[le+N-1])&H.hash_mask,H.prev[le&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=le,le++,H.insert--,!(H.lookahead+H.insert<N)););}while(H.lookahead<F&&H.strm.avail_in!==0)}function xe(H,z){for(var re,G;;){if(H.lookahead<F){if(ue(H),H.lookahead<F&&z===f)return R;if(H.lookahead===0)break}if(re=0,H.lookahead>=N&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+N-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>=N)if(G=o._tr_tally(H,H.strstart-H.match_start,H.match_length-N),H.lookahead-=H.match_length,H.match_length<=H.max_lazy_match&&H.lookahead>=N){for(H.match_length--;H.strstart++,H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+N-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 G=o._tr_tally(H,0,H.window[H.strstart]),H.lookahead--,H.strstart++;if(G&&($(H,!1),H.strm.avail_out===0))return R}return H.insert=H.strstart<N-1?H.strstart:N-1,z===g?($(H,!0),H.strm.avail_out===0?K:W):H.last_lit&&($(H,!1),H.strm.avail_out===0)?R:V}function Me(H,z){for(var re,G,J;;){if(H.lookahead<F){if(ue(H),H.lookahead<F&&z===f)return R;if(H.lookahead===0)break}if(re=0,H.lookahead>=N&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+N-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=N-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===N&&4096<H.strstart-H.match_start)&&(H.match_length=N-1)),H.prev_length>=N&&H.match_length<=H.prev_length){for(J=H.strstart+H.lookahead-N,G=o._tr_tally(H,H.strstart-1-H.prev_match,H.prev_length-N),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+N-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=N-1,H.strstart++,G&&($(H,!1),H.strm.avail_out===0))return R}else if(H.match_available){if((G=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&&(G=o._tr_tally(H,0,H.window[H.strstart-1]),H.match_available=0),H.insert=H.strstart<N-1?H.strstart:N-1,z===g?($(H,!0),H.strm.avail_out===0?K:W):H.last_lit&&($(H,!1),H.strm.avail_out===0)?R:V}function se(H,z,re,G,J){this.good_length=H,this.max_lazy=z,this.nice_length=re,this.max_chain=G,this.func=J}function ve(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=E,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*C),this.dyn_dtree=new a.Buf16(2*(2*T+1)),this.bl_tree=new a.Buf16(2*(2*P+1)),Z(this.dyn_ltree),Z(this.dyn_dtree),Z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(I+1),this.heap=new a.Buf16(2*A+1),Z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*A+1),Z(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function je(H){var z;return H&&H.state?(H.total_in=H.total_out=0,H.data_type=b,(z=H.state).pending=0,z.pending_out=0,z.wrap<0&&(z.wrap=-z.wrap),z.status=z.wrap?L:q,H.adler=z.wrap===2?0:1,z.last_flush=f,o._tr_init(z),m):ne(H,x)}function de(H){var z=je(H);return z===m&&(function(re){re.window_size=2*re.w_size,Z(re.head),re.max_lazy_match=s[re.level].max_lazy,re.good_match=s[re.level].good_length,re.nice_match=s[re.level].nice_length,re.max_chain_length=s[re.level].max_chain,re.strstart=0,re.block_start=0,re.lookahead=0,re.insert=0,re.match_length=re.prev_length=N-1,re.match_available=0,re.ins_h=0})(H.state),z}function ut(H,z,re,G,J,le){if(!H)return x;var ke=1;if(z===y&&(z=6),G<0?(ke=0,G=-G):15<G&&(ke=2,G-=16),J<1||S<J||re!==E||G<8||15<G||z<0||9<z||le<0||v<le)return ne(H,x);G===8&&(G=9);var Ne=new ve;return(H.state=Ne).strm=H,Ne.wrap=ke,Ne.gzhead=null,Ne.w_bits=G,Ne.w_size=1<<Ne.w_bits,Ne.w_mask=Ne.w_size-1,Ne.hash_bits=J+7,Ne.hash_size=1<<Ne.hash_bits,Ne.hash_mask=Ne.hash_size-1,Ne.hash_shift=~~((Ne.hash_bits+N-1)/N),Ne.window=new a.Buf8(2*Ne.w_size),Ne.head=new a.Buf16(Ne.hash_size),Ne.prev=new a.Buf16(Ne.w_size),Ne.lit_bufsize=1<<J+6,Ne.pending_buf_size=4*Ne.lit_bufsize,Ne.pending_buf=new a.Buf8(Ne.pending_buf_size),Ne.d_buf=1*Ne.lit_bufsize,Ne.l_buf=3*Ne.lit_bufsize,Ne.level=z,Ne.strategy=le,Ne.method=re,de(H)}s=[new se(0,0,0,0,function(H,z){var re=65535;for(re>H.pending_buf_size-5&&(re=H.pending_buf_size-5);;){if(H.lookahead<=1){if(ue(H),H.lookahead===0&&z===f)return R;if(H.lookahead===0)break}H.strstart+=H.lookahead,H.lookahead=0;var G=H.block_start+re;if((H.strstart===0||H.strstart>=G)&&(H.lookahead=H.strstart-G,H.strstart=G,$(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,z===g?($(H,!0),H.strm.avail_out===0?K:W):(H.strstart>H.block_start&&($(H,!1),H.strm.avail_out),R)}),new se(4,4,8,4,xe),new se(4,5,16,8,xe),new se(4,6,32,32,xe),new se(4,4,16,16,Me),new se(8,16,32,32,Me),new se(8,16,128,128,Me),new se(8,32,128,256,Me),new se(32,128,258,1024,Me),new se(32,258,258,4096,Me)],i.deflateInit=function(H,z){return ut(H,z,E,15,8,0)},i.deflateInit2=ut,i.deflateReset=de,i.deflateResetKeep=je,i.deflateSetHeader=function(H,z){return H&&H.state?H.state.wrap!==2?x:(H.state.gzhead=z,m):x},i.deflate=function(H,z){var re,G,J,le;if(!H||!H.state||5<z||z<0)return H?ne(H,x):x;if(G=H.state,!H.output||!H.input&&H.avail_in!==0||G.status===666&&z!==g)return ne(H,H.avail_out===0?-5:x);if(G.strm=H,re=G.last_flush,G.last_flush=z,G.status===L)if(G.wrap===2)H.adler=0,ee(G,31),ee(G,139),ee(G,8),G.gzhead?(ee(G,(G.gzhead.text?1:0)+(G.gzhead.hcrc?2:0)+(G.gzhead.extra?4:0)+(G.gzhead.name?8:0)+(G.gzhead.comment?16:0)),ee(G,255&G.gzhead.time),ee(G,G.gzhead.time>>8&255),ee(G,G.gzhead.time>>16&255),ee(G,G.gzhead.time>>24&255),ee(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),ee(G,255&G.gzhead.os),G.gzhead.extra&&G.gzhead.extra.length&&(ee(G,255&G.gzhead.extra.length),ee(G,G.gzhead.extra.length>>8&255)),G.gzhead.hcrc&&(H.adler=u(H.adler,G.pending_buf,G.pending,0)),G.gzindex=0,G.status=69):(ee(G,0),ee(G,0),ee(G,0),ee(G,0),ee(G,0),ee(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),ee(G,3),G.status=q);else{var ke=E+(G.w_bits-8<<4)<<8;ke|=(2<=G.strategy||G.level<2?0:G.level<6?1:G.level===6?2:3)<<6,G.strstart!==0&&(ke|=32),ke+=31-ke%31,G.status=q,ae(G,ke),G.strstart!==0&&(ae(G,H.adler>>>16),ae(G,65535&H.adler)),H.adler=1}if(G.status===69)if(G.gzhead.extra){for(J=G.pending;G.gzindex<(65535&G.gzhead.extra.length)&&(G.pending!==G.pending_buf_size||(G.gzhead.hcrc&&G.pending>J&&(H.adler=u(H.adler,G.pending_buf,G.pending-J,J)),U(H),J=G.pending,G.pending!==G.pending_buf_size));)ee(G,255&G.gzhead.extra[G.gzindex]),G.gzindex++;G.gzhead.hcrc&&G.pending>J&&(H.adler=u(H.adler,G.pending_buf,G.pending-J,J)),G.gzindex===G.gzhead.extra.length&&(G.gzindex=0,G.status=73)}else G.status=73;if(G.status===73)if(G.gzhead.name){J=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>J&&(H.adler=u(H.adler,G.pending_buf,G.pending-J,J)),U(H),J=G.pending,G.pending===G.pending_buf_size)){le=1;break}le=G.gzindex<G.gzhead.name.length?255&G.gzhead.name.charCodeAt(G.gzindex++):0,ee(G,le)}while(le!==0);G.gzhead.hcrc&&G.pending>J&&(H.adler=u(H.adler,G.pending_buf,G.pending-J,J)),le===0&&(G.gzindex=0,G.status=91)}else G.status=91;if(G.status===91)if(G.gzhead.comment){J=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>J&&(H.adler=u(H.adler,G.pending_buf,G.pending-J,J)),U(H),J=G.pending,G.pending===G.pending_buf_size)){le=1;break}le=G.gzindex<G.gzhead.comment.length?255&G.gzhead.comment.charCodeAt(G.gzindex++):0,ee(G,le)}while(le!==0);G.gzhead.hcrc&&G.pending>J&&(H.adler=u(H.adler,G.pending_buf,G.pending-J,J)),le===0&&(G.status=103)}else G.status=103;if(G.status===103&&(G.gzhead.hcrc?(G.pending+2>G.pending_buf_size&&U(H),G.pending+2<=G.pending_buf_size&&(ee(G,255&H.adler),ee(G,H.adler>>8&255),H.adler=0,G.status=q)):G.status=q),G.pending!==0){if(U(H),H.avail_out===0)return G.last_flush=-1,m}else if(H.avail_in===0&&Y(z)<=Y(re)&&z!==g)return ne(H,-5);if(G.status===666&&H.avail_in!==0)return ne(H,-5);if(H.avail_in!==0||G.lookahead!==0||z!==f&&G.status!==666){var Ne=G.strategy===2?(function(we,B){for(var j;;){if(we.lookahead===0&&(ue(we),we.lookahead===0)){if(B===f)return R;break}if(we.match_length=0,j=o._tr_tally(we,0,we.window[we.strstart]),we.lookahead--,we.strstart++,j&&($(we,!1),we.strm.avail_out===0))return R}return we.insert=0,B===g?($(we,!0),we.strm.avail_out===0?K:W):we.last_lit&&($(we,!1),we.strm.avail_out===0)?R:V})(G,z):G.strategy===3?(function(we,B){for(var j,te,be,_e,ge=we.window;;){if(we.lookahead<=D){if(ue(we),we.lookahead<=D&&B===f)return R;if(we.lookahead===0)break}if(we.match_length=0,we.lookahead>=N&&0<we.strstart&&(te=ge[be=we.strstart-1])===ge[++be]&&te===ge[++be]&&te===ge[++be]){_e=we.strstart+D;do;while(te===ge[++be]&&te===ge[++be]&&te===ge[++be]&&te===ge[++be]&&te===ge[++be]&&te===ge[++be]&&te===ge[++be]&&te===ge[++be]&&be<_e);we.match_length=D-(_e-be),we.match_length>we.lookahead&&(we.match_length=we.lookahead)}if(we.match_length>=N?(j=o._tr_tally(we,1,we.match_length-N),we.lookahead-=we.match_length,we.strstart+=we.match_length,we.match_length=0):(j=o._tr_tally(we,0,we.window[we.strstart]),we.lookahead--,we.strstart++),j&&($(we,!1),we.strm.avail_out===0))return R}return we.insert=0,B===g?($(we,!0),we.strm.avail_out===0?K:W):we.last_lit&&($(we,!1),we.strm.avail_out===0)?R:V})(G,z):s[G.level].func(G,z);if(Ne!==K&&Ne!==W||(G.status=666),Ne===R||Ne===K)return H.avail_out===0&&(G.last_flush=-1),m;if(Ne===V&&(z===1?o._tr_align(G):z!==5&&(o._tr_stored_block(G,0,0,!1),z===3&&(Z(G.head),G.lookahead===0&&(G.strstart=0,G.block_start=0,G.insert=0))),U(H),H.avail_out===0))return G.last_flush=-1,m}return z!==g?m:G.wrap<=0?1:(G.wrap===2?(ee(G,255&H.adler),ee(G,H.adler>>8&255),ee(G,H.adler>>16&255),ee(G,H.adler>>24&255),ee(G,255&H.total_in),ee(G,H.total_in>>8&255),ee(G,H.total_in>>16&255),ee(G,H.total_in>>24&255)):(ae(G,H.adler>>>16),ae(G,65535&H.adler)),U(H),0<G.wrap&&(G.wrap=-G.wrap),G.pending!==0?m:1)},i.deflateEnd=function(H){var z;return H&&H.state?(z=H.state.status)!==L&&z!==69&&z!==73&&z!==91&&z!==103&&z!==q&&z!==666?ne(H,x):(H.state=null,z===q?ne(H,-3):m):x},i.deflateSetDictionary=function(H,z){var re,G,J,le,ke,Ne,we,B,j=z.length;if(!H||!H.state||(le=(re=H.state).wrap)===2||le===1&&re.status!==L||re.lookahead)return x;for(le===1&&(H.adler=l(H.adler,z,j,0)),re.wrap=0,j>=re.w_size&&(le===0&&(Z(re.head),re.strstart=0,re.block_start=0,re.insert=0),B=new a.Buf8(re.w_size),a.arraySet(B,z,j-re.w_size,re.w_size,0),z=B,j=re.w_size),ke=H.avail_in,Ne=H.next_in,we=H.input,H.avail_in=j,H.next_in=0,H.input=z,ue(re);re.lookahead>=N;){for(G=re.strstart,J=re.lookahead-(N-1);re.ins_h=(re.ins_h<<re.hash_shift^re.window[G+N-1])&re.hash_mask,re.prev[G&re.w_mask]=re.head[re.ins_h],re.head[re.ins_h]=G,G++,--J;);re.strstart=G,re.lookahead=N-1,ue(re)}return re.strstart+=re.lookahead,re.block_start=re.strstart,re.insert=re.lookahead,re.lookahead=0,re.match_length=re.prev_length=N-1,re.match_available=0,H.next_in=Ne,H.input=we,H.avail_in=ke,re.wrap=le,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(s,a){var o,l,u,d,f,g,m,x,y,v,b,E,S,A,T,P,C,I,N,D,F,L,q,R,V;o=s.state,l=s.next_in,R=s.input,u=l+(s.avail_in-5),d=s.next_out,V=s.output,f=d-(a-s.avail_out),g=d+(s.avail_out-257),m=o.dmax,x=o.wsize,y=o.whave,v=o.wnext,b=o.window,E=o.hold,S=o.bits,A=o.lencode,T=o.distcode,P=(1<<o.lenbits)-1,C=(1<<o.distbits)-1;e:do{S<15&&(E+=R[l++]<<S,S+=8,E+=R[l++]<<S,S+=8),I=A[E&P];t:for(;;){if(E>>>=N=I>>>24,S-=N,(N=I>>>16&255)===0)V[d++]=65535&I;else{if(!(16&N)){if((64&N)==0){I=A[(65535&I)+(E&(1<<N)-1)];continue t}if(32&N){o.mode=12;break e}s.msg="invalid literal/length code",o.mode=30;break e}D=65535&I,(N&=15)&&(S<N&&(E+=R[l++]<<S,S+=8),D+=E&(1<<N)-1,E>>>=N,S-=N),S<15&&(E+=R[l++]<<S,S+=8,E+=R[l++]<<S,S+=8),I=T[E&C];n:for(;;){if(E>>>=N=I>>>24,S-=N,!(16&(N=I>>>16&255))){if((64&N)==0){I=T[(65535&I)+(E&(1<<N)-1)];continue n}s.msg="invalid distance code",o.mode=30;break e}if(F=65535&I,S<(N&=15)&&(E+=R[l++]<<S,(S+=8)<N&&(E+=R[l++]<<S,S+=8)),m<(F+=E&(1<<N)-1)){s.msg="invalid distance too far back",o.mode=30;break e}if(E>>>=N,S-=N,(N=d-f)<F){if(y<(N=F-N)&&o.sane){s.msg="invalid distance too far back",o.mode=30;break e}if(q=b,(L=0)===v){if(L+=x-N,N<D){for(D-=N;V[d++]=b[L++],--N;);L=d-F,q=V}}else if(v<N){if(L+=x+v-N,(N-=v)<D){for(D-=N;V[d++]=b[L++],--N;);if(L=0,v<D){for(D-=N=v;V[d++]=b[L++],--N;);L=d-F,q=V}}}else if(L+=v-N,N<D){for(D-=N;V[d++]=b[L++],--N;);L=d-F,q=V}for(;2<D;)V[d++]=q[L++],V[d++]=q[L++],V[d++]=q[L++],D-=3;D&&(V[d++]=q[L++],1<D&&(V[d++]=q[L++]))}else{for(L=d-F;V[d++]=V[L++],V[d++]=V[L++],V[d++]=V[L++],2<(D-=3););D&&(V[d++]=V[L++],1<D&&(V[d++]=V[L++]))}break}}break}}while(l<u&&d<g);l-=D=S>>3,E&=(1<<(S-=D<<3))-1,s.next_in=l,s.next_out=d,s.avail_in=l<u?u-l+5:5-(l-u),s.avail_out=d<g?g-d+257:257-(d-g),o.hold=E,o.bits=S}},{}],49:[function(n,r,i){var s=n("../utils/common"),a=n("./adler32"),o=n("./crc32"),l=n("./inffast"),u=n("./inftrees"),d=1,f=2,g=0,m=-2,x=1,y=852,v=592;function b(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function E(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function S(L){var q;return L&&L.state?(q=L.state,L.total_in=L.total_out=q.total=0,L.msg="",q.wrap&&(L.adler=1&q.wrap),q.mode=x,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new s.Buf32(y),q.distcode=q.distdyn=new s.Buf32(v),q.sane=1,q.back=-1,g):m}function A(L){var q;return L&&L.state?((q=L.state).wsize=0,q.whave=0,q.wnext=0,S(L)):m}function T(L,q){var R,V;return L&&L.state?(V=L.state,q<0?(R=0,q=-q):(R=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?m:(V.window!==null&&V.wbits!==q&&(V.window=null),V.wrap=R,V.wbits=q,A(L))):m}function P(L,q){var R,V;return L?(V=new E,(L.state=V).window=null,(R=T(L,q))!==g&&(L.state=null),R):m}var C,I,N=!0;function D(L){if(N){var q;for(C=new s.Buf32(512),I=new s.Buf32(32),q=0;q<144;)L.lens[q++]=8;for(;q<256;)L.lens[q++]=9;for(;q<280;)L.lens[q++]=7;for(;q<288;)L.lens[q++]=8;for(u(d,L.lens,0,288,C,0,L.work,{bits:9}),q=0;q<32;)L.lens[q++]=5;u(f,L.lens,0,32,I,0,L.work,{bits:5}),N=!1}L.lencode=C,L.lenbits=9,L.distcode=I,L.distbits=5}function F(L,q,R,V){var K,W=L.state;return W.window===null&&(W.wsize=1<<W.wbits,W.wnext=0,W.whave=0,W.window=new s.Buf8(W.wsize)),V>=W.wsize?(s.arraySet(W.window,q,R-W.wsize,W.wsize,0),W.wnext=0,W.whave=W.wsize):(V<(K=W.wsize-W.wnext)&&(K=V),s.arraySet(W.window,q,R-V,K,W.wnext),(V-=K)?(s.arraySet(W.window,q,R-V,V,0),W.wnext=V,W.whave=W.wsize):(W.wnext+=K,W.wnext===W.wsize&&(W.wnext=0),W.whave<W.wsize&&(W.whave+=K))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=S,i.inflateInit=function(L){return P(L,15)},i.inflateInit2=P,i.inflate=function(L,q){var R,V,K,W,ne,Y,Z,U,$,ee,ae,fe,ue,xe,Me,se,ve,je,de,ut,H,z,re,G,J=0,le=new s.Buf8(4),ke=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return m;(R=L.state).mode===12&&(R.mode=13),ne=L.next_out,K=L.output,Z=L.avail_out,W=L.next_in,V=L.input,Y=L.avail_in,U=R.hold,$=R.bits,ee=Y,ae=Z,z=g;e:for(;;)switch(R.mode){case x:if(R.wrap===0){R.mode=13;break}for(;$<16;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}if(2&R.wrap&&U===35615){le[R.check=0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0),$=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){L.msg="incorrect header check",R.mode=30;break}if((15&U)!=8){L.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){L.msg="invalid window size",R.mode=30;break}R.dmax=1<<H,L.adler=R.check=1,R.mode=512&U?10:12,$=U=0;break;case 2:for(;$<16;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}if(R.flags=U,(255&R.flags)!=8){L.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){L.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=U>>8&1),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0)),$=U=0,R.mode=3;case 3:for(;$<32;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}R.head&&(R.head.time=U),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,le[2]=U>>>16&255,le[3]=U>>>24&255,R.check=o(R.check,le,4,0)),$=U=0,R.mode=4;case 4:for(;$<16;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}R.head&&(R.head.xflags=255&U,R.head.os=U>>8),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0)),$=U=0,R.mode=5;case 5:if(1024&R.flags){for(;$<16;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}R.length=U,R.head&&(R.head.extra_len=U),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0)),$=U=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(Y<(fe=R.length)&&(fe=Y),fe&&(R.head&&(H=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),s.arraySet(R.head.extra,V,W,fe,H)),512&R.flags&&(R.check=o(R.check,V,fe,W)),Y-=fe,W+=fe,R.length-=fe),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(Y===0)break e;for(fe=0;H=V[W+fe++],R.head&&H&&R.length<65536&&(R.head.name+=String.fromCharCode(H)),H&&fe<Y;);if(512&R.flags&&(R.check=o(R.check,V,fe,W)),Y-=fe,W+=fe,H)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(Y===0)break e;for(fe=0;H=V[W+fe++],R.head&&H&&R.length<65536&&(R.head.comment+=String.fromCharCode(H)),H&&fe<Y;);if(512&R.flags&&(R.check=o(R.check,V,fe,W)),Y-=fe,W+=fe,H)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;$<16;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}if(U!==(65535&R.check)){L.msg="header crc mismatch",R.mode=30;break}$=U=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),L.adler=R.check=0,R.mode=12;break;case 10:for(;$<32;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}L.adler=R.check=b(U),$=U=0,R.mode=11;case 11:if(R.havedict===0)return L.next_out=ne,L.avail_out=Z,L.next_in=W,L.avail_in=Y,R.hold=U,R.bits=$,2;L.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(Y===0)break e;Y--,U+=V[W++]<<$,$+=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:L.msg="invalid block type",R.mode=30}U>>>=2,$-=2;break;case 14:for(U>>>=7&$,$-=7&$;$<32;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}if((65535&U)!=(U>>>16^65535)){L.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(Y<fe&&(fe=Y),Z<fe&&(fe=Z),fe===0)break e;s.arraySet(K,V,W,fe,ne),Y-=fe,W+=fe,Z-=fe,ne+=fe,R.length-=fe;break}R.mode=12;break;case 17:for(;$<14;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=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){L.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(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}R.lens[ke[R.have++]]=7&U,U>>>=3,$-=3}for(;R.have<19;)R.lens[ke[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,re={bits:R.lenbits},z=u(0,R.lens,0,19,R.lencode,0,R.work,re),R.lenbits=re.bits,z){L.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(;se=(J=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,ve=65535&J,!((Me=J>>>24)<=$);){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}if(ve<16)U>>>=Me,$-=Me,R.lens[R.have++]=ve;else{if(ve===16){for(G=Me+2;$<G;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}if(U>>>=Me,$-=Me,R.have===0){L.msg="invalid bit length repeat",R.mode=30;break}H=R.lens[R.have-1],fe=3+(3&U),U>>>=2,$-=2}else if(ve===17){for(G=Me+3;$<G;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}$-=Me,H=0,fe=3+(7&(U>>>=Me)),U>>>=3,$-=3}else{for(G=Me+7;$<G;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}$-=Me,H=0,fe=11+(127&(U>>>=Me)),U>>>=7,$-=7}if(R.have+fe>R.nlen+R.ndist){L.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){L.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,re={bits:R.lenbits},z=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,re),R.lenbits=re.bits,z){L.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,re={bits:R.distbits},z=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,re),R.distbits=re.bits,z){L.msg="invalid distances set",R.mode=30;break}if(R.mode=20,q===6)break e;case 20:R.mode=21;case 21:if(6<=Y&&258<=Z){L.next_out=ne,L.avail_out=Z,L.next_in=W,L.avail_in=Y,R.hold=U,R.bits=$,l(L,ae),ne=L.next_out,K=L.output,Z=L.avail_out,W=L.next_in,V=L.input,Y=L.avail_in,U=R.hold,$=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;se=(J=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,ve=65535&J,!((Me=J>>>24)<=$);){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}if(se&&(240&se)==0){for(je=Me,de=se,ut=ve;se=(J=R.lencode[ut+((U&(1<<je+de)-1)>>je)])>>>16&255,ve=65535&J,!(je+(Me=J>>>24)<=$);){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}U>>>=je,$-=je,R.back+=je}if(U>>>=Me,$-=Me,R.back+=Me,R.length=ve,se===0){R.mode=26;break}if(32&se){R.back=-1,R.mode=12;break}if(64&se){L.msg="invalid literal/length code",R.mode=30;break}R.extra=15&se,R.mode=22;case 22:if(R.extra){for(G=R.extra;$<G;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=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(;se=(J=R.distcode[U&(1<<R.distbits)-1])>>>16&255,ve=65535&J,!((Me=J>>>24)<=$);){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}if((240&se)==0){for(je=Me,de=se,ut=ve;se=(J=R.distcode[ut+((U&(1<<je+de)-1)>>je)])>>>16&255,ve=65535&J,!(je+(Me=J>>>24)<=$);){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}U>>>=je,$-=je,R.back+=je}if(U>>>=Me,$-=Me,R.back+=Me,64&se){L.msg="invalid distance code",R.mode=30;break}R.offset=ve,R.extra=15&se,R.mode=24;case 24:if(R.extra){for(G=R.extra;$<G;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}R.offset+=U&(1<<R.extra)-1,U>>>=R.extra,$-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){L.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(Z===0)break e;if(fe=ae-Z,R.offset>fe){if((fe=R.offset-fe)>R.whave&&R.sane){L.msg="invalid distance too far back",R.mode=30;break}ue=fe>R.wnext?(fe-=R.wnext,R.wsize-fe):R.wnext-fe,fe>R.length&&(fe=R.length),xe=R.window}else xe=K,ue=ne-R.offset,fe=R.length;for(Z<fe&&(fe=Z),Z-=fe,R.length-=fe;K[ne++]=xe[ue++],--fe;);R.length===0&&(R.mode=21);break;case 26:if(Z===0)break e;K[ne++]=R.length,Z--,R.mode=21;break;case 27:if(R.wrap){for(;$<32;){if(Y===0)break e;Y--,U|=V[W++]<<$,$+=8}if(ae-=Z,L.total_out+=ae,R.total+=ae,ae&&(L.adler=R.check=R.flags?o(R.check,K,ae,ne-ae):a(R.check,K,ae,ne-ae)),ae=Z,(R.flags?U:b(U))!==R.check){L.msg="incorrect data check",R.mode=30;break}$=U=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;$<32;){if(Y===0)break e;Y--,U+=V[W++]<<$,$+=8}if(U!==(4294967295&R.total)){L.msg="incorrect length check",R.mode=30;break}$=U=0}R.mode=29;case 29:z=1;break e;case 30:z=-3;break e;case 31:return-4;case 32:default:return m}return L.next_out=ne,L.avail_out=Z,L.next_in=W,L.avail_in=Y,R.hold=U,R.bits=$,(R.wsize||ae!==L.avail_out&&R.mode<30&&(R.mode<27||q!==4))&&F(L,L.output,L.next_out,ae-L.avail_out)?(R.mode=31,-4):(ee-=L.avail_in,ae-=L.avail_out,L.total_in+=ee,L.total_out+=ae,R.total+=ae,R.wrap&&ae&&(L.adler=R.check=R.flags?o(R.check,K,ae,L.next_out-ae):a(R.check,K,ae,L.next_out-ae)),L.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(ee==0&&ae===0||q===4)&&z===g&&(z=-5),z)},i.inflateEnd=function(L){if(!L||!L.state)return m;var q=L.state;return q.window&&(q.window=null),L.state=null,g},i.inflateGetHeader=function(L,q){var R;return L&&L.state?(2&(R=L.state).wrap)==0?m:((R.head=q).done=!1,g):m},i.inflateSetDictionary=function(L,q){var R,V=q.length;return L&&L.state?(R=L.state).wrap!==0&&R.mode!==11?m:R.mode===11&&a(1,q,V,0)!==R.check?-3:F(L,q,V,V)?(R.mode=31,-4):(R.havedict=1,g):m},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var s=n("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,g,m,x,y,v,b){var E,S,A,T,P,C,I,N,D,F=b.bits,L=0,q=0,R=0,V=0,K=0,W=0,ne=0,Y=0,Z=0,U=0,$=null,ee=0,ae=new s.Buf16(16),fe=new s.Buf16(16),ue=null,xe=0;for(L=0;L<=15;L++)ae[L]=0;for(q=0;q<m;q++)ae[f[g+q]]++;for(K=F,V=15;1<=V&&ae[V]===0;V--);if(V<K&&(K=V),V===0)return x[y++]=20971520,x[y++]=20971520,b.bits=1,0;for(R=1;R<V&&ae[R]===0;R++);for(K<R&&(K=R),L=Y=1;L<=15;L++)if(Y<<=1,(Y-=ae[L])<0)return-1;if(0<Y&&(d===0||V!==1))return-1;for(fe[1]=0,L=1;L<15;L++)fe[L+1]=fe[L]+ae[L];for(q=0;q<m;q++)f[g+q]!==0&&(v[fe[f[g+q]]++]=q);if(C=d===0?($=ue=v,19):d===1?($=a,ee-=257,ue=o,xe-=257,256):($=l,ue=u,-1),L=R,P=y,ne=q=U=0,A=-1,T=(Z=1<<(W=K))-1,d===1&&852<Z||d===2&&592<Z)return 1;for(;;){for(I=L-ne,D=v[q]<C?(N=0,v[q]):v[q]>C?(N=ue[xe+v[q]],$[ee+v[q]]):(N=96,0),E=1<<L-ne,R=S=1<<W;x[P+(U>>ne)+(S-=E)]=I<<24|N<<16|D|0,S!==0;);for(E=1<<L-1;U&E;)E>>=1;if(E!==0?(U&=E-1,U+=E):U=0,q++,--ae[L]==0){if(L===V)break;L=f[g+v[q]]}if(K<L&&(U&T)!==A){for(ne===0&&(ne=K),P+=R,Y=1<<(W=L-ne);W+ne<V&&!((Y-=ae[W+ne])<=0);)W++,Y<<=1;if(Z+=1<<W,d===1&&852<Z||d===2&&592<Z)return 1;x[A=U&T]=K<<24|W<<16|P-y|0}}return U!==0&&(x[P+U]=L-ne<<24|64<<16|0),b.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var s=n("../utils/common"),a=0,o=1;function l(J){for(var le=J.length;0<=--le;)J[le]=0}var u=0,d=29,f=256,g=f+1+d,m=30,x=19,y=2*g+1,v=15,b=16,E=7,S=256,A=16,T=17,P=18,C=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],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],N=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(g+2));l(F);var L=new Array(2*m);l(L);var q=new Array(512);l(q);var R=new Array(256);l(R);var V=new Array(d);l(V);var K,W,ne,Y=new Array(m);function Z(J,le,ke,Ne,we){this.static_tree=J,this.extra_bits=le,this.extra_base=ke,this.elems=Ne,this.max_length=we,this.has_stree=J&&J.length}function U(J,le){this.dyn_tree=J,this.max_code=0,this.stat_desc=le}function $(J){return J<256?q[J]:q[256+(J>>>7)]}function ee(J,le){J.pending_buf[J.pending++]=255&le,J.pending_buf[J.pending++]=le>>>8&255}function ae(J,le,ke){J.bi_valid>b-ke?(J.bi_buf|=le<<J.bi_valid&65535,ee(J,J.bi_buf),J.bi_buf=le>>b-J.bi_valid,J.bi_valid+=ke-b):(J.bi_buf|=le<<J.bi_valid&65535,J.bi_valid+=ke)}function fe(J,le,ke){ae(J,ke[2*le],ke[2*le+1])}function ue(J,le){for(var ke=0;ke|=1&J,J>>>=1,ke<<=1,0<--le;);return ke>>>1}function xe(J,le,ke){var Ne,we,B=new Array(v+1),j=0;for(Ne=1;Ne<=v;Ne++)B[Ne]=j=j+ke[Ne-1]<<1;for(we=0;we<=le;we++){var te=J[2*we+1];te!==0&&(J[2*we]=ue(B[te]++,te))}}function Me(J){var le;for(le=0;le<g;le++)J.dyn_ltree[2*le]=0;for(le=0;le<m;le++)J.dyn_dtree[2*le]=0;for(le=0;le<x;le++)J.bl_tree[2*le]=0;J.dyn_ltree[2*S]=1,J.opt_len=J.static_len=0,J.last_lit=J.matches=0}function se(J){8<J.bi_valid?ee(J,J.bi_buf):0<J.bi_valid&&(J.pending_buf[J.pending++]=J.bi_buf),J.bi_buf=0,J.bi_valid=0}function ve(J,le,ke,Ne){var we=2*le,B=2*ke;return J[we]<J[B]||J[we]===J[B]&&Ne[le]<=Ne[ke]}function je(J,le,ke){for(var Ne=J.heap[ke],we=ke<<1;we<=J.heap_len&&(we<J.heap_len&&ve(le,J.heap[we+1],J.heap[we],J.depth)&&we++,!ve(le,Ne,J.heap[we],J.depth));)J.heap[ke]=J.heap[we],ke=we,we<<=1;J.heap[ke]=Ne}function de(J,le,ke){var Ne,we,B,j,te=0;if(J.last_lit!==0)for(;Ne=J.pending_buf[J.d_buf+2*te]<<8|J.pending_buf[J.d_buf+2*te+1],we=J.pending_buf[J.l_buf+te],te++,Ne===0?fe(J,we,le):(fe(J,(B=R[we])+f+1,le),(j=C[B])!==0&&ae(J,we-=V[B],j),fe(J,B=$(--Ne),ke),(j=I[B])!==0&&ae(J,Ne-=Y[B],j)),te<J.last_lit;);fe(J,S,le)}function ut(J,le){var ke,Ne,we,B=le.dyn_tree,j=le.stat_desc.static_tree,te=le.stat_desc.has_stree,be=le.stat_desc.elems,_e=-1;for(J.heap_len=0,J.heap_max=y,ke=0;ke<be;ke++)B[2*ke]!==0?(J.heap[++J.heap_len]=_e=ke,J.depth[ke]=0):B[2*ke+1]=0;for(;J.heap_len<2;)B[2*(we=J.heap[++J.heap_len]=_e<2?++_e:0)]=1,J.depth[we]=0,J.opt_len--,te&&(J.static_len-=j[2*we+1]);for(le.max_code=_e,ke=J.heap_len>>1;1<=ke;ke--)je(J,B,ke);for(we=be;ke=J.heap[1],J.heap[1]=J.heap[J.heap_len--],je(J,B,1),Ne=J.heap[1],J.heap[--J.heap_max]=ke,J.heap[--J.heap_max]=Ne,B[2*we]=B[2*ke]+B[2*Ne],J.depth[we]=(J.depth[ke]>=J.depth[Ne]?J.depth[ke]:J.depth[Ne])+1,B[2*ke+1]=B[2*Ne+1]=we,J.heap[1]=we++,je(J,B,1),2<=J.heap_len;);J.heap[--J.heap_max]=J.heap[1],(function(ge,me){var Ae,ze,st,Ve,ce,Ye,$e=me.dyn_tree,Ze=me.max_code,at=me.stat_desc.static_tree,Q=me.stat_desc.has_stree,Fe=me.stat_desc.extra_bits,pe=me.stat_desc.extra_base,Ue=me.stat_desc.max_length,Ce=0;for(Ve=0;Ve<=v;Ve++)ge.bl_count[Ve]=0;for($e[2*ge.heap[ge.heap_max]+1]=0,Ae=ge.heap_max+1;Ae<y;Ae++)Ue<(Ve=$e[2*$e[2*(ze=ge.heap[Ae])+1]+1]+1)&&(Ve=Ue,Ce++),$e[2*ze+1]=Ve,Ze<ze||(ge.bl_count[Ve]++,ce=0,pe<=ze&&(ce=Fe[ze-pe]),Ye=$e[2*ze],ge.opt_len+=Ye*(Ve+ce),Q&&(ge.static_len+=Ye*(at[2*ze+1]+ce)));if(Ce!==0){do{for(Ve=Ue-1;ge.bl_count[Ve]===0;)Ve--;ge.bl_count[Ve]--,ge.bl_count[Ve+1]+=2,ge.bl_count[Ue]--,Ce-=2}while(0<Ce);for(Ve=Ue;Ve!==0;Ve--)for(ze=ge.bl_count[Ve];ze!==0;)Ze<(st=ge.heap[--Ae])||($e[2*st+1]!==Ve&&(ge.opt_len+=(Ve-$e[2*st+1])*$e[2*st],$e[2*st+1]=Ve),ze--)}})(J,le),xe(B,_e,J.bl_count)}function H(J,le,ke){var Ne,we,B=-1,j=le[1],te=0,be=7,_e=4;for(j===0&&(be=138,_e=3),le[2*(ke+1)+1]=65535,Ne=0;Ne<=ke;Ne++)we=j,j=le[2*(Ne+1)+1],++te<be&&we===j||(te<_e?J.bl_tree[2*we]+=te:we!==0?(we!==B&&J.bl_tree[2*we]++,J.bl_tree[2*A]++):te<=10?J.bl_tree[2*T]++:J.bl_tree[2*P]++,B=we,_e=(te=0)===j?(be=138,3):we===j?(be=6,3):(be=7,4))}function z(J,le,ke){var Ne,we,B=-1,j=le[1],te=0,be=7,_e=4;for(j===0&&(be=138,_e=3),Ne=0;Ne<=ke;Ne++)if(we=j,j=le[2*(Ne+1)+1],!(++te<be&&we===j)){if(te<_e)for(;fe(J,we,J.bl_tree),--te!=0;);else we!==0?(we!==B&&(fe(J,we,J.bl_tree),te--),fe(J,A,J.bl_tree),ae(J,te-3,2)):te<=10?(fe(J,T,J.bl_tree),ae(J,te-3,3)):(fe(J,P,J.bl_tree),ae(J,te-11,7));B=we,_e=(te=0)===j?(be=138,3):we===j?(be=6,3):(be=7,4)}}l(Y);var re=!1;function G(J,le,ke,Ne){ae(J,(u<<1)+(Ne?1:0),3),(function(we,B,j,te){se(we),ee(we,j),ee(we,~j),s.arraySet(we.pending_buf,we.window,B,j,we.pending),we.pending+=j})(J,le,ke)}i._tr_init=function(J){re||((function(){var le,ke,Ne,we,B,j=new Array(v+1);for(we=Ne=0;we<d-1;we++)for(V[we]=Ne,le=0;le<1<<C[we];le++)R[Ne++]=we;for(R[Ne-1]=we,we=B=0;we<16;we++)for(Y[we]=B,le=0;le<1<<I[we];le++)q[B++]=we;for(B>>=7;we<m;we++)for(Y[we]=B<<7,le=0;le<1<<I[we]-7;le++)q[256+B++]=we;for(ke=0;ke<=v;ke++)j[ke]=0;for(le=0;le<=143;)F[2*le+1]=8,le++,j[8]++;for(;le<=255;)F[2*le+1]=9,le++,j[9]++;for(;le<=279;)F[2*le+1]=7,le++,j[7]++;for(;le<=287;)F[2*le+1]=8,le++,j[8]++;for(xe(F,g+1,j),le=0;le<m;le++)L[2*le+1]=5,L[2*le]=ue(le,5);K=new Z(F,C,f+1,g,v),W=new Z(L,I,0,m,v),ne=new Z(new Array(0),N,0,x,E)})(),re=!0),J.l_desc=new U(J.dyn_ltree,K),J.d_desc=new U(J.dyn_dtree,W),J.bl_desc=new U(J.bl_tree,ne),J.bi_buf=0,J.bi_valid=0,Me(J)},i._tr_stored_block=G,i._tr_flush_block=function(J,le,ke,Ne){var we,B,j=0;0<J.level?(J.strm.data_type===2&&(J.strm.data_type=(function(te){var be,_e=4093624447;for(be=0;be<=31;be++,_e>>>=1)if(1&_e&&te.dyn_ltree[2*be]!==0)return a;if(te.dyn_ltree[18]!==0||te.dyn_ltree[20]!==0||te.dyn_ltree[26]!==0)return o;for(be=32;be<f;be++)if(te.dyn_ltree[2*be]!==0)return o;return a})(J)),ut(J,J.l_desc),ut(J,J.d_desc),j=(function(te){var be;for(H(te,te.dyn_ltree,te.l_desc.max_code),H(te,te.dyn_dtree,te.d_desc.max_code),ut(te,te.bl_desc),be=x-1;3<=be&&te.bl_tree[2*D[be]+1]===0;be--);return te.opt_len+=3*(be+1)+5+5+4,be})(J),we=J.opt_len+3+7>>>3,(B=J.static_len+3+7>>>3)<=we&&(we=B)):we=B=ke+5,ke+4<=we&&le!==-1?G(J,le,ke,Ne):J.strategy===4||B===we?(ae(J,2+(Ne?1:0),3),de(J,F,L)):(ae(J,4+(Ne?1:0),3),(function(te,be,_e,ge){var me;for(ae(te,be-257,5),ae(te,_e-1,5),ae(te,ge-4,4),me=0;me<ge;me++)ae(te,te.bl_tree[2*D[me]+1],3);z(te,te.dyn_ltree,be-1),z(te,te.dyn_dtree,_e-1)})(J,J.l_desc.max_code+1,J.d_desc.max_code+1,j+1),de(J,J.dyn_ltree,J.dyn_dtree)),Me(J),Ne&&se(J)},i._tr_tally=function(J,le,ke){return J.pending_buf[J.d_buf+2*J.last_lit]=le>>>8&255,J.pending_buf[J.d_buf+2*J.last_lit+1]=255&le,J.pending_buf[J.l_buf+J.last_lit]=255&ke,J.last_lit++,le===0?J.dyn_ltree[2*ke]++:(J.matches++,le--,J.dyn_ltree[2*(R[ke]+f+1)]++,J.dyn_dtree[2*$(le)]++),J.last_lit===J.lit_bufsize-1},i._tr_align=function(J){ae(J,2,3),fe(J,S,F),(function(le){le.bi_valid===16?(ee(le,le.bi_buf),le.bi_buf=0,le.bi_valid=0):8<=le.bi_valid&&(le.pending_buf[le.pending++]=255&le.bi_buf,le.bi_buf>>=8,le.bi_valid-=8)})(J)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(s){(function(a,o){if(!a.setImmediate){var l,u,d,f,g=1,m={},x=!1,y=a.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(a);v=v&&v.setTimeout?v:a,l={}.toString.call(a.process)==="[object process]"?function(A){process.nextTick(function(){E(A)})}:(function(){if(a.postMessage&&!a.importScripts){var A=!0,T=a.onmessage;return a.onmessage=function(){A=!1},a.postMessage("","*"),a.onmessage=T,A}})()?(f="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",S,!1):a.attachEvent("onmessage",S),function(A){a.postMessage(f+A,"*")}):a.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){E(A.data)},function(A){d.port2.postMessage(A)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(A){var T=y.createElement("script");T.onreadystatechange=function(){E(A),T.onreadystatechange=null,u.removeChild(T),T=null},u.appendChild(T)}):function(A){setTimeout(E,0,A)},v.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var T=new Array(arguments.length-1),P=0;P<T.length;P++)T[P]=arguments[P+1];var C={callback:A,args:T};return m[g]=C,l(g),g++},v.clearImmediate=b}function b(A){delete m[A]}function E(A){if(x)setTimeout(E,0,A);else{var T=m[A];if(T){x=!0;try{(function(P){var C=P.callback,I=P.args;switch(I.length){case 0:C();break;case 1:C(I[0]);break;case 2:C(I[0],I[1]);break;case 3:C(I[0],I[1],I[2]);break;default:C.apply(o,I)}})(T)}finally{b(A),x=!1}}}}function S(A){A.source===a&&typeof A.data=="string"&&A.data.indexOf(f)===0&&E(+A.data.slice(f.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Yv<"u"?Yv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(BA)),BA.exports}var Txe=Axe();const Cxe=oo(Txe);function Nxe(t){const e=new Jr;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 zF=Nxe;async function BF(t){const e=[],n=t.getElementsByTagName("mesh");for(let r=0;r<n.length;r++){const i=n[r],s=[],a=[],o=i.getElementsByTagName("vertex");for(let u=0;u<o.length;u++){const d=o[u];s.push(parseFloat(d.getAttribute("x")||"0"),parseFloat(d.getAttribute("y")||"0"),parseFloat(d.getAttribute("z")||"0"))}const l=i.getElementsByTagName("triangle");for(let u=0;u<l.length;u++){const d=l[u];a.push(parseInt(d.getAttribute("v1")||"0"),parseInt(d.getAttribute("v2")||"0"),parseInt(d.getAttribute("v3")||"0"))}s.length>0&&a.length>0&&e.push({vertices:s,triangles:a})}return e}async function kxe(t){const e=await Cxe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function s(d){const f=d.startsWith("/")?d.slice(1):d,g=e.files[f];if(!g)return null;const m=await g.async("string");return i.parseFromString(m,"application/xml")}const a=Object.keys(e.files).find(d=>d==="3D/3dmodel.model"||d.endsWith("/3dmodel.model"));if(!a){const d=Object.keys(e.files).find(f=>f.endsWith(".model"));if(d){const f=await s(d);if(f){const g=await BF(f);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const o=await s(a);if(!o)return{objects:n,buildItems:r};const l=o.getElementsByTagName("object");for(let d=0;d<l.length;d++){const f=l[d],g=f.getAttribute("id");if(!g)continue;const m=[],x=f.getElementsByTagName("mesh");for(let v=0;v<x.length;v++){const b=x[v],E=[],S=[],A=b.getElementsByTagName("vertex");for(let P=0;P<A.length;P++){const C=A[P];E.push(parseFloat(C.getAttribute("x")||"0"),parseFloat(C.getAttribute("y")||"0"),parseFloat(C.getAttribute("z")||"0"))}const T=b.getElementsByTagName("triangle");for(let P=0;P<T.length;P++){const C=T[P];S.push(parseInt(C.getAttribute("v1")||"0"),parseInt(C.getAttribute("v2")||"0"),parseInt(C.getAttribute("v3")||"0"))}E.length>0&&S.length>0&&m.push({vertices:E,triangles:S})}const y=f.getElementsByTagName("component");for(let v=0;v<y.length;v++){const b=y[v],E=b.getAttribute("p:path")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(E){const S=await s(E);if(S){const A=await BF(S),T=b.getAttribute("transform"),P=zF(T);for(const C of A)if(T){const I=[];for(let N=0;N<C.vertices.length;N+=3){const D=new Je(C.vertices[N],C.vertices[N+1],C.vertices[N+2]);D.applyMatrix4(P),I.push(D.x,D.y,D.z)}m.push({vertices:I,triangles:C.triangles})}else m.push(C)}}}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=zF(g.getAttribute("transform"));r.push({objectId:m,transform:x})}}return{objects:n,buildItems:r}}function HF(t){const e=new xl,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 Ja(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function Pxe({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=M.useRef(null),i=M.useRef(null),s=M.useRef(null),a=M.useRef(null),o=M.useRef(null),[l,u]=M.useState(!0),[d,f]=M.useState(null);M.useEffect(()=>{if(!r.current)return;const x=r.current,y=x.clientWidth,v=x.clientHeight,b=new lhe;b.background=new vn(1710618),s.current=b;const E=new Ga(45,y/v,.1,1e4);E.position.set(150,150,150),a.current=E;const S=new uxe({antialias:!0});S.setSize(y,v),S.setPixelRatio(window.devicePixelRatio),x.appendChild(S.domElement),i.current=S;const A=new hxe(E,S.domElement);A.enableDamping=!0,A.dampingFactor=.05,o.current=A;const T=new yhe(16777215,.6);b.add(T);const P=new uF(16777215,.8);P.position.set(100,100,100),b.add(P);const C=new uF(16777215,.4);C.position.set(-100,50,-100),b.add(C);const I=Math.max(e.x,e.y),N=Math.ceil(I/16),D=new whe(I,N,4473924,3355443);b.add(D);const F=new UR(e.x,e.y),L=new jR({color:44610,transparent:!0,opacity:.15,side:Jo}),q=new cl(F,L);q.rotation.x=-Math.PI/2,q.position.y=-.5,b.add(q);let R;const V=()=>{R=requestAnimationFrame(V),A.update(),S.render(b,E)};V(),fetch(t).then(W=>{if(!W.ok)throw new Error("Failed to load file");return W.arrayBuffer()}).then(kxe).then(({objects:W,buildItems:ne})=>{if(W.size===0)throw new Error("No meshes found in 3MF file");const Y=new mhe({color:44610,shininess:30,flatShading:!1}),Z=new _x,U=[];if(ne.length>0)for(const se of ne){const ve=W.get(se.objectId);if(ve)for(const je of ve.meshes){const de=[];for(let H=0;H<je.vertices.length;H+=3){const z=new Je(je.vertices[H],je.vertices[H+1],je.vertices[H+2]);z.applyMatrix4(se.transform),de.push(z.x,z.y,z.z)}const ut=HF({vertices:de,triangles:je.triangles});U.push(ut)}}else for(const se of W.values())for(const ve of se.meshes){const je=HF(ve);U.push(je)}if(U.length>0){const se=U.length===1?U[0]:Mxe(U,!1);if(se){const ve=new cl(se,Y);Z.add(ve)}if(U.length>1)for(const ve of U)ve.dispose()}const $=new Fh().setFromObject(Z),ee=$.getCenter(new Je);Z.position.y=-$.min.y,ne.length===0&&(Z.position.x=-ee.x,Z.position.z=-ee.z),b.add(Z);const ae=new Fh().setFromObject(Z),fe=ae.getCenter(new Je),ue=ae.getSize(new Je),Me=Math.max(ue.x,ue.y,ue.z)*1.8;E.position.set(fe.x+Me*.7,fe.y+Me*.5,fe.z+Me*.7),A.target.copy(fe),A.update(),u(!1)}).catch(W=>{f(W.message),u(!1)});const K=()=>{if(!x)return;const W=x.clientWidth,ne=x.clientHeight;E.aspect=W/ne,E.updateProjectionMatrix(),S.setSize(W,ne)};return window.addEventListener("resize",K),()=>{window.removeEventListener("resize",K),cancelAnimationFrame(R),A.dispose(),S.dispose(),x.removeChild(S.domElement)}},[t,e]);const g=()=>{a.current&&o.current&&(a.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},m=x=>{a.current&&a.current.position.multiplyScalar(x)};return c.jsxs("div",{className:`relative ${n}`,children:[c.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),l&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}),d&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:c.jsx("p",{className:"text-red-400",children:d})}),!l&&!d&&c.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[c.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:c.jsx(eue,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:c.jsx(rue,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:g,children:c.jsx(Im,{className:"w-4 h-4"})})]})]})}const AS="159",np={ROTATE:0,DOLLY:1,PAN:2},rp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Rxe=0,$F=1,Dxe=2,D7=1,Oxe=2,Zl=3,nd=0,Vs=1,tc=2,$u=0,qp=1,VF=2,GF=3,WF=4,jxe=5,eh=100,Lxe=101,Ixe=102,qF=103,KF=104,Uxe=200,Fxe=201,zxe=202,Bxe=203,tk=204,nk=205,Hxe=206,$xe=207,Vxe=208,Gxe=209,Wxe=210,qxe=211,Kxe=212,Xxe=213,Yxe=214,Zxe=0,Qxe=1,Jxe=2,m1=3,e0e=4,t0e=5,n0e=6,r0e=7,zR=0,i0e=1,s0e=2,Vu=0,a0e=1,o0e=2,l0e=3,c0e=4,u0e=5,O7=300,hm=301,fm=302,rk=303,ik=304,TS=306,sk=1e3,wo=1001,ak=1002,Ki=1003,XF=1004,HA=1005,Wa=1006,d0e=1007,y0=1008,Gu=1009,h0e=1010,f0e=1011,BR=1012,j7=1013,Lu=1014,oc=1015,_0=1016,L7=1017,I7=1018,mh=1020,p0e=1021,qa=1023,m0e=1024,g0e=1025,gh=1026,pm=1027,x0e=1028,U7=1029,b0e=1030,F7=1031,z7=1033,$A=33776,VA=33777,GA=33778,WA=33779,YF=35840,ZF=35841,QF=35842,JF=35843,B7=36196,ez=37492,tz=37496,nz=37808,rz=37809,iz=37810,sz=37811,az=37812,oz=37813,lz=37814,cz=37815,uz=37816,dz=37817,hz=37818,fz=37819,pz=37820,mz=37821,qA=36492,gz=36494,xz=36495,v0e=36283,bz=36284,vz=36285,yz=36286,H7=3e3,xh=3001,y0e=3200,_0e=3201,$7=0,w0e=1,Ka="",Xi="srgb",_c="srgb-linear",HR="display-p3",CS="display-p3-linear",g1="linear",ar="srgb",x1="rec709",b1="p3",ip=7680,_z=519,S0e=512,E0e=513,M0e=514,V7=515,A0e=516,T0e=517,C0e=518,N0e=519,ok=35044,wz="300 es",lk=1035,rl=2e3,w0=2001;class rf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const rs=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Sz=1234567;const jx=Math.PI/180,S0=180/Math.PI;function pc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(rs[t&255]+rs[t>>8&255]+rs[t>>16&255]+rs[t>>24&255]+"-"+rs[e&255]+rs[e>>8&255]+"-"+rs[e>>16&15|64]+rs[e>>24&255]+"-"+rs[n&63|128]+rs[n>>8&255]+"-"+rs[n>>16&255]+rs[n>>24&255]+rs[r&255]+rs[r>>8&255]+rs[r>>16&255]+rs[r>>24&255]).toLowerCase()}function Yi(t,e,n){return Math.max(e,Math.min(n,t))}function $R(t,e){return(t%e+e)%e}function k0e(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function P0e(t,e,n){return t!==e?(n-t)/(e-t):0}function Lx(t,e,n){return(1-n)*t+n*e}function R0e(t,e,n,r){return Lx(t,e,1-Math.exp(-n*r))}function D0e(t,e=1){return e-Math.abs($R(t,e*2)-e)}function O0e(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function j0e(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function L0e(t,e){return t+Math.floor(Math.random()*(e-t+1))}function I0e(t,e){return t+Math.random()*(e-t)}function U0e(t){return t*(.5-Math.random())}function F0e(t){t!==void 0&&(Sz=t);let e=Sz+=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 z0e(t){return t*jx}function B0e(t){return t*S0}function ck(t){return(t&t-1)===0&&t!==0}function H0e(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function v1(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function $0e(t,e,n,r,i){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),u=s((e+r)/2),d=a((e+r)/2),f=s((e-r)/2),g=a((e-r)/2),m=s((r-e)/2),x=a((r-e)/2);switch(i){case"XYX":t.set(o*d,l*f,l*g,o*u);break;case"YZY":t.set(l*g,o*d,l*f,o*u);break;case"ZXZ":t.set(l*f,l*g,o*d,o*u);break;case"XZX":t.set(o*d,l*x,l*m,o*u);break;case"YXY":t.set(l*m,o*d,l*x,o*u);break;case"ZYZ":t.set(l*x,l*m,o*d,o*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function el(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 $n(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 G7={DEG2RAD:jx,RAD2DEG:S0,generateUUID:pc,clamp:Yi,euclideanModulo:$R,mapLinear:k0e,inverseLerp:P0e,lerp:Lx,damp:R0e,pingpong:D0e,smoothstep:O0e,smootherstep:j0e,randInt:L0e,randFloat:I0e,randFloatSpread:U0e,seededRandom:F0e,degToRad:z0e,radToDeg:B0e,isPowerOfTwo:ck,ceilPowerOfTwo:H0e,floorPowerOfTwo:v1,setQuaternionFromProperEuler:$0e,normalize:$n,denormalize:el};class Yt{constructor(e=0,n=0){Yt.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Yi(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class hn{constructor(e,n,r,i,s,a,o,l,u){hn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,l,u)}set(e,n,r,i,s,a,o,l,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=s,d[5]=l,d[6]=r,d[7]=a,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[3],l=r[6],u=r[1],d=r[4],f=r[7],g=r[2],m=r[5],x=r[8],y=i[0],v=i[3],b=i[6],E=i[1],S=i[4],A=i[7],T=i[2],P=i[5],C=i[8];return s[0]=a*y+o*E+l*T,s[3]=a*v+o*S+l*P,s[6]=a*b+o*A+l*C,s[1]=u*y+d*E+f*T,s[4]=u*v+d*S+f*P,s[7]=u*b+d*A+f*C,s[2]=g*y+m*E+x*T,s[5]=g*v+m*S+x*P,s[8]=g*b+m*A+x*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],d=e[8];return n*a*d-n*o*u-r*s*d+r*o*l+i*s*u-i*a*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],d=e[8],f=d*a-o*u,g=o*l-d*s,m=u*s-a*l,x=n*f+r*g+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(o*r-i*a)*y,e[3]=g*y,e[4]=(d*n-i*l)*y,e[5]=(i*s-o*n)*y,e[6]=m*y,e[7]=(r*l-u*n)*y,e[8]=(a*n-r*s)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,a,o){const l=Math.cos(s),u=Math.sin(s);return this.set(r*l,r*u,-r*(l*a+u*o)+a+e,-i*u,i*l,-i*(-u*a+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(KA.makeScale(e,n)),this}rotate(e){return this.premultiply(KA.makeRotation(-e)),this}translate(e,n){return this.premultiply(KA.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 KA=new hn;function W7(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function y1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function V0e(){const t=y1("canvas");return t.style.display="block",t}const Ez={};function Ix(t){t in Ez||(Ez[t]=!0,console.warn(t))}const Mz=new hn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Az=new hn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Ey={[_c]:{transfer:g1,primaries:x1,toReference:t=>t,fromReference:t=>t},[Xi]:{transfer:ar,primaries:x1,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[CS]:{transfer:g1,primaries:b1,toReference:t=>t.applyMatrix3(Az),fromReference:t=>t.applyMatrix3(Mz)},[HR]:{transfer:ar,primaries:b1,toReference:t=>t.convertSRGBToLinear().applyMatrix3(Az),fromReference:t=>t.applyMatrix3(Mz).convertLinearToSRGB()}},G0e=new Set([_c,CS]),Vn={enabled:!0,_workingColorSpace:_c,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(!G0e.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=Ey[e].toReference,i=Ey[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 Ey[t].primaries},getTransfer:function(t){return t===Ka?g1:Ey[t].transfer}};function Kp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function XA(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let sp;class q7{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{sp===void 0&&(sp=y1("canvas")),sp.width=e.width,sp.height=e.height;const r=sp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=sp}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=y1("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=Kp(s[a]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Kp(n[r]/255)*255):n[r]=Kp(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 W0e=0;class K7{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:W0e++}),this.uuid=pc(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(YA(i[a].image)):s.push(YA(i[a]))}else s=YA(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function YA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?q7.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 q0e=0;class Gs extends rf{constructor(e=Gs.DEFAULT_IMAGE,n=Gs.DEFAULT_MAPPING,r=wo,i=wo,s=Wa,a=y0,o=qa,l=Gu,u=Gs.DEFAULT_ANISOTROPY,d=Ka){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:q0e++}),this.uuid=pc(),this.name="",this.source=new K7(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Yt(0,0),this.repeat=new Yt(1,1),this.center=new Yt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new hn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Ix("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===xh?Xi:Ka),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!==O7)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case sk:e.x=e.x-Math.floor(e.x);break;case wo:e.x=e.x<0?0:1;break;case ak: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 sk:e.y=e.y-Math.floor(e.y);break;case wo:e.y=e.y<0?0:1;break;case ak: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 Ix("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Xi?xh:H7}set encoding(e){Ix("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===xh?Xi:Ka}}Gs.DEFAULT_IMAGE=null;Gs.DEFAULT_MAPPING=O7;Gs.DEFAULT_ANISOTROPY=1;class Wn{constructor(e=0,n=0,r=0,i=1){Wn.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*n+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*n+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*n+a[7]*r+a[11]*i+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const l=e.elements,u=l[0],d=l[4],f=l[8],g=l[1],m=l[5],x=l[9],y=l[2],v=l[6],b=l[10];if(Math.abs(d-g)<.01&&Math.abs(f-y)<.01&&Math.abs(x-v)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+y)<.1&&Math.abs(x+v)<.1&&Math.abs(u+m+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(m+1)/2,T=(b+1)/2,P=(d+g)/4,C=(f+y)/4,I=(x+v)/4;return S>A&&S>T?S<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(S),i=P/r,s=C/r):A>T?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=P/i,s=I/i):T<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(T),r=C/s,i=I/s),this.set(r,i,s,n),this}let E=Math.sqrt((v-x)*(v-x)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(v-x)/E,this.y=(f-y)/E,this.z=(g-d)/E,this.w=Math.acos((u+m+b-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class K0e extends rf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Wn(0,0,e,n),this.scissorTest=!1,this.viewport=new Wn(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Ix("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===xh?Xi:Ka),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Wa,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Gs(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 K7(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 zh extends K0e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class X7 extends Gs{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=Ki,this.minFilter=Ki,this.wrapR=wo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class X0e extends Gs{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=Ki,this.minFilter=Ki,this.wrapR=wo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Bh{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,s,a,o){let l=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const g=s[a+0],m=s[a+1],x=s[a+2],y=s[a+3];if(o===0){e[n+0]=l,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(o===1){e[n+0]=g,e[n+1]=m,e[n+2]=x,e[n+3]=y;return}if(f!==y||l!==g||u!==m||d!==x){let v=1-o;const b=l*g+u*m+d*x+f*y,E=b>=0?1:-1,S=1-b*b;if(S>Number.EPSILON){const T=Math.sqrt(S),P=Math.atan2(T,b*E);v=Math.sin(v*P)/T,o=Math.sin(o*P)/T}const A=o*E;if(l=l*v+g*A,u=u*v+m*A,d=d*v+x*A,f=f*v+y*A,v===1-o){const T=1/Math.sqrt(l*l+u*u+d*d+f*f);l*=T,u*=T,d*=T,f*=T}}e[n]=l,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],l=r[i+1],u=r[i+2],d=r[i+3],f=s[a],g=s[a+1],m=s[a+2],x=s[a+3];return e[n]=o*x+d*f+l*m-u*g,e[n+1]=l*x+d*g+u*f-o*m,e[n+2]=u*x+d*m+o*g-l*f,e[n+3]=d*x-o*f-l*g-u*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,u=o(r/2),d=o(i/2),f=o(s/2),g=l(r/2),m=l(i/2),x=l(s/2);switch(a){case"XYZ":this._x=g*d*f+u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f-g*m*x;break;case"YXZ":this._x=g*d*f+u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f+g*m*x;break;case"ZXY":this._x=g*d*f-u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f-g*m*x;break;case"ZYX":this._x=g*d*f-u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f+g*m*x;break;case"YZX":this._x=g*d*f+u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f-g*m*x;break;case"XZY":this._x=g*d*f-u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f+g*m*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],a=n[1],o=n[5],l=n[9],u=n[2],d=n[6],f=n[10],g=r+o+f;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(d-l)*m,this._y=(s-u)*m,this._z=(a-i)*m}else if(r>o&&r>f){const m=2*Math.sqrt(1+r-o-f);this._w=(d-l)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+u)/m}else if(o>f){const m=2*Math.sqrt(1+o-r-f);this._w=(s-u)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(l+d)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(a-i)/m,this._x=(s+u)/m,this._y=(l+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Yi(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,a=e._w,o=n._x,l=n._y,u=n._z,d=n._w;return this._x=r*d+a*o+i*u-s*l,this._y=i*d+a*l+s*o-r*u,this._z=s*d+a*u+r*l-i*o,this._w=a*d-r*o-i*l-s*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+r*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=r,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-n;return this._w=m*a+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*s+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(l),d=Math.atan2(u,o),f=Math.sin((1-n)*d)/u,g=Math.sin(n*d)/u;return this._w=a*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=s*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(s),r*Math.cos(s),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class De{constructor(e=0,n=0,r=0){De.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(Tz.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(Tz.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*a,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*a,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*a,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,u=2*(a*i-o*r),d=2*(o*n-s*i),f=2*(s*r-a*n);return this.x=n+l*u+a*f-o*d,this.y=r+l*d+o*u-s*f,this.z=i+l*f+s*d-a*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,a=n.x,o=n.y,l=n.z;return this.x=i*l-s*o,this.y=s*a-r*l,this.z=r*o-i*a,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return ZA.copy(this).projectOnVector(e),this.sub(ZA)}reflect(e){return this.sub(ZA.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(Yi(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 ZA=new De,Tz=new Bh;class eo{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(bo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(bo.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=bo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,bo):bo.fromBufferAttribute(s,a),bo.applyMatrix4(e.matrixWorld),this.expandByPoint(bo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),My.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),My.copy(r.boundingBox)),My.applyMatrix4(e.matrixWorld),this.union(My)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,bo),bo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ix),Ay.subVectors(this.max,ix),ap.subVectors(e.a,ix),op.subVectors(e.b,ix),lp.subVectors(e.c,ix),fu.subVectors(op,ap),pu.subVectors(lp,op),Hd.subVectors(ap,lp);let n=[0,-fu.z,fu.y,0,-pu.z,pu.y,0,-Hd.z,Hd.y,fu.z,0,-fu.x,pu.z,0,-pu.x,Hd.z,0,-Hd.x,-fu.y,fu.x,0,-pu.y,pu.x,0,-Hd.y,Hd.x,0];return!QA(n,ap,op,lp,Ay)||(n=[1,0,0,0,1,0,0,0,1],!QA(n,ap,op,lp,Ay))?!1:(Ty.crossVectors(fu,pu),n=[Ty.x,Ty.y,Ty.z],QA(n,ap,op,lp,Ay))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,bo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(bo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Hl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Hl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Hl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Hl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Hl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Hl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Hl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Hl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Hl),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Hl=[new De,new De,new De,new De,new De,new De,new De,new De],bo=new De,My=new eo,ap=new De,op=new De,lp=new De,fu=new De,pu=new De,Hd=new De,ix=new De,Ay=new De,Ty=new De,$d=new De;function QA(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){$d.fromArray(t,s);const o=i.x*Math.abs($d.x)+i.y*Math.abs($d.y)+i.z*Math.abs($d.z),l=e.dot($d),u=n.dot($d),d=r.dot($d);if(Math.max(-Math.max(l,u,d),Math.min(l,u,d))>o)return!1}return!0}const Y0e=new eo,sx=new De,JA=new De;class sl{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):Y0e.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;sx.subVectors(e,this.center);const n=sx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(sx,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(JA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(sx.copy(e.center).add(JA)),this.expandByPoint(sx.copy(e.center).sub(JA))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const $l=new De,eT=new De,Cy=new De,mu=new De,tT=new De,Ny=new De,nT=new De;class VR{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,$l)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=$l.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):($l.copy(this.origin).addScaledVector(this.direction,n),$l.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){eT.copy(e).add(n).multiplyScalar(.5),Cy.copy(n).sub(e).normalize(),mu.copy(this.origin).sub(eT);const s=e.distanceTo(n)*.5,a=-this.direction.dot(Cy),o=mu.dot(this.direction),l=-mu.dot(Cy),u=mu.lengthSq(),d=Math.abs(1-a*a);let f,g,m,x;if(d>0)if(f=a*l-o,g=a*o-l,x=s*d,f>=0)if(g>=-x)if(g<=x){const y=1/d;f*=y,g*=y,m=f*(f+a*g+2*o)+g*(a*f+g+2*l)+u}else g=s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;else g=-s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;else g<=-x?(f=Math.max(0,-(-a*s+o)),g=f>0?-s:Math.min(Math.max(-s,-l),s),m=-f*f+g*(g+2*l)+u):g<=x?(f=0,g=Math.min(Math.max(-s,-l),s),m=g*(g+2*l)+u):(f=Math.max(0,-(a*s+o)),g=f>0?s:Math.min(Math.max(-s,-l),s),m=-f*f+g*(g+2*l)+u);else g=a>0?-s:s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(eT).addScaledVector(Cy,g),m}intersectSphere(e,n){$l.subVectors(e.center,this.origin);const r=$l.dot(this.direction),i=$l.dot($l)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,l=r+a;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,a,o,l;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(s=(e.min.y-g.y)*d,a=(e.max.y-g.y)*d):(s=(e.max.y-g.y)*d,a=(e.min.y-g.y)*d),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),f>=0?(o=(e.min.z-g.z)*f,l=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,l=(e.min.z-g.z)*f),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,$l)!==null}intersectTriangle(e,n,r,i,s){tT.subVectors(n,e),Ny.subVectors(r,e),nT.crossVectors(tT,Ny);let a=this.direction.dot(nT),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;mu.subVectors(this.origin,e);const l=o*this.direction.dot(Ny.crossVectors(mu,Ny));if(l<0)return null;const u=o*this.direction.dot(tT.cross(mu));if(u<0||l+u>a)return null;const d=-o*mu.dot(nT);return d<0?null:this.at(d/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class nr{constructor(e,n,r,i,s,a,o,l,u,d,f,g,m,x,y,v){nr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,l,u,d,f,g,m,x,y,v)}set(e,n,r,i,s,a,o,l,u,d,f,g,m,x,y,v){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=s,b[5]=a,b[9]=o,b[13]=l,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=m,b[7]=x,b[11]=y,b[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new nr().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/cp.setFromMatrixColumn(e,0).length(),s=1/cp.setFromMatrixColumn(e,1).length(),a=1/cp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,a=Math.cos(r),o=Math.sin(r),l=Math.cos(i),u=Math.sin(i),d=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const g=a*d,m=a*f,x=o*d,y=o*f;n[0]=l*d,n[4]=-l*f,n[8]=u,n[1]=m+x*u,n[5]=g-y*u,n[9]=-o*l,n[2]=y-g*u,n[6]=x+m*u,n[10]=a*l}else if(e.order==="YXZ"){const g=l*d,m=l*f,x=u*d,y=u*f;n[0]=g+y*o,n[4]=x*o-m,n[8]=a*u,n[1]=a*f,n[5]=a*d,n[9]=-o,n[2]=m*o-x,n[6]=y+g*o,n[10]=a*l}else if(e.order==="ZXY"){const g=l*d,m=l*f,x=u*d,y=u*f;n[0]=g-y*o,n[4]=-a*f,n[8]=x+m*o,n[1]=m+x*o,n[5]=a*d,n[9]=y-g*o,n[2]=-a*u,n[6]=o,n[10]=a*l}else if(e.order==="ZYX"){const g=a*d,m=a*f,x=o*d,y=o*f;n[0]=l*d,n[4]=x*u-m,n[8]=g*u+y,n[1]=l*f,n[5]=y*u+g,n[9]=m*u-x,n[2]=-u,n[6]=o*l,n[10]=a*l}else if(e.order==="YZX"){const g=a*l,m=a*u,x=o*l,y=o*u;n[0]=l*d,n[4]=y-g*f,n[8]=x*f+m,n[1]=f,n[5]=a*d,n[9]=-o*d,n[2]=-u*d,n[6]=m*f+x,n[10]=g-y*f}else if(e.order==="XZY"){const g=a*l,m=a*u,x=o*l,y=o*u;n[0]=l*d,n[4]=-f,n[8]=u*d,n[1]=g*f+y,n[5]=a*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=o*d,n[10]=y*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Z0e,e,Q0e)}lookAt(e,n,r){const i=this.elements;return la.subVectors(e,n),la.lengthSq()===0&&(la.z=1),la.normalize(),gu.crossVectors(r,la),gu.lengthSq()===0&&(Math.abs(r.z)===1?la.x+=1e-4:la.z+=1e-4,la.normalize(),gu.crossVectors(r,la)),gu.normalize(),ky.crossVectors(la,gu),i[0]=gu.x,i[4]=ky.x,i[8]=la.x,i[1]=gu.y,i[5]=ky.y,i[9]=la.y,i[2]=gu.z,i[6]=ky.z,i[10]=la.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[4],l=r[8],u=r[12],d=r[1],f=r[5],g=r[9],m=r[13],x=r[2],y=r[6],v=r[10],b=r[14],E=r[3],S=r[7],A=r[11],T=r[15],P=i[0],C=i[4],I=i[8],N=i[12],D=i[1],F=i[5],L=i[9],q=i[13],R=i[2],V=i[6],K=i[10],W=i[14],ne=i[3],Y=i[7],Z=i[11],U=i[15];return s[0]=a*P+o*D+l*R+u*ne,s[4]=a*C+o*F+l*V+u*Y,s[8]=a*I+o*L+l*K+u*Z,s[12]=a*N+o*q+l*W+u*U,s[1]=d*P+f*D+g*R+m*ne,s[5]=d*C+f*F+g*V+m*Y,s[9]=d*I+f*L+g*K+m*Z,s[13]=d*N+f*q+g*W+m*U,s[2]=x*P+y*D+v*R+b*ne,s[6]=x*C+y*F+v*V+b*Y,s[10]=x*I+y*L+v*K+b*Z,s[14]=x*N+y*q+v*W+b*U,s[3]=E*P+S*D+A*R+T*ne,s[7]=E*C+S*F+A*V+T*Y,s[11]=E*I+S*L+A*K+T*Z,s[15]=E*N+S*q+A*W+T*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],u=e[13],d=e[2],f=e[6],g=e[10],m=e[14],x=e[3],y=e[7],v=e[11],b=e[15];return x*(+s*l*f-i*u*f-s*o*g+r*u*g+i*o*m-r*l*m)+y*(+n*l*m-n*u*g+s*a*g-i*a*m+i*u*d-s*l*d)+v*(+n*u*f-n*o*m-s*a*f+r*a*m+s*o*d-r*u*d)+b*(-i*o*d-n*l*f+n*o*g+i*a*f-r*a*g+r*l*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],d=e[8],f=e[9],g=e[10],m=e[11],x=e[12],y=e[13],v=e[14],b=e[15],E=f*v*u-y*g*u+y*l*m-o*v*m-f*l*b+o*g*b,S=x*g*u-d*v*u-x*l*m+a*v*m+d*l*b-a*g*b,A=d*y*u-x*f*u+x*o*m-a*y*m-d*o*b+a*f*b,T=x*f*l-d*y*l-x*o*g+a*y*g+d*o*v-a*f*v,P=n*E+r*S+i*A+s*T;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/P;return e[0]=E*C,e[1]=(y*g*s-f*v*s-y*i*m+r*v*m+f*i*b-r*g*b)*C,e[2]=(o*v*s-y*l*s+y*i*u-r*v*u-o*i*b+r*l*b)*C,e[3]=(f*l*s-o*g*s-f*i*u+r*g*u+o*i*m-r*l*m)*C,e[4]=S*C,e[5]=(d*v*s-x*g*s+x*i*m-n*v*m-d*i*b+n*g*b)*C,e[6]=(x*l*s-a*v*s-x*i*u+n*v*u+a*i*b-n*l*b)*C,e[7]=(a*g*s-d*l*s+d*i*u-n*g*u-a*i*m+n*l*m)*C,e[8]=A*C,e[9]=(x*f*s-d*y*s-x*r*m+n*y*m+d*r*b-n*f*b)*C,e[10]=(a*y*s-x*o*s+x*r*u-n*y*u-a*r*b+n*o*b)*C,e[11]=(d*o*s-a*f*s-d*r*u+n*f*u+a*r*m-n*o*m)*C,e[12]=T*C,e[13]=(d*y*i-x*f*i+x*r*g-n*y*g-d*r*v+n*f*v)*C,e[14]=(x*o*i-a*y*i-x*r*l+n*y*l+a*r*v-n*o*v)*C,e[15]=(a*f*i-d*o*i+d*r*l-n*f*l-a*r*g+n*o*g)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,a=e.x,o=e.y,l=e.z,u=s*a,d=s*o;return this.set(u*a+r,u*o-i*l,u*l+i*o,0,u*o+i*l,d*o+r,d*l-i*a,0,u*l-i*o,d*l+i*a,s*l*l+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,a=n._y,o=n._z,l=n._w,u=s+s,d=a+a,f=o+o,g=s*u,m=s*d,x=s*f,y=a*d,v=a*f,b=o*f,E=l*u,S=l*d,A=l*f,T=r.x,P=r.y,C=r.z;return i[0]=(1-(y+b))*T,i[1]=(m+A)*T,i[2]=(x-S)*T,i[3]=0,i[4]=(m-A)*P,i[5]=(1-(g+b))*P,i[6]=(v+E)*P,i[7]=0,i[8]=(x+S)*C,i[9]=(v-E)*C,i[10]=(1-(g+y))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=cp.set(i[0],i[1],i[2]).length();const a=cp.set(i[4],i[5],i[6]).length(),o=cp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],vo.copy(this);const u=1/s,d=1/a,f=1/o;return vo.elements[0]*=u,vo.elements[1]*=u,vo.elements[2]*=u,vo.elements[4]*=d,vo.elements[5]*=d,vo.elements[6]*=d,vo.elements[8]*=f,vo.elements[9]*=f,vo.elements[10]*=f,n.setFromRotationMatrix(vo),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=rl){const l=this.elements,u=2*s/(n-e),d=2*s/(r-i),f=(n+e)/(n-e),g=(r+i)/(r-i);let m,x;if(o===rl)m=-(a+s)/(a-s),x=-2*a*s/(a-s);else if(o===w0)m=-a/(a-s),x=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=d,l[9]=g,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=x,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=rl){const l=this.elements,u=1/(n-e),d=1/(r-i),f=1/(a-s),g=(n+e)*u,m=(r+i)*d;let x,y;if(o===rl)x=(a+s)*f,y=-2*f;else if(o===w0)x=s*f,y=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*u,l[4]=0,l[8]=0,l[12]=-g,l[1]=0,l[5]=2*d,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=y,l[14]=-x,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const cp=new De,vo=new nr,Z0e=new De(0,0,0),Q0e=new De(1,1,1),gu=new De,ky=new De,la=new De,Cz=new nr,Nz=new Bh;class sb{constructor(e=0,n=0,r=0,i=sb.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],u=i[5],d=i[9],f=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Yi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Yi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Yi(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Yi(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(Yi(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Yi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return Cz.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Cz,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return Nz.setFromEuler(this),this.setFromQuaternion(Nz,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}}sb.DEFAULT_ORDER="XYZ";class Y7{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 J0e=0;const kz=new De,up=new Bh,Vl=new nr,Py=new De,ax=new De,ebe=new De,tbe=new Bh,Pz=new De(1,0,0),Rz=new De(0,1,0),Dz=new De(0,0,1),nbe={type:"added"},rbe={type:"removed"};class Es extends rf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:J0e++}),this.uuid=pc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Es.DEFAULT_UP.clone();const e=new De,n=new sb,r=new Bh,i=new De(1,1,1);function s(){r.setFromEuler(n,!1)}function a(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new nr},normalMatrix:{value:new hn}}),this.matrix=new nr,this.matrixWorld=new nr,this.matrixAutoUpdate=Es.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Es.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Y7,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 up.setFromAxisAngle(e,n),this.quaternion.multiply(up),this}rotateOnWorldAxis(e,n){return up.setFromAxisAngle(e,n),this.quaternion.premultiply(up),this}rotateX(e){return this.rotateOnAxis(Pz,e)}rotateY(e){return this.rotateOnAxis(Rz,e)}rotateZ(e){return this.rotateOnAxis(Dz,e)}translateOnAxis(e,n){return kz.copy(e).applyQuaternion(this.quaternion),this.position.add(kz.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(Pz,e)}translateY(e){return this.translateOnAxis(Rz,e)}translateZ(e){return this.translateOnAxis(Dz,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Vl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Py.copy(e):Py.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),ax.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Vl.lookAt(ax,Py,this.up):Vl.lookAt(Py,ax,this.up),this.quaternion.setFromRotationMatrix(Vl),i&&(Vl.extractRotation(i.matrixWorld),up.setFromRotationMatrix(Vl),this.quaternion.premultiply(up.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(nbe)):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(rbe)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Vl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Vl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Vl),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const a=this.children[r].getObjectByProperty(e,n);if(a!==void 0)return a}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ax,e,ebe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ax,tbe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const s=n[r];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++){const o=i[s];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let u=0,d=l.length;u<d;u++){const f=l[u];s(e.shapes,f)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,u=this.material.length;l<u;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(n){const o=a(e.geometries),l=a(e.materials),u=a(e.textures),d=a(e.images),f=a(e.shapes),g=a(e.skeletons),m=a(e.animations),x=a(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),x.length>0&&(r.nodes=x)}return r.object=i,r;function a(o){const l=[];for(const u in o){const d=o[u];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Es.DEFAULT_UP=new De(0,1,0);Es.DEFAULT_MATRIX_AUTO_UPDATE=!0;Es.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const yo=new De,Gl=new De,rT=new De,Wl=new De,dp=new De,hp=new De,Oz=new De,iT=new De,sT=new De,aT=new De;let Ry=!1;class _o{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),yo.subVectors(e,n),i.cross(yo);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){yo.subVectors(i,n),Gl.subVectors(r,n),rT.subVectors(e,n);const a=yo.dot(yo),o=yo.dot(Gl),l=yo.dot(rT),u=Gl.dot(Gl),d=Gl.dot(rT),f=a*u-o*o;if(f===0)return s.set(-2,-1,-1);const g=1/f,m=(u*l-o*d)*g,x=(a*d-o*l)*g;return s.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Wl),Wl.x>=0&&Wl.y>=0&&Wl.x+Wl.y<=1}static getUV(e,n,r,i,s,a,o,l){return Ry===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Ry=!0),this.getInterpolation(e,n,r,i,s,a,o,l)}static getInterpolation(e,n,r,i,s,a,o,l){return this.getBarycoord(e,n,r,i,Wl),l.setScalar(0),l.addScaledVector(s,Wl.x),l.addScaledVector(a,Wl.y),l.addScaledVector(o,Wl.z),l}static isFrontFacing(e,n,r,i){return yo.subVectors(r,n),Gl.subVectors(e,n),yo.cross(Gl).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return yo.subVectors(this.c,this.b),Gl.subVectors(this.a,this.b),yo.cross(Gl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return _o.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return _o.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return Ry===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Ry=!0),_o.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return _o.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return _o.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return _o.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let a,o;dp.subVectors(i,r),hp.subVectors(s,r),iT.subVectors(e,r);const l=dp.dot(iT),u=hp.dot(iT);if(l<=0&&u<=0)return n.copy(r);sT.subVectors(e,i);const d=dp.dot(sT),f=hp.dot(sT);if(d>=0&&f<=d)return n.copy(i);const g=l*f-d*u;if(g<=0&&l>=0&&d<=0)return a=l/(l-d),n.copy(r).addScaledVector(dp,a);aT.subVectors(e,s);const m=dp.dot(aT),x=hp.dot(aT);if(x>=0&&m<=x)return n.copy(s);const y=m*u-l*x;if(y<=0&&u>=0&&x<=0)return o=u/(u-x),n.copy(r).addScaledVector(hp,o);const v=d*x-m*f;if(v<=0&&f-d>=0&&m-x>=0)return Oz.subVectors(s,i),o=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(Oz,o);const b=1/(v+y+g);return a=y*b,o=g*b,n.copy(r).addScaledVector(dp,a).addScaledVector(hp,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Z7={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},xu={h:0,s:0,l:0},Dy={h:0,s:0,l:0};function oT(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=Xi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Vn.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Vn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Vn.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Vn.workingColorSpace){if(e=$R(e,1),n=Yi(n,0,1),r=Yi(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,a=2*r-s;this.r=oT(a,s,e+1/3),this.g=oT(a,s,e),this.b=oT(a,s,e-1/3)}return Vn.toWorkingColorSpace(this,i),this}setStyle(e,n=Xi){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(a===6)return this.setHex(parseInt(s,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Xi){const r=Z7[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=Kp(e.r),this.g=Kp(e.g),this.b=Kp(e.b),this}copyLinearToSRGB(e){return this.r=XA(e.r),this.g=XA(e.g),this.b=XA(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Xi){return Vn.fromWorkingColorSpace(is.copy(this),e),Math.round(Yi(is.r*255,0,255))*65536+Math.round(Yi(is.g*255,0,255))*256+Math.round(Yi(is.b*255,0,255))}getHexString(e=Xi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Vn.workingColorSpace){Vn.fromWorkingColorSpace(is.copy(this),n);const r=is.r,i=is.g,s=is.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,u;const d=(o+a)/2;if(o===a)l=0,u=0;else{const f=a-o;switch(u=d<=.5?f/(a+o):f/(2-a-o),a){case r:l=(i-s)/f+(i<s?6:0);break;case i:l=(s-r)/f+2;break;case s:l=(r-i)/f+4;break}l/=6}return e.h=l,e.s=u,e.l=d,e}getRGB(e,n=Vn.workingColorSpace){return Vn.fromWorkingColorSpace(is.copy(this),n),e.r=is.r,e.g=is.g,e.b=is.b,e}getStyle(e=Xi){Vn.fromWorkingColorSpace(is.copy(this),e);const n=is.r,r=is.g,i=is.b;return e!==Xi?`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(xu),this.setHSL(xu.h+e,xu.s+n,xu.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(xu),e.getHSL(Dy);const r=Lx(xu.h,Dy.h,n),i=Lx(xu.s,Dy.s,n),s=Lx(xu.l,Dy.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const is=new $t;$t.NAMES=Z7;let ibe=0;class Bm extends rf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ibe++}),this.uuid=pc(),this.name="",this.type="Material",this.blending=qp,this.side=nd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=tk,this.blendDst=nk,this.blendEquation=eh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new $t(0,0,0),this.blendAlpha=0,this.depthFunc=m1,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=_z,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ip,this.stencilZFail=ip,this.stencilZPass=ip,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!==qp&&(r.blending=this.blending),this.side!==nd&&(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!==tk&&(r.blendSrc=this.blendSrc),this.blendDst!==nk&&(r.blendDst=this.blendDst),this.blendEquation!==eh&&(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!==m1&&(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!==_z&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ip&&(r.stencilFail=this.stencilFail),this.stencilZFail!==ip&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==ip&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(n){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Q7 extends Bm{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=zR,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 Vr=new De,Oy=new Yt;class xa{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=ok,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=oc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)Oy.fromBufferAttribute(this,n),Oy.applyMatrix3(e),this.setXY(n,Oy.x,Oy.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Vr.fromBufferAttribute(this,n),Vr.applyMatrix3(e),this.setXYZ(n,Vr.x,Vr.y,Vr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Vr.fromBufferAttribute(this,n),Vr.applyMatrix4(e),this.setXYZ(n,Vr.x,Vr.y,Vr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Vr.fromBufferAttribute(this,n),Vr.applyNormalMatrix(e),this.setXYZ(n,Vr.x,Vr.y,Vr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Vr.fromBufferAttribute(this,n),Vr.transformDirection(e),this.setXYZ(n,Vr.x,Vr.y,Vr.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=el(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=$n(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=el(n,this.array)),n}setX(e,n){return this.normalized&&(n=$n(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=el(n,this.array)),n}setY(e,n){return this.normalized&&(n=$n(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=el(n,this.array)),n}setZ(e,n){return this.normalized&&(n=$n(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=el(n,this.array)),n}setW(e,n){return this.normalized&&(n=$n(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=$n(n,this.array),r=$n(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=$n(n,this.array),r=$n(r,this.array),i=$n(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=$n(n,this.array),r=$n(r,this.array),i=$n(i,this.array),s=$n(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ok&&(e.usage=this.usage),e}}class J7 extends xa{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class eW extends xa{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Lr extends xa{constructor(e,n,r){super(new Float32Array(e),n,r)}}let sbe=0;const Ra=new nr,lT=new Es,fp=new De,ca=new eo,ox=new eo,Ti=new De;class fs extends rf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:sbe++}),this.uuid=pc(),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(W7(e)?eW:J7)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new hn().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ra.makeRotationFromQuaternion(e),this.applyMatrix4(Ra),this}rotateX(e){return Ra.makeRotationX(e),this.applyMatrix4(Ra),this}rotateY(e){return Ra.makeRotationY(e),this.applyMatrix4(Ra),this}rotateZ(e){return Ra.makeRotationZ(e),this.applyMatrix4(Ra),this}translate(e,n,r){return Ra.makeTranslation(e,n,r),this.applyMatrix4(Ra),this}scale(e,n,r){return Ra.makeScale(e,n,r),this.applyMatrix4(Ra),this}lookAt(e){return lT.lookAt(e),lT.updateMatrix(),this.applyMatrix4(lT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(fp).negate(),this.translate(fp.x,fp.y,fp.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const s=e[r];n.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Lr(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new eo);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new De(-1/0,-1/0,-1/0),new De(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];ca.setFromBufferAttribute(s),this.morphTargetsRelative?(Ti.addVectors(this.boundingBox.min,ca.min),this.boundingBox.expandByPoint(Ti),Ti.addVectors(this.boundingBox.max,ca.max),this.boundingBox.expandByPoint(Ti)):(this.boundingBox.expandByPoint(ca.min),this.boundingBox.expandByPoint(ca.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&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 sl);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(ca.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];ox.setFromBufferAttribute(o),this.morphTargetsRelative?(Ti.addVectors(ca.min,ox.min),ca.expandByPoint(Ti),Ti.addVectors(ca.max,ox.max),ca.expandByPoint(Ti)):(ca.expandByPoint(ox.min),ca.expandByPoint(ox.max))}ca.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Ti.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Ti));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],l=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)Ti.fromBufferAttribute(o,u),l&&(fp.fromBufferAttribute(e,u),Ti.add(fp)),i=Math.max(i,r.distanceToSquared(Ti))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,s=n.normal.array,a=n.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new xa(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,u=[],d=[];for(let D=0;D<o;D++)u[D]=new De,d[D]=new De;const f=new De,g=new De,m=new De,x=new Yt,y=new Yt,v=new Yt,b=new De,E=new De;function S(D,F,L){f.fromArray(i,D*3),g.fromArray(i,F*3),m.fromArray(i,L*3),x.fromArray(a,D*2),y.fromArray(a,F*2),v.fromArray(a,L*2),g.sub(f),m.sub(f),y.sub(x),v.sub(x);const q=1/(y.x*v.y-v.x*y.y);isFinite(q)&&(b.copy(g).multiplyScalar(v.y).addScaledVector(m,-y.y).multiplyScalar(q),E.copy(m).multiplyScalar(y.x).addScaledVector(g,-v.x).multiplyScalar(q),u[D].add(b),u[F].add(b),u[L].add(b),d[D].add(E),d[F].add(E),d[L].add(E))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let D=0,F=A.length;D<F;++D){const L=A[D],q=L.start,R=L.count;for(let V=q,K=q+R;V<K;V+=3)S(r[V+0],r[V+1],r[V+2])}const T=new De,P=new De,C=new De,I=new De;function N(D){C.fromArray(s,D*3),I.copy(C);const F=u[D];T.copy(F),T.sub(C.multiplyScalar(C.dot(F))).normalize(),P.crossVectors(I,F);const q=P.dot(d[D])<0?-1:1;l[D*4]=T.x,l[D*4+1]=T.y,l[D*4+2]=T.z,l[D*4+3]=q}for(let D=0,F=A.length;D<F;++D){const L=A[D],q=L.start,R=L.count;for(let V=q,K=q+R;V<K;V+=3)N(r[V+0]),N(r[V+1]),N(r[V+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 xa(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new De,s=new De,a=new De,o=new De,l=new De,u=new De,d=new De,f=new De;if(e)for(let g=0,m=e.count;g<m;g+=3){const x=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),a.fromBufferAttribute(n,v),d.subVectors(a,s),f.subVectors(i,s),d.cross(f),o.fromBufferAttribute(r,x),l.fromBufferAttribute(r,y),u.fromBufferAttribute(r,v),o.add(d),l.add(d),u.add(d),r.setXYZ(x,o.x,o.y,o.z),r.setXYZ(y,l.x,l.y,l.z),r.setXYZ(v,u.x,u.y,u.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),s.fromBufferAttribute(n,g+1),a.fromBufferAttribute(n,g+2),d.subVectors(a,s),f.subVectors(i,s),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Ti.fromBufferAttribute(e,n),Ti.normalize(),e.setXYZ(n,Ti.x,Ti.y,Ti.z)}toNonIndexed(){function e(o,l){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(l.length*d);let m=0,x=0;for(let y=0,v=l.length;y<v;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*d;for(let b=0;b<d;b++)g[x++]=u[m++]}return new xa(g,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new fs,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],u=e(l,r);n.setAttribute(o,u)}const s=this.morphAttributes;for(const o in s){const l=[],u=s[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const u=a[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const u in l)l[u]!==void 0&&(e[u]=l[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const l in r){const u=r[l];e.data.attributes[l]=u.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const u=this.morphAttributes[l],d=[];for(let f=0,g=u.length;f<g;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[l]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const s=e.morphAttributes;for(const u in s){const d=[],f=s[u];for(let g=0,m=f.length;g<m;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let u=0,d=a.length;u<d;u++){const f=a[u];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const jz=new nr,Vd=new VR,jy=new sl,Lz=new De,pp=new De,mp=new De,gp=new De,cT=new De,Ly=new De,Iy=new Yt,Uy=new Yt,Fy=new Yt,Iz=new De,Uz=new De,Fz=new De,zy=new De,By=new De;class No extends Es{constructor(e=new fs,n=new Q7){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){Ly.set(0,0,0);for(let l=0,u=s.length;l<u;l++){const d=o[l],f=s[l];d!==0&&(cT.fromBufferAttribute(f,e),a?Ly.addScaledVector(cT,d):Ly.addScaledVector(cT.sub(n),d))}n.add(Ly)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),jy.copy(r.boundingSphere),jy.applyMatrix4(s),Vd.copy(e.ray).recast(e.near),!(jy.containsPoint(Vd.origin)===!1&&(Vd.intersectSphere(jy,Lz)===null||Vd.origin.distanceToSquared(Lz)>(e.far-e.near)**2))&&(jz.copy(s).invert(),Vd.copy(e.ray).applyMatrix4(jz),!(r.boundingBox!==null&&Vd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Vd)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,f=s.attributes.normal,g=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let x=0,y=g.length;x<y;x++){const v=g[x],b=a[v.materialIndex],E=Math.max(v.start,m.start),S=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=S;A<T;A+=3){const P=o.getX(A),C=o.getX(A+1),I=o.getX(A+2);i=Hy(this,b,e,r,u,d,f,P,C,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const E=o.getX(v),S=o.getX(v+1),A=o.getX(v+2);i=Hy(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let x=0,y=g.length;x<y;x++){const v=g[x],b=a[v.materialIndex],E=Math.max(v.start,m.start),S=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=S;A<T;A+=3){const P=A,C=A+1,I=A+2;i=Hy(this,b,e,r,u,d,f,P,C,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const E=v,S=v+1,A=v+2;i=Hy(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}}function abe(t,e,n,r,i,s,a,o){let l;if(e.side===Vs?l=r.intersectTriangle(a,s,i,!0,o):l=r.intersectTriangle(i,s,a,e.side===nd,o),l===null)return null;By.copy(o),By.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(By);return u<n.near||u>n.far?null:{distance:u,point:By.clone(),object:t}}function Hy(t,e,n,r,i,s,a,o,l,u){t.getVertexPosition(o,pp),t.getVertexPosition(l,mp),t.getVertexPosition(u,gp);const d=abe(t,e,n,r,pp,mp,gp,zy);if(d){i&&(Iy.fromBufferAttribute(i,o),Uy.fromBufferAttribute(i,l),Fy.fromBufferAttribute(i,u),d.uv=_o.getInterpolation(zy,pp,mp,gp,Iy,Uy,Fy,new Yt)),s&&(Iy.fromBufferAttribute(s,o),Uy.fromBufferAttribute(s,l),Fy.fromBufferAttribute(s,u),d.uv1=_o.getInterpolation(zy,pp,mp,gp,Iy,Uy,Fy,new Yt),d.uv2=d.uv1),a&&(Iz.fromBufferAttribute(a,o),Uz.fromBufferAttribute(a,l),Fz.fromBufferAttribute(a,u),d.normal=_o.getInterpolation(zy,pp,mp,gp,Iz,Uz,Fz,new De),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:o,b:l,c:u,normal:new De,materialIndex:0};_o.getNormal(pp,mp,gp,f.normal),d.face=f}return d}class ab extends fs{constructor(e=1,n=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],u=[],d=[],f=[];let g=0,m=0;x("z","y","x",-1,-1,r,n,e,a,s,0),x("z","y","x",1,-1,r,n,-e,a,s,1),x("x","z","y",1,1,e,r,n,i,a,2),x("x","z","y",1,-1,e,r,-n,i,a,3),x("x","y","z",1,-1,e,n,r,i,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Lr(u,3)),this.setAttribute("normal",new Lr(d,3)),this.setAttribute("uv",new Lr(f,2));function x(y,v,b,E,S,A,T,P,C,I,N){const D=A/C,F=T/I,L=A/2,q=T/2,R=P/2,V=C+1,K=I+1;let W=0,ne=0;const Y=new De;for(let Z=0;Z<K;Z++){const U=Z*F-q;for(let $=0;$<V;$++){const ee=$*D-L;Y[y]=ee*E,Y[v]=U*S,Y[b]=R,u.push(Y.x,Y.y,Y.z),Y[y]=0,Y[v]=0,Y[b]=P>0?1:-1,d.push(Y.x,Y.y,Y.z),f.push($/C),f.push(1-Z/I),W+=1}}for(let Z=0;Z<I;Z++)for(let U=0;U<C;U++){const $=g+U+V*Z,ee=g+U+V*(Z+1),ae=g+(U+1)+V*(Z+1),fe=g+(U+1)+V*Z;l.push($,ee,fe),l.push(ee,ae,fe),ne+=6}o.addGroup(m,ne,N),m+=ne,g+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ab(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function mm(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 vs(t){const e={};for(let n=0;n<t.length;n++){const r=mm(t[n]);for(const i in r)e[i]=r[i]}return e}function obe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function tW(t){return t.getRenderTarget()===null?t.outputColorSpace:Vn.workingColorSpace}const GR={clone:mm,merge:vs};var lbe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,cbe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class rd extends Bm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=lbe,this.fragmentShader=cbe,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=mm(e.uniforms),this.uniformsGroups=obe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?n.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?n.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?n.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?n.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?n.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?n.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?n.uniforms[i]={type:"m4",value:a.toArray()}:n.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}}class nW extends Es{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new nr,this.projectionMatrix=new nr,this.projectionMatrixInverse=new nr,this.coordinateSystem=rl}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 da extends nW{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=S0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(jx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return S0*2*Math.atan(Math.tan(jx*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,s,a){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(jx*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,u=a.fullHeight;s+=a.offsetX*i/l,n-=a.offsetY*r/u,i*=a.width/l,r*=a.height/u}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const xp=-90,bp=1;class ube extends Es{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new da(xp,bp,e,n);i.layers=this.layers,this.add(i);const s=new da(xp,bp,e,n);s.layers=this.layers,this.add(s);const a=new da(xp,bp,e,n);a.layers=this.layers,this.add(a);const o=new da(xp,bp,e,n);o.layers=this.layers,this.add(o);const l=new da(xp,bp,e,n);l.layers=this.layers,this.add(l);const u=new da(xp,bp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,a,o,l]=n;for(const u of n)this.remove(u);if(e===rl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===w0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,a),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,l),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class rW extends Gs{constructor(e,n,r,i,s,a,o,l,u,d){e=e!==void 0?e:[],n=n!==void 0?n:hm,super(e,n,r,i,s,a,o,l,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class dbe extends zh{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&&(Ix("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===xh?Xi:Ka),this.texture=new rW(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:Wa}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 ab(5,5,5),s=new rd({name:"CubemapFromEquirect",uniforms:mm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Vs,blending:$u});s.uniforms.tEquirect.value=n;const a=new No(i,s),o=n.minFilter;return n.minFilter===y0&&(n.minFilter=Wa),new ube(1,10,this).update(e,a),n.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,n,r,i){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(n,r,i);e.setRenderTarget(s)}}const uT=new De,hbe=new De,fbe=new hn;class Su{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=uT.subVectors(r,n).cross(hbe.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(uT),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||fbe.getNormalMatrix(e),i=this.coplanarPoint(uT).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Gd=new sl,$y=new De;class NS{constructor(e=new Su,n=new Su,r=new Su,i=new Su,s=new Su,a=new Su){this.planes=[e,n,r,i,s,a]}set(e,n,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=rl){const r=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],l=i[3],u=i[4],d=i[5],f=i[6],g=i[7],m=i[8],x=i[9],y=i[10],v=i[11],b=i[12],E=i[13],S=i[14],A=i[15];if(r[0].setComponents(l-s,g-u,v-m,A-b).normalize(),r[1].setComponents(l+s,g+u,v+m,A+b).normalize(),r[2].setComponents(l+a,g+d,v+x,A+E).normalize(),r[3].setComponents(l-a,g-d,v-x,A-E).normalize(),r[4].setComponents(l-o,g-f,v-y,A-S).normalize(),n===rl)r[5].setComponents(l+o,g+f,v+y,A+S).normalize();else if(n===w0)r[5].setComponents(o,f,y,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),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){return Gd.center.set(0,0,0),Gd.radius=.7071067811865476,Gd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Gd)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if($y.x=i.normal.x>0?e.max.x:e.min.x,$y.y=i.normal.y>0?e.max.y:e.min.y,$y.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint($y)<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 iW(){let t=null,e=!1,n=null,r=null;function i(s,a){n(s,a),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){n=s},setContext:function(s){t=s}}}function pbe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,g=u.usage,m=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,g),u.onUploadCallback();let y;if(f instanceof Float32Array)y=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=t.SHORT;else if(f instanceof Uint32Array)y=t.UNSIGNED_INT;else if(f instanceof Int32Array)y=t.INT;else if(f instanceof Int8Array)y=t.BYTE;else if(f instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:y,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:m}}function s(u,d,f){const g=d.array,m=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),m.count===-1&&x.length===0&&t.bufferSubData(f,0,g),x.length!==0){for(let y=0,v=x.length;y<v;y++){const b=x[y];n?t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g,b.start,b.count):t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g.subarray(b.start,b.start+b.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(f,m.offset*g.BYTES_PER_ELEMENT,g,m.offset,m.count):t.bufferSubData(f,m.offset*g.BYTES_PER_ELEMENT,g.subarray(m.offset,m.offset+m.count)),m.count=-1),d.onUploadCallback()}function a(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function o(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function l(u,d){if(u.isGLBufferAttribute){const g=r.get(u);(!g||g.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(f.buffer,u,d),f.version=u.version}}return{get:a,remove:o,update:l}}class WR extends fs{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,a=n/2,o=Math.floor(r),l=Math.floor(i),u=o+1,d=l+1,f=e/o,g=n/l,m=[],x=[],y=[],v=[];for(let b=0;b<d;b++){const E=b*g-a;for(let S=0;S<u;S++){const A=S*f-s;x.push(A,-E,0),y.push(0,0,1),v.push(S/o),v.push(1-b/l)}}for(let b=0;b<l;b++)for(let E=0;E<o;E++){const S=E+u*b,A=E+u*(b+1),T=E+1+u*(b+1),P=E+1+u*b;m.push(S,A,P),m.push(A,T,P)}this.setIndex(m),this.setAttribute("position",new Lr(x,3)),this.setAttribute("normal",new Lr(y,3)),this.setAttribute("uv",new Lr(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new WR(e.width,e.height,e.widthSegments,e.heightSegments)}}var mbe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,gbe=`#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`,xbe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,bbe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,vbe=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,ybe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,_be=`#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`,wbe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,Sbe=`#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`,Ebe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,Mbe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,Abe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,Tbe=`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`,Cbe=`#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`,Nbe=`#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`,kbe=`#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`,Pbe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,Rbe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,Dbe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,Obe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,jbe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,Lbe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,Ibe=`#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`,Ube=`#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`,Fbe=`#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`,zbe=`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`,Bbe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,Hbe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,$be=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,Vbe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,Gbe="gl_FragColor = linearToOutputTexel( gl_FragColor );",Wbe=`
- 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 );
- }`,qbe=`#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`,Kbe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,Xbe=`#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`,Ybe=`#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`,Zbe=`#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`,Qbe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,Jbe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,eve=`#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`,tve=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,nve=`#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
- }`,rve=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,ive=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,sve=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,ave=`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`,ove=`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`,lve=`#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`,cve=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,uve=`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`,dve=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,hve=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,fve=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,pve=`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 );
- }`,mve=`
- 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`,gve=`#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`,xve=`#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`,bve=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,vve=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,yve=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,_ve=`#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`,wve=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,Sve=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,Eve=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,Mve=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Ave=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,Tve=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,Cve=`#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`,Nve=`#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`,kve=`#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`,Pve=`#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`,Rve=`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;`,Dve=`#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`,Ove=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,jve=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Lve=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,Ive=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,Uve=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Fve=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,zve=`#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`,Bve=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Hve=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,$ve=`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 );
- }`,Vve=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,Gve=`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;`,Wve=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,qve=`#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`,Kve=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Xve=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Yve=`#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`,Zve=`#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`,Qve=`#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`,Jve=`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;
- }`,eye=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,tye=`#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`,nye=`#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`,rye=`#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`,iye=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,sye=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,aye=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,oye=`#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; }`,lye=`#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`,cye=`#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`,uye=`#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`,dye=`#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`,hye=`#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`,fye=`#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 pye=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,mye=`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>
- }`,gye=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,xye=`#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>
- }`,bye=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,vye=`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>
- }`,yye=`#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;
- }`,_ye=`#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
- }`,wye=`#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;
- }`,Sye=`#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 );
- }`,Eye=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,Mye=`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>
- }`,Aye=`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>
- }`,Tye=`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>
- }`,Cye=`#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>
- }`,Nye=`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>
- }`,kye=`#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>
- }`,Pye=`#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>
- }`,Rye=`#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;
- }`,Dye=`#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>
- }`,Oye=`#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
- }`,jye=`#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
- }`,Lye=`#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>
- }`,Iye=`#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>
- }`,Uye=`#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
- }`,Fye=`#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>
- }`,zye=`#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>
- }`,Bye=`#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>
- }`,Hye=`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>
- }`,$ye=`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>
- }`,Vye=`#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>
- }`,Gye=`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>
- }`,Wye=`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>
- }`,qye=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,an={alphahash_fragment:mbe,alphahash_pars_fragment:gbe,alphamap_fragment:xbe,alphamap_pars_fragment:bbe,alphatest_fragment:vbe,alphatest_pars_fragment:ybe,aomap_fragment:_be,aomap_pars_fragment:wbe,batching_pars_vertex:Sbe,batching_vertex:Ebe,begin_vertex:Mbe,beginnormal_vertex:Abe,bsdfs:Tbe,iridescence_fragment:Cbe,bumpmap_pars_fragment:Nbe,clipping_planes_fragment:kbe,clipping_planes_pars_fragment:Pbe,clipping_planes_pars_vertex:Rbe,clipping_planes_vertex:Dbe,color_fragment:Obe,color_pars_fragment:jbe,color_pars_vertex:Lbe,color_vertex:Ibe,common:Ube,cube_uv_reflection_fragment:Fbe,defaultnormal_vertex:zbe,displacementmap_pars_vertex:Bbe,displacementmap_vertex:Hbe,emissivemap_fragment:$be,emissivemap_pars_fragment:Vbe,colorspace_fragment:Gbe,colorspace_pars_fragment:Wbe,envmap_fragment:qbe,envmap_common_pars_fragment:Kbe,envmap_pars_fragment:Xbe,envmap_pars_vertex:Ybe,envmap_physical_pars_fragment:lve,envmap_vertex:Zbe,fog_vertex:Qbe,fog_pars_vertex:Jbe,fog_fragment:eve,fog_pars_fragment:tve,gradientmap_pars_fragment:nve,lightmap_fragment:rve,lightmap_pars_fragment:ive,lights_lambert_fragment:sve,lights_lambert_pars_fragment:ave,lights_pars_begin:ove,lights_toon_fragment:cve,lights_toon_pars_fragment:uve,lights_phong_fragment:dve,lights_phong_pars_fragment:hve,lights_physical_fragment:fve,lights_physical_pars_fragment:pve,lights_fragment_begin:mve,lights_fragment_maps:gve,lights_fragment_end:xve,logdepthbuf_fragment:bve,logdepthbuf_pars_fragment:vve,logdepthbuf_pars_vertex:yve,logdepthbuf_vertex:_ve,map_fragment:wve,map_pars_fragment:Sve,map_particle_fragment:Eve,map_particle_pars_fragment:Mve,metalnessmap_fragment:Ave,metalnessmap_pars_fragment:Tve,morphcolor_vertex:Cve,morphnormal_vertex:Nve,morphtarget_pars_vertex:kve,morphtarget_vertex:Pve,normal_fragment_begin:Rve,normal_fragment_maps:Dve,normal_pars_fragment:Ove,normal_pars_vertex:jve,normal_vertex:Lve,normalmap_pars_fragment:Ive,clearcoat_normal_fragment_begin:Uve,clearcoat_normal_fragment_maps:Fve,clearcoat_pars_fragment:zve,iridescence_pars_fragment:Bve,opaque_fragment:Hve,packing:$ve,premultiplied_alpha_fragment:Vve,project_vertex:Gve,dithering_fragment:Wve,dithering_pars_fragment:qve,roughnessmap_fragment:Kve,roughnessmap_pars_fragment:Xve,shadowmap_pars_fragment:Yve,shadowmap_pars_vertex:Zve,shadowmap_vertex:Qve,shadowmask_pars_fragment:Jve,skinbase_vertex:eye,skinning_pars_vertex:tye,skinning_vertex:nye,skinnormal_vertex:rye,specularmap_fragment:iye,specularmap_pars_fragment:sye,tonemapping_fragment:aye,tonemapping_pars_fragment:oye,transmission_fragment:lye,transmission_pars_fragment:cye,uv_pars_fragment:uye,uv_pars_vertex:dye,uv_vertex:hye,worldpos_vertex:fye,background_vert:pye,background_frag:mye,backgroundCube_vert:gye,backgroundCube_frag:xye,cube_vert:bye,cube_frag:vye,depth_vert:yye,depth_frag:_ye,distanceRGBA_vert:wye,distanceRGBA_frag:Sye,equirect_vert:Eye,equirect_frag:Mye,linedashed_vert:Aye,linedashed_frag:Tye,meshbasic_vert:Cye,meshbasic_frag:Nye,meshlambert_vert:kye,meshlambert_frag:Pye,meshmatcap_vert:Rye,meshmatcap_frag:Dye,meshnormal_vert:Oye,meshnormal_frag:jye,meshphong_vert:Lye,meshphong_frag:Iye,meshphysical_vert:Uye,meshphysical_frag:Fye,meshtoon_vert:zye,meshtoon_frag:Bye,points_vert:Hye,points_frag:$ye,shadow_vert:Vye,shadow_frag:Gye,sprite_vert:Wye,sprite_frag:qye},vt={common:{diffuse:{value:new $t(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new hn},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new hn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new hn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new hn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new hn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new hn},normalScale:{value:new Yt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new hn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new hn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new hn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new hn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new $t(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new $t(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0},uvTransform:{value:new hn}},sprite:{diffuse:{value:new $t(16777215)},opacity:{value:1},center:{value:new Yt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new hn},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0}}},zs={basic:{uniforms:vs([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.fog]),vertexShader:an.meshbasic_vert,fragmentShader:an.meshbasic_frag},lambert:{uniforms:vs([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,vt.lights,{emissive:{value:new $t(0)}}]),vertexShader:an.meshlambert_vert,fragmentShader:an.meshlambert_frag},phong:{uniforms:vs([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,vt.lights,{emissive:{value:new $t(0)},specular:{value:new $t(1118481)},shininess:{value:30}}]),vertexShader:an.meshphong_vert,fragmentShader:an.meshphong_frag},standard:{uniforms:vs([vt.common,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.roughnessmap,vt.metalnessmap,vt.fog,vt.lights,{emissive:{value:new $t(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag},toon:{uniforms:vs([vt.common,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.gradientmap,vt.fog,vt.lights,{emissive:{value:new $t(0)}}]),vertexShader:an.meshtoon_vert,fragmentShader:an.meshtoon_frag},matcap:{uniforms:vs([vt.common,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,{matcap:{value:null}}]),vertexShader:an.meshmatcap_vert,fragmentShader:an.meshmatcap_frag},points:{uniforms:vs([vt.points,vt.fog]),vertexShader:an.points_vert,fragmentShader:an.points_frag},dashed:{uniforms:vs([vt.common,vt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:an.linedashed_vert,fragmentShader:an.linedashed_frag},depth:{uniforms:vs([vt.common,vt.displacementmap]),vertexShader:an.depth_vert,fragmentShader:an.depth_frag},normal:{uniforms:vs([vt.common,vt.bumpmap,vt.normalmap,vt.displacementmap,{opacity:{value:1}}]),vertexShader:an.meshnormal_vert,fragmentShader:an.meshnormal_frag},sprite:{uniforms:vs([vt.sprite,vt.fog]),vertexShader:an.sprite_vert,fragmentShader:an.sprite_frag},background:{uniforms:{uvTransform:{value:new hn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:an.background_vert,fragmentShader:an.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:an.backgroundCube_vert,fragmentShader:an.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:an.cube_vert,fragmentShader:an.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:an.equirect_vert,fragmentShader:an.equirect_frag},distanceRGBA:{uniforms:vs([vt.common,vt.displacementmap,{referencePosition:{value:new De},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:an.distanceRGBA_vert,fragmentShader:an.distanceRGBA_frag},shadow:{uniforms:vs([vt.lights,vt.fog,{color:{value:new $t(0)},opacity:{value:1}}]),vertexShader:an.shadow_vert,fragmentShader:an.shadow_frag}};zs.physical={uniforms:vs([zs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new hn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new hn},clearcoatNormalScale:{value:new Yt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new hn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new hn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new hn},sheen:{value:0},sheenColor:{value:new $t(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new hn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new hn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new hn},transmissionSamplerSize:{value:new Yt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new hn},attenuationDistance:{value:0},attenuationColor:{value:new $t(0)},specularColor:{value:new $t(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new hn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new hn},anisotropyVector:{value:new Yt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new hn}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag};const Vy={r:0,b:0,g:0};function Kye(t,e,n,r,i,s,a){const o=new $t(0);let l=s===!0?0:1,u,d,f=null,g=0,m=null;function x(v,b){let E=!1,S=b.isScene===!0?b.background:null;S&&S.isTexture&&(S=(b.backgroundBlurriness>0?n:e).get(S)),S===null?y(o,l):S&&S.isColor&&(y(S,1),E=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,a):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,a),(t.autoClear||E)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),S&&(S.isCubeTexture||S.mapping===TS)?(d===void 0&&(d=new No(new ab(1,1,1),new rd({name:"BackgroundCubeMaterial",uniforms:mm(zs.backgroundCube.uniforms),vertexShader:zs.backgroundCube.vertexShader,fragmentShader:zs.backgroundCube.fragmentShader,side:Vs,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,P,C){this.matrixWorld.copyPosition(C.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=Vn.getTransfer(S.colorSpace)!==ar,(f!==S||g!==S.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=S,g=S.version,m=t.toneMapping),d.layers.enableAll(),v.unshift(d,d.geometry,d.material,0,0,null)):S&&S.isTexture&&(u===void 0&&(u=new No(new WR(2,2),new rd({name:"BackgroundMaterial",uniforms:mm(zs.background.uniforms),vertexShader:zs.background.vertexShader,fragmentShader:zs.background.fragmentShader,side:nd,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=Vn.getTransfer(S.colorSpace)!==ar,S.matrixAutoUpdate===!0&&S.updateMatrix(),u.material.uniforms.uvTransform.value.copy(S.matrix),(f!==S||g!==S.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=S,g=S.version,m=t.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null))}function y(v,b){v.getRGB(Vy,tW(t)),r.buffers.color.setClear(Vy.r,Vy.g,Vy.b,b,a)}return{getClearColor:function(){return o},setClearColor:function(v,b=1){o.set(v),l=b,y(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,y(o,l)},render:x}}function Xye(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=r.isWebGL2?null:e.get("OES_vertex_array_object"),a=r.isWebGL2||s!==null,o={},l=v(null);let u=l,d=!1;function f(R,V,K,W,ne){let Y=!1;if(a){const Z=y(W,K,V);u!==Z&&(u=Z,m(u.object)),Y=b(R,W,K,ne),Y&&E(R,W,K,ne)}else{const Z=V.wireframe===!0;(u.geometry!==W.id||u.program!==K.id||u.wireframe!==Z)&&(u.geometry=W.id,u.program=K.id,u.wireframe=Z,Y=!0)}ne!==null&&n.update(ne,t.ELEMENT_ARRAY_BUFFER),(Y||d)&&(d=!1,I(R,V,K,W),ne!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(ne).buffer))}function g(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function m(R){return r.isWebGL2?t.bindVertexArray(R):s.bindVertexArrayOES(R)}function x(R){return r.isWebGL2?t.deleteVertexArray(R):s.deleteVertexArrayOES(R)}function y(R,V,K){const W=K.wireframe===!0;let ne=o[R.id];ne===void 0&&(ne={},o[R.id]=ne);let Y=ne[V.id];Y===void 0&&(Y={},ne[V.id]=Y);let Z=Y[W];return Z===void 0&&(Z=v(g()),Y[W]=Z),Z}function v(R){const V=[],K=[],W=[];for(let ne=0;ne<i;ne++)V[ne]=0,K[ne]=0,W[ne]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:V,enabledAttributes:K,attributeDivisors:W,object:R,attributes:{},index:null}}function b(R,V,K,W){const ne=u.attributes,Y=V.attributes;let Z=0;const U=K.getAttributes();for(const $ in U)if(U[$].location>=0){const ae=ne[$];let fe=Y[$];if(fe===void 0&&($==="instanceMatrix"&&R.instanceMatrix&&(fe=R.instanceMatrix),$==="instanceColor"&&R.instanceColor&&(fe=R.instanceColor)),ae===void 0||ae.attribute!==fe||fe&&ae.data!==fe.data)return!0;Z++}return u.attributesNum!==Z||u.index!==W}function E(R,V,K,W){const ne={},Y=V.attributes;let Z=0;const U=K.getAttributes();for(const $ in U)if(U[$].location>=0){let ae=Y[$];ae===void 0&&($==="instanceMatrix"&&R.instanceMatrix&&(ae=R.instanceMatrix),$==="instanceColor"&&R.instanceColor&&(ae=R.instanceColor));const fe={};fe.attribute=ae,ae&&ae.data&&(fe.data=ae.data),ne[$]=fe,Z++}u.attributes=ne,u.attributesNum=Z,u.index=W}function S(){const R=u.newAttributes;for(let V=0,K=R.length;V<K;V++)R[V]=0}function A(R){T(R,0)}function T(R,V){const K=u.newAttributes,W=u.enabledAttributes,ne=u.attributeDivisors;K[R]=1,W[R]===0&&(t.enableVertexAttribArray(R),W[R]=1),ne[R]!==V&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,V),ne[R]=V)}function P(){const R=u.newAttributes,V=u.enabledAttributes;for(let K=0,W=V.length;K<W;K++)V[K]!==R[K]&&(t.disableVertexAttribArray(K),V[K]=0)}function C(R,V,K,W,ne,Y,Z){Z===!0?t.vertexAttribIPointer(R,V,K,ne,Y):t.vertexAttribPointer(R,V,K,W,ne,Y)}function I(R,V,K,W){if(r.isWebGL2===!1&&(R.isInstancedMesh||W.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;S();const ne=W.attributes,Y=K.getAttributes(),Z=V.defaultAttributeValues;for(const U in Y){const $=Y[U];if($.location>=0){let ee=ne[U];if(ee===void 0&&(U==="instanceMatrix"&&R.instanceMatrix&&(ee=R.instanceMatrix),U==="instanceColor"&&R.instanceColor&&(ee=R.instanceColor)),ee!==void 0){const ae=ee.normalized,fe=ee.itemSize,ue=n.get(ee);if(ue===void 0)continue;const xe=ue.buffer,Me=ue.type,se=ue.bytesPerElement,ve=r.isWebGL2===!0&&(Me===t.INT||Me===t.UNSIGNED_INT||ee.gpuType===j7);if(ee.isInterleavedBufferAttribute){const je=ee.data,de=je.stride,ut=ee.offset;if(je.isInstancedInterleavedBuffer){for(let H=0;H<$.locationSize;H++)T($.location+H,je.meshPerAttribute);R.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._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++)C($.location+H,fe/$.locationSize,Me,ae,de*se,(ut+fe/$.locationSize*H)*se,ve)}else{if(ee.isInstancedBufferAttribute){for(let je=0;je<$.locationSize;je++)T($.location+je,ee.meshPerAttribute);R.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=ee.meshPerAttribute*ee.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++)C($.location+je,fe/$.locationSize,Me,ae,fe*se,fe/$.locationSize*je*se,ve)}}else if(Z!==void 0){const ae=Z[U];if(ae!==void 0)switch(ae.length){case 2:t.vertexAttrib2fv($.location,ae);break;case 3:t.vertexAttrib3fv($.location,ae);break;case 4:t.vertexAttrib4fv($.location,ae);break;default:t.vertexAttrib1fv($.location,ae)}}}}P()}function N(){L();for(const R in o){const V=o[R];for(const K in V){const W=V[K];for(const ne in W)x(W[ne].object),delete W[ne];delete V[K]}delete o[R]}}function D(R){if(o[R.id]===void 0)return;const V=o[R.id];for(const K in V){const W=V[K];for(const ne in W)x(W[ne].object),delete W[ne];delete V[K]}delete o[R.id]}function F(R){for(const V in o){const K=o[V];if(K[R.id]===void 0)continue;const W=K[R.id];for(const ne in W)x(W[ne].object),delete W[ne];delete K[R.id]}}function L(){q(),d=!0,u!==l&&(u=l,m(u.object))}function q(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:f,reset:L,resetDefaultState:q,dispose:N,releaseStatesOfGeometry:D,releaseStatesOfProgram:F,initAttributes:S,enableAttribute:A,disableUnusedAttributes:P}}function Yye(t,e,n,r){const i=r.isWebGL2;let s;function a(d){s=d}function o(d,f){t.drawArrays(s,d,f),n.update(f,s,1)}function l(d,f,g){if(g===0)return;let m,x;if(i)m=t,x="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[x](s,d,f,g),n.update(f,s,g)}function u(d,f,g){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<g;x++)this.render(d[x],f[x]);else{m.multiDrawArraysWEBGL(s,d,0,f,0,g);let x=0;for(let y=0;y<g;y++)x+=f[y];n.update(x,s,1)}}this.setMode=a,this.render=o,this.renderInstances=l,this.renderMultiDraw=u}function Zye(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const a=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let o=n.precision!==void 0?n.precision:"highp";const l=s(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);const u=a||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),v=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),b=t.getParameter(t.MAX_VARYING_VECTORS),E=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),S=g>0,A=a||e.has("OES_texture_float"),T=S&&A,P=a?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:m,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:v,maxVaryings:b,maxFragmentUniforms:E,vertexTextures:S,floatFragmentTextures:A,floatVertexTextures:T,maxSamples:P}}function Qye(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new Su,o=new hn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const m=f.length!==0||g||r!==0||i;return i=g,r=f.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,m){const x=f.clippingPlanes,y=f.clipIntersection,v=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||s&&!v)s?d(null):u();else{const E=s?0:r,S=E*4;let A=b.clippingState||null;l.value=A,A=d(x,g,S,m);for(let T=0;T!==S;++T)A[T]=n[T];b.clippingState=A,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=E}};function u(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,m,x){const y=f!==null?f.length:0;let v=null;if(y!==0){if(v=l.value,x!==!0||v===null){const b=m+y*4,E=g.matrixWorldInverse;o.getNormalMatrix(E),(v===null||v.length<b)&&(v=new Float32Array(b));for(let S=0,A=m;S!==y;++S,A+=4)a.copy(f[S]).applyMatrix4(E,o),a.normal.toArray(v,A),v[A+3]=a.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function Jye(t){let e=new WeakMap;function n(a,o){return o===rk?a.mapping=hm:o===ik&&(a.mapping=fm),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===rk||o===ik)if(e.has(a)){const l=e.get(a).texture;return n(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const u=new dbe(l.height/2);return u.fromEquirectangularTexture(t,a),e.set(a,u),a.addEventListener("dispose",i),n(u.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}class e_e extends nW{constructor(e=-1,n=1,r=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,a=r+e,o=i+n,l=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,a=s+u*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const Lp=4,zz=[.125,.215,.35,.446,.526,.582],th=20,dT=new e_e,Bz=new $t;let hT=null,fT=0,pT=0;const Kd=(1+Math.sqrt(5))/2,vp=1/Kd,Hz=[new De(1,1,1),new De(-1,1,1),new De(1,1,-1),new De(-1,1,-1),new De(0,Kd,vp),new De(0,Kd,-vp),new De(vp,0,Kd),new De(-vp,0,Kd),new De(Kd,vp,0),new De(-Kd,vp,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){hT=this._renderer.getRenderTarget(),fT=this._renderer.getActiveCubeFace(),pT=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,r,i,s),n>0&&this._blur(s,0,0,n),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Wz(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Gz(),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(hT,fT,pT),e.scissorTest=!1,Gy(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===hm||e.mapping===fm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),hT=this._renderer.getRenderTarget(),fT=this._renderer.getActiveCubeFace(),pT=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:Wa,minFilter:Wa,generateMipmaps:!1,type:_0,format:qa,colorSpace:_c,depthBuffer:!1},i=Vz(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Vz(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=t_e(s)),this._blurMaterial=n_e(s,e,n)}return i}_compileMaterial(e){const n=new No(this._lodPlanes[0],e);this._renderer.compile(n,dT)}_sceneToCubeUV(e,n,r,i){const o=new da(90,1,n,r),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,g=d.toneMapping;d.getClearColor(Bz),d.toneMapping=Vu,d.autoClear=!1;const m=new Q7({name:"PMREM.Background",side:Vs,depthWrite:!1,depthTest:!1}),x=new No(new ab,m);let y=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,y=!0):(m.color.copy(Bz),y=!0);for(let b=0;b<6;b++){const E=b%3;E===0?(o.up.set(0,l[b],0),o.lookAt(u[b],0,0)):E===1?(o.up.set(0,0,l[b]),o.lookAt(0,u[b],0)):(o.up.set(0,l[b],0),o.lookAt(0,0,u[b]));const S=this._cubeSize;Gy(i,E*S,b>2?S:0,S,S),d.setRenderTarget(i),y&&d.render(x,o),d.render(e,o)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=g,d.autoClear=f,e.background=v}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===hm||e.mapping===fm;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Wz()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Gz());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new No(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Gy(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(a,dT)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),a=Hz[(i-1)%Hz.length];this._blur(e,i-1,i,s,a)}n.autoClear=r}_blur(e,n,r,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,n,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,a,o){const l=this._renderer,u=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new No(this._lodPlanes[i],u),g=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*th-1),y=s/x,v=isFinite(s)?1+Math.floor(d*y):th;v>th&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${th}`);const b=[];let E=0;for(let C=0;C<th;++C){const I=C/y,N=Math.exp(-I*I/2);b.push(N),C===0?E+=N:C<v&&(E+=2*N)}for(let C=0;C<b.length;C++)b[C]=b[C]/E;g.envMap.value=e.texture,g.samples.value=v,g.weights.value=b,g.latitudinal.value=a==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:S}=this;g.dTheta.value=x,g.mipInt.value=S-r;const A=this._sizeLods[i],T=3*A*(i>S-Lp?i-S+Lp:0),P=4*(this._cubeSize-A);Gy(n,T,P,3*A,2*A),l.setRenderTarget(n),l.render(f,dT)}}function t_e(t){const e=[],n=[],r=[];let i=t;const s=t-Lp+1+zz.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);n.push(o);let l=1/o;a>t-Lp?l=zz[a-t+Lp-1]:a===0&&(l=0),r.push(l);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,y=3,v=2,b=1,E=new Float32Array(y*x*m),S=new Float32Array(v*x*m),A=new Float32Array(b*x*m);for(let P=0;P<m;P++){const C=P%3*2/3-1,I=P>2?0:-1,N=[C,I,0,C+2/3,I,0,C+2/3,I+1,0,C,I,0,C+2/3,I+1,0,C,I+1,0];E.set(N,y*x*P),S.set(g,v*x*P);const D=[P,P,P,P,P,P];A.set(D,b*x*P)}const T=new fs;T.setAttribute("position",new xa(E,y)),T.setAttribute("uv",new xa(S,v)),T.setAttribute("faceIndex",new xa(A,b)),e.push(T),i>Lp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function Vz(t,e,n){const r=new zh(t,e,n);return r.texture.mapping=TS,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Gy(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function n_e(t,e,n){const r=new Float32Array(th),i=new De(0,1,0);return new rd({name:"SphericalGaussianBlur",defines:{n:th,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:qR(),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:$u,depthTest:!1,depthWrite:!1})}function Gz(){return new rd({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:qR(),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:$u,depthTest:!1,depthWrite:!1})}function Wz(){return new rd({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:qR(),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:$u,depthTest:!1,depthWrite:!1})}function qR(){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 r_e(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,u=l===rk||l===ik,d=l===hm||l===fm;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",s),g.texture}else return null}}}return o}function i(o){let l=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&l++;return l===u}function s(o){const l=o.target;l.removeEventListener("dispose",s);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function a(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:a}}function i_e(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 s_e(t,e,n,r){const i={},s=new WeakMap;function a(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);for(const x in g.morphAttributes){const y=g.morphAttributes[x];for(let v=0,b=y.length;v<b;v++)e.remove(y[v])}g.removeEventListener("dispose",a),delete i[g.id];const m=s.get(g);m&&(e.remove(m),s.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(f,g){return i[g.id]===!0||(g.addEventListener("dispose",a),i[g.id]=!0,n.memory.geometries++),g}function l(f){const g=f.attributes;for(const x in g)e.update(g[x],t.ARRAY_BUFFER);const m=f.morphAttributes;for(const x in m){const y=m[x];for(let v=0,b=y.length;v<b;v++)e.update(y[v],t.ARRAY_BUFFER)}}function u(f){const g=[],m=f.index,x=f.attributes.position;let y=0;if(m!==null){const E=m.array;y=m.version;for(let S=0,A=E.length;S<A;S+=3){const T=E[S+0],P=E[S+1],C=E[S+2];g.push(T,P,P,C,C,T)}}else if(x!==void 0){const E=x.array;y=x.version;for(let S=0,A=E.length/3-1;S<A;S+=3){const T=S+0,P=S+1,C=S+2;g.push(T,P,P,C,C,T)}}else return;const v=new(W7(g)?eW:J7)(g,1);v.version=y;const b=s.get(f);b&&e.remove(b),s.set(f,v)}function d(f){const g=s.get(f);if(g){const m=f.index;m!==null&&g.version<m.version&&u(f)}else u(f);return s.get(f)}return{get:o,update:l,getWireframeAttribute:d}}function a_e(t,e,n,r){const i=r.isWebGL2;let s;function a(m){s=m}let o,l;function u(m){o=m.type,l=m.bytesPerElement}function d(m,x){t.drawElements(s,x,o,m*l),n.update(x,s,1)}function f(m,x,y){if(y===0)return;let v,b;if(i)v=t,b="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),b="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[b](s,x,o,m*l,y),n.update(x,s,y)}function g(m,x,y){if(y===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let b=0;b<y;b++)this.render(m[b]/l,x[b]);else{v.multiDrawElementsWEBGL(s,x,0,o,m,0,y);let b=0;for(let E=0;E<y;E++)b+=x[E];n.update(b,s,1)}}this.setMode=a,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=g}function o_e(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,a,o){switch(n.calls++,a){case t.TRIANGLES:n.triangles+=o*(s/3);break;case t.LINES:n.lines+=o*(s/2);break;case t.LINE_STRIP:n.lines+=o*(s-1);break;case t.LINE_LOOP:n.lines+=o*s;break;case t.POINTS:n.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function l_e(t,e){return t[0]-e[0]}function c_e(t,e){return Math.abs(e[1])-Math.abs(t[1])}function u_e(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,a=new Wn,o=[];for(let u=0;u<8;u++)o[u]=[u,0];function l(u,d,f){const g=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,y=x!==void 0?x.length:0;let v=s.get(d);if(v===void 0||v.count!==y){let V=function(){q.dispose(),s.delete(d),d.removeEventListener("dispose",V)};var m=V;v!==void 0&&v.texture.dispose();const S=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,T=d.morphAttributes.color!==void 0,P=d.morphAttributes.position||[],C=d.morphAttributes.normal||[],I=d.morphAttributes.color||[];let N=0;S===!0&&(N=1),A===!0&&(N=2),T===!0&&(N=3);let D=d.attributes.position.count*N,F=1;D>e.maxTextureSize&&(F=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const L=new Float32Array(D*F*4*y),q=new X7(L,D,F,y);q.type=oc,q.needsUpdate=!0;const R=N*4;for(let K=0;K<y;K++){const W=P[K],ne=C[K],Y=I[K],Z=D*F*4*K;for(let U=0;U<W.count;U++){const $=U*R;S===!0&&(a.fromBufferAttribute(W,U),L[Z+$+0]=a.x,L[Z+$+1]=a.y,L[Z+$+2]=a.z,L[Z+$+3]=0),A===!0&&(a.fromBufferAttribute(ne,U),L[Z+$+4]=a.x,L[Z+$+5]=a.y,L[Z+$+6]=a.z,L[Z+$+7]=0),T===!0&&(a.fromBufferAttribute(Y,U),L[Z+$+8]=a.x,L[Z+$+9]=a.y,L[Z+$+10]=a.z,L[Z+$+11]=Y.itemSize===4?a.w:1)}}v={count:y,texture:q,size:new Yt(D,F)},s.set(d,v),d.addEventListener("dispose",V)}let b=0;for(let S=0;S<g.length;S++)b+=g[S];const E=d.morphTargetsRelative?1:1-b;f.getUniforms().setValue(t,"morphTargetBaseInfluence",E),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",v.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",v.size)}else{const x=g===void 0?0:g.length;let y=r[d.id];if(y===void 0||y.length!==x){y=[];for(let A=0;A<x;A++)y[A]=[A,0];r[d.id]=y}for(let A=0;A<x;A++){const T=y[A];T[0]=A,T[1]=g[A]}y.sort(c_e);for(let A=0;A<8;A++)A<x&&y[A][1]?(o[A][0]=y[A][0],o[A][1]=y[A][1]):(o[A][0]=Number.MAX_SAFE_INTEGER,o[A][1]=0);o.sort(l_e);const v=d.morphAttributes.position,b=d.morphAttributes.normal;let E=0;for(let A=0;A<8;A++){const T=o[A],P=T[0],C=T[1];P!==Number.MAX_SAFE_INTEGER&&C?(v&&d.getAttribute("morphTarget"+A)!==v[P]&&d.setAttribute("morphTarget"+A,v[P]),b&&d.getAttribute("morphNormal"+A)!==b[P]&&d.setAttribute("morphNormal"+A,b[P]),i[A]=C,E+=C):(v&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),b&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const S=d.morphTargetsRelative?1:1-E;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:l}}function d_e(t,e,n,r){let i=new WeakMap;function s(l){const u=r.render.frame,d=l.geometry,f=e.get(l,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==u&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,u))),l.isSkinnedMesh){const g=l.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function a(){i=new WeakMap}function o(l){const u=l.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:a}}class sW extends Gs{constructor(e,n,r,i,s,a,o,l,u,d){if(d=d!==void 0?d:gh,d!==gh&&d!==pm)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===gh&&(r=Lu),r===void 0&&d===pm&&(r=mh),super(null,i,s,a,o,l,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Ki,this.minFilter=l!==void 0?l:Ki,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 aW=new Gs,oW=new sW(1,1);oW.compareFunction=V7;const lW=new X7,cW=new X0e,uW=new rW,qz=[],Kz=[],Xz=new Float32Array(16),Yz=new Float32Array(9),Zz=new Float32Array(4);function Hm(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=qz[i];if(s===void 0&&(s=new Float32Array(i),qz[i]=s),e!==0){r.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=n,t[a].toArray(s,o)}return s}function pi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function mi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function kS(t,e){let n=Kz[e];n===void 0&&(n=new Int32Array(e),Kz[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function h_e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function f_e(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 p_e(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 m_e(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 g_e(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;Zz.set(r),t.uniformMatrix2fv(this.addr,!1,Zz),mi(n,r)}}function x_e(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;Yz.set(r),t.uniformMatrix3fv(this.addr,!1,Yz),mi(n,r)}}function b_e(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;Xz.set(r),t.uniformMatrix4fv(this.addr,!1,Xz),mi(n,r)}}function v_e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function y_e(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 __e(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 w_e(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 S_e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function E_e(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 M_e(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 A_e(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 T_e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const s=this.type===t.SAMPLER_2D_SHADOW?oW:aW;n.setTexture2D(e||s,i)}function C_e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||cW,i)}function N_e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||uW,i)}function k_e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||lW,i)}function P_e(t){switch(t){case 5126:return h_e;case 35664:return f_e;case 35665:return p_e;case 35666:return m_e;case 35674:return g_e;case 35675:return x_e;case 35676:return b_e;case 5124:case 35670:return v_e;case 35667:case 35671:return y_e;case 35668:case 35672:return __e;case 35669:case 35673:return w_e;case 5125:return S_e;case 36294:return E_e;case 36295:return M_e;case 36296:return A_e;case 35678:case 36198:case 36298:case 36306:case 35682:return T_e;case 35679:case 36299:case 36307:return C_e;case 35680:case 36300:case 36308:case 36293:return N_e;case 36289:case 36303:case 36311:case 36292:return k_e}}function R_e(t,e){t.uniform1fv(this.addr,e)}function D_e(t,e){const n=Hm(e,this.size,2);t.uniform2fv(this.addr,n)}function O_e(t,e){const n=Hm(e,this.size,3);t.uniform3fv(this.addr,n)}function j_e(t,e){const n=Hm(e,this.size,4);t.uniform4fv(this.addr,n)}function L_e(t,e){const n=Hm(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function I_e(t,e){const n=Hm(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function U_e(t,e){const n=Hm(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function F_e(t,e){t.uniform1iv(this.addr,e)}function z_e(t,e){t.uniform2iv(this.addr,e)}function B_e(t,e){t.uniform3iv(this.addr,e)}function H_e(t,e){t.uniform4iv(this.addr,e)}function $_e(t,e){t.uniform1uiv(this.addr,e)}function V_e(t,e){t.uniform2uiv(this.addr,e)}function G_e(t,e){t.uniform3uiv(this.addr,e)}function W_e(t,e){t.uniform4uiv(this.addr,e)}function q_e(t,e,n){const r=this.cache,i=e.length,s=kS(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||aW,s[a])}function K_e(t,e,n){const r=this.cache,i=e.length,s=kS(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||cW,s[a])}function X_e(t,e,n){const r=this.cache,i=e.length,s=kS(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||uW,s[a])}function Y_e(t,e,n){const r=this.cache,i=e.length,s=kS(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||lW,s[a])}function Z_e(t){switch(t){case 5126:return R_e;case 35664:return D_e;case 35665:return O_e;case 35666:return j_e;case 35674:return L_e;case 35675:return I_e;case 35676:return U_e;case 5124:case 35670:return F_e;case 35667:case 35671:return z_e;case 35668:case 35672:return B_e;case 35669:case 35673:return H_e;case 5125:return $_e;case 36294:return V_e;case 36295:return G_e;case 36296:return W_e;case 35678:case 36198:case 36298:case 36306:case 35682:return q_e;case 35679:case 36299:case 36307:return K_e;case 35680:case 36300:case 36308:case 36293:return X_e;case 36289:case 36303:case 36311:case 36292:return Y_e}}class Q_e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=P_e(n.type)}}class J_e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Z_e(n.type)}}class e1e{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,n[o.id],r)}}}const mT=/(\w+)(\])?(\[|\.)?/g;function Qz(t,e){t.seq.push(e),t.map[e.id]=e}function t1e(t,e,n){const r=t.name,i=r.length;for(mT.lastIndex=0;;){const s=mT.exec(r),a=mT.lastIndex;let o=s[1];const l=s[2]==="]",u=s[3];if(l&&(o=o|0),u===void 0||u==="["&&a+2===i){Qz(n,u===void 0?new Q_e(o,t,e):new J_e(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new e1e(o),Qz(n,f)),n=f}}}class $_{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),a=e.getUniformLocation(n,s.name);t1e(s,a,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let s=0,a=n.length;s!==a;++s){const o=n[s],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in n&&r.push(a)}return r}}function Jz(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const n1e=37297;let r1e=0;function i1e(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let a=i;a<s;a++){const o=a+1;r.push(`${o===e?">":" "} ${o}: ${n[a]}`)}return r.join(`
- `)}function s1e(t){const e=Vn.getPrimaries(Vn.workingColorSpace),n=Vn.getPrimaries(t);let r;switch(e===n?r="":e===b1&&n===x1?r="LinearDisplayP3ToLinearSRGB":e===x1&&n===b1&&(r="LinearSRGBToLinearDisplayP3"),t){case _c:case CS:return[r,"LinearTransferOETF"];case Xi:case HR:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function eB(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return n.toUpperCase()+`
- `+i+`
- `+i1e(t.getShaderSource(e),a)}else return i}function a1e(t,e){const n=s1e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function o1e(t,e){let n;switch(e){case a0e:n="Linear";break;case o0e:n="Reinhard";break;case l0e:n="OptimizedCineon";break;case c0e:n="ACESFilmic";break;case u0e:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function l1e(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(Sx).join(`
- `)}function c1e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function u1e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),a=s.name;let o=1;s.type===t.FLOAT_MAT2&&(o=2),s.type===t.FLOAT_MAT3&&(o=3),s.type===t.FLOAT_MAT4&&(o=4),n[a]={type:s.type,location:t.getAttribLocation(e,a),locationSize:o}}return n}function Sx(t){return t!==""}function tB(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 nB(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const d1e=/^[ \t]*#include +<([\w\d./]+)>/gm;function uk(t){return t.replace(d1e,f1e)}const h1e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function f1e(t,e){let n=an[e];if(n===void 0){const r=h1e.get(e);if(r!==void 0)n=an[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return uk(n)}const p1e=/#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 rB(t){return t.replace(p1e,m1e)}function m1e(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function iB(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 g1e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===D7?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Oxe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Zl&&(e="SHADOWMAP_TYPE_VSM"),e}function x1e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case hm:case fm:e="ENVMAP_TYPE_CUBE";break;case TS:e="ENVMAP_TYPE_CUBE_UV";break}return e}function b1e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case fm:e="ENVMAP_MODE_REFRACTION";break}return e}function v1e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case zR:e="ENVMAP_BLENDING_MULTIPLY";break;case i0e:e="ENVMAP_BLENDING_MIX";break;case s0e:e="ENVMAP_BLENDING_ADD";break}return e}function y1e(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 _1e(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=g1e(n),u=x1e(n),d=b1e(n),f=v1e(n),g=y1e(n),m=n.isWebGL2?"":l1e(n),x=c1e(s),y=i.createProgram();let v,b,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Sx).join(`
- `),v.length>0&&(v+=`
- `),b=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Sx).join(`
- `),b.length>0&&(b+=`
- `)):(v=[iB(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Sx).join(`
- `),b=[m,iB(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Vu?"#define TONE_MAPPING":"",n.toneMapping!==Vu?an.tonemapping_pars_fragment:"",n.toneMapping!==Vu?o1e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",an.colorspace_pars_fragment,a1e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Sx).join(`
- `)),a=uk(a),a=tB(a,n),a=nB(a,n),o=uk(o),o=tB(o,n),o=nB(o,n),a=rB(a),o=rB(o),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,b=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===wz?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===wz?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+b);const S=E+v+a,A=E+b+o,T=Jz(i,i.VERTEX_SHADER,S),P=Jz(i,i.FRAGMENT_SHADER,A);i.attachShader(y,T),i.attachShader(y,P),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(F){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(y).trim(),q=i.getShaderInfoLog(T).trim(),R=i.getShaderInfoLog(P).trim();let V=!0,K=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(V=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,P);else{const W=eB(i,T,"vertex"),ne=eB(i,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+L+`
- `+W+`
- `+ne)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(q===""||R==="")&&(K=!1);K&&(F.diagnostics={runnable:V,programLog:L,vertexShader:{log:q,prefix:v},fragmentShader:{log:R,prefix:b}})}i.deleteShader(T),i.deleteShader(P),I=new $_(i,y),N=u1e(i,y)}let I;this.getUniforms=function(){return I===void 0&&C(this),I};let N;this.getAttributes=function(){return N===void 0&&C(this),N};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,n1e)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=r1e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=P,this}let w1e=0;class S1e{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new E1e(e),n.set(e,r)),r}}class E1e{constructor(e){this.id=w1e++,this.code=e,this.usedTimes=0}}function M1e(t,e,n,r,i,s,a){const o=new Y7,l=new S1e,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(N){return N===0?"uv":`uv${N}`}function v(N,D,F,L,q){const R=L.fog,V=q.geometry,K=N.isMeshStandardMaterial?L.environment:null,W=(N.isMeshStandardMaterial?n:e).get(N.envMap||K),ne=W&&W.mapping===TS?W.image.height:null,Y=x[N.type];N.precision!==null&&(m=i.getMaxPrecision(N.precision),m!==N.precision&&console.warn("THREE.WebGLProgram.getParameters:",N.precision,"not supported, using",m,"instead."));const Z=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,U=Z!==void 0?Z.length:0;let $=0;V.morphAttributes.position!==void 0&&($=1),V.morphAttributes.normal!==void 0&&($=2),V.morphAttributes.color!==void 0&&($=3);let ee,ae,fe,ue;if(Y){const cn=zs[Y];ee=cn.vertexShader,ae=cn.fragmentShader}else ee=N.vertexShader,ae=N.fragmentShader,l.update(N),fe=l.getVertexShaderID(N),ue=l.getFragmentShaderID(N);const xe=t.getRenderTarget(),Me=q.isInstancedMesh===!0,se=q.isBatchedMesh===!0,ve=!!N.map,je=!!N.matcap,de=!!W,ut=!!N.aoMap,H=!!N.lightMap,z=!!N.bumpMap,re=!!N.normalMap,G=!!N.displacementMap,J=!!N.emissiveMap,le=!!N.metalnessMap,ke=!!N.roughnessMap,Ne=N.anisotropy>0,we=N.clearcoat>0,B=N.iridescence>0,j=N.sheen>0,te=N.transmission>0,be=Ne&&!!N.anisotropyMap,_e=we&&!!N.clearcoatMap,ge=we&&!!N.clearcoatNormalMap,me=we&&!!N.clearcoatRoughnessMap,Ae=B&&!!N.iridescenceMap,ze=B&&!!N.iridescenceThicknessMap,st=j&&!!N.sheenColorMap,Ve=j&&!!N.sheenRoughnessMap,ce=!!N.specularMap,Ye=!!N.specularColorMap,$e=!!N.specularIntensityMap,Ze=te&&!!N.transmissionMap,at=te&&!!N.thicknessMap,Q=!!N.gradientMap,Fe=!!N.alphaMap,pe=N.alphaTest>0,Ue=!!N.alphaHash,Ce=!!N.extensions,ye=!!V.attributes.uv1,He=!!V.attributes.uv2,ht=!!V.attributes.uv3;let wt=Vu;return N.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(wt=t.toneMapping),{isWebGL2:d,shaderID:Y,shaderType:N.type,shaderName:N.name,vertexShader:ee,fragmentShader:ae,defines:N.defines,customVertexShaderID:fe,customFragmentShaderID:ue,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:m,batching:se,instancing:Me,instancingColor:Me&&q.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:_c,map:ve,matcap:je,envMap:de,envMapMode:de&&W.mapping,envMapCubeUVHeight:ne,aoMap:ut,lightMap:H,bumpMap:z,normalMap:re,displacementMap:g&&G,emissiveMap:J,normalMapObjectSpace:re&&N.normalMapType===w0e,normalMapTangentSpace:re&&N.normalMapType===$7,metalnessMap:le,roughnessMap:ke,anisotropy:Ne,anisotropyMap:be,clearcoat:we,clearcoatMap:_e,clearcoatNormalMap:ge,clearcoatRoughnessMap:me,iridescence:B,iridescenceMap:Ae,iridescenceThicknessMap:ze,sheen:j,sheenColorMap:st,sheenRoughnessMap:Ve,specularMap:ce,specularColorMap:Ye,specularIntensityMap:$e,transmission:te,transmissionMap:Ze,thicknessMap:at,gradientMap:Q,opaque:N.transparent===!1&&N.blending===qp,alphaMap:Fe,alphaTest:pe,alphaHash:Ue,combine:N.combine,mapUv:ve&&y(N.map.channel),aoMapUv:ut&&y(N.aoMap.channel),lightMapUv:H&&y(N.lightMap.channel),bumpMapUv:z&&y(N.bumpMap.channel),normalMapUv:re&&y(N.normalMap.channel),displacementMapUv:G&&y(N.displacementMap.channel),emissiveMapUv:J&&y(N.emissiveMap.channel),metalnessMapUv:le&&y(N.metalnessMap.channel),roughnessMapUv:ke&&y(N.roughnessMap.channel),anisotropyMapUv:be&&y(N.anisotropyMap.channel),clearcoatMapUv:_e&&y(N.clearcoatMap.channel),clearcoatNormalMapUv:ge&&y(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:me&&y(N.clearcoatRoughnessMap.channel),iridescenceMapUv:Ae&&y(N.iridescenceMap.channel),iridescenceThicknessMapUv:ze&&y(N.iridescenceThicknessMap.channel),sheenColorMapUv:st&&y(N.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&y(N.sheenRoughnessMap.channel),specularMapUv:ce&&y(N.specularMap.channel),specularColorMapUv:Ye&&y(N.specularColorMap.channel),specularIntensityMapUv:$e&&y(N.specularIntensityMap.channel),transmissionMapUv:Ze&&y(N.transmissionMap.channel),thicknessMapUv:at&&y(N.thicknessMap.channel),alphaMapUv:Fe&&y(N.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(re||Ne),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,vertexUv1s:ye,vertexUv2s:He,vertexUv3s:ht,pointsUvs:q.isPoints===!0&&!!V.attributes.uv&&(ve||Fe),fog:!!R,useFog:N.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:N.flatShading===!0,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.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:a.numPlanes,numClipIntersection:a.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:wt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:ve&&N.map.isVideoTexture===!0&&Vn.getTransfer(N.map.colorSpace)===ar,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===tc,flipSided:N.side===Vs,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionDerivatives:Ce&&N.extensions.derivatives===!0,extensionFragDepth:Ce&&N.extensions.fragDepth===!0,extensionDrawBuffers:Ce&&N.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ce&&N.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:N.customProgramCacheKey()}}function b(N){const D=[];if(N.shaderID?D.push(N.shaderID):(D.push(N.customVertexShaderID),D.push(N.customFragmentShaderID)),N.defines!==void 0)for(const F in N.defines)D.push(F),D.push(N.defines[F]);return N.isRawShaderMaterial===!1&&(E(D,N),S(D,N),D.push(t.outputColorSpace)),D.push(N.customProgramCacheKey),D.join()}function E(N,D){N.push(D.precision),N.push(D.outputColorSpace),N.push(D.envMapMode),N.push(D.envMapCubeUVHeight),N.push(D.mapUv),N.push(D.alphaMapUv),N.push(D.lightMapUv),N.push(D.aoMapUv),N.push(D.bumpMapUv),N.push(D.normalMapUv),N.push(D.displacementMapUv),N.push(D.emissiveMapUv),N.push(D.metalnessMapUv),N.push(D.roughnessMapUv),N.push(D.anisotropyMapUv),N.push(D.clearcoatMapUv),N.push(D.clearcoatNormalMapUv),N.push(D.clearcoatRoughnessMapUv),N.push(D.iridescenceMapUv),N.push(D.iridescenceThicknessMapUv),N.push(D.sheenColorMapUv),N.push(D.sheenRoughnessMapUv),N.push(D.specularMapUv),N.push(D.specularColorMapUv),N.push(D.specularIntensityMapUv),N.push(D.transmissionMapUv),N.push(D.thicknessMapUv),N.push(D.combine),N.push(D.fogExp2),N.push(D.sizeAttenuation),N.push(D.morphTargetsCount),N.push(D.morphAttributeCount),N.push(D.numDirLights),N.push(D.numPointLights),N.push(D.numSpotLights),N.push(D.numSpotLightMaps),N.push(D.numHemiLights),N.push(D.numRectAreaLights),N.push(D.numDirLightShadows),N.push(D.numPointLightShadows),N.push(D.numSpotLightShadows),N.push(D.numSpotLightShadowsWithMaps),N.push(D.numLightProbes),N.push(D.shadowMapType),N.push(D.toneMapping),N.push(D.numClippingPlanes),N.push(D.numClipIntersection),N.push(D.depthPacking)}function S(N,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),N.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),N.push(o.mask)}function A(N){const D=x[N.type];let F;if(D){const L=zs[D];F=GR.clone(L.uniforms)}else F=N.uniforms;return F}function T(N,D){let F;for(let L=0,q=u.length;L<q;L++){const R=u[L];if(R.cacheKey===D){F=R,++F.usedTimes;break}}return F===void 0&&(F=new _1e(t,D,N,s),u.push(F)),F}function P(N){if(--N.usedTimes===0){const D=u.indexOf(N);u[D]=u[u.length-1],u.pop(),N.destroy()}}function C(N){l.remove(N)}function I(){l.dispose()}return{getParameters:v,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:P,releaseShaderCache:C,programs:u,dispose:I}}function A1e(){let t=new WeakMap;function e(s){let a=t.get(s);return a===void 0&&(a={},t.set(s,a)),a}function n(s){t.delete(s)}function r(s,a,o){t.get(s)[a]=o}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function T1e(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 sB(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 aB(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function a(f,g,m,x,y,v){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:m,groupOrder:x,renderOrder:f.renderOrder,z:y,group:v},t[e]=b):(b.id=f.id,b.object=f,b.geometry=g,b.material=m,b.groupOrder=x,b.renderOrder=f.renderOrder,b.z=y,b.group=v),e++,b}function o(f,g,m,x,y,v){const b=a(f,g,m,x,y,v);m.transmission>0?r.push(b):m.transparent===!0?i.push(b):n.push(b)}function l(f,g,m,x,y,v){const b=a(f,g,m,x,y,v);m.transmission>0?r.unshift(b):m.transparent===!0?i.unshift(b):n.unshift(b)}function u(f,g){n.length>1&&n.sort(f||T1e),r.length>1&&r.sort(g||sB),i.length>1&&i.sort(g||sB)}function d(){for(let f=e,g=t.length;f<g;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:o,unshift:l,finish:d,sort:u}}function C1e(){let t=new WeakMap;function e(r,i){const s=t.get(r);let a;return s===void 0?(a=new aB,t.set(r,[a])):i>=s.length?(a=new aB,s.push(a)):a=s[i],a}function n(){t=new WeakMap}return{get:e,dispose:n}}function N1e(){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 k1e(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Yt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Yt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Yt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let P1e=0;function R1e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function D1e(t,e){const n=new N1e,r=k1e(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)i.probe.push(new De);const s=new De,a=new nr,o=new nr;function l(d,f){let g=0,m=0,x=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let y=0,v=0,b=0,E=0,S=0,A=0,T=0,P=0,C=0,I=0,N=0;d.sort(R1e);const D=f===!0?Math.PI:1;for(let L=0,q=d.length;L<q;L++){const R=d[L],V=R.color,K=R.intensity,W=R.distance,ne=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)g+=V.r*K*D,m+=V.g*K*D,x+=V.b*K*D;else if(R.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(R.sh.coefficients[Y],K);N++}else if(R.isDirectionalLight){const Y=n.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity*D),R.castShadow){const Z=R.shadow,U=r.get(R);U.shadowBias=Z.bias,U.shadowNormalBias=Z.normalBias,U.shadowRadius=Z.radius,U.shadowMapSize=Z.mapSize,i.directionalShadow[y]=U,i.directionalShadowMap[y]=ne,i.directionalShadowMatrix[y]=R.shadow.matrix,A++}i.directional[y]=Y,y++}else if(R.isSpotLight){const Y=n.get(R);Y.position.setFromMatrixPosition(R.matrixWorld),Y.color.copy(V).multiplyScalar(K*D),Y.distance=W,Y.coneCos=Math.cos(R.angle),Y.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),Y.decay=R.decay,i.spot[b]=Y;const Z=R.shadow;if(R.map&&(i.spotLightMap[C]=R.map,C++,Z.updateMatrices(R),R.castShadow&&I++),i.spotLightMatrix[b]=Z.matrix,R.castShadow){const U=r.get(R);U.shadowBias=Z.bias,U.shadowNormalBias=Z.normalBias,U.shadowRadius=Z.radius,U.shadowMapSize=Z.mapSize,i.spotShadow[b]=U,i.spotShadowMap[b]=ne,P++}b++}else if(R.isRectAreaLight){const Y=n.get(R);Y.color.copy(V).multiplyScalar(K),Y.halfWidth.set(R.width*.5,0,0),Y.halfHeight.set(0,R.height*.5,0),i.rectArea[E]=Y,E++}else if(R.isPointLight){const Y=n.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity*D),Y.distance=R.distance,Y.decay=R.decay,R.castShadow){const Z=R.shadow,U=r.get(R);U.shadowBias=Z.bias,U.shadowNormalBias=Z.normalBias,U.shadowRadius=Z.radius,U.shadowMapSize=Z.mapSize,U.shadowCameraNear=Z.camera.near,U.shadowCameraFar=Z.camera.far,i.pointShadow[v]=U,i.pointShadowMap[v]=ne,i.pointShadowMatrix[v]=R.shadow.matrix,T++}i.point[v]=Y,v++}else if(R.isHemisphereLight){const Y=n.get(R);Y.skyColor.copy(R.color).multiplyScalar(K*D),Y.groundColor.copy(R.groundColor).multiplyScalar(K*D),i.hemi[S]=Y,S++}}E>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=vt.LTC_FLOAT_1,i.rectAreaLTC2=vt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=vt.LTC_HALF_1,i.rectAreaLTC2=vt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=m,i.ambient[2]=x;const F=i.hash;(F.directionalLength!==y||F.pointLength!==v||F.spotLength!==b||F.rectAreaLength!==E||F.hemiLength!==S||F.numDirectionalShadows!==A||F.numPointShadows!==T||F.numSpotShadows!==P||F.numSpotMaps!==C||F.numLightProbes!==N)&&(i.directional.length=y,i.spot.length=b,i.rectArea.length=E,i.point.length=v,i.hemi.length=S,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=P,i.spotShadowMap.length=P,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=P+C-I,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=N,F.directionalLength=y,F.pointLength=v,F.spotLength=b,F.rectAreaLength=E,F.hemiLength=S,F.numDirectionalShadows=A,F.numPointShadows=T,F.numSpotShadows=P,F.numSpotMaps=C,F.numLightProbes=N,i.version=P1e++)}function u(d,f){let g=0,m=0,x=0,y=0,v=0;const b=f.matrixWorldInverse;for(let E=0,S=d.length;E<S;E++){const A=d[E];if(A.isDirectionalLight){const T=i.directional[g];T.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(b),g++}else if(A.isSpotLight){const T=i.spot[x];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),T.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(b),x++}else if(A.isRectAreaLight){const T=i.rectArea[y];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),o.identity(),a.copy(A.matrixWorld),a.premultiply(b),o.extractRotation(a),T.halfWidth.set(A.width*.5,0,0),T.halfHeight.set(0,A.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),y++}else if(A.isPointLight){const T=i.point[m];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),m++}else if(A.isHemisphereLight){const T=i.hemi[v];T.direction.setFromMatrixPosition(A.matrixWorld),T.direction.transformDirection(b),v++}}}return{setup:l,setupView:u,state:i}}function oB(t,e){const n=new D1e(t,e),r=[],i=[];function s(){r.length=0,i.length=0}function a(f){r.push(f)}function o(f){i.push(f)}function l(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:l,setupLightsView:u,pushLight:a,pushShadow:o}}function O1e(t,e){let n=new WeakMap;function r(s,a=0){const o=n.get(s);let l;return o===void 0?(l=new oB(t,e),n.set(s,[l])):a>=o.length?(l=new oB(t,e),o.push(l)):l=o[a],l}function i(){n=new WeakMap}return{get:r,dispose:i}}class j1e extends Bm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=y0e,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 L1e extends Bm{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 I1e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,U1e=`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 F1e(t,e,n){let r=new NS;const i=new Yt,s=new Yt,a=new Wn,o=new j1e({depthPacking:_0e}),l=new L1e,u={},d=n.maxTextureSize,f={[nd]:Vs,[Vs]:nd,[tc]:tc},g=new rd({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Yt},radius:{value:4}},vertexShader:I1e,fragmentShader:U1e}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const x=new fs;x.setAttribute("position",new xa(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new No(x,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=D7;let b=this.type;this.render=function(T,P,C){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||T.length===0)return;const I=t.getRenderTarget(),N=t.getActiveCubeFace(),D=t.getActiveMipmapLevel(),F=t.state;F.setBlending($u),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const L=b!==Zl&&this.type===Zl,q=b===Zl&&this.type!==Zl;for(let R=0,V=T.length;R<V;R++){const K=T[R],W=K.shadow;if(W===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;i.copy(W.mapSize);const ne=W.getFrameExtents();if(i.multiply(ne),s.copy(W.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/ne.x),i.x=s.x*ne.x,W.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/ne.y),i.y=s.y*ne.y,W.mapSize.y=s.y)),W.map===null||L===!0||q===!0){const Z=this.type!==Zl?{minFilter:Ki,magFilter:Ki}:{};W.map!==null&&W.map.dispose(),W.map=new zh(i.x,i.y,Z),W.map.texture.name=K.name+".shadowMap",W.camera.updateProjectionMatrix()}t.setRenderTarget(W.map),t.clear();const Y=W.getViewportCount();for(let Z=0;Z<Y;Z++){const U=W.getViewport(Z);a.set(s.x*U.x,s.y*U.y,s.x*U.z,s.y*U.w),F.viewport(a),W.updateMatrices(K,Z),r=W.getFrustum(),A(P,C,W.camera,K,this.type)}W.isPointLightShadow!==!0&&this.type===Zl&&E(W,C),W.needsUpdate=!1}b=this.type,v.needsUpdate=!1,t.setRenderTarget(I,N,D)};function E(T,P){const C=e.update(y);g.defines.VSM_SAMPLES!==T.blurSamples&&(g.defines.VSM_SAMPLES=T.blurSamples,m.defines.VSM_SAMPLES=T.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new zh(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(P,null,C,g,y,null),m.uniforms.shadow_pass.value=T.mapPass.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(P,null,C,m,y,null)}function S(T,P,C,I){let N=null;const D=C.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(D!==void 0)N=D;else if(N=C.isPointLight===!0?l:o,t.localClippingEnabled&&P.clipShadows===!0&&Array.isArray(P.clippingPlanes)&&P.clippingPlanes.length!==0||P.displacementMap&&P.displacementScale!==0||P.alphaMap&&P.alphaTest>0||P.map&&P.alphaTest>0){const F=N.uuid,L=P.uuid;let q=u[F];q===void 0&&(q={},u[F]=q);let R=q[L];R===void 0&&(R=N.clone(),q[L]=R),N=R}if(N.visible=P.visible,N.wireframe=P.wireframe,I===Zl?N.side=P.shadowSide!==null?P.shadowSide:P.side:N.side=P.shadowSide!==null?P.shadowSide:f[P.side],N.alphaMap=P.alphaMap,N.alphaTest=P.alphaTest,N.map=P.map,N.clipShadows=P.clipShadows,N.clippingPlanes=P.clippingPlanes,N.clipIntersection=P.clipIntersection,N.displacementMap=P.displacementMap,N.displacementScale=P.displacementScale,N.displacementBias=P.displacementBias,N.wireframeLinewidth=P.wireframeLinewidth,N.linewidth=P.linewidth,C.isPointLight===!0&&N.isMeshDistanceMaterial===!0){const F=t.properties.get(N);F.light=C}return N}function A(T,P,C,I,N){if(T.visible===!1)return;if(T.layers.test(P.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&N===Zl)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,T.matrixWorld);const L=e.update(T),q=T.material;if(Array.isArray(q)){const R=L.groups;for(let V=0,K=R.length;V<K;V++){const W=R[V],ne=q[W.materialIndex];if(ne&&ne.visible){const Y=S(T,ne,I,N);T.onBeforeShadow(t,T,P,C,L,Y,W),t.renderBufferDirect(C,null,L,Y,T,W),T.onAfterShadow(t,T,P,C,L,Y,W)}}}else if(q.visible){const R=S(T,q,I,N);T.onBeforeShadow(t,T,P,C,L,R,null),t.renderBufferDirect(C,null,L,R,T,null),T.onAfterShadow(t,T,P,C,L,R,null)}}const F=T.children;for(let L=0,q=F.length;L<q;L++)A(F[L],P,C,I,N)}}function z1e(t,e,n){const r=n.isWebGL2;function i(){let pe=!1;const Ue=new Wn;let Ce=null;const ye=new Wn(0,0,0,0);return{setMask:function(He){Ce!==He&&!pe&&(t.colorMask(He,He,He,He),Ce=He)},setLocked:function(He){pe=He},setClear:function(He,ht,wt,Ot,cn){cn===!0&&(He*=Ot,ht*=Ot,wt*=Ot),Ue.set(He,ht,wt,Ot),ye.equals(Ue)===!1&&(t.clearColor(He,ht,wt,Ot),ye.copy(Ue))},reset:function(){pe=!1,Ce=null,ye.set(-1,0,0,0)}}}function s(){let pe=!1,Ue=null,Ce=null,ye=null;return{setTest:function(He){He?se(t.DEPTH_TEST):ve(t.DEPTH_TEST)},setMask:function(He){Ue!==He&&!pe&&(t.depthMask(He),Ue=He)},setFunc:function(He){if(Ce!==He){switch(He){case Zxe:t.depthFunc(t.NEVER);break;case Qxe:t.depthFunc(t.ALWAYS);break;case Jxe:t.depthFunc(t.LESS);break;case m1:t.depthFunc(t.LEQUAL);break;case e0e:t.depthFunc(t.EQUAL);break;case t0e:t.depthFunc(t.GEQUAL);break;case n0e:t.depthFunc(t.GREATER);break;case r0e:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ce=He}},setLocked:function(He){pe=He},setClear:function(He){ye!==He&&(t.clearDepth(He),ye=He)},reset:function(){pe=!1,Ue=null,Ce=null,ye=null}}}function a(){let pe=!1,Ue=null,Ce=null,ye=null,He=null,ht=null,wt=null,Ot=null,cn=null;return{setTest:function(It){pe||(It?se(t.STENCIL_TEST):ve(t.STENCIL_TEST))},setMask:function(It){Ue!==It&&!pe&&(t.stencilMask(It),Ue=It)},setFunc:function(It,Rn,Kn){(Ce!==It||ye!==Rn||He!==Kn)&&(t.stencilFunc(It,Rn,Kn),Ce=It,ye=Rn,He=Kn)},setOp:function(It,Rn,Kn){(ht!==It||wt!==Rn||Ot!==Kn)&&(t.stencilOp(It,Rn,Kn),ht=It,wt=Rn,Ot=Kn)},setLocked:function(It){pe=It},setClear:function(It){cn!==It&&(t.clearStencil(It),cn=It)},reset:function(){pe=!1,Ue=null,Ce=null,ye=null,He=null,ht=null,wt=null,Ot=null,cn=null}}}const o=new i,l=new s,u=new a,d=new WeakMap,f=new WeakMap;let g={},m={},x=new WeakMap,y=[],v=null,b=!1,E=null,S=null,A=null,T=null,P=null,C=null,I=null,N=new $t(0,0,0),D=0,F=!1,L=null,q=null,R=null,V=null,K=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let ne=!1,Y=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(Z)[1]),ne=Y>=1):Z.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),ne=Y>=2);let U=null,$={};const ee=t.getParameter(t.SCISSOR_BOX),ae=t.getParameter(t.VIEWPORT),fe=new Wn().fromArray(ee),ue=new Wn().fromArray(ae);function xe(pe,Ue,Ce,ye){const He=new Uint8Array(4),ht=t.createTexture();t.bindTexture(pe,ht),t.texParameteri(pe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(pe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let wt=0;wt<Ce;wt++)r&&(pe===t.TEXTURE_3D||pe===t.TEXTURE_2D_ARRAY)?t.texImage3D(Ue,0,t.RGBA,1,1,ye,0,t.RGBA,t.UNSIGNED_BYTE,He):t.texImage2D(Ue+wt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,He);return ht}const Me={};Me[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),Me[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Me[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Me[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),u.setClear(0),se(t.DEPTH_TEST),l.setFunc(m1),J(!1),le($F),se(t.CULL_FACE),re($u);function se(pe){g[pe]!==!0&&(t.enable(pe),g[pe]=!0)}function ve(pe){g[pe]!==!1&&(t.disable(pe),g[pe]=!1)}function je(pe,Ue){return m[pe]!==Ue?(t.bindFramebuffer(pe,Ue),m[pe]=Ue,r&&(pe===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Ue),pe===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Ue)),!0):!1}function de(pe,Ue){let Ce=y,ye=!1;if(pe)if(Ce=x.get(Ue),Ce===void 0&&(Ce=[],x.set(Ue,Ce)),pe.isWebGLMultipleRenderTargets){const He=pe.texture;if(Ce.length!==He.length||Ce[0]!==t.COLOR_ATTACHMENT0){for(let ht=0,wt=He.length;ht<wt;ht++)Ce[ht]=t.COLOR_ATTACHMENT0+ht;Ce.length=He.length,ye=!0}}else Ce[0]!==t.COLOR_ATTACHMENT0&&(Ce[0]=t.COLOR_ATTACHMENT0,ye=!0);else Ce[0]!==t.BACK&&(Ce[0]=t.BACK,ye=!0);ye&&(n.isWebGL2?t.drawBuffers(Ce):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ce))}function ut(pe){return v!==pe?(t.useProgram(pe),v=pe,!0):!1}const H={[eh]:t.FUNC_ADD,[Lxe]:t.FUNC_SUBTRACT,[Ixe]:t.FUNC_REVERSE_SUBTRACT};if(r)H[qF]=t.MIN,H[KF]=t.MAX;else{const pe=e.get("EXT_blend_minmax");pe!==null&&(H[qF]=pe.MIN_EXT,H[KF]=pe.MAX_EXT)}const z={[Uxe]:t.ZERO,[Fxe]:t.ONE,[zxe]:t.SRC_COLOR,[tk]:t.SRC_ALPHA,[Wxe]:t.SRC_ALPHA_SATURATE,[Vxe]:t.DST_COLOR,[Hxe]:t.DST_ALPHA,[Bxe]:t.ONE_MINUS_SRC_COLOR,[nk]:t.ONE_MINUS_SRC_ALPHA,[Gxe]:t.ONE_MINUS_DST_COLOR,[$xe]:t.ONE_MINUS_DST_ALPHA,[qxe]:t.CONSTANT_COLOR,[Kxe]:t.ONE_MINUS_CONSTANT_COLOR,[Xxe]:t.CONSTANT_ALPHA,[Yxe]:t.ONE_MINUS_CONSTANT_ALPHA};function re(pe,Ue,Ce,ye,He,ht,wt,Ot,cn,It){if(pe===$u){b===!0&&(ve(t.BLEND),b=!1);return}if(b===!1&&(se(t.BLEND),b=!0),pe!==jxe){if(pe!==E||It!==F){if((S!==eh||P!==eh)&&(t.blendEquation(t.FUNC_ADD),S=eh,P=eh),It)switch(pe){case qp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case VF:t.blendFunc(t.ONE,t.ONE);break;case GF:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case WF:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",pe);break}else switch(pe){case qp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case VF:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case GF:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case WF:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",pe);break}A=null,T=null,C=null,I=null,N.set(0,0,0),D=0,E=pe,F=It}return}He=He||Ue,ht=ht||Ce,wt=wt||ye,(Ue!==S||He!==P)&&(t.blendEquationSeparate(H[Ue],H[He]),S=Ue,P=He),(Ce!==A||ye!==T||ht!==C||wt!==I)&&(t.blendFuncSeparate(z[Ce],z[ye],z[ht],z[wt]),A=Ce,T=ye,C=ht,I=wt),(Ot.equals(N)===!1||cn!==D)&&(t.blendColor(Ot.r,Ot.g,Ot.b,cn),N.copy(Ot),D=cn),E=pe,F=!1}function G(pe,Ue){pe.side===tc?ve(t.CULL_FACE):se(t.CULL_FACE);let Ce=pe.side===Vs;Ue&&(Ce=!Ce),J(Ce),pe.blending===qp&&pe.transparent===!1?re($u):re(pe.blending,pe.blendEquation,pe.blendSrc,pe.blendDst,pe.blendEquationAlpha,pe.blendSrcAlpha,pe.blendDstAlpha,pe.blendColor,pe.blendAlpha,pe.premultipliedAlpha),l.setFunc(pe.depthFunc),l.setTest(pe.depthTest),l.setMask(pe.depthWrite),o.setMask(pe.colorWrite);const ye=pe.stencilWrite;u.setTest(ye),ye&&(u.setMask(pe.stencilWriteMask),u.setFunc(pe.stencilFunc,pe.stencilRef,pe.stencilFuncMask),u.setOp(pe.stencilFail,pe.stencilZFail,pe.stencilZPass)),Ne(pe.polygonOffset,pe.polygonOffsetFactor,pe.polygonOffsetUnits),pe.alphaToCoverage===!0?se(t.SAMPLE_ALPHA_TO_COVERAGE):ve(t.SAMPLE_ALPHA_TO_COVERAGE)}function J(pe){L!==pe&&(pe?t.frontFace(t.CW):t.frontFace(t.CCW),L=pe)}function le(pe){pe!==Rxe?(se(t.CULL_FACE),pe!==q&&(pe===$F?t.cullFace(t.BACK):pe===Dxe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ve(t.CULL_FACE),q=pe}function ke(pe){pe!==R&&(ne&&t.lineWidth(pe),R=pe)}function Ne(pe,Ue,Ce){pe?(se(t.POLYGON_OFFSET_FILL),(V!==Ue||K!==Ce)&&(t.polygonOffset(Ue,Ce),V=Ue,K=Ce)):ve(t.POLYGON_OFFSET_FILL)}function we(pe){pe?se(t.SCISSOR_TEST):ve(t.SCISSOR_TEST)}function B(pe){pe===void 0&&(pe=t.TEXTURE0+W-1),U!==pe&&(t.activeTexture(pe),U=pe)}function j(pe,Ue,Ce){Ce===void 0&&(U===null?Ce=t.TEXTURE0+W-1:Ce=U);let ye=$[Ce];ye===void 0&&(ye={type:void 0,texture:void 0},$[Ce]=ye),(ye.type!==pe||ye.texture!==Ue)&&(U!==Ce&&(t.activeTexture(Ce),U=Ce),t.bindTexture(pe,Ue||Me[pe]),ye.type=pe,ye.texture=Ue)}function te(){const pe=$[U];pe!==void 0&&pe.type!==void 0&&(t.bindTexture(pe.type,null),pe.type=void 0,pe.texture=void 0)}function be(){try{t.compressedTexImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function _e(){try{t.compressedTexImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function ge(){try{t.texSubImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function me(){try{t.texSubImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ae(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function ze(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function st(){try{t.texStorage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ve(){try{t.texStorage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function ce(){try{t.texImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ye(){try{t.texImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function $e(pe){fe.equals(pe)===!1&&(t.scissor(pe.x,pe.y,pe.z,pe.w),fe.copy(pe))}function Ze(pe){ue.equals(pe)===!1&&(t.viewport(pe.x,pe.y,pe.z,pe.w),ue.copy(pe))}function at(pe,Ue){let Ce=f.get(Ue);Ce===void 0&&(Ce=new WeakMap,f.set(Ue,Ce));let ye=Ce.get(pe);ye===void 0&&(ye=t.getUniformBlockIndex(Ue,pe.name),Ce.set(pe,ye))}function Q(pe,Ue){const ye=f.get(Ue).get(pe);d.get(Ue)!==ye&&(t.uniformBlockBinding(Ue,ye,pe.__bindingPointIndex),d.set(Ue,ye))}function Fe(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),g={},U=null,$={},m={},x=new WeakMap,y=[],v=null,b=!1,E=null,S=null,A=null,T=null,P=null,C=null,I=null,N=new $t(0,0,0),D=0,F=!1,L=null,q=null,R=null,V=null,K=null,fe.set(0,0,t.canvas.width,t.canvas.height),ue.set(0,0,t.canvas.width,t.canvas.height),o.reset(),l.reset(),u.reset()}return{buffers:{color:o,depth:l,stencil:u},enable:se,disable:ve,bindFramebuffer:je,drawBuffers:de,useProgram:ut,setBlending:re,setMaterial:G,setFlipSided:J,setCullFace:le,setLineWidth:ke,setPolygonOffset:Ne,setScissorTest:we,activeTexture:B,bindTexture:j,unbindTexture:te,compressedTexImage2D:be,compressedTexImage3D:_e,texImage2D:ce,texImage3D:Ye,updateUBOMapping:at,uniformBlockBinding:Q,texStorage2D:st,texStorage3D:Ve,texSubImage2D:ge,texSubImage3D:me,compressedTexSubImage2D:Ae,compressedTexSubImage3D:ze,scissor:$e,viewport:Ze,reset:Fe}}function B1e(t,e,n,r,i,s,a){const o=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let y;const v=new WeakMap;let b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E(B,j){return b?new OffscreenCanvas(B,j):y1("canvas")}function S(B,j,te,be){let _e=1;if((B.width>be||B.height>be)&&(_e=be/Math.max(B.width,B.height)),_e<1||j===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){const ge=j?v1:Math.floor,me=ge(_e*B.width),Ae=ge(_e*B.height);y===void 0&&(y=E(me,Ae));const ze=te?E(me,Ae):y;return ze.width=me,ze.height=Ae,ze.getContext("2d").drawImage(B,0,0,me,Ae),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+me+"x"+Ae+")."),ze}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function A(B){return ck(B.width)&&ck(B.height)}function T(B){return o?!1:B.wrapS!==wo||B.wrapT!==wo||B.minFilter!==Ki&&B.minFilter!==Wa}function P(B,j){return B.generateMipmaps&&j&&B.minFilter!==Ki&&B.minFilter!==Wa}function C(B){t.generateMipmap(B)}function I(B,j,te,be,_e=!1){if(o===!1)return j;if(B!==null){if(t[B]!==void 0)return t[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ge=j;if(j===t.RED&&(te===t.FLOAT&&(ge=t.R32F),te===t.HALF_FLOAT&&(ge=t.R16F),te===t.UNSIGNED_BYTE&&(ge=t.R8)),j===t.RED_INTEGER&&(te===t.UNSIGNED_BYTE&&(ge=t.R8UI),te===t.UNSIGNED_SHORT&&(ge=t.R16UI),te===t.UNSIGNED_INT&&(ge=t.R32UI),te===t.BYTE&&(ge=t.R8I),te===t.SHORT&&(ge=t.R16I),te===t.INT&&(ge=t.R32I)),j===t.RG&&(te===t.FLOAT&&(ge=t.RG32F),te===t.HALF_FLOAT&&(ge=t.RG16F),te===t.UNSIGNED_BYTE&&(ge=t.RG8)),j===t.RGBA){const me=_e?g1:Vn.getTransfer(be);te===t.FLOAT&&(ge=t.RGBA32F),te===t.HALF_FLOAT&&(ge=t.RGBA16F),te===t.UNSIGNED_BYTE&&(ge=me===ar?t.SRGB8_ALPHA8:t.RGBA8),te===t.UNSIGNED_SHORT_4_4_4_4&&(ge=t.RGBA4),te===t.UNSIGNED_SHORT_5_5_5_1&&(ge=t.RGB5_A1)}return(ge===t.R16F||ge===t.R32F||ge===t.RG16F||ge===t.RG32F||ge===t.RGBA16F||ge===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function N(B,j,te){return P(B,te)===!0||B.isFramebufferTexture&&B.minFilter!==Ki&&B.minFilter!==Wa?Math.log2(Math.max(j.width,j.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?j.mipmaps.length:1}function D(B){return B===Ki||B===XF||B===HA?t.NEAREST:t.LINEAR}function F(B){const j=B.target;j.removeEventListener("dispose",F),q(j),j.isVideoTexture&&x.delete(j)}function L(B){const j=B.target;j.removeEventListener("dispose",L),V(j)}function q(B){const j=r.get(B);if(j.__webglInit===void 0)return;const te=B.source,be=v.get(te);if(be){const _e=be[j.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&R(B),Object.keys(be).length===0&&v.delete(te)}r.remove(B)}function R(B){const j=r.get(B);t.deleteTexture(j.__webglTexture);const te=B.source,be=v.get(te);delete be[j.__cacheKey],a.memory.textures--}function V(B){const j=B.texture,te=r.get(B),be=r.get(j);if(be.__webglTexture!==void 0&&(t.deleteTexture(be.__webglTexture),a.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let _e=0;_e<6;_e++){if(Array.isArray(te.__webglFramebuffer[_e]))for(let ge=0;ge<te.__webglFramebuffer[_e].length;ge++)t.deleteFramebuffer(te.__webglFramebuffer[_e][ge]);else t.deleteFramebuffer(te.__webglFramebuffer[_e]);te.__webglDepthbuffer&&t.deleteRenderbuffer(te.__webglDepthbuffer[_e])}else{if(Array.isArray(te.__webglFramebuffer))for(let _e=0;_e<te.__webglFramebuffer.length;_e++)t.deleteFramebuffer(te.__webglFramebuffer[_e]);else t.deleteFramebuffer(te.__webglFramebuffer);if(te.__webglDepthbuffer&&t.deleteRenderbuffer(te.__webglDepthbuffer),te.__webglMultisampledFramebuffer&&t.deleteFramebuffer(te.__webglMultisampledFramebuffer),te.__webglColorRenderbuffer)for(let _e=0;_e<te.__webglColorRenderbuffer.length;_e++)te.__webglColorRenderbuffer[_e]&&t.deleteRenderbuffer(te.__webglColorRenderbuffer[_e]);te.__webglDepthRenderbuffer&&t.deleteRenderbuffer(te.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let _e=0,ge=j.length;_e<ge;_e++){const me=r.get(j[_e]);me.__webglTexture&&(t.deleteTexture(me.__webglTexture),a.memory.textures--),r.remove(j[_e])}r.remove(j),r.remove(B)}let K=0;function W(){K=0}function ne(){const B=K;return B>=l&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+l),K+=1,B}function Y(B){const j=[];return j.push(B.wrapS),j.push(B.wrapT),j.push(B.wrapR||0),j.push(B.magFilter),j.push(B.minFilter),j.push(B.anisotropy),j.push(B.internalFormat),j.push(B.format),j.push(B.type),j.push(B.generateMipmaps),j.push(B.premultiplyAlpha),j.push(B.flipY),j.push(B.unpackAlignment),j.push(B.colorSpace),j.join()}function Z(B,j){const te=r.get(B);if(B.isVideoTexture&&Ne(B),B.isRenderTargetTexture===!1&&B.version>0&&te.__version!==B.version){const be=B.image;if(be===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{se(te,B,j);return}}n.bindTexture(t.TEXTURE_2D,te.__webglTexture,t.TEXTURE0+j)}function U(B,j){const te=r.get(B);if(B.version>0&&te.__version!==B.version){se(te,B,j);return}n.bindTexture(t.TEXTURE_2D_ARRAY,te.__webglTexture,t.TEXTURE0+j)}function $(B,j){const te=r.get(B);if(B.version>0&&te.__version!==B.version){se(te,B,j);return}n.bindTexture(t.TEXTURE_3D,te.__webglTexture,t.TEXTURE0+j)}function ee(B,j){const te=r.get(B);if(B.version>0&&te.__version!==B.version){ve(te,B,j);return}n.bindTexture(t.TEXTURE_CUBE_MAP,te.__webglTexture,t.TEXTURE0+j)}const ae={[sk]:t.REPEAT,[wo]:t.CLAMP_TO_EDGE,[ak]:t.MIRRORED_REPEAT},fe={[Ki]:t.NEAREST,[XF]:t.NEAREST_MIPMAP_NEAREST,[HA]:t.NEAREST_MIPMAP_LINEAR,[Wa]:t.LINEAR,[d0e]:t.LINEAR_MIPMAP_NEAREST,[y0]:t.LINEAR_MIPMAP_LINEAR},ue={[S0e]:t.NEVER,[N0e]:t.ALWAYS,[E0e]:t.LESS,[V7]:t.LEQUAL,[M0e]:t.EQUAL,[C0e]:t.GEQUAL,[A0e]:t.GREATER,[T0e]:t.NOTEQUAL};function xe(B,j,te){if(te?(t.texParameteri(B,t.TEXTURE_WRAP_S,ae[j.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,ae[j.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,ae[j.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,fe[j.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,fe[j.minFilter])):(t.texParameteri(B,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(B,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(j.wrapS!==wo||j.wrapT!==wo)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(B,t.TEXTURE_MAG_FILTER,D(j.magFilter)),t.texParameteri(B,t.TEXTURE_MIN_FILTER,D(j.minFilter)),j.minFilter!==Ki&&j.minFilter!==Wa&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),j.compareFunction&&(t.texParameteri(B,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(B,t.TEXTURE_COMPARE_FUNC,ue[j.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const be=e.get("EXT_texture_filter_anisotropic");if(j.magFilter===Ki||j.minFilter!==HA&&j.minFilter!==y0||j.type===oc&&e.has("OES_texture_float_linear")===!1||o===!1&&j.type===_0&&e.has("OES_texture_half_float_linear")===!1)return;(j.anisotropy>1||r.get(j).__currentAnisotropy)&&(t.texParameterf(B,be.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(j.anisotropy,i.getMaxAnisotropy())),r.get(j).__currentAnisotropy=j.anisotropy)}}function Me(B,j){let te=!1;B.__webglInit===void 0&&(B.__webglInit=!0,j.addEventListener("dispose",F));const be=j.source;let _e=v.get(be);_e===void 0&&(_e={},v.set(be,_e));const ge=Y(j);if(ge!==B.__cacheKey){_e[ge]===void 0&&(_e[ge]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,te=!0),_e[ge].usedTimes++;const me=_e[B.__cacheKey];me!==void 0&&(_e[B.__cacheKey].usedTimes--,me.usedTimes===0&&R(j)),B.__cacheKey=ge,B.__webglTexture=_e[ge].texture}return te}function se(B,j,te){let be=t.TEXTURE_2D;(j.isDataArrayTexture||j.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),j.isData3DTexture&&(be=t.TEXTURE_3D);const _e=Me(B,j),ge=j.source;n.bindTexture(be,B.__webglTexture,t.TEXTURE0+te);const me=r.get(ge);if(ge.version!==me.__version||_e===!0){n.activeTexture(t.TEXTURE0+te);const Ae=Vn.getPrimaries(Vn.workingColorSpace),ze=j.colorSpace===Ka?null:Vn.getPrimaries(j.colorSpace),st=j.colorSpace===Ka||Ae===ze?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,st);const Ve=T(j)&&A(j.image)===!1;let ce=S(j.image,Ve,!1,d);ce=we(j,ce);const Ye=A(ce)||o,$e=s.convert(j.format,j.colorSpace);let Ze=s.convert(j.type),at=I(j.internalFormat,$e,Ze,j.colorSpace,j.isVideoTexture);xe(be,j,Ye);let Q;const Fe=j.mipmaps,pe=o&&j.isVideoTexture!==!0&&at!==B7,Ue=me.__version===void 0||_e===!0,Ce=N(j,ce,Ye);if(j.isDepthTexture)at=t.DEPTH_COMPONENT,o?j.type===oc?at=t.DEPTH_COMPONENT32F:j.type===Lu?at=t.DEPTH_COMPONENT24:j.type===mh?at=t.DEPTH24_STENCIL8:at=t.DEPTH_COMPONENT16:j.type===oc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),j.format===gh&&at===t.DEPTH_COMPONENT&&j.type!==BR&&j.type!==Lu&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),j.type=Lu,Ze=s.convert(j.type)),j.format===pm&&at===t.DEPTH_COMPONENT&&(at=t.DEPTH_STENCIL,j.type!==mh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),j.type=mh,Ze=s.convert(j.type))),Ue&&(pe?n.texStorage2D(t.TEXTURE_2D,1,at,ce.width,ce.height):n.texImage2D(t.TEXTURE_2D,0,at,ce.width,ce.height,0,$e,Ze,null));else if(j.isDataTexture)if(Fe.length>0&&Ye){pe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,Fe[0].width,Fe[0].height);for(let ye=0,He=Fe.length;ye<He;ye++)Q=Fe[ye],pe?n.texSubImage2D(t.TEXTURE_2D,ye,0,0,Q.width,Q.height,$e,Ze,Q.data):n.texImage2D(t.TEXTURE_2D,ye,at,Q.width,Q.height,0,$e,Ze,Q.data);j.generateMipmaps=!1}else pe?(Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,ce.width,ce.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ce.width,ce.height,$e,Ze,ce.data)):n.texImage2D(t.TEXTURE_2D,0,at,ce.width,ce.height,0,$e,Ze,ce.data);else if(j.isCompressedTexture)if(j.isCompressedArrayTexture){pe&&Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,at,Fe[0].width,Fe[0].height,ce.depth);for(let ye=0,He=Fe.length;ye<He;ye++)Q=Fe[ye],j.format!==qa?$e!==null?pe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ye,0,0,0,Q.width,Q.height,ce.depth,$e,Q.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ye,at,Q.width,Q.height,ce.depth,0,Q.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pe?n.texSubImage3D(t.TEXTURE_2D_ARRAY,ye,0,0,0,Q.width,Q.height,ce.depth,$e,Ze,Q.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ye,at,Q.width,Q.height,ce.depth,0,$e,Ze,Q.data)}else{pe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,Fe[0].width,Fe[0].height);for(let ye=0,He=Fe.length;ye<He;ye++)Q=Fe[ye],j.format!==qa?$e!==null?pe?n.compressedTexSubImage2D(t.TEXTURE_2D,ye,0,0,Q.width,Q.height,$e,Q.data):n.compressedTexImage2D(t.TEXTURE_2D,ye,at,Q.width,Q.height,0,Q.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pe?n.texSubImage2D(t.TEXTURE_2D,ye,0,0,Q.width,Q.height,$e,Ze,Q.data):n.texImage2D(t.TEXTURE_2D,ye,at,Q.width,Q.height,0,$e,Ze,Q.data)}else if(j.isDataArrayTexture)pe?(Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,at,ce.width,ce.height,ce.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ce.width,ce.height,ce.depth,$e,Ze,ce.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,at,ce.width,ce.height,ce.depth,0,$e,Ze,ce.data);else if(j.isData3DTexture)pe?(Ue&&n.texStorage3D(t.TEXTURE_3D,Ce,at,ce.width,ce.height,ce.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ce.width,ce.height,ce.depth,$e,Ze,ce.data)):n.texImage3D(t.TEXTURE_3D,0,at,ce.width,ce.height,ce.depth,0,$e,Ze,ce.data);else if(j.isFramebufferTexture){if(Ue)if(pe)n.texStorage2D(t.TEXTURE_2D,Ce,at,ce.width,ce.height);else{let ye=ce.width,He=ce.height;for(let ht=0;ht<Ce;ht++)n.texImage2D(t.TEXTURE_2D,ht,at,ye,He,0,$e,Ze,null),ye>>=1,He>>=1}}else if(Fe.length>0&&Ye){pe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,Fe[0].width,Fe[0].height);for(let ye=0,He=Fe.length;ye<He;ye++)Q=Fe[ye],pe?n.texSubImage2D(t.TEXTURE_2D,ye,0,0,$e,Ze,Q):n.texImage2D(t.TEXTURE_2D,ye,at,$e,Ze,Q);j.generateMipmaps=!1}else pe?(Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,ce.width,ce.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,$e,Ze,ce)):n.texImage2D(t.TEXTURE_2D,0,at,$e,Ze,ce);P(j,Ye)&&C(be),me.__version=ge.version,j.onUpdate&&j.onUpdate(j)}B.__version=j.version}function ve(B,j,te){if(j.image.length!==6)return;const be=Me(B,j),_e=j.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+te);const ge=r.get(_e);if(_e.version!==ge.__version||be===!0){n.activeTexture(t.TEXTURE0+te);const me=Vn.getPrimaries(Vn.workingColorSpace),Ae=j.colorSpace===Ka?null:Vn.getPrimaries(j.colorSpace),ze=j.colorSpace===Ka||me===Ae?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ze);const st=j.isCompressedTexture||j.image[0].isCompressedTexture,Ve=j.image[0]&&j.image[0].isDataTexture,ce=[];for(let ye=0;ye<6;ye++)!st&&!Ve?ce[ye]=S(j.image[ye],!1,!0,u):ce[ye]=Ve?j.image[ye].image:j.image[ye],ce[ye]=we(j,ce[ye]);const Ye=ce[0],$e=A(Ye)||o,Ze=s.convert(j.format,j.colorSpace),at=s.convert(j.type),Q=I(j.internalFormat,Ze,at,j.colorSpace),Fe=o&&j.isVideoTexture!==!0,pe=ge.__version===void 0||be===!0;let Ue=N(j,Ye,$e);xe(t.TEXTURE_CUBE_MAP,j,$e);let Ce;if(st){Fe&&pe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,Q,Ye.width,Ye.height);for(let ye=0;ye<6;ye++){Ce=ce[ye].mipmaps;for(let He=0;He<Ce.length;He++){const ht=Ce[He];j.format!==qa?Ze!==null?Fe?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He,0,0,ht.width,ht.height,Ze,ht.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He,Q,ht.width,ht.height,0,ht.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He,0,0,ht.width,ht.height,Ze,at,ht.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He,Q,ht.width,ht.height,0,Ze,at,ht.data)}}}else{Ce=j.mipmaps,Fe&&pe&&(Ce.length>0&&Ue++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,Q,ce[0].width,ce[0].height));for(let ye=0;ye<6;ye++)if(Ve){Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,ce[ye].width,ce[ye].height,Ze,at,ce[ye].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,Q,ce[ye].width,ce[ye].height,0,Ze,at,ce[ye].data);for(let He=0;He<Ce.length;He++){const wt=Ce[He].image[ye].image;Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He+1,0,0,wt.width,wt.height,Ze,at,wt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He+1,Q,wt.width,wt.height,0,Ze,at,wt.data)}}else{Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,Ze,at,ce[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,Q,Ze,at,ce[ye]);for(let He=0;He<Ce.length;He++){const ht=Ce[He];Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He+1,0,0,Ze,at,ht.image[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,He+1,Q,Ze,at,ht.image[ye])}}}P(j,$e)&&C(t.TEXTURE_CUBE_MAP),ge.__version=_e.version,j.onUpdate&&j.onUpdate(j)}B.__version=j.version}function je(B,j,te,be,_e,ge){const me=s.convert(te.format,te.colorSpace),Ae=s.convert(te.type),ze=I(te.internalFormat,me,Ae,te.colorSpace);if(!r.get(j).__hasExternalTextures){const Ve=Math.max(1,j.width>>ge),ce=Math.max(1,j.height>>ge);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,ge,ze,Ve,ce,j.depth,0,me,Ae,null):n.texImage2D(_e,ge,ze,Ve,ce,0,me,Ae,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),ke(j)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,_e,r.get(te).__webglTexture,0,le(j)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,_e,r.get(te).__webglTexture,ge),n.bindFramebuffer(t.FRAMEBUFFER,null)}function de(B,j,te){if(t.bindRenderbuffer(t.RENDERBUFFER,B),j.depthBuffer&&!j.stencilBuffer){let be=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(te||ke(j)){const _e=j.depthTexture;_e&&_e.isDepthTexture&&(_e.type===oc?be=t.DEPTH_COMPONENT32F:_e.type===Lu&&(be=t.DEPTH_COMPONENT24));const ge=le(j);ke(j)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ge,be,j.width,j.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ge,be,j.width,j.height)}else t.renderbufferStorage(t.RENDERBUFFER,be,j.width,j.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,B)}else if(j.depthBuffer&&j.stencilBuffer){const be=le(j);te&&ke(j)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,j.width,j.height):ke(j)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,j.width,j.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,B)}else{const be=j.isWebGLMultipleRenderTargets===!0?j.texture:[j.texture];for(let _e=0;_e<be.length;_e++){const ge=be[_e],me=s.convert(ge.format,ge.colorSpace),Ae=s.convert(ge.type),ze=I(ge.internalFormat,me,Ae,ge.colorSpace),st=le(j);te&&ke(j)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,st,ze,j.width,j.height):ke(j)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,st,ze,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,ze,j.width,j.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ut(B,j){if(j&&j.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,B),!(j.depthTexture&&j.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(j.depthTexture).__webglTexture||j.depthTexture.image.width!==j.width||j.depthTexture.image.height!==j.height)&&(j.depthTexture.image.width=j.width,j.depthTexture.image.height=j.height,j.depthTexture.needsUpdate=!0),Z(j.depthTexture,0);const be=r.get(j.depthTexture).__webglTexture,_e=le(j);if(j.depthTexture.format===gh)ke(j)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0);else if(j.depthTexture.format===pm)ke(j)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0);else throw new Error("Unknown depthTexture format")}function H(B){const j=r.get(B),te=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!j.__autoAllocateDepthBuffer){if(te)throw new Error("target.depthTexture not supported in Cube render targets");ut(j.__webglFramebuffer,B)}else if(te){j.__webglDepthbuffer=[];for(let be=0;be<6;be++)n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer[be]),j.__webglDepthbuffer[be]=t.createRenderbuffer(),de(j.__webglDepthbuffer[be],B,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer),j.__webglDepthbuffer=t.createRenderbuffer(),de(j.__webglDepthbuffer,B,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function z(B,j,te){const be=r.get(B);j!==void 0&&je(be.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),te!==void 0&&H(B)}function re(B){const j=B.texture,te=r.get(B),be=r.get(j);B.addEventListener("dispose",L),B.isWebGLMultipleRenderTargets!==!0&&(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=j.version,a.memory.textures++);const _e=B.isWebGLCubeRenderTarget===!0,ge=B.isWebGLMultipleRenderTargets===!0,me=A(B)||o;if(_e){te.__webglFramebuffer=[];for(let Ae=0;Ae<6;Ae++)if(o&&j.mipmaps&&j.mipmaps.length>0){te.__webglFramebuffer[Ae]=[];for(let ze=0;ze<j.mipmaps.length;ze++)te.__webglFramebuffer[Ae][ze]=t.createFramebuffer()}else te.__webglFramebuffer[Ae]=t.createFramebuffer()}else{if(o&&j.mipmaps&&j.mipmaps.length>0){te.__webglFramebuffer=[];for(let Ae=0;Ae<j.mipmaps.length;Ae++)te.__webglFramebuffer[Ae]=t.createFramebuffer()}else te.__webglFramebuffer=t.createFramebuffer();if(ge)if(i.drawBuffers){const Ae=B.texture;for(let ze=0,st=Ae.length;ze<st;ze++){const Ve=r.get(Ae[ze]);Ve.__webglTexture===void 0&&(Ve.__webglTexture=t.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&B.samples>0&&ke(B)===!1){const Ae=ge?j:[j];te.__webglMultisampledFramebuffer=t.createFramebuffer(),te.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,te.__webglMultisampledFramebuffer);for(let ze=0;ze<Ae.length;ze++){const st=Ae[ze];te.__webglColorRenderbuffer[ze]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,te.__webglColorRenderbuffer[ze]);const Ve=s.convert(st.format,st.colorSpace),ce=s.convert(st.type),Ye=I(st.internalFormat,Ve,ce,st.colorSpace,B.isXRRenderTarget===!0),$e=le(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,$e,Ye,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ze,t.RENDERBUFFER,te.__webglColorRenderbuffer[ze])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(te.__webglDepthRenderbuffer=t.createRenderbuffer(),de(te.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(_e){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),xe(t.TEXTURE_CUBE_MAP,j,me);for(let Ae=0;Ae<6;Ae++)if(o&&j.mipmaps&&j.mipmaps.length>0)for(let ze=0;ze<j.mipmaps.length;ze++)je(te.__webglFramebuffer[Ae][ze],B,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,ze);else je(te.__webglFramebuffer[Ae],B,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0);P(j,me)&&C(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ge){const Ae=B.texture;for(let ze=0,st=Ae.length;ze<st;ze++){const Ve=Ae[ze],ce=r.get(Ve);n.bindTexture(t.TEXTURE_2D,ce.__webglTexture),xe(t.TEXTURE_2D,Ve,me),je(te.__webglFramebuffer,B,Ve,t.COLOR_ATTACHMENT0+ze,t.TEXTURE_2D,0),P(Ve,me)&&C(t.TEXTURE_2D)}n.unbindTexture()}else{let Ae=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(o?Ae=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ae,be.__webglTexture),xe(Ae,j,me),o&&j.mipmaps&&j.mipmaps.length>0)for(let ze=0;ze<j.mipmaps.length;ze++)je(te.__webglFramebuffer[ze],B,j,t.COLOR_ATTACHMENT0,Ae,ze);else je(te.__webglFramebuffer,B,j,t.COLOR_ATTACHMENT0,Ae,0);P(j,me)&&C(Ae),n.unbindTexture()}B.depthBuffer&&H(B)}function G(B){const j=A(B)||o,te=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let be=0,_e=te.length;be<_e;be++){const ge=te[be];if(P(ge,j)){const me=B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ae=r.get(ge).__webglTexture;n.bindTexture(me,Ae),C(me),n.unbindTexture()}}}function J(B){if(o&&B.samples>0&&ke(B)===!1){const j=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],te=B.width,be=B.height;let _e=t.COLOR_BUFFER_BIT;const ge=[],me=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ae=r.get(B),ze=B.isWebGLMultipleRenderTargets===!0;if(ze)for(let st=0;st<j.length;st++)n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ae.__webglFramebuffer);for(let st=0;st<j.length;st++){ge.push(t.COLOR_ATTACHMENT0+st),B.depthBuffer&&ge.push(me);const Ve=Ae.__ignoreDepthValues!==void 0?Ae.__ignoreDepthValues:!1;if(Ve===!1&&(B.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),ze&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ae.__webglColorRenderbuffer[st]),Ve===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[me]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[me])),ze){const ce=r.get(j[st]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ce,0)}t.blitFramebuffer(0,0,te,be,0,0,te,be,_e,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ge)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),ze)for(let st=0;st<j.length;st++){n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,Ae.__webglColorRenderbuffer[st]);const Ve=r.get(j[st]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,Ve,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer)}}function le(B){return Math.min(f,B.samples)}function ke(B){const j=r.get(B);return o&&B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&j.__useRenderToTexture!==!1}function Ne(B){const j=a.render.frame;x.get(B)!==j&&(x.set(B,j),B.update())}function we(B,j){const te=B.colorSpace,be=B.format,_e=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===lk||te!==_c&&te!==Ka&&(Vn.getTransfer(te)===ar?o===!1?e.has("EXT_sRGB")===!0&&be===qa?(B.format=lk,B.minFilter=Wa,B.generateMipmaps=!1):j=q7.sRGBToLinear(j):(be!==qa||_e!==Gu)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",te)),j}this.allocateTextureUnit=ne,this.resetTextureUnits=W,this.setTexture2D=Z,this.setTexture2DArray=U,this.setTexture3D=$,this.setTextureCube=ee,this.rebindTextures=z,this.setupRenderTarget=re,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=J,this.setupDepthRenderbuffer=H,this.setupFrameBufferTexture=je,this.useMultisampledRTT=ke}function H1e(t,e,n){const r=n.isWebGL2;function i(s,a=Ka){let o;const l=Vn.getTransfer(a);if(s===Gu)return t.UNSIGNED_BYTE;if(s===L7)return t.UNSIGNED_SHORT_4_4_4_4;if(s===I7)return t.UNSIGNED_SHORT_5_5_5_1;if(s===h0e)return t.BYTE;if(s===f0e)return t.SHORT;if(s===BR)return t.UNSIGNED_SHORT;if(s===j7)return t.INT;if(s===Lu)return t.UNSIGNED_INT;if(s===oc)return t.FLOAT;if(s===_0)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===p0e)return t.ALPHA;if(s===qa)return t.RGBA;if(s===m0e)return t.LUMINANCE;if(s===g0e)return t.LUMINANCE_ALPHA;if(s===gh)return t.DEPTH_COMPONENT;if(s===pm)return t.DEPTH_STENCIL;if(s===lk)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===x0e)return t.RED;if(s===U7)return t.RED_INTEGER;if(s===b0e)return t.RG;if(s===F7)return t.RG_INTEGER;if(s===z7)return t.RGBA_INTEGER;if(s===$A||s===VA||s===GA||s===WA)if(l===ar)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===$A)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===VA)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===GA)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===WA)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===$A)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===VA)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===GA)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===WA)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===YF||s===ZF||s===QF||s===JF)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===YF)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===ZF)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===QF)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===JF)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===B7)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===ez||s===tz)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===ez)return l===ar?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===tz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===nz||s===rz||s===iz||s===sz||s===az||s===oz||s===lz||s===cz||s===uz||s===dz||s===hz||s===fz||s===pz||s===mz)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===nz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===rz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===iz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===sz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===az)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===oz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===lz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===cz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===uz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===dz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===hz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===fz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===pz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===mz)return l===ar?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===qA||s===gz||s===xz)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===qA)return l===ar?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===gz)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===xz)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===v0e||s===bz||s===vz||s===yz)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(s===qA)return o.COMPRESSED_RED_RGTC1_EXT;if(s===bz)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===vz)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===yz)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===mh?r?t.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):t[s]!==void 0?t[s]:null}return{convert:i}}class $1e extends da{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Ex extends Es{constructor(){super(),this.isGroup=!0,this.type="Group"}}const V1e={type:"move"};class gT{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ex,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 Ex,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 Ex,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new De,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new De),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){a=!0;for(const y of e.hand.values()){const v=n.getJointPose(y,r),b=this._getHandJoint(u,y);v!==null&&(b.matrix.fromArray(v.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=v.radius),b.visible=v!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),m=.02,x=.005;u.inputState.pinching&&g>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=m-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(V1e)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Ex;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class G1e extends rf{constructor(e,n){super();const r=this;let i=null,s=1,a=null,o="local-floor",l=1,u=null,d=null,f=null,g=null,m=null,x=null;const y=n.getContextAttributes();let v=null,b=null;const E=[],S=[],A=new Yt;let T=null;const P=new da;P.layers.enable(1),P.viewport=new Wn;const C=new da;C.layers.enable(2),C.viewport=new Wn;const I=[P,C],N=new $1e;N.layers.enable(1),N.layers.enable(2);let D=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ee){let ae=E[ee];return ae===void 0&&(ae=new gT,E[ee]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(ee){let ae=E[ee];return ae===void 0&&(ae=new gT,E[ee]=ae),ae.getGripSpace()},this.getHand=function(ee){let ae=E[ee];return ae===void 0&&(ae=new gT,E[ee]=ae),ae.getHandSpace()};function L(ee){const ae=S.indexOf(ee.inputSource);if(ae===-1)return;const fe=E[ae];fe!==void 0&&(fe.update(ee.inputSource,ee.frame,u||a),fe.dispatchEvent({type:ee.type,data:ee.inputSource}))}function q(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",R);for(let ee=0;ee<E.length;ee++){const ae=S[ee];ae!==null&&(S[ee]=null,E[ee].disconnect(ae))}D=null,F=null,e.setRenderTarget(v),m=null,g=null,f=null,i=null,b=null,$.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ee){s=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ee){o=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||a},this.setReferenceSpace=function(ee){u=ee},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ee){if(i=ee,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",L),i.addEventListener("selectstart",L),i.addEventListener("selectend",L),i.addEventListener("squeeze",L),i.addEventListener("squeezestart",L),i.addEventListener("squeezeend",L),i.addEventListener("end",q),i.addEventListener("inputsourceschange",R),y.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ae={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,ae),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),b=new zh(m.framebufferWidth,m.framebufferHeight,{format:qa,type:Gu,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ae=null,fe=null,ue=null;y.depth&&(ue=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ae=y.stencil?pm:gh,fe=y.stencil?mh:Lu);const xe={colorFormat:n.RGBA8,depthFormat:ue,scaleFactor:s};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(xe),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),b=new zh(g.textureWidth,g.textureHeight,{format:qa,type:Gu,depthTexture:new sW(g.textureWidth,g.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Me=e.properties.get(b);Me.__ignoreDepthValues=g.ignoreDepthValues}b.isXRRenderTarget=!0,this.setFoveation(l),u=null,a=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(ee){for(let ae=0;ae<ee.removed.length;ae++){const fe=ee.removed[ae],ue=S.indexOf(fe);ue>=0&&(S[ue]=null,E[ue].disconnect(fe))}for(let ae=0;ae<ee.added.length;ae++){const fe=ee.added[ae];let ue=S.indexOf(fe);if(ue===-1){for(let Me=0;Me<E.length;Me++)if(Me>=S.length){S.push(fe),ue=Me;break}else if(S[Me]===null){S[Me]=fe,ue=Me;break}if(ue===-1)break}const xe=E[ue];xe&&xe.connect(fe)}}const V=new De,K=new De;function W(ee,ae,fe){V.setFromMatrixPosition(ae.matrixWorld),K.setFromMatrixPosition(fe.matrixWorld);const ue=V.distanceTo(K),xe=ae.projectionMatrix.elements,Me=fe.projectionMatrix.elements,se=xe[14]/(xe[10]-1),ve=xe[14]/(xe[10]+1),je=(xe[9]+1)/xe[5],de=(xe[9]-1)/xe[5],ut=(xe[8]-1)/xe[0],H=(Me[8]+1)/Me[0],z=se*ut,re=se*H,G=ue/(-ut+H),J=G*-ut;ae.matrixWorld.decompose(ee.position,ee.quaternion,ee.scale),ee.translateX(J),ee.translateZ(G),ee.matrixWorld.compose(ee.position,ee.quaternion,ee.scale),ee.matrixWorldInverse.copy(ee.matrixWorld).invert();const le=se+G,ke=ve+G,Ne=z-J,we=re+(ue-J),B=je*ve/ke*le,j=de*ve/ke*le;ee.projectionMatrix.makePerspective(Ne,we,B,j,le,ke),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert()}function ne(ee,ae){ae===null?ee.matrixWorld.copy(ee.matrix):ee.matrixWorld.multiplyMatrices(ae.matrixWorld,ee.matrix),ee.matrixWorldInverse.copy(ee.matrixWorld).invert()}this.updateCamera=function(ee){if(i===null)return;N.near=C.near=P.near=ee.near,N.far=C.far=P.far=ee.far,(D!==N.near||F!==N.far)&&(i.updateRenderState({depthNear:N.near,depthFar:N.far}),D=N.near,F=N.far);const ae=ee.parent,fe=N.cameras;ne(N,ae);for(let ue=0;ue<fe.length;ue++)ne(fe[ue],ae);fe.length===2?W(N,P,C):N.projectionMatrix.copy(P.projectionMatrix),Y(ee,N,ae)};function Y(ee,ae,fe){fe===null?ee.matrix.copy(ae.matrixWorld):(ee.matrix.copy(fe.matrixWorld),ee.matrix.invert(),ee.matrix.multiply(ae.matrixWorld)),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.updateMatrixWorld(!0),ee.projectionMatrix.copy(ae.projectionMatrix),ee.projectionMatrixInverse.copy(ae.projectionMatrixInverse),ee.isPerspectiveCamera&&(ee.fov=S0*2*Math.atan(1/ee.projectionMatrix.elements[5]),ee.zoom=1)}this.getCamera=function(){return N},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(ee){l=ee,g!==null&&(g.fixedFoveation=ee),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ee)};let Z=null;function U(ee,ae){if(d=ae.getViewerPose(u||a),x=ae,d!==null){const fe=d.views;m!==null&&(e.setRenderTargetFramebuffer(b,m.framebuffer),e.setRenderTarget(b));let ue=!1;fe.length!==N.cameras.length&&(N.cameras.length=0,ue=!0);for(let xe=0;xe<fe.length;xe++){const Me=fe[xe];let se=null;if(m!==null)se=m.getViewport(Me);else{const je=f.getViewSubImage(g,Me);se=je.viewport,xe===0&&(e.setRenderTargetTextures(b,je.colorTexture,g.ignoreDepthValues?void 0:je.depthStencilTexture),e.setRenderTarget(b))}let ve=I[xe];ve===void 0&&(ve=new da,ve.layers.enable(xe),ve.viewport=new Wn,I[xe]=ve),ve.matrix.fromArray(Me.transform.matrix),ve.matrix.decompose(ve.position,ve.quaternion,ve.scale),ve.projectionMatrix.fromArray(Me.projectionMatrix),ve.projectionMatrixInverse.copy(ve.projectionMatrix).invert(),ve.viewport.set(se.x,se.y,se.width,se.height),xe===0&&(N.matrix.copy(ve.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),ue===!0&&N.cameras.push(ve)}}for(let fe=0;fe<E.length;fe++){const ue=S[fe],xe=E[fe];ue!==null&&xe!==void 0&&xe.update(ue,ae,u||a)}Z&&Z(ee,ae),ae.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ae}),x=null}const $=new iW;$.setAnimationLoop(U),this.setAnimationLoop=function(ee){Z=ee},this.dispose=function(){}}}function W1e(t,e){function n(v,b){v.matrixAutoUpdate===!0&&v.updateMatrix(),b.value.copy(v.matrix)}function r(v,b){b.color.getRGB(v.fogColor.value,tW(t)),b.isFog?(v.fogNear.value=b.near,v.fogFar.value=b.far):b.isFogExp2&&(v.fogDensity.value=b.density)}function i(v,b,E,S,A){b.isMeshBasicMaterial||b.isMeshLambertMaterial?s(v,b):b.isMeshToonMaterial?(s(v,b),f(v,b)):b.isMeshPhongMaterial?(s(v,b),d(v,b)):b.isMeshStandardMaterial?(s(v,b),g(v,b),b.isMeshPhysicalMaterial&&m(v,b,A)):b.isMeshMatcapMaterial?(s(v,b),x(v,b)):b.isMeshDepthMaterial?s(v,b):b.isMeshDistanceMaterial?(s(v,b),y(v,b)):b.isMeshNormalMaterial?s(v,b):b.isLineBasicMaterial?(a(v,b),b.isLineDashedMaterial&&o(v,b)):b.isPointsMaterial?l(v,b,E,S):b.isSpriteMaterial?u(v,b):b.isShadowMaterial?(v.color.value.copy(b.color),v.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function s(v,b){v.opacity.value=b.opacity,b.color&&v.diffuse.value.copy(b.color),b.emissive&&v.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.bumpMap&&(v.bumpMap.value=b.bumpMap,n(b.bumpMap,v.bumpMapTransform),v.bumpScale.value=b.bumpScale,b.side===Vs&&(v.bumpScale.value*=-1)),b.normalMap&&(v.normalMap.value=b.normalMap,n(b.normalMap,v.normalMapTransform),v.normalScale.value.copy(b.normalScale),b.side===Vs&&v.normalScale.value.negate()),b.displacementMap&&(v.displacementMap.value=b.displacementMap,n(b.displacementMap,v.displacementMapTransform),v.displacementScale.value=b.displacementScale,v.displacementBias.value=b.displacementBias),b.emissiveMap&&(v.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,v.emissiveMapTransform)),b.specularMap&&(v.specularMap.value=b.specularMap,n(b.specularMap,v.specularMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest);const E=e.get(b).envMap;if(E&&(v.envMap.value=E,v.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=b.reflectivity,v.ior.value=b.ior,v.refractionRatio.value=b.refractionRatio),b.lightMap){v.lightMap.value=b.lightMap;const S=t._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=b.lightMapIntensity*S,n(b.lightMap,v.lightMapTransform)}b.aoMap&&(v.aoMap.value=b.aoMap,v.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,v.aoMapTransform))}function a(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform))}function o(v,b){v.dashSize.value=b.dashSize,v.totalSize.value=b.dashSize+b.gapSize,v.scale.value=b.scale}function l(v,b,E,S){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.size.value=b.size*E,v.scale.value=S*.5,b.map&&(v.map.value=b.map,n(b.map,v.uvTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function u(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.rotation.value=b.rotation,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function d(v,b){v.specular.value.copy(b.specular),v.shininess.value=Math.max(b.shininess,1e-4)}function f(v,b){b.gradientMap&&(v.gradientMap.value=b.gradientMap)}function g(v,b){v.metalness.value=b.metalness,b.metalnessMap&&(v.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,v.metalnessMapTransform)),v.roughness.value=b.roughness,b.roughnessMap&&(v.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,v.roughnessMapTransform)),e.get(b).envMap&&(v.envMapIntensity.value=b.envMapIntensity)}function m(v,b,E){v.ior.value=b.ior,b.sheen>0&&(v.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),v.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(v.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,v.sheenColorMapTransform)),b.sheenRoughnessMap&&(v.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,v.sheenRoughnessMapTransform))),b.clearcoat>0&&(v.clearcoat.value=b.clearcoat,v.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(v.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,v.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(v.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===Vs&&v.clearcoatNormalScale.value.negate())),b.iridescence>0&&(v.iridescence.value=b.iridescence,v.iridescenceIOR.value=b.iridescenceIOR,v.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(v.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,v.iridescenceMapTransform)),b.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),b.transmission>0&&(v.transmission.value=b.transmission,v.transmissionSamplerMap.value=E.texture,v.transmissionSamplerSize.value.set(E.width,E.height),b.transmissionMap&&(v.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,v.transmissionMapTransform)),v.thickness.value=b.thickness,b.thicknessMap&&(v.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=b.attenuationDistance,v.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(v.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(v.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=b.specularIntensity,v.specularColor.value.copy(b.specularColor),b.specularColorMap&&(v.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,v.specularColorMapTransform)),b.specularIntensityMap&&(v.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,v.specularIntensityMapTransform))}function x(v,b){b.matcap&&(v.matcap.value=b.matcap)}function y(v,b){const E=e.get(b).light;v.referencePosition.value.setFromMatrixPosition(E.matrixWorld),v.nearDistance.value=E.shadow.camera.near,v.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function q1e(t,e,n,r){let i={},s={},a=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(E,S){const A=S.program;r.uniformBlockBinding(E,A)}function u(E,S){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",v));const T=S.program;r.updateUBOMapping(E,T);const P=e.render.frame;s[E.id]!==P&&(g(E),s[E.id]=P)}function d(E){const S=f();E.__bindingPointIndex=S;const A=t.createBuffer(),T=E.__size,P=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,P),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let E=0;E<o;E++)if(a.indexOf(E)===-1)return a.push(E),E;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const S=i[E.id],A=E.uniforms,T=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let P=0,C=A.length;P<C;P++){const I=A[P];if(m(I,P,T)===!0){const N=I.__offset,D=Array.isArray(I.value)?I.value:[I.value];let F=0;for(let L=0;L<D.length;L++){const q=D[L],R=y(q);typeof q=="number"?(I.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,N+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,N,I.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(E,S,A){const T=E.value;if(A[S]===void 0){if(typeof T=="number")A[S]=T;else{const P=Array.isArray(T)?T:[T],C=[];for(let I=0;I<P.length;I++)C.push(P[I].clone());A[S]=C}return!0}else if(typeof T=="number"){if(A[S]!==T)return A[S]=T,!0}else{const P=Array.isArray(A[S])?A[S]:[A[S]],C=Array.isArray(T)?T:[T];for(let I=0;I<P.length;I++){const N=P[I];if(N.equals(C[I])===!1)return N.copy(C[I]),!0}}return!1}function x(E){const S=E.uniforms;let A=0;const T=16;let P=0;for(let C=0,I=S.length;C<I;C++){const N=S[C],D={boundary:0,storage:0},F=Array.isArray(N.value)?N.value:[N.value];for(let L=0,q=F.length;L<q;L++){const R=F[L],V=y(R);D.boundary+=V.boundary,D.storage+=V.storage}if(N.__data=new Float32Array(D.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=A,C>0){P=A%T;const L=T-P;P!==0&&L-D.boundary<0&&(A+=T-P,N.__offset=A)}A+=D.storage}return P=A%T,P>0&&(A+=T-P),E.__size=A,E.__cache={},this}function y(E){const S={boundary:0,storage:0};return typeof E=="number"?(S.boundary=4,S.storage=4):E.isVector2?(S.boundary=8,S.storage=8):E.isVector3||E.isColor?(S.boundary=16,S.storage=12):E.isVector4?(S.boundary=16,S.storage=16):E.isMatrix3?(S.boundary=48,S.storage=48):E.isMatrix4?(S.boundary=64,S.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),S}function v(E){const S=E.target;S.removeEventListener("dispose",v);const A=a.indexOf(S.__bindingPointIndex);a.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete s[S.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);a=[],i={},s={}}return{bind:l,update:u,dispose:b}}class dk{constructor(e={}){const{canvas:n=V0e(),context:r=null,depth:i=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=a;const m=new Uint32Array(4),x=new Int32Array(4);let y=null,v=null;const b=[],E=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Xi,this._useLegacyLights=!1,this.toneMapping=Vu,this.toneMappingExposure=1;const S=this;let A=!1,T=0,P=0,C=null,I=-1,N=null;const D=new Wn,F=new Wn;let L=null;const q=new $t(0);let R=0,V=n.width,K=n.height,W=1,ne=null,Y=null;const Z=new Wn(0,0,V,K),U=new Wn(0,0,V,K);let $=!1;const ee=new NS;let ae=!1,fe=!1,ue=null;const xe=new nr,Me=new Yt,se=new De,ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function je(){return C===null?W:1}let de=r;function ut(he,Ge){for(let tt=0;tt<he.length;tt++){const rt=he[tt],et=n.getContext(rt,Ge);if(et!==null)return et}return null}try{const he={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${AS}`),n.addEventListener("webglcontextlost",Fe,!1),n.addEventListener("webglcontextrestored",pe,!1),n.addEventListener("webglcontextcreationerror",Ue,!1),de===null){const Ge=["webgl2","webgl","experimental-webgl"];if(S.isWebGL1Renderer===!0&&Ge.shift(),de=ut(Ge,he),de===null)throw ut(Ge)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&de instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),de.getShaderPrecisionFormat===void 0&&(de.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(he){throw console.error("THREE.WebGLRenderer: "+he.message),he}let H,z,re,G,J,le,ke,Ne,we,B,j,te,be,_e,ge,me,Ae,ze,st,Ve,ce,Ye,$e,Ze;function at(){H=new i_e(de),z=new Zye(de,H,e),H.init(z),Ye=new H1e(de,H,z),re=new z1e(de,H,z),G=new o_e(de),J=new A1e,le=new B1e(de,H,re,J,z,Ye,G),ke=new Jye(S),Ne=new r_e(S),we=new pbe(de,z),$e=new Xye(de,H,we,z),B=new s_e(de,we,G,$e),j=new d_e(de,B,we,G),st=new u_e(de,z,le),me=new Qye(J),te=new M1e(S,ke,Ne,H,z,$e,me),be=new W1e(S,J),_e=new C1e,ge=new O1e(H,z),ze=new Kye(S,ke,Ne,re,j,g,l),Ae=new F1e(S,j,z),Ze=new q1e(de,G,z,re),Ve=new Yye(de,H,G,z),ce=new a_e(de,H,G,z),G.programs=te.programs,S.capabilities=z,S.extensions=H,S.properties=J,S.renderLists=_e,S.shadowMap=Ae,S.state=re,S.info=G}at();const Q=new G1e(S,de);this.xr=Q,this.getContext=function(){return de},this.getContextAttributes=function(){return de.getContextAttributes()},this.forceContextLoss=function(){const he=H.get("WEBGL_lose_context");he&&he.loseContext()},this.forceContextRestore=function(){const he=H.get("WEBGL_lose_context");he&&he.restoreContext()},this.getPixelRatio=function(){return W},this.setPixelRatio=function(he){he!==void 0&&(W=he,this.setSize(V,K,!1))},this.getSize=function(he){return he.set(V,K)},this.setSize=function(he,Ge,tt=!0){if(Q.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}V=he,K=Ge,n.width=Math.floor(he*W),n.height=Math.floor(Ge*W),tt===!0&&(n.style.width=he+"px",n.style.height=Ge+"px"),this.setViewport(0,0,he,Ge)},this.getDrawingBufferSize=function(he){return he.set(V*W,K*W).floor()},this.setDrawingBufferSize=function(he,Ge,tt){V=he,K=Ge,W=tt,n.width=Math.floor(he*tt),n.height=Math.floor(Ge*tt),this.setViewport(0,0,he,Ge)},this.getCurrentViewport=function(he){return he.copy(D)},this.getViewport=function(he){return he.copy(Z)},this.setViewport=function(he,Ge,tt,rt){he.isVector4?Z.set(he.x,he.y,he.z,he.w):Z.set(he,Ge,tt,rt),re.viewport(D.copy(Z).multiplyScalar(W).floor())},this.getScissor=function(he){return he.copy(U)},this.setScissor=function(he,Ge,tt,rt){he.isVector4?U.set(he.x,he.y,he.z,he.w):U.set(he,Ge,tt,rt),re.scissor(F.copy(U).multiplyScalar(W).floor())},this.getScissorTest=function(){return $},this.setScissorTest=function(he){re.setScissorTest($=he)},this.setOpaqueSort=function(he){ne=he},this.setTransparentSort=function(he){Y=he},this.getClearColor=function(he){return he.copy(ze.getClearColor())},this.setClearColor=function(){ze.setClearColor.apply(ze,arguments)},this.getClearAlpha=function(){return ze.getClearAlpha()},this.setClearAlpha=function(){ze.setClearAlpha.apply(ze,arguments)},this.clear=function(he=!0,Ge=!0,tt=!0){let rt=0;if(he){let et=!1;if(C!==null){const St=C.texture.format;et=St===z7||St===F7||St===U7}if(et){const St=C.texture.type,ie=St===Gu||St===Lu||St===BR||St===mh||St===L7||St===I7,Se=ze.getClearColor(),Le=ze.getClearAlpha(),Oe=Se.r,Te=Se.g,ot=Se.b;ie?(m[0]=Oe,m[1]=Te,m[2]=ot,m[3]=Le,de.clearBufferuiv(de.COLOR,0,m)):(x[0]=Oe,x[1]=Te,x[2]=ot,x[3]=Le,de.clearBufferiv(de.COLOR,0,x))}else rt|=de.COLOR_BUFFER_BIT}Ge&&(rt|=de.DEPTH_BUFFER_BIT),tt&&(rt|=de.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),de.clear(rt)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Fe,!1),n.removeEventListener("webglcontextrestored",pe,!1),n.removeEventListener("webglcontextcreationerror",Ue,!1),_e.dispose(),ge.dispose(),J.dispose(),ke.dispose(),Ne.dispose(),j.dispose(),$e.dispose(),Ze.dispose(),te.dispose(),Q.dispose(),Q.removeEventListener("sessionstart",cn),Q.removeEventListener("sessionend",It),ue&&(ue.dispose(),ue=null),Rn.stop()};function Fe(he){he.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function pe(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const he=G.autoReset,Ge=Ae.enabled,tt=Ae.autoUpdate,rt=Ae.needsUpdate,et=Ae.type;at(),G.autoReset=he,Ae.enabled=Ge,Ae.autoUpdate=tt,Ae.needsUpdate=rt,Ae.type=et}function Ue(he){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",he.statusMessage)}function Ce(he){const Ge=he.target;Ge.removeEventListener("dispose",Ce),ye(Ge)}function ye(he){He(he),J.remove(he)}function He(he){const Ge=J.get(he).programs;Ge!==void 0&&(Ge.forEach(function(tt){te.releaseProgram(tt)}),he.isShaderMaterial&&te.releaseShaderCache(he))}this.renderBufferDirect=function(he,Ge,tt,rt,et,St){Ge===null&&(Ge=ve);const ie=et.isMesh&&et.matrixWorld.determinant()<0,Se=kr(he,Ge,tt,rt,et);re.setMaterial(rt,ie);let Le=tt.index,Oe=1;if(rt.wireframe===!0){if(Le=B.getWireframeAttribute(tt),Le===void 0)return;Oe=2}const Te=tt.drawRange,ot=tt.attributes.position;let ft=Te.start*Oe,bt=(Te.start+Te.count)*Oe;St!==null&&(ft=Math.max(ft,St.start*Oe),bt=Math.min(bt,(St.start+St.count)*Oe)),Le!==null?(ft=Math.max(ft,0),bt=Math.min(bt,Le.count)):ot!=null&&(ft=Math.max(ft,0),bt=Math.min(bt,ot.count));const xt=bt-ft;if(xt<0||xt===1/0)return;$e.setup(et,rt,Se,tt,Le);let jt,Mt=Ve;if(Le!==null&&(jt=we.get(Le),Mt=ce,Mt.setIndex(jt)),et.isMesh)rt.wireframe===!0?(re.setLineWidth(rt.wireframeLinewidth*je()),Mt.setMode(de.LINES)):Mt.setMode(de.TRIANGLES);else if(et.isLine){let mt=rt.linewidth;mt===void 0&&(mt=1),re.setLineWidth(mt*je()),et.isLineSegments?Mt.setMode(de.LINES):et.isLineLoop?Mt.setMode(de.LINE_LOOP):Mt.setMode(de.LINE_STRIP)}else et.isPoints?Mt.setMode(de.POINTS):et.isSprite&&Mt.setMode(de.TRIANGLES);if(et.isBatchedMesh)Mt.renderMultiDraw(et._multiDrawStarts,et._multiDrawCounts,et._multiDrawCount);else if(et.isInstancedMesh)Mt.renderInstances(ft,xt,et.count);else if(tt.isInstancedBufferGeometry){const mt=tt._maxInstanceCount!==void 0?tt._maxInstanceCount:1/0,Kt=Math.min(tt.instanceCount,mt);Mt.renderInstances(ft,xt,Kt)}else Mt.render(ft,xt)};function ht(he,Ge,tt){he.transparent===!0&&he.side===tc&&he.forceSinglePass===!1?(he.side=Vs,he.needsUpdate=!0,Ji(he,Ge,tt),he.side=nd,he.needsUpdate=!0,Ji(he,Ge,tt),he.side=tc):Ji(he,Ge,tt)}this.compile=function(he,Ge,tt=null){tt===null&&(tt=he),v=ge.get(tt),v.init(),E.push(v),tt.traverseVisible(function(et){et.isLight&&et.layers.test(Ge.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),he!==tt&&he.traverseVisible(function(et){et.isLight&&et.layers.test(Ge.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),v.setupLights(S._useLegacyLights);const rt=new Set;return he.traverse(function(et){const St=et.material;if(St)if(Array.isArray(St))for(let ie=0;ie<St.length;ie++){const Se=St[ie];ht(Se,tt,et),rt.add(Se)}else ht(St,tt,et),rt.add(St)}),E.pop(),v=null,rt},this.compileAsync=function(he,Ge,tt=null){const rt=this.compile(he,Ge,tt);return new Promise(et=>{function St(){if(rt.forEach(function(ie){J.get(ie).currentProgram.isReady()&&rt.delete(ie)}),rt.size===0){et(he);return}setTimeout(St,10)}H.get("KHR_parallel_shader_compile")!==null?St():setTimeout(St,10)})};let wt=null;function Ot(he){wt&&wt(he)}function cn(){Rn.stop()}function It(){Rn.start()}const Rn=new iW;Rn.setAnimationLoop(Ot),typeof self<"u"&&Rn.setContext(self),this.setAnimationLoop=function(he){wt=he,Q.setAnimationLoop(he),he===null?Rn.stop():Rn.start()},Q.addEventListener("sessionstart",cn),Q.addEventListener("sessionend",It),this.render=function(he,Ge){if(Ge!==void 0&&Ge.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),Ge.parent===null&&Ge.matrixWorldAutoUpdate===!0&&Ge.updateMatrixWorld(),Q.enabled===!0&&Q.isPresenting===!0&&(Q.cameraAutoUpdate===!0&&Q.updateCamera(Ge),Ge=Q.getCamera()),he.isScene===!0&&he.onBeforeRender(S,he,Ge,C),v=ge.get(he,E.length),v.init(),E.push(v),xe.multiplyMatrices(Ge.projectionMatrix,Ge.matrixWorldInverse),ee.setFromProjectionMatrix(xe),fe=this.localClippingEnabled,ae=me.init(this.clippingPlanes,fe),y=_e.get(he,b.length),y.init(),b.push(y),Kn(he,Ge,0,S.sortObjects),y.finish(),S.sortObjects===!0&&y.sort(ne,Y),this.info.render.frame++,ae===!0&&me.beginShadows();const tt=v.state.shadowsArray;if(Ae.render(tt,he,Ge),ae===!0&&me.endShadows(),this.info.autoReset===!0&&this.info.reset(),ze.render(y,he),v.setupLights(S._useLegacyLights),Ge.isArrayCamera){const rt=Ge.cameras;for(let et=0,St=rt.length;et<St;et++){const ie=rt[et];_i(y,he,ie,ie.viewport)}}else _i(y,he,Ge);C!==null&&(le.updateMultisampleRenderTarget(C),le.updateRenderTargetMipmap(C)),he.isScene===!0&&he.onAfterRender(S,he,Ge),$e.resetDefaultState(),I=-1,N=null,E.pop(),E.length>0?v=E[E.length-1]:v=null,b.pop(),b.length>0?y=b[b.length-1]:y=null};function Kn(he,Ge,tt,rt){if(he.visible===!1)return;if(he.layers.test(Ge.layers)){if(he.isGroup)tt=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(Ge);else if(he.isLight)v.pushLight(he),he.castShadow&&v.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||ee.intersectsSprite(he)){rt&&se.setFromMatrixPosition(he.matrixWorld).applyMatrix4(xe);const ie=j.update(he),Se=he.material;Se.visible&&y.push(he,ie,Se,tt,se.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||ee.intersectsObject(he))){const ie=j.update(he),Se=he.material;if(rt&&(he.boundingSphere!==void 0?(he.boundingSphere===null&&he.computeBoundingSphere(),se.copy(he.boundingSphere.center)):(ie.boundingSphere===null&&ie.computeBoundingSphere(),se.copy(ie.boundingSphere.center)),se.applyMatrix4(he.matrixWorld).applyMatrix4(xe)),Array.isArray(Se)){const Le=ie.groups;for(let Oe=0,Te=Le.length;Oe<Te;Oe++){const ot=Le[Oe],ft=Se[ot.materialIndex];ft&&ft.visible&&y.push(he,ie,ft,tt,se.z,ot)}}else Se.visible&&y.push(he,ie,Se,tt,se.z,null)}}const St=he.children;for(let ie=0,Se=St.length;ie<Se;ie++)Kn(St[ie],Ge,tt,rt)}function _i(he,Ge,tt,rt){const et=he.opaque,St=he.transmissive,ie=he.transparent;v.setupLightsView(tt),ae===!0&&me.setGlobalState(S.clippingPlanes,tt),St.length>0&&si(et,St,Ge,tt),rt&&re.viewport(D.copy(rt)),et.length>0&&wi(et,Ge,tt),St.length>0&&wi(St,Ge,tt),ie.length>0&&wi(ie,Ge,tt),re.buffers.depth.setTest(!0),re.buffers.depth.setMask(!0),re.buffers.color.setMask(!0),re.setPolygonOffset(!1)}function si(he,Ge,tt,rt){if((tt.isScene===!0?tt.overrideMaterial:null)!==null)return;const St=z.isWebGL2;ue===null&&(ue=new zh(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?_0:Gu,minFilter:y0,samples:St?4:0})),S.getDrawingBufferSize(Me),St?ue.setSize(Me.x,Me.y):ue.setSize(v1(Me.x),v1(Me.y));const ie=S.getRenderTarget();S.setRenderTarget(ue),S.getClearColor(q),R=S.getClearAlpha(),R<1&&S.setClearColor(16777215,.5),S.clear();const Se=S.toneMapping;S.toneMapping=Vu,wi(he,tt,rt),le.updateMultisampleRenderTarget(ue),le.updateRenderTargetMipmap(ue);let Le=!1;for(let Oe=0,Te=Ge.length;Oe<Te;Oe++){const ot=Ge[Oe],ft=ot.object,bt=ot.geometry,xt=ot.material,jt=ot.group;if(xt.side===tc&&ft.layers.test(rt.layers)){const Mt=xt.side;xt.side=Vs,xt.needsUpdate=!0,Ii(ft,tt,rt,bt,xt,jt),xt.side=Mt,xt.needsUpdate=!0,Le=!0}}Le===!0&&(le.updateMultisampleRenderTarget(ue),le.updateRenderTargetMipmap(ue)),S.setRenderTarget(ie),S.setClearColor(q,R),S.toneMapping=Se}function wi(he,Ge,tt){const rt=Ge.isScene===!0?Ge.overrideMaterial:null;for(let et=0,St=he.length;et<St;et++){const ie=he[et],Se=ie.object,Le=ie.geometry,Oe=rt===null?ie.material:rt,Te=ie.group;Se.layers.test(tt.layers)&&Ii(Se,Ge,tt,Le,Oe,Te)}}function Ii(he,Ge,tt,rt,et,St){he.onBeforeRender(S,Ge,tt,rt,et,St),he.modelViewMatrix.multiplyMatrices(tt.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),et.onBeforeRender(S,Ge,tt,rt,he,St),et.transparent===!0&&et.side===tc&&et.forceSinglePass===!1?(et.side=Vs,et.needsUpdate=!0,S.renderBufferDirect(tt,Ge,rt,et,he,St),et.side=nd,et.needsUpdate=!0,S.renderBufferDirect(tt,Ge,rt,et,he,St),et.side=tc):S.renderBufferDirect(tt,Ge,rt,et,he,St),he.onAfterRender(S,Ge,tt,rt,et,St)}function Ji(he,Ge,tt){Ge.isScene!==!0&&(Ge=ve);const rt=J.get(he),et=v.state.lights,St=v.state.shadowsArray,ie=et.state.version,Se=te.getParameters(he,et.state,St,Ge,tt),Le=te.getProgramCacheKey(Se);let Oe=rt.programs;rt.environment=he.isMeshStandardMaterial?Ge.environment:null,rt.fog=Ge.fog,rt.envMap=(he.isMeshStandardMaterial?Ne:ke).get(he.envMap||rt.environment),Oe===void 0&&(he.addEventListener("dispose",Ce),Oe=new Map,rt.programs=Oe);let Te=Oe.get(Le);if(Te!==void 0){if(rt.currentProgram===Te&&rt.lightsStateVersion===ie)return xr(he,Se),Te}else Se.uniforms=te.getUniforms(he),he.onBuild(tt,Se,S),he.onBeforeCompile(Se,S),Te=te.acquireProgram(Se,Le),Oe.set(Le,Te),rt.uniforms=Se.uniforms;const ot=rt.uniforms;return(!he.isShaderMaterial&&!he.isRawShaderMaterial||he.clipping===!0)&&(ot.clippingPlanes=me.uniform),xr(he,Se),rt.needsLights=Ic(he),rt.lightsStateVersion=ie,rt.needsLights&&(ot.ambientLightColor.value=et.state.ambient,ot.lightProbe.value=et.state.probe,ot.directionalLights.value=et.state.directional,ot.directionalLightShadows.value=et.state.directionalShadow,ot.spotLights.value=et.state.spot,ot.spotLightShadows.value=et.state.spotShadow,ot.rectAreaLights.value=et.state.rectArea,ot.ltc_1.value=et.state.rectAreaLTC1,ot.ltc_2.value=et.state.rectAreaLTC2,ot.pointLights.value=et.state.point,ot.pointLightShadows.value=et.state.pointShadow,ot.hemisphereLights.value=et.state.hemi,ot.directionalShadowMap.value=et.state.directionalShadowMap,ot.directionalShadowMatrix.value=et.state.directionalShadowMatrix,ot.spotShadowMap.value=et.state.spotShadowMap,ot.spotLightMatrix.value=et.state.spotLightMatrix,ot.spotLightMap.value=et.state.spotLightMap,ot.pointShadowMap.value=et.state.pointShadowMap,ot.pointShadowMatrix.value=et.state.pointShadowMatrix),rt.currentProgram=Te,rt.uniformsList=null,Te}function Ur(he){if(he.uniformsList===null){const Ge=he.currentProgram.getUniforms();he.uniformsList=$_.seqWithValue(Ge.seq,he.uniforms)}return he.uniformsList}function xr(he,Ge){const tt=J.get(he);tt.outputColorSpace=Ge.outputColorSpace,tt.batching=Ge.batching,tt.instancing=Ge.instancing,tt.instancingColor=Ge.instancingColor,tt.skinning=Ge.skinning,tt.morphTargets=Ge.morphTargets,tt.morphNormals=Ge.morphNormals,tt.morphColors=Ge.morphColors,tt.morphTargetsCount=Ge.morphTargetsCount,tt.numClippingPlanes=Ge.numClippingPlanes,tt.numIntersection=Ge.numClipIntersection,tt.vertexAlphas=Ge.vertexAlphas,tt.vertexTangents=Ge.vertexTangents,tt.toneMapping=Ge.toneMapping}function kr(he,Ge,tt,rt,et){Ge.isScene!==!0&&(Ge=ve),le.resetTextureUnits();const St=Ge.fog,ie=rt.isMeshStandardMaterial?Ge.environment:null,Se=C===null?S.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:_c,Le=(rt.isMeshStandardMaterial?Ne:ke).get(rt.envMap||ie),Oe=rt.vertexColors===!0&&!!tt.attributes.color&&tt.attributes.color.itemSize===4,Te=!!tt.attributes.tangent&&(!!rt.normalMap||rt.anisotropy>0),ot=!!tt.morphAttributes.position,ft=!!tt.morphAttributes.normal,bt=!!tt.morphAttributes.color;let xt=Vu;rt.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(xt=S.toneMapping);const jt=tt.morphAttributes.position||tt.morphAttributes.normal||tt.morphAttributes.color,Mt=jt!==void 0?jt.length:0,mt=J.get(rt),Kt=v.state.lights;if(ae===!0&&(fe===!0||he!==N)){const Pr=he===N&&rt.id===I;me.setState(rt,he,Pr)}let Ft=!1;rt.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Kt.state.version||mt.outputColorSpace!==Se||et.isBatchedMesh&&mt.batching===!1||!et.isBatchedMesh&&mt.batching===!0||et.isInstancedMesh&&mt.instancing===!1||!et.isInstancedMesh&&mt.instancing===!0||et.isSkinnedMesh&&mt.skinning===!1||!et.isSkinnedMesh&&mt.skinning===!0||et.isInstancedMesh&&mt.instancingColor===!0&&et.instanceColor===null||et.isInstancedMesh&&mt.instancingColor===!1&&et.instanceColor!==null||mt.envMap!==Le||rt.fog===!0&&mt.fog!==St||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==me.numPlanes||mt.numIntersection!==me.numIntersection)||mt.vertexAlphas!==Oe||mt.vertexTangents!==Te||mt.morphTargets!==ot||mt.morphNormals!==ft||mt.morphColors!==bt||mt.toneMapping!==xt||z.isWebGL2===!0&&mt.morphTargetsCount!==Mt)&&(Ft=!0):(Ft=!0,mt.__version=rt.version);let nn=mt.currentProgram;Ft===!0&&(nn=Ji(rt,Ge,et));let dn=!1,gn=!1,Ut=!1;const Zt=nn.getUniforms(),Jt=mt.uniforms;if(re.useProgram(nn.program)&&(dn=!0,gn=!0,Ut=!0),rt.id!==I&&(I=rt.id,gn=!0),dn||N!==he){Zt.setValue(de,"projectionMatrix",he.projectionMatrix),Zt.setValue(de,"viewMatrix",he.matrixWorldInverse);const Pr=Zt.map.cameraPosition;Pr!==void 0&&Pr.setValue(de,se.setFromMatrixPosition(he.matrixWorld)),z.logarithmicDepthBuffer&&Zt.setValue(de,"logDepthBufFC",2/(Math.log(he.far+1)/Math.LN2)),(rt.isMeshPhongMaterial||rt.isMeshToonMaterial||rt.isMeshLambertMaterial||rt.isMeshBasicMaterial||rt.isMeshStandardMaterial||rt.isShaderMaterial)&&Zt.setValue(de,"isOrthographic",he.isOrthographicCamera===!0),N!==he&&(N=he,gn=!0,Ut=!0)}if(et.isSkinnedMesh){Zt.setOptional(de,et,"bindMatrix"),Zt.setOptional(de,et,"bindMatrixInverse");const Pr=et.skeleton;Pr&&(z.floatVertexTextures?(Pr.boneTexture===null&&Pr.computeBoneTexture(),Zt.setValue(de,"boneTexture",Pr.boneTexture,le)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}et.isBatchedMesh&&(Zt.setOptional(de,et,"batchingTexture"),Zt.setValue(de,"batchingTexture",et._matricesTexture,le));const Sr=tt.morphAttributes;if((Sr.position!==void 0||Sr.normal!==void 0||Sr.color!==void 0&&z.isWebGL2===!0)&&st.update(et,tt,nn),(gn||mt.receiveShadow!==et.receiveShadow)&&(mt.receiveShadow=et.receiveShadow,Zt.setValue(de,"receiveShadow",et.receiveShadow)),rt.isMeshGouraudMaterial&&rt.envMap!==null&&(Jt.envMap.value=Le,Jt.flipEnvMap.value=Le.isCubeTexture&&Le.isRenderTargetTexture===!1?-1:1),gn&&(Zt.setValue(de,"toneMappingExposure",S.toneMappingExposure),mt.needsLights&&co(Jt,Ut),St&&rt.fog===!0&&be.refreshFogUniforms(Jt,St),be.refreshMaterialUniforms(Jt,rt,W,K,ue),$_.upload(de,Ur(mt),Jt,le)),rt.isShaderMaterial&&rt.uniformsNeedUpdate===!0&&($_.upload(de,Ur(mt),Jt,le),rt.uniformsNeedUpdate=!1),rt.isSpriteMaterial&&Zt.setValue(de,"center",et.center),Zt.setValue(de,"modelViewMatrix",et.modelViewMatrix),Zt.setValue(de,"normalMatrix",et.normalMatrix),Zt.setValue(de,"modelMatrix",et.matrixWorld),rt.isShaderMaterial||rt.isRawShaderMaterial){const Pr=rt.uniformsGroups;for(let Pn=0,uo=Pr.length;Pn<uo;Pn++)if(z.isWebGL2){const Dn=Pr[Pn];Ze.update(Dn,nn),Ze.bind(Dn,nn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return nn}function co(he,Ge){he.ambientLightColor.needsUpdate=Ge,he.lightProbe.needsUpdate=Ge,he.directionalLights.needsUpdate=Ge,he.directionalLightShadows.needsUpdate=Ge,he.pointLights.needsUpdate=Ge,he.pointLightShadows.needsUpdate=Ge,he.spotLights.needsUpdate=Ge,he.spotLightShadows.needsUpdate=Ge,he.rectAreaLights.needsUpdate=Ge,he.hemisphereLights.needsUpdate=Ge}function Ic(he){return he.isMeshLambertMaterial||he.isMeshToonMaterial||he.isMeshPhongMaterial||he.isMeshStandardMaterial||he.isShadowMaterial||he.isShaderMaterial&&he.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return P},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(he,Ge,tt){J.get(he.texture).__webglTexture=Ge,J.get(he.depthTexture).__webglTexture=tt;const rt=J.get(he);rt.__hasExternalTextures=!0,rt.__hasExternalTextures&&(rt.__autoAllocateDepthBuffer=tt===void 0,rt.__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"),rt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(he,Ge){const tt=J.get(he);tt.__webglFramebuffer=Ge,tt.__useDefaultFramebuffer=Ge===void 0},this.setRenderTarget=function(he,Ge=0,tt=0){C=he,T=Ge,P=tt;let rt=!0,et=null,St=!1,ie=!1;if(he){const Le=J.get(he);Le.__useDefaultFramebuffer!==void 0?(re.bindFramebuffer(de.FRAMEBUFFER,null),rt=!1):Le.__webglFramebuffer===void 0?le.setupRenderTarget(he):Le.__hasExternalTextures&&le.rebindTextures(he,J.get(he.texture).__webglTexture,J.get(he.depthTexture).__webglTexture);const Oe=he.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(ie=!0);const Te=J.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(Array.isArray(Te[Ge])?et=Te[Ge][tt]:et=Te[Ge],St=!0):z.isWebGL2&&he.samples>0&&le.useMultisampledRTT(he)===!1?et=J.get(he).__webglMultisampledFramebuffer:Array.isArray(Te)?et=Te[tt]:et=Te,D.copy(he.viewport),F.copy(he.scissor),L=he.scissorTest}else D.copy(Z).multiplyScalar(W).floor(),F.copy(U).multiplyScalar(W).floor(),L=$;if(re.bindFramebuffer(de.FRAMEBUFFER,et)&&z.drawBuffers&&rt&&re.drawBuffers(he,et),re.viewport(D),re.scissor(F),re.setScissorTest(L),St){const Le=J.get(he.texture);de.framebufferTexture2D(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0,de.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,Le.__webglTexture,tt)}else if(ie){const Le=J.get(he.texture),Oe=Ge||0;de.framebufferTextureLayer(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0,Le.__webglTexture,tt||0,Oe)}I=-1},this.readRenderTargetPixels=function(he,Ge,tt,rt,et,St,ie){if(!(he&&he.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=J.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&ie!==void 0&&(Se=Se[ie]),Se){re.bindFramebuffer(de.FRAMEBUFFER,Se);try{const Le=he.texture,Oe=Le.format,Te=Le.type;if(Oe!==qa&&Ye.convert(Oe)!==de.getParameter(de.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ot=Te===_0&&(H.has("EXT_color_buffer_half_float")||z.isWebGL2&&H.has("EXT_color_buffer_float"));if(Te!==Gu&&Ye.convert(Te)!==de.getParameter(de.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Te===oc&&(z.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}Ge>=0&&Ge<=he.width-rt&&tt>=0&&tt<=he.height-et&&de.readPixels(Ge,tt,rt,et,Ye.convert(Oe),Ye.convert(Te),St)}finally{const Le=C!==null?J.get(C).__webglFramebuffer:null;re.bindFramebuffer(de.FRAMEBUFFER,Le)}}},this.copyFramebufferToTexture=function(he,Ge,tt=0){const rt=Math.pow(2,-tt),et=Math.floor(Ge.image.width*rt),St=Math.floor(Ge.image.height*rt);le.setTexture2D(Ge,0),de.copyTexSubImage2D(de.TEXTURE_2D,tt,0,0,he.x,he.y,et,St),re.unbindTexture()},this.copyTextureToTexture=function(he,Ge,tt,rt=0){const et=Ge.image.width,St=Ge.image.height,ie=Ye.convert(tt.format),Se=Ye.convert(tt.type);le.setTexture2D(tt,0),de.pixelStorei(de.UNPACK_FLIP_Y_WEBGL,tt.flipY),de.pixelStorei(de.UNPACK_PREMULTIPLY_ALPHA_WEBGL,tt.premultiplyAlpha),de.pixelStorei(de.UNPACK_ALIGNMENT,tt.unpackAlignment),Ge.isDataTexture?de.texSubImage2D(de.TEXTURE_2D,rt,he.x,he.y,et,St,ie,Se,Ge.image.data):Ge.isCompressedTexture?de.compressedTexSubImage2D(de.TEXTURE_2D,rt,he.x,he.y,Ge.mipmaps[0].width,Ge.mipmaps[0].height,ie,Ge.mipmaps[0].data):de.texSubImage2D(de.TEXTURE_2D,rt,he.x,he.y,ie,Se,Ge.image),rt===0&&tt.generateMipmaps&&de.generateMipmap(de.TEXTURE_2D),re.unbindTexture()},this.copyTextureToTexture3D=function(he,Ge,tt,rt,et=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const St=he.max.x-he.min.x+1,ie=he.max.y-he.min.y+1,Se=he.max.z-he.min.z+1,Le=Ye.convert(rt.format),Oe=Ye.convert(rt.type);let Te;if(rt.isData3DTexture)le.setTexture3D(rt,0),Te=de.TEXTURE_3D;else if(rt.isDataArrayTexture)le.setTexture2DArray(rt,0),Te=de.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}de.pixelStorei(de.UNPACK_FLIP_Y_WEBGL,rt.flipY),de.pixelStorei(de.UNPACK_PREMULTIPLY_ALPHA_WEBGL,rt.premultiplyAlpha),de.pixelStorei(de.UNPACK_ALIGNMENT,rt.unpackAlignment);const ot=de.getParameter(de.UNPACK_ROW_LENGTH),ft=de.getParameter(de.UNPACK_IMAGE_HEIGHT),bt=de.getParameter(de.UNPACK_SKIP_PIXELS),xt=de.getParameter(de.UNPACK_SKIP_ROWS),jt=de.getParameter(de.UNPACK_SKIP_IMAGES),Mt=tt.isCompressedTexture?tt.mipmaps[0]:tt.image;de.pixelStorei(de.UNPACK_ROW_LENGTH,Mt.width),de.pixelStorei(de.UNPACK_IMAGE_HEIGHT,Mt.height),de.pixelStorei(de.UNPACK_SKIP_PIXELS,he.min.x),de.pixelStorei(de.UNPACK_SKIP_ROWS,he.min.y),de.pixelStorei(de.UNPACK_SKIP_IMAGES,he.min.z),tt.isDataTexture||tt.isData3DTexture?de.texSubImage3D(Te,et,Ge.x,Ge.y,Ge.z,St,ie,Se,Le,Oe,Mt.data):tt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),de.compressedTexSubImage3D(Te,et,Ge.x,Ge.y,Ge.z,St,ie,Se,Le,Mt.data)):de.texSubImage3D(Te,et,Ge.x,Ge.y,Ge.z,St,ie,Se,Le,Oe,Mt),de.pixelStorei(de.UNPACK_ROW_LENGTH,ot),de.pixelStorei(de.UNPACK_IMAGE_HEIGHT,ft),de.pixelStorei(de.UNPACK_SKIP_PIXELS,bt),de.pixelStorei(de.UNPACK_SKIP_ROWS,xt),de.pixelStorei(de.UNPACK_SKIP_IMAGES,jt),et===0&&rt.generateMipmaps&&de.generateMipmap(Te),re.unbindTexture()},this.initTexture=function(he){he.isCubeTexture?le.setTextureCube(he,0):he.isData3DTexture?le.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?le.setTexture2DArray(he,0):le.setTexture2D(he,0),re.unbindTexture()},this.resetState=function(){T=0,P=0,C=null,re.reset(),$e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return rl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===HR?"display-p3":"srgb",n.unpackColorSpace=Vn.workingColorSpace===CS?"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===Xi?xh:H7}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===xh?Xi:_c}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 K1e extends dk{}K1e.prototype.isWebGL1Renderer=!0;class KR{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 KR(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class X1e extends Es{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 Y1e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=ok,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=pc()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=pc()),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=pc()),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 xs=new De;class Iu{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++)xs.fromBufferAttribute(this,n),xs.applyMatrix4(e),this.setXYZ(n,xs.x,xs.y,xs.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)xs.fromBufferAttribute(this,n),xs.applyNormalMatrix(e),this.setXYZ(n,xs.x,xs.y,xs.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)xs.fromBufferAttribute(this,n),xs.transformDirection(e),this.setXYZ(n,xs.x,xs.y,xs.z);return this}setX(e,n){return this.normalized&&(n=$n(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=$n(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=$n(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=$n(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=el(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=el(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=el(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=el(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=$n(n,this.array),r=$n(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=$n(n,this.array),r=$n(r,this.array),i=$n(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(n=$n(n,this.array),r=$n(r,this.array),i=$n(i,this.array),s=$n(s,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return new xa(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 Iu(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Z1e extends Gs{constructor(e=null,n=1,r=1,i,s,a,o,l,u=Ki,d=Ki,f,g){super(null,a,o,l,u,d,i,s,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function Q1e(t,e){return t.z-e.z}function J1e(t,e){return e.z-t.z}class ewe{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const s=r[this.index];i.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=n}reset(){this.list.length=0,this.index=0}}const yp="batchId",bu=new nr,lB=new nr,twe=new nr,cB=new nr,xT=new NS,Wy=new eo,Wd=new sl,lx=new De,bT=new ewe,ss=new No,qy=[];function nwe(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let s=0;s<i;s++)for(let a=0;a<r;a++)e.setComponent(s+n,a,t.getComponent(s,a))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class rwe extends No{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new fs,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 Z1e(n,e,e,qa,oc);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const l=e.getAttribute(o),{array:u,itemSize:d,normalized:f}=l,g=new u.constructor(r*d),m=new l.constructor(g,d,f);m.setUsage(l.usage),n.setAttribute(o,m)}if(e.getIndex()!==null){const o=r>65536?new Uint32Array(s):new Uint16Array(s);n.setIndex(new xa(o,1))}const a=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(yp,new xa(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(yp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${yp}"`);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===yp)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),s=n.getAttribute(r);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new eo);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,bu),this.getBoundingBoxAt(i,Wy).applyMatrix4(bu),n.union(Wy))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new sl);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,bu),this.getBoundingSphereAt(i,Wd).applyMatrix4(bu),n.union(Wd))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,s===null?i.vertexStart=0:i.vertexStart=s.vertexStart+s.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,s===null?i.indexStart=0:i.indexStart=s.indexStart+s.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,g=this._active,m=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),g.push(!0);const y=this._geometryCount;this._geometryCount++,twe.toArray(x,y*16),m.needsUpdate=!0,a.push(i),o.push({start:d?i.indexStart:i.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new eo,sphereInitialized:!1,sphere:new sl});const v=this.geometry.getAttribute(yp);for(let b=0;b<i.vertexCount;b++)v.setX(i.vertexStart+b,y);return v.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,s=r.getIndex(),a=n.getIndex(),o=this._reservedRanges[e];if(i&&a.count>o.indexCount||n.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,u=o.vertexCount;for(const m in r.attributes){if(m===yp)continue;const x=n.getAttribute(m),y=r.getAttribute(m);nwe(x,y,l);const v=x.itemSize;for(let b=x.count,E=u;b<E;b++){const S=l+b;for(let A=0;A<v;A++)y.setComponent(S,A,0)}y.needsUpdate=!0}if(i){const m=o.indexStart;for(let x=0;x<a.count;x++)s.setX(m+x,l+a.getX(x));for(let x=a.count,y=o.indexCount;x<y;x++)s.setX(m+x,l);s.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],g=n.getAttribute("position");return f.count=i?a.count:g.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],s=i.box,a=this.geometry;if(i.boxInitialized===!1){s.makeEmpty();const o=a.index,l=a.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let g=d;o&&(g=o.getX(g)),s.expandByPoint(lx.fromBufferAttribute(l,g))}i.boxInitialized=!0}return n.copy(s),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],s=i.sphere,a=this.geometry;if(i.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,Wy),Wy.getCenter(s.center);const o=a.index,l=a.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,g=u.start+u.count;f<g;f++){let m=f;o&&(m=o.getX(m)),lx.fromBufferAttribute(l,m),d=Math.max(d,s.center.distanceToSquared(lx))}s.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(s),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,s=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?this:(n.toArray(s,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,s=this._geometryCount;return e>=s||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,s=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,l=this.geometry;ss.material=this.material,ss.geometry.index=l.index,ss.geometry.attributes=l.attributes,ss.geometry.boundingBox===null&&(ss.geometry.boundingBox=new eo),ss.geometry.boundingSphere===null&&(ss.geometry.boundingSphere=new sl);for(let u=0;u<a;u++){if(!r[u]||!i[u])continue;const d=s[u];ss.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ss.matrixWorld).premultiply(o),this.getBoundingBoxAt(u,ss.geometry.boundingBox),this.getBoundingSphereAt(u,ss.geometry.boundingSphere),ss.raycast(e,qy);for(let f=0,g=qy.length;f<g;f++){const m=qy[f];m.object=this,m.batchId=u,n.push(m)}qy.length=0}ss.material=null,ss.geometry.index=null,ss.geometry.attributes={},ss.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(cB.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),xT.setFromProjectionMatrix(cB,e.isWebGPURenderer?w0:rl));let m=0;if(this.sortObjects){lB.copy(this.matrixWorld).invert(),lx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(lB);for(let v=0,b=l.length;v<b;v++)if(l[v]){this.getMatrixAt(v,bu),this.getBoundingSphereAt(v,Wd).applyMatrix4(bu);let E=!1;if(g&&(E=!xT.intersectsSphere(Wd)),!E){const S=lx.distanceTo(Wd.center);bT.push(f[v],S)}}const x=bT.list,y=this.customSort;y===null?x.sort(s.transparent?J1e:Q1e):y.call(this,x,r);for(let v=0,b=x.length;v<b;v++){const E=x[v];u[m]=E.start*o,d[m]=E.count,m++}bT.reset()}else for(let x=0,y=l.length;x<y;x++)if(l[x]){let v=!1;if(g&&(this.getMatrixAt(x,bu),this.getBoundingSphereAt(x,Wd).applyMatrix4(bu),v=!xT.intersectsSphere(Wd)),!v){const b=f[x];u[m]=b.start*o,d[m]=b.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,s,a){this.onBeforeRender(e,null,i,s,a)}}class ob extends Bm{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 uB=new De,dB=new De,hB=new nr,vT=new VR,Ky=new sl;class iwe extends Es{constructor(e=new fs,n=new ob){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,s=n.count;i<s;i++)uB.fromBufferAttribute(n,i-1),dB.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=uB.distanceTo(dB);e.setAttribute("lineDistance",new Lr(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Ky.copy(r.boundingSphere),Ky.applyMatrix4(i),Ky.radius+=s,e.ray.intersectsSphere(Ky)===!1)return;hB.copy(i).invert(),vT.copy(e.ray).applyMatrix4(hB);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,u=new De,d=new De,f=new De,g=new De,m=this.isLineSegments?2:1,x=r.index,v=r.attributes.position;if(x!==null){const b=Math.max(0,a.start),E=Math.min(x.count,a.start+a.count);for(let S=b,A=E-1;S<A;S+=m){const T=x.getX(S),P=x.getX(S+1);if(u.fromBufferAttribute(v,T),d.fromBufferAttribute(v,P),vT.distanceSqToSegment(u,d,g,f)>l)continue;g.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(g);I<e.near||I>e.far||n.push({distance:I,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const b=Math.max(0,a.start),E=Math.min(v.count,a.start+a.count);for(let S=b,A=E-1;S<A;S+=m){if(u.fromBufferAttribute(v,S),d.fromBufferAttribute(v,S+1),vT.distanceSqToSegment(u,d,g,f)>l)continue;g.applyMatrix4(this.matrixWorld);const P=e.ray.origin.distanceTo(g);P<e.near||P>e.far||n.push({distance:P,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}const fB=new De,pB=new De;class PS extends iwe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,s=n.count;i<s;i+=2)fB.fromBufferAttribute(n,i),pB.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+fB.distanceTo(pB);e.setAttribute("lineDistance",new Lr(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class swe extends fs{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new De,s=new De;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let u=0,d=l.length;u<d;++u){const f=l[u],g=f.start,m=f.count;for(let x=g,y=g+m;x<y;x+=3)for(let v=0;v<3;v++){const b=o.getX(x+v),E=o.getX(x+(v+1)%3);i.fromBufferAttribute(a,b),s.fromBufferAttribute(a,E),mB(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let u=0;u<3;u++){const d=3*o+u,f=3*o+(u+1)%3;i.fromBufferAttribute(a,d),s.fromBufferAttribute(a,f),mB(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new Lr(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function mB(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 awe extends Bm{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=$7,this.normalScale=new Yt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=zR,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 owe extends ob{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 dW extends Es{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 yT=new nr,gB=new De,xB=new De;class lwe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Yt(512,512),this.map=null,this.mapPass=null,this.matrix=new nr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new NS,this._frameExtents=new Yt(1,1),this._viewportCount=1,this._viewports=[new Wn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;gB.setFromMatrixPosition(e.matrixWorld),n.position.copy(gB),xB.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(xB),n.updateMatrixWorld(),yT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yT),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(yT)}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 bB=new nr,cx=new De,_T=new De;class cwe extends lwe{constructor(){super(new da(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Yt(4,2),this._viewportCount=6,this._viewports=[new Wn(2,1,1,1),new Wn(0,1,1,1),new Wn(3,1,1,1),new Wn(1,1,1,1),new Wn(3,0,1,1),new Wn(1,0,1,1)],this._cubeDirections=[new De(1,0,0),new De(-1,0,0),new De(0,0,1),new De(0,0,-1),new De(0,1,0),new De(0,-1,0)],this._cubeUps=[new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,0,1),new De(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),cx.setFromMatrixPosition(e.matrixWorld),r.position.copy(cx),_T.copy(r.position),_T.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(_T),r.updateMatrixWorld(),i.makeTranslation(-cx.x,-cx.y,-cx.z),bB.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bB)}}class uwe extends dW{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 cwe}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 dwe extends dW{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class hwe extends fs{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 hk extends Y1e{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 vB{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(Yi(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const yB=new De,Xy=new De;class fwe{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){yB.subVectors(e,this.start),Xy.subVectors(this.end,this.start);const r=Xy.dot(Xy);let s=Xy.dot(yB)/r;return n&&(s=Yi(s,0,1)),s}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class pwe extends PS{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 fs;i.setAttribute("position",new Lr(n,3)),i.setAttribute("color",new Lr(r,3));const s=new ob({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new $t,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(n),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:AS}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=AS);class al{constructor(e,n,r,i,s="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(s),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),al.nextNameID=al.nextNameID||0,this.$name.id=`lil-gui-name-${++al.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",a=>a.stopPropagation()),this.domElement.addEventListener("keyup",a=>a.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class mwe extends al{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 fk(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 gwe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:fk,toHexString:fk},E0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},xwe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=E0.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 E0.toHexString(i)}},bwe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=E0.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 E0.toHexString(i)}},vwe=[gwe,E0,xwe,bwe];function ywe(t){return vwe.find(e=>e.match(t))}class _we extends al{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=ywe(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const s=fk(this.$text.value);s&&this._setValueFromHexString(s)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class wT extends al{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 wwe extends al{constructor(e,n,r,i,s,a){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(s);const o=a!==void 0;this.step(o?a:this._getImplicitStep(),o),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let E=parseFloat(this.$input.value);isNaN(E)||(this._stepExplicit&&(E=this._snap(E)),this.setValue(this._clamp(E)))},r=E=>{const S=parseFloat(this.$input.value);isNaN(S)||(this._snapClampSetValue(S+E),this.$input.value=this.getValue())},i=E=>{E.key==="Enter"&&this.$input.blur(),E.code==="ArrowUp"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E))),E.code==="ArrowDown"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E)*-1))},s=E=>{this._inputFocused&&(E.preventDefault(),r(this._step*this._normalizeMouseWheel(E)))};let a=!1,o,l,u,d,f;const g=5,m=E=>{o=E.clientX,l=u=E.clientY,a=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",y)},x=E=>{if(a){const S=E.clientX-o,A=E.clientY-l;Math.abs(A)>g?(E.preventDefault(),this.$input.blur(),a=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(S)>g&&y()}if(!a){const S=E.clientY-u;f-=S*this._step*this._arrowKeyMultiplier(E),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=E.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",y)},v=()=>{this._inputFocused=!0},b=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",m),this.$input.addEventListener("focus",v),this.$input.addEventListener("blur",b)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(b,E,S,A,T)=>(b-E)/(S-E)*(T-A)+A,n=b=>{const E=this.$slider.getBoundingClientRect();let S=e(b,E.left,E.right,this._min,this._max);this._snapClampSetValue(S)},r=b=>{this._setDraggingStyle(!0),n(b.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=b=>{n(b.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let a=!1,o,l;const u=b=>{b.preventDefault(),this._setDraggingStyle(!0),n(b.touches[0].clientX),a=!1},d=b=>{b.touches.length>1||(this._hasScrollBar?(o=b.touches[0].clientX,l=b.touches[0].clientY,a=!0):u(b),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=b=>{if(a){const E=b.touches[0].clientX-o,S=b.touches[0].clientY-l;Math.abs(E)>Math.abs(S)?u(b):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else b.preventDefault(),n(b.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},m=this._callOnFinishChange.bind(this),x=400;let y;const v=b=>{if(Math.abs(b.deltaX)<Math.abs(b.deltaY)&&this._hasScrollBar)return;b.preventDefault();const S=this._normalizeMouseWheel(b)*this._step;this._snapClampSetValue(this.getValue()+S),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(m,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",v,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class Swe extends al{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 Ewe extends al{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 Mwe=`.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 Awe(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 _B=!1;class _1{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:s="Controls",closeFolders:a=!1,injectStyles:o=!0,touchStyles:l=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),l&&this.domElement.classList.add("allow-touch-styles"),!_B&&o&&(Awe(Mwe),_B=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=a}add(e,n,r,i,s){if(Object(r)===r)return new Swe(this,e,n,r);const a=e[n];switch(typeof a){case"number":return new wwe(this,e,n,r,i,s);case"boolean":return new mwe(this,e,n);case"string":return new Ewe(this,e,n);case"function":return new wT(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,a)}addColor(e,n,r=1){return new _we(this,e,n,r)}addFolder(e){const n=new _1({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof wT||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 wT)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=s=>{s.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function ST(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(u){try{l(r.next(u))}catch(d){s(d)}}function o(u){try{l(r.throw(u))}catch(d){s(d)}}function l(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(a,o)}l((r=r.apply(t,[])).next())}))}class XR{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 XR(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 YR{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class wB extends YR{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class vu extends YR{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class SB{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class w1{constructor(e){this.lines=[],this.preamble=new SB(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((s=>s.comment))).thumbnails;for(const[s,a]of Object.entries(i))this.metadata.thumbnails[s]=a;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),s=i[0],a=n&&i[1]||void 0,o=s.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),l=o.length?`${(r=o[0])===null||r===void 0?void 0:r.toLowerCase()}${o[1]}`:"",u=this.parseParams(o.slice(2));switch(l){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new wB(e,l,u,a);case"t0":return new vu(e,l,a,0);case"t1":return new vu(e,l,a,1);case"t2":return new vu(e,l,a,2);case"t3":return new vu(e,l,a,3);case"t4":return new vu(e,l,a,4);case"t5":return new vu(e,l,a,5);case"t6":return new vu(e,l,a,6);case"t7":return new vu(e,l,a,7);default:return new YR(e,l,u,a)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,s)=>{if(i%2==0)return n;let a=s[i-1];return a=a.toLowerCase(),this.isAlpha(a)&&(n[a]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof wB){const s=i.params;if(s.z&&(this.curZ=s.z),((n=s.e)!==null&&n!==void 0?n:0)>0&&(s.x!=null||s.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const a=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new SB(this.layers.length,[],r,a))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const s=i.comment;if(!s)continue;const a=s.indexOf("thumbnail begin"),o=s.indexOf("thumbnail end");a>-1?r=XR.parse(s.slice(a+15).trim()):r&&(o==-1?r.chars+=s.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}w1.prototype.parseGcode=w1.prototype.parseGCode;const EB={type:"change"},ET={type:"start"},MB={type:"end"},Yy=new VR,AB=new Su,Twe=Math.cos(70*G7.DEG2RAD);class Cwe extends rf{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:np.ROTATE,MIDDLE:np.DOLLY,RIGHT:np.PAN},this.touches={ONE:rp.ROTATE,TWO:rp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(z){z.addEventListener("keydown",je),this._domElementKeyEvents=z},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(EB),r.update(),s=i.NONE},this.update=(function(){const z=new De,re=new Bh().setFromUnitVectors(e.up,new De(0,1,0)),G=re.clone().invert(),J=new De,le=new Bh,ke=new De,Ne=2*Math.PI;return function(we=null){const B=r.object.position;z.copy(B).sub(r.target),z.applyQuaternion(re),o.setFromVector3(z),r.autoRotate&&s===i.NONE&&D((function(_e){return _e!==null?2*Math.PI/60*r.autoRotateSpeed*_e:2*Math.PI/60/60*r.autoRotateSpeed})(we)),r.enableDamping?(o.theta+=l.theta*r.dampingFactor,o.phi+=l.phi*r.dampingFactor):(o.theta+=l.theta,o.phi+=l.phi);let j=r.minAzimuthAngle,te=r.maxAzimuthAngle;isFinite(j)&&isFinite(te)&&(j<-Math.PI?j+=Ne:j>Math.PI&&(j-=Ne),te<-Math.PI?te+=Ne:te>Math.PI&&(te-=Ne),o.theta=j<=te?Math.max(j,Math.min(te,o.theta)):o.theta>(j+te)/2?Math.max(j,o.theta):Math.min(te,o.theta)),o.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,o.phi)),o.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&P||r.object.isOrthographicCamera?o.radius=ne(o.radius):o.radius=ne(o.radius*u),z.setFromSpherical(o),z.applyQuaternion(G),B.copy(r.target).add(z),r.object.lookAt(r.target),r.enableDamping===!0?(l.theta*=1-r.dampingFactor,l.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(l.set(0,0,0),d.set(0,0,0));let be=!1;if(r.zoomToCursor&&P){let _e=null;if(r.object.isPerspectiveCamera){const ge=z.length();_e=ne(ge*u);const me=ge-_e;r.object.position.addScaledVector(A,me),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ge=new De(T.x,T.y,0);ge.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0;const me=new De(T.x,T.y,0);me.unproject(r.object),r.object.position.sub(me).add(ge),r.object.updateMatrixWorld(),_e=z.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;_e!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(_e).add(r.object.position):(Yy.origin.copy(r.object.position),Yy.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(Yy.direction))<Twe?e.lookAt(r.target):(AB.setFromNormalAndCoplanarPoint(r.object.up,r.target),Yy.intersectPlane(AB,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0);return u=1,P=!1,!!(be||J.distanceToSquared(r.object.position)>a||8*(1-le.dot(r.object.quaternion))>a||ke.distanceToSquared(r.target)>0)&&(r.dispatchEvent(EB),J.copy(r.object.position),le.copy(r.object.quaternion),ke.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",de),r.domElement.removeEventListener("pointerdown",xe),r.domElement.removeEventListener("pointercancel",se),r.domElement.removeEventListener("wheel",ve),r.domElement.removeEventListener("pointermove",Me),r.domElement.removeEventListener("pointerup",se),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",je),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const a=1e-6,o=new vB,l=new vB;let u=1;const d=new De,f=new Yt,g=new Yt,m=new Yt,x=new Yt,y=new Yt,v=new Yt,b=new Yt,E=new Yt,S=new Yt,A=new De,T=new Yt;let P=!1;const C=[],I={};function N(){return Math.pow(.95,r.zoomSpeed)}function D(z){l.theta-=z}function F(z){l.phi-=z}const L=(function(){const z=new De;return function(re,G){z.setFromMatrixColumn(G,0),z.multiplyScalar(-re),d.add(z)}})(),q=(function(){const z=new De;return function(re,G){r.screenSpacePanning===!0?z.setFromMatrixColumn(G,1):(z.setFromMatrixColumn(G,0),z.crossVectors(r.object.up,z)),z.multiplyScalar(re),d.add(z)}})(),R=(function(){const z=new De;return function(re,G){const J=r.domElement;if(r.object.isPerspectiveCamera){const le=r.object.position;z.copy(le).sub(r.target);let ke=z.length();ke*=Math.tan(r.object.fov/2*Math.PI/180),L(2*re*ke/J.clientHeight,r.object.matrix),q(2*G*ke/J.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(L(re*(r.object.right-r.object.left)/r.object.zoom/J.clientWidth,r.object.matrix),q(G*(r.object.top-r.object.bottom)/r.object.zoom/J.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function V(z){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(z){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function W(z){if(!r.zoomToCursor)return;P=!0;const re=r.domElement.getBoundingClientRect(),G=z.clientX-re.left,J=z.clientY-re.top,le=re.width,ke=re.height;T.x=G/le*2-1,T.y=-J/ke*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function ne(z){return Math.max(r.minDistance,Math.min(r.maxDistance,z))}function Y(z){f.set(z.clientX,z.clientY)}function Z(z){x.set(z.clientX,z.clientY)}function U(){if(C.length===1)f.set(C[0].pageX,C[0].pageY);else{const z=.5*(C[0].pageX+C[1].pageX),re=.5*(C[0].pageY+C[1].pageY);f.set(z,re)}}function $(){if(C.length===1)x.set(C[0].pageX,C[0].pageY);else{const z=.5*(C[0].pageX+C[1].pageX),re=.5*(C[0].pageY+C[1].pageY);x.set(z,re)}}function ee(){const z=C[0].pageX-C[1].pageX,re=C[0].pageY-C[1].pageY,G=Math.sqrt(z*z+re*re);b.set(0,G)}function ae(z){if(C.length==1)g.set(z.pageX,z.pageY);else{const G=H(z),J=.5*(z.pageX+G.x),le=.5*(z.pageY+G.y);g.set(J,le)}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(z){if(C.length===1)y.set(z.pageX,z.pageY);else{const re=H(z),G=.5*(z.pageX+re.x),J=.5*(z.pageY+re.y);y.set(G,J)}v.subVectors(y,x).multiplyScalar(r.panSpeed),R(v.x,v.y),x.copy(y)}function ue(z){const re=H(z),G=z.pageX-re.x,J=z.pageY-re.y,le=Math.sqrt(G*G+J*J);E.set(0,le),S.set(0,Math.pow(E.y/b.y,r.zoomSpeed)),V(S.y),b.copy(E)}function xe(z){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(z.pointerId),r.domElement.addEventListener("pointermove",Me),r.domElement.addEventListener("pointerup",se)),(function(re){C.push(re)})(z),z.pointerType==="touch"?(function(re){switch(ut(re),C.length){case 1:switch(r.touches.ONE){case rp.ROTATE:if(r.enableRotate===!1)return;U(),s=i.TOUCH_ROTATE;break;case rp.PAN:if(r.enablePan===!1)return;$(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case rp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ee(),r.enablePan&&$(),s=i.TOUCH_DOLLY_PAN;break;case rp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ee(),r.enableRotate&&U(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(ET)})(z):(function(re){let G;switch(re.button){case 0:G=r.mouseButtons.LEFT;break;case 1:G=r.mouseButtons.MIDDLE;break;case 2:G=r.mouseButtons.RIGHT;break;default:G=-1}switch(G){case np.DOLLY:if(r.enableZoom===!1)return;(function(J){W(J),b.set(J.clientX,J.clientY)})(re),s=i.DOLLY;break;case np.ROTATE:if(re.ctrlKey||re.metaKey||re.shiftKey){if(r.enablePan===!1)return;Z(re),s=i.PAN}else{if(r.enableRotate===!1)return;Y(re),s=i.ROTATE}break;case np.PAN:if(re.ctrlKey||re.metaKey||re.shiftKey){if(r.enableRotate===!1)return;Y(re),s=i.ROTATE}else{if(r.enablePan===!1)return;Z(re),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(ET)})(z))}function Me(z){r.enabled!==!1&&(z.pointerType==="touch"?(function(re){switch(ut(re),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ae(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(G){r.enableZoom&&ue(G),r.enablePan&&fe(G)})(re),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(G){r.enableZoom&&ue(G),r.enableRotate&&ae(G)})(re),r.update();break;default:s=i.NONE}})(z):(function(re){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(G){g.set(G.clientX,G.clientY),m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const J=r.domElement;D(2*Math.PI*m.x/J.clientHeight),F(2*Math.PI*m.y/J.clientHeight),f.copy(g),r.update()})(re);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(G){E.set(G.clientX,G.clientY),S.subVectors(E,b),S.y>0?V(N()):S.y<0&&K(N()),b.copy(E),r.update()})(re);break;case i.PAN:if(r.enablePan===!1)return;(function(G){y.set(G.clientX,G.clientY),v.subVectors(y,x).multiplyScalar(r.panSpeed),R(v.x,v.y),x.copy(y),r.update()})(re)}})(z))}function se(z){(function(re){delete I[re.pointerId];for(let G=0;G<C.length;G++)if(C[G].pointerId==re.pointerId)return void C.splice(G,1)})(z),C.length===0&&(r.domElement.releasePointerCapture(z.pointerId),r.domElement.removeEventListener("pointermove",Me),r.domElement.removeEventListener("pointerup",se)),r.dispatchEvent(MB),s=i.NONE}function ve(z){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(z.preventDefault(),r.dispatchEvent(ET),(function(re){W(re),re.deltaY<0?K(N()):re.deltaY>0&&V(N()),r.update()})(z),r.dispatchEvent(MB))}function je(z){r.enabled!==!1&&r.enablePan!==!1&&(function(re){let G=!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),G=!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),G=!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),G=!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),G=!0}G&&(re.preventDefault(),r.update())})(z)}function de(z){r.enabled!==!1&&z.preventDefault()}function ut(z){let re=I[z.pointerId];re===void 0&&(re=new Yt,I[z.pointerId]=re),re.set(z.pageX,z.pageY)}function H(z){const re=z.pointerId===C[0].pointerId?C[1]:C[0];return I[re.pointerId]}r.domElement.addEventListener("contextmenu",de),r.domElement.addEventListener("pointerdown",xe),r.domElement.addEventListener("pointercancel",se),r.domElement.addEventListener("wheel",ve,{passive:!1}),this.update()}}vt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Yt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},zs.line={uniforms:GR.merge([vt.common,vt.fog,vt.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class hW extends rd{constructor(e){super({type:"LineMaterial",uniforms:GR.clone(zs.line.uniforms),vertexShader:zs.line.vertexShader,fragmentShader:zs.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 TB=new eo,Zy=new De;class fW extends hwe{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new Lr([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new Lr([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const n=this.attributes.instanceStart,r=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),r.applyMatrix4(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new hk(n,6,1);return this.setAttribute("instanceStart",new Iu(r,3,0)),this.setAttribute("instanceEnd",new Iu(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 hk(n,6,1);return this.setAttribute("instanceColorStart",new Iu(r,3,0)),this.setAttribute("instanceColorEnd",new Iu(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 swe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new eo);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),TB.setFromBufferAttribute(n),this.boundingBox.union(TB))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new sl),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Zy.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Zy)),Zy.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(Zy));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 CB=new De,NB=new De,$i=new Wn,Vi=new Wn,Wo=new Wn,MT=new De,AT=new nr,Gi=new fwe,kB=new De,Qy=new eo,Jy=new sl,qo=new Wn;let Ko,nh;function PB(t,e,n){return qo.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),qo.multiplyScalar(1/qo.w),qo.x=nh/n.width,qo.y=nh/n.height,qo.applyMatrix4(t.projectionMatrixInverse),qo.multiplyScalar(1/qo.w),Math.abs(Math.max(qo.x,qo.y))}class Nwe extends No{constructor(e=new fW,n=new hW({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let a=0,o=0,l=n.count;a<l;a++,o+=2)CB.fromBufferAttribute(n,a),NB.fromBufferAttribute(r,a),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+CB.distanceTo(NB);const s=new hk(i,2,1);return e.setAttribute("instanceDistanceStart",new Iu(s,1,0)),e.setAttribute("instanceDistanceEnd",new Iu(s,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Ko=e.ray;const a=this.matrixWorld,o=this.geometry,l=this.material;let u,d;nh=l.linewidth+s,o.boundingSphere===null&&o.computeBoundingSphere(),Jy.copy(o.boundingSphere).applyMatrix4(a),r?u=.5*nh:u=PB(i,Math.max(i.near,Jy.distanceToPoint(Ko.origin)),l.resolution),Jy.radius+=u,Ko.intersectsSphere(Jy)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),Qy.copy(o.boundingBox).applyMatrix4(a),r?d=.5*nh:d=PB(i,Math.max(i.near,Qy.distanceToPoint(Ko.origin)),l.resolution),Qy.expandByScalar(d),Ko.intersectsBox(Qy)!==!1&&(r?(function(f,g){const m=f.matrixWorld,x=f.geometry,y=x.attributes.instanceStart,v=x.attributes.instanceEnd;for(let b=0,E=Math.min(x.instanceCount,y.count);b<E;b++){Gi.start.fromBufferAttribute(y,b),Gi.end.fromBufferAttribute(v,b),Gi.applyMatrix4(m);const S=new De,A=new De;Ko.distanceSqToSegment(Gi.start,Gi.end,A,S),A.distanceTo(S)<.5*nh&&g.push({point:A,pointOnLine:S,distance:Ko.origin.distanceTo(A),object:f,face:null,faceIndex:b,uv:null,uv1:null})}})(this,n):(function(f,g,m){const x=g.projectionMatrix,y=f.material.resolution,v=f.matrixWorld,b=f.geometry,E=b.attributes.instanceStart,S=b.attributes.instanceEnd,A=Math.min(b.instanceCount,E.count),T=-g.near;Ko.at(1,Wo),Wo.w=1,Wo.applyMatrix4(g.matrixWorldInverse),Wo.applyMatrix4(x),Wo.multiplyScalar(1/Wo.w),Wo.x*=y.x/2,Wo.y*=y.y/2,Wo.z=0,MT.copy(Wo),AT.multiplyMatrices(g.matrixWorldInverse,v);for(let P=0,C=A;P<C;P++){if($i.fromBufferAttribute(E,P),Vi.fromBufferAttribute(S,P),$i.w=1,Vi.w=1,$i.applyMatrix4(AT),Vi.applyMatrix4(AT),$i.z>T&&Vi.z>T)continue;if($i.z>T){const L=$i.z-Vi.z,q=($i.z-T)/L;$i.lerp(Vi,q)}else if(Vi.z>T){const L=Vi.z-$i.z,q=(Vi.z-T)/L;Vi.lerp($i,q)}$i.applyMatrix4(x),Vi.applyMatrix4(x),$i.multiplyScalar(1/$i.w),Vi.multiplyScalar(1/Vi.w),$i.x*=y.x/2,$i.y*=y.y/2,Vi.x*=y.x/2,Vi.y*=y.y/2,Gi.start.copy($i),Gi.start.z=0,Gi.end.copy(Vi),Gi.end.z=0;const I=Gi.closestPointToPointParameter(MT,!0);Gi.at(I,kB);const N=G7.lerp($i.z,Vi.z,I),D=N>=-1&&N<=1,F=MT.distanceTo(kB)<.5*nh;if(D&&F){Gi.start.fromBufferAttribute(E,P),Gi.end.fromBufferAttribute(S,P),Gi.start.applyMatrix4(v),Gi.end.applyMatrix4(v);const L=new De,q=new De;Ko.distanceSqToSegment(Gi.start,Gi.end,q,L),m.push({point:q,pointOnLine:L,distance:Ko.origin.distanceTo(q),object:f,face:null,faceIndex:P,uv:null,uv1:null})}}})(this,i,n)))}}class kwe extends PS{constructor(e,n,r,i,s=4473924,a=8947848){s=new $t(s),a=new $t(a);const o=Math.round(e/n);r=Math.round(r/i)*i/2;const l=[],u=[];let d=0;for(let g=-1*(e=o*n/2);g<=e;g+=n){l.push(g,0,-1*r,g,0,r);const m=g===0?s:a;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}for(let g=-1*r;g<=r;g+=i){l.push(-1*e,0,g,e,0,g);const m=g===0?s:a;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}const f=new fs;f.setAttribute("position",new Lr(l,3)),f.setAttribute("color",new Lr(u,3)),super(f,new ob({vertexColors:!0,toneMapped:!1}))}}function Pwe(t,e,n,r){const i=(function(a,o,l){a*=.5,o*=.5,l*=.5;const u=new fs,d=[];return d.push(-a,-o,-l,-a,o,-l,-a,o,-l,a,o,-l,a,o,-l,a,-o,-l,a,-o,-l,-a,-o,-l,-a,-o,l,-a,o,l,-a,o,l,a,o,l,a,o,l,a,-o,l,a,-o,l,-a,-o,l,-a,-o,-l,-a,-o,l,-a,o,-l,-a,o,l,a,o,-l,a,o,l,a,-o,-l,a,-o,l),u.setAttribute("position",new Lr(d,3)),u})(t,e,n),s=new PS(i,new owe({color:new $t(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var Ux=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),s=i,a=0,o=n(new Ux.Panel("FPS","#0ff","#002")),l=n(new Ux.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Ux.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){a++;var d=(performance||Date).now();if(l.update(d-i,200),d>=s+1e3&&(o.update(1e3*a/(d-s),100),s=d,a=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};Ux.Panel=function(t,e,n){var r=1/0,i=0,s=Math.round,a=s(window.devicePixelRatio||1),o=80*a,l=48*a,u=3*a,d=2*a,f=3*a,g=15*a,m=74*a,x=30*a,y=document.createElement("canvas");y.width=o,y.height=l,y.style.cssText="width:80px;height:48px";var v=y.getContext("2d");return v.font="bold "+9*a+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=n,v.fillRect(0,0,o,l),v.fillStyle=e,v.fillText(t,u,d),v.fillRect(f,g,m,x),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f,g,m,x),{dom:y,update:function(b,E){r=Math.min(r,b),i=Math.max(i,b),v.fillStyle=n,v.globalAlpha=1,v.fillRect(0,0,o,g),v.fillStyle=e,v.fillText(s(b)+" "+t+" ("+s(r)+"-"+s(i)+")",u,d),v.drawImage(y,f+a,g,m-a,x,f,g,m-a,x),v.fillRect(f+m-a,g,a,x),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f+m-a,g,a,s((1-b/E)*x))}}};var Rwe=Ux;class RB{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new _1,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 _1,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 Dwe extends fs{constructor(e=[new De],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const s=new De,a=new De,o=new Yt,l=[],u=[],d=[],f=[];function g(m){const[x,y,v]=(function(b){const E=e[b],S=new De,A=new De,T=new De,P=new De;S.copy(E).sub(e[b-1]||E).normalize().add((e[b+1]||E).clone().sub(E).normalize()).normalize();let C=Number.MAX_VALUE;const I=Math.abs(S.x),N=Math.abs(S.y),D=Math.abs(S.z);return I<=C&&(C=I,A.set(1,0,0)),N<=C&&(C=N,A.set(0,1,0)),D<=C&&A.set(0,0,1),P.crossVectors(S,A).normalize(),A.crossVectors(S,P),T.crossVectors(S,A),[E,A,T]})(m);for(let b=0;b<=i;b++){const E=b/i*Math.PI*2,S=Math.sin(E),A=-Math.cos(E);a.x=A*y.x+S*v.x,a.y=A*y.y+S*v.y,a.z=A*y.z+S*v.z,a.normalize(),u.push(a.x,a.y,a.z),s.x=x.x+n*a.x*.5,s.y=x.y+n*a.y*.5,s.z=x.z+r*a.z*.5,l.push(s.x,s.y,s.z)}}(function(){for(let m=0;m<e.length;m++)g(m);g(closed===!1?e.length-1:0),(function(){for(let m=0;m<e.length;m++)for(let x=0;x<=i;x++)o.x=m/e.length,o.y=x/i,d.push(o.x,o.y)})(),(function(){for(let m=1;m<e.length;m++)for(let x=1;x<=i;x++){const y=(i+1)*(m-1)+(x-1),v=(i+1)*m+(x-1),b=(i+1)*m+x,E=(i+1)*(m-1)+x;f.push(y,v,E),f.push(v,b,E)}})()})(),this.setIndex(f),this.setAttribute("position",new Lr(l,3)),this.setAttribute("normal",new Lr(u,3)),this.setAttribute("uv",new Lr(d,2))}}class Fx{static get initial(){const e=new Fx;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const TT={h:0,s:0,l:0};class Xp{constructor(e){var n,r,i,s,a,o,l,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=Fx.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Xp.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 w1(this.minLayerThreshold),this.scene=new X1e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new $t(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(s=e.renderExtrusion)!==null&&s!==void 0?s:this.renderExtrusion,this.renderTravel=(a=e.renderTravel)!==null&&a!==void 0?a:this.renderTravel,this.nonTravelmoves=(o=e.nonTravelMoves)!==null&&o!==void 0?o:this.nonTravelmoves,this.renderTubes=(l=e.renderTubes)!==null&&l!==void 0?l:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new Rwe: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"+AS),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 dk({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 dk({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new da(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 KR(this._backgroundColor,g,f),this.resize(),this.controls=new Cwe(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?Xp.defaultExtrusionColor:this._extrusionColor instanceof $t?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Xp.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 pwe(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 dwe(13421772,.3*Math.PI),n=new uwe(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 Ex;return n.name=e,n.quaternion.setFromEuler(new sb(-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=Fx.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 ST(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,s,a,o,l,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const g of d.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const m=g;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const m=g,x={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=m.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=m.params.z)!==null&&i!==void 0?i:this.state.z,r:(s=m.params.r)!==null&&s!==void 0?s:this.state.r,e:(a=m.params.e)!==null&&a!==void 0?a:this.state.e,i:(o=m.params.i)!==null&&o!==void 0?o:this.state.i,j:(l=m.params.j)!==null&&l!==void 0?l:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((u=m.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(f,this.state,x,y,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,x,y))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let s=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const a=.1+.7*n/this.layers.length;s.getHSL(TT),s=new $t().setHSL(TT.h,TT.s,a)}if(n==this.layers.length-1){const a=(r=this._topLayerColor)!==null&&r!==void 0?r:s,o=(i=this._lastSegmentColor)!==null&&i!==void 0?i:a,l=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,a.getHex(),e.height),this.addTubeLine([...u,...l],o.getHex(),e.height)):(this.addLine(e.extrusion,a.getHex()),this.addLine([...u,...l],o.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,s.getHex(),e.height):this.addLine(e.extrusion,s.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new kwe(this.buildVolume.x,10,this.buildVolume.y,10));const e=Pwe(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 w1(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Fx.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,s){const a=i?e.extrusion:e.travel,o=n.x,l=n.y,u=n.z,d=r.x,f=r.y,g=r.z;let m=r.r,x=r.i,y=r.j;if(m){const V=d-o,K=f-l,W=Math.sqrt(Math.pow(V/2,2)+Math.pow(K/2,2));m=Math.max(m,W);const ne=Math.pow(V,2)+Math.pow(K,2),Y=Math.pow(m,2)-ne/4;let Z=Math.sqrt(Y/ne);(s&&m<0||!s&&m>0)&&(Z=-Z),x=V/2+K*Z,y=K/2-V*Z}const v=o==d&&l==f,b=o+x,E=l+y,S=Math.sqrt(x*x+y*y),A=Math.atan2(-y,-x),T=Math.atan2(f-E,d-b);let P;v?P=2*Math.PI:(P=s?A-T:T-A,P<0&&(P+=2*Math.PI));let C=S*P/1.8;this.inches&&(C*=25),C<1&&(C=1);let I=P/C;I*=s?-1:1;const N=[];N.push({x:o,y:l,z:u});const D=(u-g)/C;let F=o,L=l,q=u,R=A;for(let V=0;V<C-1;V++)R+=I,F=b+S*Math.cos(R),L=E+S*Math.sin(R),q+=D,N.push({x:F,y:L,z:q});N.push({x:r.x,y:r.y,z:r.z});for(let V=0;V<N.length-1;V++)a.push(N[V].x,N[V].y,N[V].z,N[V+1].x,N[V+1].y,N[V+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new fs;i.setAttribute("position",new Lr(e,3)),this.disposables.push(i);const s=new ob({color:n});this.disposables.push(s);const a=new PS(i,s);(r=this.group)===null||r===void 0||r.add(a)}addTubeLine(e,n,r=.2){let i=[];const s=[];for(let a=0;a<e.length;a+=6){const o=e.slice(a,a+9),l=new De(o[0],o[1],o[2]),u=new De(o[3],o[4],o[5]),d=new De(o[6],o[7],o[8]);i.push(l),u.equals(d)||(i.push(u),s.push(i),i=[])}s.forEach((a=>{var o;const l=new Dwe(a,this.extrusionWidth,this.lineHeight||r,4);(o=this._geometries)[n]||(o[n]=[]),this._geometries[n].push(l)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new fW;this.disposables.push(i);const s=new hW({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const a=new Nwe(i,s);(r=this.group)===null||r===void 0||r.add(a)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>ST(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 awe({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((o,l)=>3*l.attributes.position.count+o),0),a=new rwe(r.length,s,void 0,i);return this.disposables.push(a),(n=this.group)===null||n===void 0||n.add(a),a}_readFromStream(e){var n,r;return ST(this,void 0,void 0,(function*(){const i=e.getReader();let s,a="",o=0;do{console.debug("reading from stream"),s=yield i.read(),o+=(r=(n=s.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(l=s.value,new TextDecoder("utf-8").decode(l)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(a+f),a=u.slice(d)}while(!s.done);var l;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new RB(this):typeof this.devMode=="object"&&(this.devGui=new RB(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())}}Xp.defaultExtrusionColor=new $t("hotpink");const Owe=function(t){return new Xp(t)};function jwe({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=M.useRef(null),i=M.useRef(null),[s,a]=M.useState(!0),[o,l]=M.useState(null),[u,d]=M.useState(!1),[f,g]=M.useState(0),[m,x]=M.useState(0);M.useEffect(()=>{if(!r.current)return;const b=r.current,E=Owe({canvas:b,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:44610,topLayerColor:65370,lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});i.current=E,a(!0),l(null),d(!1),fetch(t).then(async A=>{if(!A.ok)throw A.status===404&&(await A.json().catch(()=>({}))).detail?.includes("sliced")?(d(!0),new Error("not_sliced")):new Error("Failed to load G-code");return A.text()}).then(A=>{E.processGCode(A);const T=E.layers?.length||0;x(T),g(T),E.render(),a(!1)}).catch(A=>{l(A.message),a(!1)});const S=()=>{if(b.parentElement){const A=b.parentElement.getBoundingClientRect();b.width=A.width,b.height=A.height,E.resize()}};return S(),window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S),E.dispose()}},[t,e]);const y=b=>{if(!i.current)return;const E=Math.max(1,Math.min(b,m));g(E),i.current.render()},v=b=>{y(parseInt(b.target.value,10))};return c.jsxs("div",{className:`relative flex flex-col h-full ${n}`,children:[c.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[c.jsx("canvas",{ref:r,className:"w-full h-full"}),s&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:c.jsxs("div",{className:"text-center",children:[c.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),c.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),u&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:c.jsxs("div",{className:"text-center max-w-sm px-4",children:[c.jsx(yoe,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),c.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),c.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing the model in Bambu Studio or Orca Slicer."})]})}),o&&!u&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:c.jsx("div",{className:"text-center text-red-400",children:c.jsx("p",{className:"text-sm",children:o})})})]}),!s&&!o&&!u&&m>0&&c.jsx("div",{className:"mt-4 px-2",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Oh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),c.jsx("button",{onClick:()=>y(f-1),disabled:f<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:c.jsx(Rh,{className:"w-4 h-4"})}),c.jsx("input",{type:"range",min:1,max:m,value:f,onChange:v,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),c.jsx("button",{onClick:()=>y(f+1),disabled:f>=m,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:c.jsx(tf,{className:"w-4 h-4"})}),c.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[f," / ",m]})]})})]})}function Lwe({archiveId:t,title:e,onClose:n}){const[r,i]=M.useState(null),[s,a]=M.useState(null),[o,l]=M.useState(!0);M.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),M.useEffect(()=>{Pe.getArchiveCapabilities(t).then(d=>{a(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),l(!1)}).catch(()=>{a({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256}}),i("3d"),l(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${Pe.getArchiveForSlicer(t,d)}`;window.location.href=`bambustudioopen://${encodeURIComponent(f)}`};return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:u,children:[c.jsx(ro,{className:"w-4 h-4"}),"Open in Slicer"]}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,children:c.jsx(Gt,{className:"w-5 h-5"})})]})]}),s&&c.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[c.jsxs("button",{onClick:()=>s.has_model&&i("3d"),disabled:!s.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":s.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[c.jsx(rm,{className:"w-4 h-4"}),"3D Model",!s.has_model&&c.jsx("span",{className:"text-xs",children:"(not available)"})]}),c.jsxs("button",{onClick:()=>s.has_gcode&&i("gcode"),disabled:!s.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":s.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[c.jsx(Kae,{className:"w-4 h-4"}),"G-code Preview",!s.has_gcode&&c.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),c.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?c.jsx("div",{className:"w-full h-full flex items-center justify-center",children:c.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&s?c.jsx(Pxe,{url:Pe.getArchiveDownload(t),buildVolume:s.build_volume,className:"w-full h-full"}):r==="gcode"&&s?c.jsx(jwe,{gcodeUrl:Pe.getArchiveGcode(t),buildVolume:s.build_volume,className:"w-full h-full"}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function Iwe({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const[i,s]=M.useState(null);M.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]);const{data:a,isLoading:o}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),l=_t({mutationFn:()=>{if(!i)throw new Error("No printer selected");return Pe.reprintArchive(t,i)},onSuccess:()=>{r(),n()}}),u=a?.filter(d=>d.is_active)||[];return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:c.jsx(Nt,{className:"w-full max-w-md",children:c.jsxs(Dt,{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",c.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?c.jsx("div",{className:"flex justify-center py-8",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u.length===0?c.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):c.jsx("div",{className:"space-y-2 mb-6",children:u.map(d=>c.jsxs("button",{onClick:()=>s(d.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${i===d.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[c.jsx("div",{className:`p-2 rounded-lg ${i===d.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:c.jsx(jo,{className:`w-5 h-5 ${i===d.id?"text-bambu-green":"text-bambu-gray"}`})}),c.jsxs("div",{className:"text-left",children:[c.jsx("p",{className:"text-white font-medium",children:d.name}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.model||"Unknown model"," • ",d.ip_address]})]})]},d.id))}),l.isError&&c.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:l.error.message||"Failed to start print"}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx(Ie,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{onClick:()=>l.mutate(),disabled:!i||l.isPending,className:"flex-1",children:l.isPending?c.jsxs(c.Fragment,{children:[c.jsx(At,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):c.jsxs(c.Fragment,{children:[c.jsx(jo,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function Uwe({onClose:t,initialFiles:e}){const n=Sn(),{showToast:r}=ri(),i=M.useRef(null),[s,a]=M.useState(()=>e?.filter(C=>C.name.endsWith(".3mf")).map(C=>({file:C,status:"pending"}))||[]),[o,l]=M.useState(!1),[u,d]=M.useState(),[f,g]=M.useState(null);M.useEffect(()=>{const C=I=>{I.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]);const{data:m}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),x=_t({mutationFn:C=>Pe.uploadArchivesBulk(C,u),onSuccess:C=>{g(C),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),a(I=>I.map(N=>{const D=C.results.find(L=>L.filename===N.file.name),F=C.errors.find(L=>L.filename===N.file.name);return D?{...N,status:"success",archiveId:D.id}:F?{...N,status:"error",error:F.error}:N})),C.failed===0?r(`${C.uploaded} file${C.uploaded!==1?"s":""} uploaded`):C.uploaded===0?r(`Failed to upload ${C.failed} file${C.failed!==1?"s":""}`,"error"):r(`${C.uploaded} uploaded, ${C.failed} failed`,"warning")},onError:()=>{a(C=>C.map(I=>({...I,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=M.useCallback(C=>{C.preventDefault(),l(!0)},[]),v=M.useCallback(C=>{C.preventDefault(),l(!1)},[]),b=M.useCallback(C=>{C.preventDefault(),l(!1);const I=Array.from(C.dataTransfer.files).filter(N=>N.name.endsWith(".3mf"));I.length>0&&a(N=>[...N,...I.map(D=>({file:D,status:"pending"}))])},[]),E=M.useCallback(C=>{const I=Array.from(C.target.files||[]).filter(N=>N.name.endsWith(".3mf"));I.length>0&&a(N=>[...N,...I.map(D=>({file:D,status:"pending"}))]),i.current&&(i.current.value="")},[]),S=M.useCallback(C=>{a(I=>I.filter((N,D)=>D!==C))},[]),A=()=>{if(s.length===0)return;const C=s.filter(I=>I.status==="pending");C.length!==0&&(a(I=>I.map(N=>N.status==="pending"?{...N,status:"uploading"}:N)),x.mutate(C.map(I=>I.file)))},T=s.filter(C=>C.status==="pending").length,P=x.isPending;return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsx(Nt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:c.jsxs(Dt,{className:"p-0 flex flex-col h-full",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),c.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsx("div",{className:"p-4",children:c.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:y,onDragLeave:v,onDrop:b,children:[c.jsx(ma,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),c.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),c.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),c.jsx(Ie,{variant:"secondary",onClick:()=>i.current?.click(),disabled:P,children:"Browse Files"}),c.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:E})]})}),c.jsxs("div",{className:"px-4 pb-4",children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),c.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u||"",onChange:C=>d(C.target.value?Number(C.target.value):void 0),disabled:P,children:[c.jsx("option",{value:"",children:"No printer"}),m?.map(C=>c.jsx("option",{value:C.id,children:C.name},C.id))]})]}),s.length>0&&c.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:c.jsx("div",{className:"space-y-2",children:s.map((C,I)=>c.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[c.jsx(kG,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),c.jsx("span",{className:"flex-1 text-white text-sm truncate",children:C.file.name}),c.jsxs("span",{className:"text-xs text-bambu-gray",children:[(C.file.size/(1024*1024)).toFixed(1)," MB"]}),C.status==="pending"&&c.jsx("button",{onClick:()=>S(I),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:P,children:c.jsx(Gt,{className:"w-4 h-4"})}),C.status==="uploading"&&c.jsx(At,{className:"w-4 h-4 text-bambu-green animate-spin"}),C.status==="success"&&c.jsx(ds,{className:"w-4 h-4 text-bambu-green"}),C.status==="error"&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs text-red-400",children:C.error}),c.jsx(Oo,{className:"w-4 h-4 text-red-400"})]})]},`${C.file.name}-${I}`))})}),f&&c.jsx("div",{className:"px-4 pb-4",children:c.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:c.jsxs("p",{className:"text-sm text-white",children:[c.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&c.jsxs(c.Fragment,{children:[", ",c.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),c.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[c.jsx(Ie,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&c.jsx(Ie,{onClick:A,disabled:T===0||P,className:"flex-1",children:P?c.jsxs(c.Fragment,{children:[c.jsx(At,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):c.jsxs(c.Fragment,{children:[c.jsx(ma,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const Fwe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"];function zwe({archive:t,onClose:e,existingTags:n=[]}){M.useEffect(()=>{const U=$=>{$.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const r=Sn(),[i,s]=M.useState(t.print_name||""),[a,o]=M.useState(t.printer_id),[l,u]=M.useState(t.project_id??null),[d,f]=M.useState(t.notes||""),[g,m]=M.useState(t.tags||""),[x,y]=M.useState(t.failure_reason||""),[v,b]=M.useState(t.photos||[]),[E,S]=M.useState(!1),[A,T]=M.useState(!1),P=M.useRef(null),C=M.useRef(null),I=M.useRef(null),{data:N}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:D}=yt({queryKey:["projects"],queryFn:()=>Pe.getProjects()}),{data:F}=yt({queryKey:["archives"],queryFn:()=>Pe.getArchives(void 0,1e3,0),enabled:n.length===0}),L=n.length>0?n:[...new Set(F?.flatMap(U=>U.tags?.split(",").map($=>$.trim())||[]).filter(Boolean)||[])].sort(),q=g.split(",").map(U=>U.trim()).filter(Boolean),R=L.filter(U=>!q.includes(U)),V=U=>{if(!q.includes(U)){const $=[...q,U].join(", ");m($)}I.current!==null&&clearTimeout(I.current),P.current?.focus()},K=U=>{const $=q.filter(ee=>ee!==U).join(", ");m($)},W=_t({mutationFn:U=>Pe.updateArchive(t.id,U),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),ne=async U=>{const $=U.target.files?.[0];if($){S(!0);try{const ee=await Pe.uploadArchivePhoto(t.id,$);b(ee.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ee){console.error("Failed to upload photo:",ee)}finally{S(!1),C.current&&(C.current.value="")}}},Y=async U=>{try{const $=await Pe.deleteArchivePhoto(t.id,U);b($.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch($){console.error("Failed to delete photo:",$)}},Z=U=>{U.preventDefault(),W.mutate({print_name:i||void 0,printer_id:a,project_id:l,notes:d||void 0,tags:g||void 0,failure_reason:t.status==="failed"&&x||void 0})};return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:U=>U.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:Z,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),c.jsx("input",{type:"text",value:i,onChange:U=>s(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),c.jsxs("select",{value:a??"",onChange:U=>o(U.target.value?Number(U.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"",children:"No printer"}),N?.map(U=>c.jsx("option",{value:U.id,children:U.name},U.id))]})]}),c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[c.jsx(ph,{className:"w-4 h-4 inline mr-1"}),"Project"]}),c.jsxs("select",{value:l??"",onChange:U=>u(U.target.value?Number(U.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"",children:"No project"}),D?.map(U=>c.jsx("option",{value:U.id,children:U.name},U.id))]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),c.jsx("textarea",{value:d,onChange:U=>f(U.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:"Add notes about this print..."})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),q.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:q.map(U=>c.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[c.jsx(f0,{className:"w-3 h-3"}),U,c.jsx("button",{type:"button",onClick:()=>K(U),className:"ml-0.5 text-bambu-gray hover:text-white",children:c.jsx(Gt,{className:"w-3 h-3"})})]},U))}),c.jsxs("div",{className:"relative",children:[c.jsx("input",{ref:P,type:"text",value:g,onChange:U=>m(U.target.value),onFocus:()=>{I.current!==null&&clearTimeout(I.current),T(!0)},onBlur:()=>{I.current=window.setTimeout(()=>T(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:q.length>0?"Add more tags...":"Add tags..."}),A&&R.length>0&&c.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[c.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),c.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:R.map(U=>c.jsx("button",{type:"button",onClick:()=>V(U),className:"px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors",children:U},U))})]})]})]}),t.status==="failed"&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),c.jsxs("select",{value:x,onChange:U=>y(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"",children:"Select reason..."}),Fwe.map(U=>c.jsx("option",{value:U,children:U},U))]})]}),c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[c.jsx(a0,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),c.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[v.map(U=>c.jsxs("div",{className:"relative group",children:[c.jsx("img",{src:Pe.getArchivePhotoUrl(t.id,U),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),c.jsx("button",{type:"button",onClick:()=>Y(U),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:c.jsx(kn,{className:"w-3 h-3 text-white"})})]},U)),c.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[c.jsx("input",{ref:C,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:ne,className:"hidden",disabled:E}),E?c.jsx(At,{className:"w-6 h-6 text-bambu-gray animate-spin"}):c.jsx(fr,{className:"w-6 h-6 text-bambu-gray"})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{type:"submit",disabled:W.isPending,className:"flex-1",children:[c.jsx(To,{className:"w-4 h-4"}),W.isPending?"Saving...":"Save"]})]})]})]})})}function Bwe({x:t,y:e,items:n,onClose:r}){const i=M.useRef(null),[s,a]=M.useState(null),o=M.useRef(null);M.useEffect(()=>{const d=m=>{i.current&&!i.current.contains(m.target)&&r()},f=m=>{m.key==="Escape"&&r()},g=()=>{r()};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),document.addEventListener("scroll",g,!0),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f),document.removeEventListener("scroll",g,!0),o.current&&clearTimeout(o.current)}},[r]),M.useEffect(()=>{if(i.current){const d=i.current.getBoundingClientRect(),f=window.innerWidth,g=window.innerHeight;let m=t,x=e;t+d.width>f&&(m=f-d.width-8),e+d.height>g&&(x=g-d.height-8),i.current.style.left=`${m}px`,i.current.style.top=`${x}px`}},[t,e]);const l=d=>{o.current&&(clearTimeout(o.current),o.current=null),a(d)},u=()=>{o.current=window.setTimeout(()=>{a(null)},150)};return c.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:t,top:e},children:n.map((d,f)=>{if(d.divider)return c.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},f);const g=d.submenu&&d.submenu.length>0;return c.jsxs("div",{className:"relative",onMouseEnter:()=>g&&l(f),onMouseLeave:()=>g&&u(),children:[c.jsxs("button",{onClick:()=>{g?a(s===f?null:f):d.disabled||(d.onClick(),r())},disabled:d.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${d.disabled?"text-bambu-gray cursor-not-allowed":d.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${g&&s===f?"bg-bambu-dark-tertiary":""}`,children:[d.icon&&c.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:d.icon}),c.jsx("span",{className:"flex-1",children:d.label}),g&&c.jsx(tf,{className:"w-4 h-4 text-bambu-gray"})]}),g&&s===f&&c.jsx("div",{className:"absolute left-full top-0 ml-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60]",onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null)},onMouseLeave:()=>u(),children:d.submenu.map((m,x)=>c.jsxs("button",{onClick:()=>{m.disabled||(m.onClick(),r())},disabled:m.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${m.disabled?"text-bambu-gray cursor-not-allowed":m.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[m.icon&&c.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:m.icon}),m.label]},x))})]},f)})})}function Hwe({selectedIds:t,existingTags:e,onClose:n}){const r=Sn(),{showToast:i}=ri(),[s,a]=M.useState(""),[o,l]=M.useState(new Set),[u,d]=M.useState("add");M.useEffect(()=>{const y=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const f=_t({mutationFn:async()=>{const y=Array.from(o);let v=0;for(const b of t)try{const E=await Pe.getArchive(b),S=E.tags?E.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...S,...y])]:A=S.filter(T=>!o.has(T)),await Pe.updateArchive(b,{tags:A.join(", ")}),v++}catch(E){throw console.error(`Failed to update archive ${b}:`,E),new Error(`Failed on archive ${b}: ${E instanceof Error?E.message:"Unknown error"}`)}return{count:v,mode:u,tags:y}},onSuccess:({count:y,mode:v,tags:b})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${v==="add"?"Added":"Removed"} ${b.length} tag${b.length!==1?"s":""} ${v==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),g=y=>{l(v=>{const b=new Set(v);return b.has(y)?b.delete(y):b.add(y),b})},m=()=>{s.trim()&&!o.has(s.trim())&&(l(y=>new Set([...y,s.trim()])),a(""))},x=y=>{y.key==="Enter"&&(y.preventDefault(),m())};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsx(Nt,{className:"w-full max-w-md",children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(f0,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),c.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"p-4 space-y-4",children:[c.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),c.jsx(Ie,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&c.jsxs("div",{className:"flex gap-2",children:[c.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:s,onChange:y=>a(y.target.value),onKeyDown:x}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:m,disabled:!s.trim(),children:c.jsx(fr,{className:"w-4 h-4"})})]}),e.length>0&&c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>c.jsx("button",{onClick:()=>g(y),className:`px-2 py-1 rounded text-sm transition-colors ${o.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),o.size>0&&c.jsxs("div",{children:[c.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),c.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(y=>c.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,c.jsx("button",{onClick:()=>g(y),className:"hover:opacity-70",children:c.jsx(Gt,{className:"w-3 h-3"})})]},y))})]})]}),c.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[c.jsx(Ie,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{onClick:()=>f.mutate(),disabled:o.size===0||f.isPending,className:"flex-1",children:f.isPending?c.jsxs(c.Fragment,{children:[c.jsx(At,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):c.jsxs(c.Fragment,{children:[c.jsx(f0,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function $we(t,e){return new Date(t,e+1,0).getDate()}function Vwe(t,e){return new Date(t,e,1).getDay()}const Gwe=["January","February","March","April","May","June","July","August","September","October","November","December"],Wwe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function qwe({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=M.useState(n.getMonth()),[s,a]=M.useState(n.getFullYear()),[o,l]=M.useState(null),u=M.useMemo(()=>{const b=new Map;return t.forEach(E=>{const S=new Date(E.completed_at||E.created_at),A=`${S.getFullYear()}-${String(S.getMonth()+1).padStart(2,"0")}-${String(S.getDate()).padStart(2,"0")}`,T=b.get(A)||[];T.push(E),b.set(A,T)}),b},[t]),d=$we(s,r),f=Vwe(s,r),g=()=>{r===0?(i(11),a(s-1)):i(r-1)},m=()=>{r===11?(i(0),a(s+1)):i(r+1)},x=()=>{i(n.getMonth()),a(n.getFullYear())},y=[];for(let b=0;b<f;b++)y.push(null);for(let b=1;b<=d;b++)y.push(b);const v=o?u.get(o)||[]:[];return c.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Rh,{className:"w-5 h-5 text-bambu-gray"})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white",children:[Gwe[r]," ",s]}),c.jsx("button",{onClick:x,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),c.jsx("button",{onClick:m,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(tf,{className:"w-5 h-5 text-bambu-gray"})})]}),c.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:Wwe.map(b=>c.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:b},b))}),c.jsx("div",{className:"grid grid-cols-7 gap-1",children:y.map((b,E)=>{if(b===null)return c.jsx("div",{className:"aspect-square"},`empty-${E}`);const S=`${s}-${String(r+1).padStart(2,"0")}-${String(b).padStart(2,"0")}`,A=u.get(S)||[],T=A.length>0,P=b===n.getDate()&&r===n.getMonth()&&s===n.getFullYear(),C=S===o,I=A.filter(D=>D.status==="completed").length,N=A.filter(D=>D.status==="failed").length;return c.jsxs("button",{onClick:()=>l(C?null:S),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${C?"bg-bambu-green text-white":P?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":T?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[c.jsx("span",{className:`text-sm font-medium ${P&&!C?"text-bambu-green":""}`,children:b}),T&&c.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[c.jsx("div",{className:`w-2 h-2 rounded-full ${N>0&&I===0?"bg-red-400":N>0?"bg-yellow-400":"bg-green-400"}`}),c.jsx("span",{className:"text-xs font-medium",children:A.length})]})]},b)})}),c.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:c.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===s}).length}),c.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===s&&b.status==="completed"}).length}),c.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===s&&b.status==="failed"}).length}),c.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),c.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?c.jsxs(c.Fragment,{children:[c.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(o+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),v.length>0?c.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:v.map(b=>c.jsxs("button",{onClick:()=>e?.(b),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[b.thumbnail_path?c.jsx("img",{src:Pe.getArchiveThumbnail(b.id),alt:"",className:"w-12 h-12 rounded object-cover"}):c.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:c.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-sm text-white truncate",children:b.print_name||b.filename}),c.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[c.jsx("span",{className:b.status==="failed"?"text-red-400":"text-green-400",children:b.status==="failed"?"Failed":"Completed"}),b.filament_color&&c.jsx("div",{className:"flex gap-0.5",children:b.filament_color.split(",").map((E,S)=>c.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},S))})]})]})]},b.id))}):c.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):c.jsx("div",{className:"text-center py-8",children:c.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function Kwe({archiveId:t,archiveName:e,onClose:n}){const r=Pe.getArchiveQRCodeUrl(t,300);M.useEffect(()=>{const s=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=()=>{const s=document.createElement("a");s.href=r,s.download=`${e}_qrcode.png`,s.click()};return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),c.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"p-6 flex flex-col items-center",children:[c.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),c.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:c.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),c.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),c.jsxs(Ie,{onClick:i,className:"w-full",children:[c.jsx(ya,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Xwe({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,a]=M.useState(0),[o,l]=M.useState(!1);if(M.useEffect(()=>{const m=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&a(y=>Math.max(0,y-1)),x.key==="ArrowRight"&&a(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),M.useEffect(()=>{s>=n.length&&a(Math.max(0,n.length-1))},[n.length,s]),n.length===0)return r(),null;const u=n[s],d=Pe.getArchivePhotoUrl(t,u),f=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${s+1}.jpg`,m.click()},g=()=>{i&&l(!0)};return c.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[c.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),c.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",s+1," of ",n.length]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:f,children:[c.jsx(ya,{className:"w-4 h-4"}),"Download"]}),i&&c.jsx(Ie,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:c.jsx(kn,{className:"w-4 h-4"})}),c.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-6 h-6"})})]})]}),c.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[s>0&&c.jsx("button",{onClick:()=>a(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:c.jsx(Rh,{className:"w-8 h-8 text-white"})}),c.jsx("img",{src:d,alt:`Photo ${s+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),s<n.length-1&&c.jsx("button",{onClick:()=>a(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:c.jsx(tf,{className:"w-8 h-8 text-white"})})]}),n.length>1&&c.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,x)=>c.jsx("button",{onClick:()=>a(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===s?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:c.jsx("img",{src:Pe.getArchivePhotoUrl(t,m),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},m))})]}),o&&c.jsx(Kr,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),l(!1)},onCancel:()=>l(!1)})]})}function qi(t){this.content=t}qi.prototype={constructor:qi,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new qi(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new qi(n)},addToStart:function(t,e){return new qi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new qi(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new qi(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=qi.from(t),t.size?new qi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=qi.from(t),t.size?new qi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=qi.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}};qi.from=function(t){if(t instanceof qi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new qi(e)};function pW(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let a=0;i.text[a]==s.text[a];a++)n++;return n}if(i.content.size||s.content.size){let a=pW(i.content,s.content,n+1);if(a!=null)return a}n+=i.nodeSize}}function mW(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let a=t.child(--i),o=e.child(--s),l=a.nodeSize;if(a==o){n-=l,r-=l;continue}if(!a.sameMarkup(o))return{a:n,b:r};if(a.isText&&a.text!=o.text){let u=0,d=Math.min(a.text.length,o.text.length);for(;u<d&&a.text[a.text.length-u-1]==o.text[o.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(a.content.size||o.content.size){let u=mW(a.content,o.content,n-1,r-1);if(u)return u}n-=l,r-=l}}class pt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){for(let a=0,o=0;o<n;a++){let l=this.content[a],u=o+l.nodeSize;if(u>e&&r(l,i+o,s||null,a)!==!1&&l.content.size){let d=o+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,n-d),r,i+d)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",a=!0;return this.nodesBetween(e,n,(o,l)=>{let u=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(a?a=!1:s+=r),s+=u},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new pt(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,a=0;a<n;s++){let o=this.content[s],l=a+o.nodeSize;l>e&&((a<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-a),Math.min(o.text.length,n-a)):o=o.cut(Math.max(0,e-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=l}return new pt(r,i)}cutByIndex(e,n){return e==n?pt.empty:e==0&&n==this.content.length?this:new pt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new pt(i,s)}addToStart(e){return new pt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new pt(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return pW(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return mW(this,e,n,r)}findIndex(e){if(e==0)return e_(0,e);if(e==this.size)return e_(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?e_(n+1,s):e_(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return pt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new pt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return pt.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new pt(n||e,r)}static from(e){if(!e)return pt.empty;if(e instanceof pt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new pt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}pt.empty=new pt([],0);const CT={index:0,offset:0};function e_(t,e){return CT.index=t,CT.offset=e,CT}function S1(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(!S1(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!S1(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Qn=class pk{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&S1(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 pk.none;if(e instanceof pk)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Qn.none=[];class E1 extends Error{}class Tt{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=xW(this.content,e+this.openStart,n);return r&&new Tt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Tt(gW(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 Tt.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 Tt(pt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Tt(e,r,i)}}Tt.empty=new Tt(pt.empty,0,0);function gW(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:a,offset:o}=t.findIndex(n);if(i==e||s.isText){if(o!=n&&!t.child(a).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=a)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(gW(s.content,e-i-1,n-i-1)))}function xW(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),a=t.maybeChild(i);if(s==e||a.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=xW(a.content,e-s-1,n,a);return o&&t.replaceChild(i,a.copy(o))}function Ywe(t,e,n){if(n.openStart>t.depth)throw new E1("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new E1("Inconsistent open depths");return bW(t,e,n,0)}function bW(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let a=bW(t,e,n,r+1);return s.copy(s.content.replaceChild(i,a))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let a=t.parent,o=a.content;return vh(a,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:a,end:o}=Zwe(n,t);return vh(s,yW(t,a,o,e,r))}else return vh(s,M1(t,e,r))}function vW(t,e){if(!e.type.compatibleContent(t.type))throw new E1("Cannot join "+e.type.name+" onto "+t.type.name)}function mk(t,e,n){let r=t.node(n);return vW(r,e.node(n)),r}function bh(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 zx(t,e,n,r){let i=(e||t).node(n),s=0,a=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(bh(t.nodeAfter,r),s++));for(let o=s;o<a;o++)bh(i.child(o),r);e&&e.depth==n&&e.textOffset&&bh(e.nodeBefore,r)}function vh(t,e){return t.type.checkContent(e),t.copy(e)}function yW(t,e,n,r,i){let s=t.depth>i&&mk(t,e,i+1),a=r.depth>i&&mk(n,r,i+1),o=[];return zx(null,t,i,o),s&&a&&e.index(i)==n.index(i)?(vW(s,a),bh(vh(s,yW(t,e,n,r,i+1)),o)):(s&&bh(vh(s,M1(t,e,i+1)),o),zx(e,n,i,o),a&&bh(vh(a,M1(n,r,i+1)),o)),zx(r,null,i,o),new pt(o)}function M1(t,e,n){let r=[];if(zx(null,t,n,r),t.depth>n){let i=mk(t,e,n+1);bh(vh(i,M1(t,e,n+1)),r)}return zx(e,null,n,r),new pt(r)}function Zwe(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(pt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class M0{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Qn.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let o=r;r=i,i=o}let s=r.marks;for(var a=0;a<s.length;a++)s[a].type.spec.inclusive===!1&&(!i||!s[a].isInSet(i.marks))&&(s=s[a--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new A1(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let a=e;;){let{index:o,offset:l}=a.content.findIndex(s),u=s-l;if(r.push(a,o,i+l),!u||(a=a.child(o),a.isText))break;s=u-1,i+=l+1}return new M0(n,r,s)}static resolveCached(e,n){let r=DB.get(e);if(r)for(let s=0;s<r.elts.length;s++){let a=r.elts[s];if(a.pos==n)return a}else DB.set(e,r=new Qwe);let i=r.elts[r.i]=M0.resolve(e,n);return r.i=(r.i+1)%Jwe,i}}class Qwe{constructor(){this.elts=[],this.i=0}}const Jwe=12,DB=new WeakMap;class A1{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 eSe=Object.create(null);let Wu=class gk{constructor(e,n,r,i=Qn.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&&S1(this.attrs,n||e.defaultAttrs||eSe)&&Qn.sameSet(this.marks,r||Qn.none)}copy(e=null){return e==this.content?this:new gk(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new gk(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 Tt.empty;let i=this.resolve(e),s=this.resolve(n),a=r?0:i.sharedDepth(n),o=i.start(a),u=i.node(a).content.cut(i.pos-o,s.pos-o);return new Tt(u,i.depth-a,s.depth-a)}replace(e,n,r){return Ywe(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 M0.resolveCached(this,e)}resolveNoCache(e){return M0.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),_W(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=pt.empty,i=0,s=r.childCount){let a=this.contentMatchAt(e).matchFragment(r,i,s),o=a&&a.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=i;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),a=s&&s.matchFragment(this.content,n);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Qn.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(!Qn.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=pt.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Wu.prototype.text=void 0;class T1 extends Wu{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):_W(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 T1(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new T1(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 _W(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Hh{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new tSe(e,n);if(r.next==null)return Hh.empty;let i=wW(r);r.next&&r.err("Unexpected trailing text");let s=lSe(oSe(i));return cSe(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function s(a,o){let l=a.matchFragment(e,r);if(l&&(!n||l.validEnd))return pt.from(o.map(u=>u.createAndFill()));for(let u=0;u<a.next.length;u++){let{type:d,next:f}=a.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let g=s(f,o.concat(d));if(g)return g}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let a=[];for(let o=i;o.type;o=o.via)a.push(o.type);return a.reverse()}for(let a=0;a<s.next.length;a++){let{type:o,next:l}=s.next[a];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let a=0;a<r.next.length;a++)s+=(a?", ":"")+r.next[a].type.name+"->"+e.indexOf(r.next[a].next);return s}).join(`
- `)}}Hh.empty=new Hh(!0);class tSe{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 wW(t){let e=[];do e.push(nSe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function nSe(t){let e=[];do e.push(rSe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function rSe(t){let e=aSe(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=iSe(t,e);else break;return e}function OB(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function iSe(t,e){let n=OB(t),r=n;return t.eat(",")&&(t.next!="}"?r=OB(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function sSe(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let a=n[s];a.isInGroup(e)&&i.push(a)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function aSe(t){if(t.eat("(")){let e=wW(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=sSe(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 oSe(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(a,o,l){let u={term:l,to:o};return e[a].push(u),u}function i(a,o){a.forEach(l=>l.to=o)}function s(a,o){if(a.type=="choice")return a.exprs.reduce((l,u)=>l.concat(s(u,o)),[]);if(a.type=="seq")for(let l=0;;l++){let u=s(a.exprs[l],o);if(l==a.exprs.length-1)return u;i(u,o=n())}else if(a.type=="star"){let l=n();return r(o,l),i(s(a.expr,l),l),[r(l)]}else if(a.type=="plus"){let l=n();return i(s(a.expr,o),l),i(s(a.expr,l),l),[r(l)]}else{if(a.type=="opt")return[r(o)].concat(s(a.expr,o));if(a.type=="range"){let l=o;for(let u=0;u<a.min;u++){let d=n();i(s(a.expr,l),d),l=d}if(a.max==-1)i(s(a.expr,l),l);else for(let u=a.min;u<a.max;u++){let d=n();r(l,d),i(s(a.expr,l),d),l=d}return[r(l)]}else{if(a.type=="name")return[r(o,void 0,a.value)];throw new Error("Unknown expr type")}}}}function SW(t,e){return e-t}function jB(t,e){let n=[];return r(e),n.sort(SW);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let a=0;a<s.length;a++){let{term:o,to:l}=s[a];!o&&n.indexOf(l)==-1&&r(l)}}}function lSe(t){let e=Object.create(null);return n(jB(t,0));function n(r){let i=[];r.forEach(a=>{t[a].forEach(({term:o,to:l})=>{if(!o)return;let u;for(let d=0;d<i.length;d++)i[d][0]==o&&(u=i[d][1]);jB(t,l).forEach(d=>{u||i.push([o,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let s=e[r.join(",")]=new Hh(r.indexOf(t.length-1)>-1);for(let a=0;a<i.length;a++){let o=i[a][1].sort(SW);s.next.push({type:i[a][0],next:e[o.join(",")]||n(o)})}return s}}function cSe(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,a=[];for(let o=0;o<i.next.length;o++){let{type:l,next:u}=i.next[o];a.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(u)==-1&&r.push(u)}s&&e.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function EW(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 MW(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function AW(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let s=t[i];s.validate&&s.validate(e[i])}}function TW(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new dSe(t,r,e[r]);return n}let LB=class CW{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=TW(e,r.attrs),this.defaultAttrs=EW(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==Hh.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:MW(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Wu(this,this.computeAttrs(e),pt.from(n),Qn.setFrom(r))}createChecked(e=null,n,r){return n=pt.from(n),this.checkContent(n),new Wu(this,this.computeAttrs(e),n,Qn.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=pt.from(n),n.size){let a=this.contentMatch.fillBefore(n);if(!a)return null;n=a.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(pt.empty,!0);return s?new Wu(this,e,n.append(s),Qn.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){AW(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Qn.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,a)=>r[s]=new CW(s,n,a));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function uSe(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class dSe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?uSe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class RS{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=TW(e,i.attrs),this.excluded=null;let s=EW(this.attrs);this.instance=s?new Qn(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Qn(this,MW(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,a)=>r[s]=new RS(s,i++,n,a)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){AW(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class NW{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=qi.from(e.nodes),n.marks=qi.from(e.marks||{}),this.nodes=LB.compile(this.spec.nodes,this),this.marks=RS.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],a=s.spec.content||"",o=s.spec.marks;if(s.contentMatch=r[a]||(r[a]=Hh.parse(a,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=o=="_"?null:o?IB(this,o.split(" ")):o==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],a=s.spec.excludes;s.excluded=a==null?[s]:a==""?[]:IB(this,a.split(" "))}this.nodeFromJSON=i=>Wu.fromJSON(this,i),this.markFromJSON=i=>Qn.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 LB){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 T1(r,r.defaultAttrs,e,Qn.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 IB(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],a=s;if(s)n.push(s);else for(let o in t.marks){let l=t.marks[o];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(a=l)}if(!a)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function hSe(t){return t.tag!=null}function fSe(t){return t.style!=null}let Bx=class xk{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(hSe(i))this.tags.push(i);else if(fSe(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new FB(this,n,!1);return r.addAll(e,Qn.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new FB(this,n,!0);return r.addAll(e,Qn.none,n.from,n.to),Tt.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(gSe(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let a=s.getAttrs(e);if(a===!1)continue;s.attrs=a||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let a=this.styles[s],o=a.style;if(!(o.indexOf(e)!=0||a.context&&!r.matchesContext(a.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(a.getAttrs){let l=a.getAttrs(n);if(l===!1)continue;a.attrs=l||void 0}return a}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,a=0;for(;a<n.length;a++){let o=n[a];if((o.priority==null?50:o.priority)<s)break}n.splice(a,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(a=>{r(a=zB(a)),a.mark||a.ignore||a.clearMark||(a.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(a=>{r(a=zB(a)),a.node||a.ignore||a.mark||(a.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new xk(e,xk.schemaRules(e)))}};const kW={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},pSe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},PW={ol:!0,ul:!0},A0=1,bk=2,Hx=4;function UB(t,e,n){return e!=null?(e?A0:0)|(e==="full"?bk:0):t&&t.whitespace=="pre"?A0|bk:n&~Hx}class t_{constructor(e,n,r,i,s,a){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=a,this.content=[],this.activeMarks=Qn.none,this.match=s||(a&Hx?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&A0)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=pt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(pt.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!kW.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class FB{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,a=UB(null,n.preserveWhitespace,0)|(r?Hx:0);i?s=new t_(i.type,i.attrs,Qn.none,!0,n.topMatch||i.type.contentMatch,a):r?s=new t_(null,null,Qn.none,!0,null,a):s=new t_(e.schema.topNodeType,null,Qn.none,!0,null,a),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,s=i.options&bk?"full":this.localPreserveWS||(i.options&A0)>0,{schema:a}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
- `);else if(a.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(a.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let l=0;l<o.length;l++)l&&this.insertNode(a.linebreakReplacement.create(),n,!0),o[l]&&this.insertNode(a.text(o[l]),n,!/\S/.test(o[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(a.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;PW.hasOwnProperty(a)&&this.parser.normalizeLists&&mSe(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:pSe.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let u,d=this.needsBlock;if(kW.hasOwnProperty(a))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),u=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(s),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,l,u,l.consuming===!1?o:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],a=r.getPropertyValue(s);if(a)for(let o=void 0;;){let l=this.parser.matchStyle(s,a,this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(u=>!l.clearMark(u)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)o=l;else break}}return n}addElementByRule(e,n,r,i){let s,a;if(n.node)if(a=this.parser.schema.nodes[n.node],a.isLeaf)this.insertNode(a.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(a,n.attrs||null,r,n.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}s&&this.sync(o)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let a=r?e.childNodes[r]:e.firstChild,o=i==null?null:e.childNodes[i];a!=o;a=a.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(a,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let a=this.open,o=0;a>=0;a--){let l=this.nodes[a],u=l.findWrapping(e);if(u&&(!i||i.length>u.length+o)&&(i=u,s=l,!u.length))break;if(l.solid){if(r)break;o+=2}}if(!i)return null;this.sync(s);for(let a=0;a<i.length;a++)n=this.enterInner(i[a],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let a=Qn.none;for(let o of i.concat(e.marks))(s.type?s.type.allowsMarkType(o.type):BB(o.type,e.type))&&(a=o.addToSet(a));return s.content.push(e.mark(a)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=UB(e,s,a.options);a.options&Hx&&a.content.length==0&&(o|=Hx);let l=Qn.none;return r=r.filter(u=>(a.type?a.type.allowsMarkType(u.type):BB(u.type,e))?(l=u.addToSet(l),!1):!0),this.nodes.push(new t_(e,n,l,i,null,o)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=A0)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),a=(o,l)=>{for(;o>=0;o--){let u=n[o];if(u==""){if(o==n.length-1||o==0)continue;for(;l>=s;l--)if(a(o-1,l))return!0;return!1}else{let d=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;l--}}return!0};return a(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function mSe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&PW.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function gSe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function zB(t){let e={};for(let n in t)e[n]=t[n];return e}function BB(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],a=o=>{s.push(o);for(let l=0;l<o.edgeCount;l++){let{type:u,next:d}=o.edge(l);if(u==e||s.indexOf(d)<0&&a(d))return!0}};if(a(i.contentMatch))return!0}}class sf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=NT(n).createDocumentFragment());let i=r,s=[];return e.forEach(a=>{if(s.length||a.marks.length){let o=0,l=0;for(;o<s.length&&l<a.marks.length;){let u=a.marks[l];if(!this.marks[u.type.name]){l++;continue}if(!u.eq(s[o][0])||u.type.spec.spanning===!1)break;o++,l++}for(;o<s.length;)i=s.pop()[1];for(;l<a.marks.length;){let u=a.marks[l++],d=this.serializeMark(u,a.isInline,n);d&&(s.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(a,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=V_(NT(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&V_(NT(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return V_(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new sf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=HB(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return HB(e.marks)}}function HB(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function NT(t){return t.document||window.document}const $B=new WeakMap;function xSe(t){let e=$B.get(t);return e===void 0&&$B.set(t,e=bSe(t)),e}function bSe(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 V_(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=xSe(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let a=i.indexOf(" ");a>0&&(n=i.slice(0,a),i=i.slice(a+1));let o,l=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?l.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&l.style?l.style.cssText=u[f]:l.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:m,contentDOM:x}=V_(t,g,n,r);if(l.appendChild(m),x){if(o)throw new RangeError("Multiple content holes");o=x}}}return{dom:l,contentDOM:o}}const RW=65535,DW=Math.pow(2,16);function vSe(t,e){return t+e*DW}function VB(t){return t&RW}function ySe(t){return(t-(t&RW))/DW}const OW=1,jW=2,G_=4,LW=8;class vk{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&LW)>0}get deletedBefore(){return(this.delInfo&(OW|G_))>0}get deletedAfter(){return(this.delInfo&(jW|G_))>0}get deletedAcross(){return(this.delInfo&G_)>0}}class ha{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ha.empty)return ha.empty}recover(e){let n=0,r=VB(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+ySe(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,s=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>e)break;let u=this.ranges[o+s],d=this.ranges[o+a],f=l+u;if(e<=f){let g=u?e==l?-1:e==f?1:n:n,m=l+i+(g<0?0:d);if(r)return m;let x=e==(n<0?l:f)?null:vSe(o/3,e-l),y=e==l?jW:e==f?OW:G_;return(n<0?e!=l:e!=f)&&(y|=LW),new vk(m,y,x)}i+=d-u}return r?e+i:new vk(e+i,0,null)}touches(e,n){let r=0,i=VB(n),s=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>e)break;let u=this.ranges[o+s],d=l+u;if(e<=d&&o==i*3)return!0;r+=this.ranges[o+a]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let a=this.ranges[i],o=a-(this.inverted?s:0),l=a+(this.inverted?0:s),u=this.ranges[i+n],d=this.ranges[i+r];e(o,o+u,l,l+d),s+=d-u}}invert(){return new ha(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ha.empty:new ha(e<0?[0,-e,0]:[0,0,e])}}ha.empty=new ha([]);class T0{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 T0(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 T0;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let s=this.from;s<this.to;s++){let a=this._maps[s],o=a.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this._maps[l].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new vk(e,i,null)}}const kT=Object.create(null);let ps=class{getMap(){return ha.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=kT[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 kT)throw new RangeError("Duplicate use of step JSON ID "+e);return kT[e]=n,n.prototype.jsonID=e,n}};class Xr{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Xr(e,null)}static fail(e){return new Xr(null,e)}static fromReplace(e,n,r,i){try{return Xr.ok(e.replace(n,r,i))}catch(s){if(s instanceof E1)return Xr.fail(s.message);throw s}}}function ZR(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(ZR(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return pt.fromArray(r)}class Uu extends ps{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new Tt(ZR(n.content,(a,o)=>!a.isAtom||!o.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),i),n.openStart,n.openEnd);return Xr.fromReplace(e,this.from,this.to,s)}invert(){return new ko(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 Uu(n.pos,r.pos,this.mark)}merge(e){return e instanceof Uu&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Uu(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 Uu(n.from,n.to,e.markFromJSON(n.mark))}}ps.jsonID("addMark",Uu);class ko extends ps{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 Tt(ZR(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Xr.fromReplace(e,this.from,this.to,r)}invert(){return new Uu(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 ko(n.pos,r.pos,this.mark)}merge(e){return e instanceof ko&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ko(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 ko(n.from,n.to,e.markFromJSON(n.mark))}}ps.jsonID("removeMark",ko);class Fu extends ps{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Xr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Xr.fromReplace(e,this.pos,this.pos+1,new Tt(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 Fu(this.pos,n.marks[i]);return new Fu(this.pos,this.mark)}}return new $h(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Fu(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 Fu(n.pos,e.markFromJSON(n.mark))}}ps.jsonID("addNodeMark",Fu);class $h extends ps{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Xr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Xr.fromReplace(e,this.pos,this.pos+1,new Tt(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 Fu(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new $h(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 $h(n.pos,e.markFromJSON(n.mark))}}ps.jsonID("removeNodeMark",$h);class Ri extends ps{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&yk(e,this.from,this.to)?Xr.fail("Structure replace would overwrite content"):Xr.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ha([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ri(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 Ri(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ri)||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?Tt.empty:new Tt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ri(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?Tt.empty:new Tt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ri(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 Ri(n.from,n.to,Tt.fromJSON(e,n.slice),!!n.structure)}}ps.jsonID("replace",Ri);class Oi extends ps{constructor(e,n,r,i,s,a,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=a,this.structure=o}apply(e){if(this.structure&&(yk(e,this.from,this.gapFrom)||yk(e,this.gapTo,this.to)))return Xr.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Xr.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Xr.fromReplace(e,this.from,this.to,r):Xr.fail("Content does not fit in gap")}getMap(){return new ha([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 Oi(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new Oi(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Oi(n.from,n.to,n.gapFrom,n.gapTo,Tt.fromJSON(e,n.slice),n.insert,!!n.structure)}}ps.jsonID("replaceAround",Oi);function yk(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let a=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,i--}}return!1}function _Se(t,e,n,r){let i=[],s=[],a,o;t.doc.nodesBetween(e,n,(l,u,d)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let g=Math.max(u,e),m=Math.min(u+l.nodeSize,n),x=r.addToSet(f);for(let y=0;y<f.length;y++)f[y].isInSet(x)||(a&&a.to==g&&a.mark.eq(f[y])?a.to=m:i.push(a=new ko(g,m,f[y])));o&&o.to==g?o.to=m:s.push(o=new Uu(g,m,r))}}),i.forEach(l=>t.step(l)),s.forEach(l=>t.step(l))}function wSe(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(a,o)=>{if(!a.isInline)return;s++;let l=null;if(r instanceof RS){let u=a.marks,d;for(;d=r.isInSet(u);)(l||(l=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(a.marks)&&(l=[r]):l=a.marks;if(l&&l.length){let u=Math.min(o+a.nodeSize,n);for(let d=0;d<l.length;d++){let f=l[d],g;for(let m=0;m<i.length;m++){let x=i[m];x.step==s-1&&f.eq(i[m].style)&&(g=x)}g?(g.to=u,g.step=s):i.push({style:f,from:Math.max(o,e),to:u,step:s})}}}),i.forEach(a=>t.step(new ko(a.from,a.to,a.style)))}function QR(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),a=[],o=e+1;for(let l=0;l<s.childCount;l++){let u=s.child(l),d=o+u.nodeSize,f=r.matchType(u.type);if(!f)a.push(new Ri(o,d,Tt.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new ko(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 Tt(pt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),a.push(new Ri(o+g.index,o+g.index+g[0].length,x))}}o=d}if(!r.validEnd){let l=r.fillBefore(pt.empty,!0);t.replace(o,o,new Tt(l,0,0))}for(let l=a.length-1;l>=0;l--)t.step(a[l])}function SSe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function $m(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let a=t.$from.node(r),o=t.$from.index(r)+i,l=t.$to.indexAfter(r)-s;if(r<t.depth&&a.canReplace(o,l,n))return r;if(r==0||a.type.spec.isolating||!SSe(a,o,l))break;o&&(i=1),l<a.childCount&&(s=1)}return null}function ESe(t,e,n){let{$from:r,$to:i,depth:s}=e,a=r.before(s+1),o=i.after(s+1),l=a,u=o,d=pt.empty,f=0;for(let x=s,y=!1;x>n;x--)y||r.index(x)>0?(y=!0,d=pt.from(r.node(x).copy(d)),f++):l--;let g=pt.empty,m=0;for(let x=s,y=!1;x>n;x--)y||i.after(x+1)<i.end(x)?(y=!0,g=pt.from(i.node(x).copy(g)),m++):u++;t.step(new Oi(l,u,a,o,new Tt(d.append(g),f,m),d.size-f,!0))}function JR(t,e,n=null,r=t){let i=MSe(t,e),s=i&&ASe(r,e);return s?i.map(GB).concat({type:e,attrs:n}).concat(s.map(GB)):null}function GB(t){return{type:t,attrs:null}}function MSe(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let a=s.length?s[0]:e;return n.canReplaceWith(r,i,a)?s:null}function ASe(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),a=e.contentMatch.findWrapping(s.type);if(!a)return null;let l=(a.length?a[a.length-1]:e).contentMatch;for(let u=r;l&&u<i;u++)l=l.matchType(n.child(u).type);return!l||!l.validEnd?null:a}function TSe(t,e,n){let r=pt.empty;for(let a=n.length-1;a>=0;a--){if(r.size){let o=n[a].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=pt.from(n[a].type.create(n[a].attrs,r))}let i=e.start,s=e.end;t.step(new Oi(i,s,i,s,new Tt(r,0,0),n.length,!0))}function CSe(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(a,o)=>{let l=typeof i=="function"?i(a):i;if(a.isTextblock&&!a.hasMarkup(r,l)&&NSe(t.doc,t.mapping.slice(s).map(o),r)){let u=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!x?u=!1:!m&&x&&(u=!0)}u===!1&&UW(t,a,o,s),QR(t,t.mapping.slice(s).map(o,1),r,void 0,u===null);let d=t.mapping.slice(s),f=d.map(o,1),g=d.map(o+a.nodeSize,1);return t.step(new Oi(f,g,f+1,g-1,new Tt(pt.from(r.create(l,null,a.marks)),0,0),1,!0)),u===!0&&IW(t,a,o,s),!1}})}function IW(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let a,o=/\r?\n|\r/g;for(;a=o.exec(i.text);){let l=t.mapping.slice(r).map(n+1+s+a.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function UW(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let a=t.mapping.slice(r).map(n+1+s);t.replaceWith(a,a+1,e.type.schema.text(`
- `))}})}function NSe(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function kSe(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let a=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,a);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Oi(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Tt(pt.from(a),0,0),1,!0))}function mc(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,a=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!a.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>s;u--,d--){let f=i.node(u),g=i.index(u);if(f.type.spec.isolating)return!1;let m=f.content.cutByIndex(g,f.childCount),x=r&&r[d+1];x&&(m=m.replaceChild(0,x.type.create(x.attrs)));let y=r&&r[d]||f;if(!f.canReplace(g+1,f.childCount)||!y.type.validContent(m))return!1}let o=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(o,o,l?l.type:i.node(s+1).type)}function PSe(t,e,n=1,r){let i=t.doc.resolve(e),s=pt.empty,a=pt.empty;for(let o=i.depth,l=i.depth-n,u=n-1;o>l;o--,u--){s=pt.from(i.node(o).copy(s));let d=r&&r[u];a=pt.from(d?d.type.create(d.attrs,a):i.node(o).copy(a))}t.step(new Ri(e,e,new Tt(s.append(a),n,n),!0))}function pd(t,e){let n=t.resolve(e),r=n.index();return FW(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function RSe(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),a=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(a),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function FW(t,e){return!!(t&&e&&!t.isLeaf&&RSe(t,e))}function DS(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,a,o=r.index(i);if(i==r.depth?(s=r.nodeBefore,a=r.nodeAfter):n>0?(s=r.node(i+1),o++,a=r.node(i).maybeChild(o)):(s=r.node(i).maybeChild(o-1),a=r.node(i+1)),s&&!s.isTextblock&&FW(s,a)&&r.node(i).canReplace(o,o+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function DSe(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),a=s.node().type;if(i&&a.inlineContent){let d=a.whitespace=="pre",f=!!a.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let o=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);UW(t,d.node(),d.before(),o)}a.inlineContent&&QR(t,e+n-1,a,s.node().contentMatchAt(s.index()),r==null);let l=t.mapping.slice(o),u=l.map(e-n);if(t.step(new Ri(u,l.map(e+n,-1),Tt.empty,!0)),r===!0){let d=t.doc.resolve(u);IW(t,d.node(),d.before(),t.steps.length)}return t}function OSe(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function zW(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let a=r.depth;a>=0;a--){let o=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,l=r.index(a)+(o>0?1:0),u=r.node(a),d=!1;if(s==1)d=u.canReplace(l,l,i);else{let f=u.contentMatchAt(l).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(l,l,f[0])}if(d)return o==0?r.pos:o<0?r.before(a+1):r.after(a+1)}return null}function OS(t,e,n=e,r=Tt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return BW(i,s,r)?new Ri(e,n,r):new jSe(i,s,r).fit()}function BW(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class jSe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=pt.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=pt.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,a=r.depth,o=i.depth;for(;a&&o&&s.childCount==1;)s=s.firstChild.content,a--,o--;let l=new Tt(s,a,o);return e>-1?new Oi(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Ri(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=PT(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let a=i.firstChild;for(let o=this.depth;o>=0;o--){let{type:l,match:u}=this.frontier[o],d,f=null;if(n==1&&(a?u.matchType(a.type)||(f=u.fillBefore(pt.from(a),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:o,parent:s,inject:f};if(n==2&&a&&(d=u.findWrapping(a.type)))return{sliceDepth:r,frontierDepth:o,parent:s,wrap:d};if(s&&u.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=PT(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Tt(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=PT(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Tt(Mx(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Tt(Mx(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let y=0;y<s.length;y++)this.openFrontierNode(s[y]);let a=this.unplaced,o=r?r.content:a.content,l=a.openStart-e,u=0,d=[],{match:f,type:g}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));f=f.matchFragment(i)}let m=o.size+e-(a.content.size-a.openEnd);for(;u<o.childCount;){let y=o.child(u),v=f.matchType(y.type);if(!v)break;u++,(u>1||l==0||y.content.size)&&(f=v,d.push(HW(y.mark(g.allowedMarks(y.marks)),u==1?l:0,u==o.childCount?m:-1)))}let x=u==o.childCount;x||(m=-1),this.placed=Ax(this.placed,n,pt.from(d)),this.frontier[n].match=f,x&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,v=o;y<m;y++){let b=v.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),v=b.content}this.unplaced=x?e==0?Tt.empty:new Tt(Mx(a.content,e-1,1),e-1,m<0?a.openEnd:e-1):new Tt(Mx(a.content,e,u),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!RT(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),a=RT(e,n,i,r,s);if(a){for(let o=n-1;o>=0;o--){let{match:l,type:u}=this.frontier[o],d=RT(e,o,u,l,!0);if(!d||d.childCount)continue e}return{depth:n,fit:a,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Ax(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ax(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=Ax(this.placed,this.frontier.length,n))}}function Mx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Mx(t.firstChild.content,e-1,n)))}function Ax(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ax(t.lastChild.content,e-1,n)))}function PT(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function HW(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,HW(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 RT(t,e,n,r,i){let s=t.node(e),a=i?t.indexAfter(e):t.index(e);if(a==s.childCount&&!n.compatibleContent(s.type))return null;let o=r.fillBefore(s.content,!0,a);return o&&!LSe(n,s.content,a)?o:null}function LSe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function ISe(t){return t.spec.defining||t.spec.definingForContent}function USe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(BW(i,s,r))return t.step(new Ri(e,n,r));let a=VW(i,s);a[a.length-1]==0&&a.pop();let o=-(i.depth+1);a.unshift(o);for(let g=i.depth,m=i.pos-1;g>0;g--,m--){let x=i.node(g).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;a.indexOf(g)>-1?o=g:i.before(g)==m&&a.splice(1,0,-g)}let l=a.indexOf(o),u=[],d=r.openStart;for(let g=r.content,m=0;;m++){let x=g.firstChild;if(u.push(x),m==r.openStart)break;g=x.content}for(let g=d-1;g>=0;g--){let m=u[g],x=ISe(m.type);if(x&&!m.sameMarkup(i.node(Math.abs(o)-1)))d=g;else if(x||!m.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let m=(g+d+1)%(r.openStart+1),x=u[m];if(x)for(let y=0;y<a.length;y++){let v=a[(y+l)%a.length],b=!0;v<0&&(b=!1,v=-v);let E=i.node(v-1),S=i.index(v-1);if(E.canReplaceWith(S,S,x.type,x.marks))return t.replace(i.before(v),b?s.after(v):n,new Tt($W(r.content,0,r.openStart,m),m,r.openEnd))}}let f=t.steps.length;for(let g=a.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>f));g--){let m=a[g];m<0||(e=i.before(m),n=s.after(m))}}function $W(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy($W(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),a=s.fillBefore(t).append(t);t=a.append(s.matchFragment(a).fillBefore(pt.empty,!0))}return t}function FSe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=OSe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Tt(pt.from(r),0,0))}function zSe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=VW(r,i);for(let a=0;a<s.length;a++){let o=s[a],l=a==s.length-1;if(l&&o==0||r.node(o).type.contentMatch.validEnd)return t.delete(r.start(o),i.end(o));if(o>0&&(l||r.node(o-1).canReplace(r.index(o-1),i.indexAfter(o-1))))return t.delete(r.before(o),i.after(o))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(e-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return t.delete(r.before(a),n);t.delete(e,n)}function VW(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class Yp extends ps{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 Xr.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Xr.fromReplace(e,this.pos,this.pos+1,new Tt(pt.from(i),0,n.isLeaf?0:1))}getMap(){return ha.empty}invert(e){return new Yp(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 Yp(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 Yp(n.pos,n.attr,n.value)}}ps.jsonID("attr",Yp);class C0 extends ps{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 Xr.ok(r)}getMap(){return ha.empty}invert(e){return new C0(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 C0(n.attr,n.value)}}ps.jsonID("docAttr",C0);let gm=class extends Error{};gm=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};gm.prototype=Object.create(Error.prototype);gm.prototype.constructor=gm;gm.prototype.name="TransformError";class GW{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new T0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new gm(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=Tt.empty){let i=OS(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Tt(pt.from(r),0,0))}delete(e,n){return this.replace(e,n,Tt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return USe(this,e,n,r),this}replaceRangeWith(e,n,r){return FSe(this,e,n,r),this}deleteRange(e,n){return zSe(this,e,n),this}lift(e,n){return ESe(this,e,n),this}join(e,n=1){return DSe(this,e,n),this}wrap(e,n){return TSe(this,e,n),this}setBlockType(e,n=e,r,i=null){return CSe(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return kSe(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Yp(e,n,r)),this}setDocAttribute(e,n){return this.step(new C0(e,n)),this}addNodeMark(e,n){return this.step(new Fu(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 Qn)n.isInSet(r.marks)&&this.step(new $h(e,n));else{let i=r.marks,s,a=[];for(;s=n.isInSet(i);)a.push(new $h(e,s)),i=s.removeFromSet(i);for(let o=a.length-1;o>=0;o--)this.step(a[o])}return this}split(e,n=1,r){return PSe(this,e,n,r),this}addMark(e,n,r){return _Se(this,e,n,r),this}removeMark(e,n,r){return wSe(this,e,n,r),this}clearIncompatible(e,n,r){return QR(this,e,n,r),this}}const DT=Object.create(null);class ln{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new BSe(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=Tt.empty){let r=n.content.lastChild,i=null;for(let o=0;o<n.openEnd;o++)i=r,r=r.lastChild;let s=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:l,$to:u}=a[o],d=e.mapping.slice(s);e.replaceRange(d.map(l.pos),d.map(u.pos),o?Tt.empty:n),o==0&&KB(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:o}=i[s],l=e.mapping.slice(r),u=l.map(a.pos),d=l.map(o.pos);s?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),KB(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new qt(e):Np(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let a=n<0?Np(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Np(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(a)return a}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ba(e.node(0))}static atStart(e){return Np(e,e,0,0,1)||new ba(e)}static atEnd(e){return Np(e,e,e.content.size,e.childCount,-1)||new ba(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=DT[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 DT)throw new RangeError("Duplicate use of selection JSON ID "+e);return DT[e]=n,n.prototype.jsonID=e,n}getBookmark(){return qt.between(this.$anchor,this.$head).getBookmark()}}ln.prototype.visible=!0;class BSe{constructor(e,n){this.$from=e,this.$to=n}}let WB=!1;function qB(t){!WB&&!t.parent.inlineContent&&(WB=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class qt extends ln{constructor(e,n=e){qB(e),qB(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return ln.near(r);let i=e.resolve(n.map(this.anchor));return new qt(i.parent.inlineContent?i:r,r)}replace(e,n=Tt.empty){if(super.replace(e,n),n==Tt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof qt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new jS(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new qt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=ln.findFrom(n,r,!0)||ln.findFrom(n,-r,!0);if(s)n=s.$head;else return ln.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(ln.findFrom(e,-r,!0)||ln.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new qt(e,n)}}ln.jsonID("text",qt);class jS{constructor(e,n){this.anchor=e,this.head=n}map(e){return new jS(e.map(this.anchor),e.map(this.head))}resolve(e){return qt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ht extends ln{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?ln.near(s):new Ht(s)}content(){return new Tt(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 eD(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ht(e.resolve(n.anchor))}static create(e,n){return new Ht(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ht.prototype.visible=!1;ln.jsonID("node",Ht);class eD{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new jS(r,r):new eD(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ht.isSelectable(r)?new Ht(n):ln.near(n)}}class ba extends ln{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Tt.empty){if(n==Tt.empty){e.delete(0,e.doc.content.size);let r=ln.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new ba(e)}map(e){return new ba(e)}eq(e){return e instanceof ba}getBookmark(){return HSe}}ln.jsonID("all",ba);const HSe={map(){return this},resolve(t){return new ba(t)}};function Np(t,e,n,r,i,s=!1){if(e.inlineContent)return qt.create(t,n);for(let a=r-(i>0?0:1);i>0?a<e.childCount:a>=0;a+=i){let o=e.child(a);if(o.isAtom){if(!s&&Ht.isSelectable(o))return Ht.create(t,n-(i<0?o.nodeSize:0))}else{let l=Np(t,o,n+i,i<0?o.childCount:0,i,s);if(l)return l}n+=o.nodeSize*i}return null}function KB(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ri||i instanceof Oi))return;let s=t.mapping.maps[r],a;s.forEach((o,l,u,d)=>{a==null&&(a=d)}),t.setSelection(ln.near(t.doc.resolve(a),n))}const XB=1,n_=2,YB=4;class $Se extends GW{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|XB)&~n_,this.storedMarks=null,this}get selectionSet(){return(this.updated&XB)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=n_,this}ensureMarks(e){return Qn.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&n_)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~n_,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Qn.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let a=this.doc.resolve(n);s=r==n?a.marks():a.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ln.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=YB,this}get scrolledIntoView(){return(this.updated&YB)>0}}function ZB(t,e){return!e||!t?t:t.bind(e)}class Tx{constructor(e,n,r){this.name=e,this.init=ZB(n.init,r),this.apply=ZB(n.apply,r)}}const VSe=[new Tx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Tx("selection",{init(t,e){return t.selection||ln.atStart(e.doc)},apply(t){return t.selection}}),new Tx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Tx("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class OT{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=VSe.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 Tx(r.key,r.spec.state,r))})}}class Ip{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let l=i?i[a].n:0,u=i?i[a].state:this,d=l<n.length&&o.spec.appendTransaction.call(o,l?n.slice(l):n,u,r);if(d&&r.filterTransaction(d,a)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<a?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),s=!0}i&&(i[a]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Ip(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new $Se(this)}static create(e){let n=new OT(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ip(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 OT(this.schema,e.plugins),r=n.fields,i=new Ip(n);for(let s=0;s<r.length;s++){let a=r[s].name;i[a]=this.hasOwnProperty(a)?this[a]:r[s].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new OT(e.schema,e.plugins),s=new Ip(i);return i.fields.forEach(a=>{if(a.name=="doc")s.doc=Wu.fromJSON(e.schema,n.doc);else if(a.name=="selection")s.selection=ln.fromJSON(s.doc,n.selection);else if(a.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let o in r){let l=r[o],u=l.spec.state;if(l.key==a.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){s[a.name]=u.fromJSON.call(l,e,n[o],s);return}}s[a.name]=a.init(e,s)}}),s}}function WW(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=WW(i,e,{})),n[r]=i}return n}class _r{constructor(e){this.spec=e,this.props={},e.props&&WW(e.props,this,this.props),this.key=e.key?e.key.key:qW("plugin")}getState(e){return e[this.key]}}const jT=Object.create(null);function qW(t){return t in jT?t+"$"+ ++jT[t]:(jT[t]=0,t+"$")}class gi{constructor(e="key"){this.key=qW(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const tD=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function KW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const XW=(t,e,n)=>{let r=KW(t,n);if(!r)return!1;let i=nD(r);if(!i){let a=r.blockRange(),o=a&&$m(a);return o==null?!1:(e&&e(t.tr.lift(a,o).scrollIntoView()),!0)}let s=i.nodeBefore;if(iq(t,i,e,-1))return!0;if(r.parent.content.size==0&&(xm(s,"end")||Ht.isSelectable(s)))for(let a=r.depth;;a--){let o=OS(t.doc,r.before(a),r.after(a),Tt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(xm(s,"end")?ln.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Ht.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}if(a==1||r.node(a-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},GSe=(t,e,n)=>{let r=KW(t,n);if(!r)return!1;let i=nD(r);return i?YW(t,i,e):!1},WSe=(t,e,n)=>{let r=QW(t,n);if(!r)return!1;let i=rD(r);return i?YW(t,i,e):!1};function YW(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let a=e.nodeAfter,o=a,l=e.pos+1;for(;!o.isTextblock;l++){if(o.type.spec.isolating)return!1;let d=o.firstChild;if(!d)return!1;o=d}let u=OS(t.doc,s,l,Tt.empty);if(!u||u.from!=s||u instanceof Ri&&u.slice.size>=l-s)return!1;if(n){let d=t.tr.step(u);d.setSelection(qt.create(d.doc,s)),n(d.scrollIntoView())}return!0}function xm(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 ZW=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=nD(r)}let a=s&&s.nodeBefore;return!a||!Ht.isSelectable(a)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,s.pos-a.nodeSize)).scrollIntoView()),!0)};function nD(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 QW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const JW=(t,e,n)=>{let r=QW(t,n);if(!r)return!1;let i=rD(r);if(!i)return!1;let s=i.nodeAfter;if(iq(t,i,e,1))return!0;if(r.parent.content.size==0&&(xm(s,"start")||Ht.isSelectable(s))){let a=OS(t.doc,r.before(),r.after(),Tt.empty);if(a&&a.slice.size<a.to-a.from){if(e){let o=t.tr.step(a);o.setSelection(xm(s,"start")?ln.findFrom(o.doc.resolve(o.mapping.map(i.pos)),1):Ht.create(o.doc,o.mapping.map(i.pos))),e(o.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},eq=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=rD(r)}let a=s&&s.nodeAfter;return!a||!Ht.isSelectable(a)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,s.pos)).scrollIntoView()),!0)};function rD(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 qSe=(t,e)=>{let n=t.selection,r=n instanceof Ht,i;if(r){if(n.node.isTextblock||!pd(t.doc,n.from))return!1;i=n.from}else if(i=DS(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(Ht.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},KSe=(t,e)=>{let n=t.selection,r;if(n instanceof Ht){if(n.node.isTextblock||!pd(t.doc,n.to))return!1;r=n.to}else if(r=DS(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},XSe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&$m(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},tq=(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 iD(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 YSe=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),a=iD(i.contentMatchAt(s));if(!a||!i.canReplaceWith(s,s,a))return!1;if(e){let o=n.after(),l=t.tr.replaceWith(o,o,a.createAndFill());l.setSelection(ln.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},nq=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof ba||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=iD(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let a=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(a,s.createAndFill());o.setSelection(qt.create(o.doc,a+1)),e(o.scrollIntoView())}return!0},rq=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(mc(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&$m(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function ZSe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ht&&e.selection.node.isBlock)return!r.parentOffset||!mc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],a,o,l=!1,u=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){l=r.end(m)==r.pos+(r.depth-m),u=r.start(m)==r.pos-(r.depth-m),o=iD(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),s.unshift(l&&o?{type:o}:null),a=m;break}else{if(m==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof qt||e.selection instanceof ba)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=mc(d.doc,f,s.length,s);if(g||(s[0]=o?{type:o}:null,g=mc(d.doc,f,s.length,s)),!g)return!1;if(d.split(f,s.length,s),!l&&u&&r.node(a).type!=o){let m=d.mapping.map(r.before(a)),x=d.doc.resolve(m);o&&r.node(a-1).canReplaceWith(x.index(),x.index()+1,o)&&d.setNodeMarkup(d.mapping.map(r.before(a)),o)}return n&&n(d.scrollIntoView()),!0}}const QSe=ZSe(),JSe=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(Ht.create(t.doc,i))),!0)};function eEe(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||pd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function iq(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,a,o,l=i.type.spec.isolating||s.type.spec.isolating;if(!l&&eEe(t,e,n))return!0;let u=!l&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(a=(o=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&o.matchType(a[0]||s.type).validEnd){if(n){let m=e.pos+s.nodeSize,x=pt.empty;for(let b=a.length-1;b>=0;b--)x=pt.from(a[b].create(null,x));x=pt.from(i.copy(x));let y=t.tr.step(new Oi(e.pos-1,m,e.pos,m,new Tt(x,1,0),a.length,!0)),v=y.doc.resolve(m+2*a.length);v.nodeAfter&&v.nodeAfter.type==i.type&&pd(y.doc,v.pos)&&y.join(v.pos),n(y.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&l?null:ln.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),g=f&&$m(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&xm(s,"start",!0)&&xm(i,"end")){let m=i,x=[];for(;x.push(m),!m.isTextblock;)m=m.lastChild;let y=s,v=1;for(;!y.isTextblock;y=y.firstChild)v++;if(m.canReplace(m.childCount,m.childCount,y.content)){if(n){let b=pt.empty;for(let S=x.length-1;S>=0;S--)b=pt.from(x[S].copy(b));let E=t.tr.step(new Oi(e.pos-x.length,e.pos+s.nodeSize,e.pos+v,e.pos+s.nodeSize-v,new Tt(b,x.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function sq(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(qt.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const tEe=sq(-1),nEe=sq(1);function rEe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,a=i.blockRange(s),o=a&&JR(a,t,e);return o?(r&&r(n.tr.wrap(a,o).scrollIntoView()),!0):!1}}function QB(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[s];n.doc.nodesBetween(a,o,(l,u)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let a=0;a<n.selection.ranges.length;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];s.setBlockType(o,l,t,e)}r(s.scrollIntoView())}return!0}}function sD(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}sD(tD,XW,ZW);sD(tD,JW,eq);sD(tq,nq,rq,QSe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function iEe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,a=i.blockRange(s);if(!a)return!1;let o=r?n.tr:null;return sEe(o,a,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function sEe(t,e,n,r=null){let i=!1,s=e,a=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=a.resolve(e.start-2);s=new A1(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new A1(e.$from,a.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let o=JR(s,n,r,e);return o?(t&&aEe(t,e,o,i,n),!0):!1}function aEe(t,e,n,r,i){let s=pt.empty;for(let d=n.length-1;d>=0;d--)s=pt.from(n[d].type.create(n[d].attrs,s));t.step(new Oi(e.start-(r?2:0),e.end,e.start,e.end,new Tt(s,0,0),n.length,!0));let a=0;for(let d=0;d<n.length;d++)n[d].type==i&&(a=d+1);let o=n.length-a,l=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,g=!0;d<f;d++,g=!1)!g&&mc(t.doc,l,o)&&(t.split(l,o),l+=2*o),l+=u.child(d).nodeSize;return t}function oEe(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,a=>a.childCount>0&&a.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?lEe(e,n,t,s):cEe(e,n,s):!0:!1}}function lEe(t,e,n,r){let i=t.tr,s=r.end,a=r.$to.end(r.depth);s<a&&(i.step(new Oi(s-1,a,s,a,new Tt(pt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new A1(i.doc.resolve(r.$from.pos),i.doc.resolve(a),r.depth));const o=$m(r);if(o==null)return!1;i.lift(r,o);let l=i.doc.resolve(i.mapping.map(s,-1)-1);return pd(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function cEe(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,x=n.endIndex-1,y=n.startIndex;x>y;x--)m-=i.child(x).nodeSize,r.delete(m-1,m+1);let s=r.doc.resolve(n.start),a=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let o=n.startIndex==0,l=n.endIndex==i.childCount,u=s.node(-1),d=s.index(-1);if(!u.canReplace(d+(o?0:1),d+1,a.content.append(l?pt.empty:pt.from(i))))return!1;let f=s.pos,g=f+a.nodeSize;return r.step(new Oi(f-(o?1:0),g+(l?1:0),f+1,g-1,new Tt((o?pt.empty:pt.from(i.copy(pt.empty))).append(l?pt.empty:pt.from(i.copy(pt.empty))),o?0:1,l?0:1),o?0:1)),e(r.scrollIntoView()),!0}function uEe(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!s)return!1;let a=s.startIndex;if(a==0)return!1;let o=s.parent,l=o.child(a-1);if(l.type!=t)return!1;if(n){let u=l.lastChild&&l.lastChild.type==o.type,d=pt.from(u?t.create():null),f=new Tt(pt.from(t.create(null,pt.from(o.type.create(null,d)))),u?3:1,0),g=s.start,m=s.end;n(e.tr.step(new Oi(g-(u?3:1),m,g,m,f,1,!0)).scrollIntoView())}return!0}}const Zi=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},bm=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let _k=null;const Jl=function(t,e,n){let r=_k||(_k=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},dEe=function(){_k=null},Vh=function(t,e,n,r){return n&&(JB(t,e,n,r,-1)||JB(t,e,n,r,1))},hEe=/^(img|br|input|textarea|hr)$/i;function JB(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Xa(t))){let a=t.parentNode;if(!a||a.nodeType!=1||lb(t)||hEe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Zi(t)+(i<0?0:1),t=a}else if(t.nodeType==1){let a=t.childNodes[e+(i<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((s=a.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=a,e=i<0?Xa(t):0}else return!1}}function Xa(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function fEe(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=Xa(t)}else if(t.parentNode&&!lb(t))e=Zi(t),t=t.parentNode;else return null}}function pEe(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&&!lb(t))e=Zi(t)+1,t=t.parentNode;else return null}}function mEe(t,e,n){for(let r=e==0,i=e==Xa(t);r||i;){if(t==n)return!0;let s=Zi(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==Xa(t)}}function lb(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 LS=function(t){return t.focusNode&&Vh(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function rh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function gEe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function xEe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Xa(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Xa(r.startContainer),r.startOffset)}}}const ul=typeof navigator<"u"?navigator:null,e6=typeof document<"u"?document:null,md=ul&&ul.userAgent||"",wk=/Edge\/(\d+)/.exec(md),aq=/MSIE \d/.exec(md),Sk=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(md),Ws=!!(aq||Sk||wk),qu=aq?document.documentMode:Sk?+Sk[1]:wk?+wk[1]:0,to=!Ws&&/gecko\/(\d+)/i.test(md);to&&+(/Firefox\/(\d+)/.exec(md)||[0,0])[1];const Ek=!Ws&&/Chrome\/(\d+)/.exec(md),us=!!Ek,oq=Ek?+Ek[1]:0,Ms=!Ws&&!!ul&&/Apple Computer/.test(ul.vendor),vm=Ms&&(/Mobile\/\w+/.test(md)||!!ul&&ul.maxTouchPoints>2),$a=vm||(ul?/Mac/.test(ul.platform):!1),bEe=ul?/Win/.test(ul.platform):!1,lc=/Android \d/.test(md),cb=!!e6&&"webkitFontSmoothing"in e6.documentElement.style,vEe=cb?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function yEe(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 ql(t,e){return typeof t=="number"?t:t[e]}function _Ee(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 t6(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let a=n||t.dom;a;){if(a.nodeType!=1){a=bm(a);continue}let o=a,l=o==s.body,u=l?yEe(s):_Ee(o),d=0,f=0;if(e.top<u.top+ql(r,"top")?f=-(u.top-e.top+ql(i,"top")):e.bottom>u.bottom-ql(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+ql(i,"top")-u.top:e.bottom-u.bottom+ql(i,"bottom")),e.left<u.left+ql(r,"left")?d=-(u.left-e.left+ql(i,"left")):e.right>u.right-ql(r,"right")&&(d=e.right-u.right+ql(i,"right")),d||f)if(l)s.defaultView.scrollBy(d,f);else{let m=o.scrollLeft,x=o.scrollTop;f&&(o.scrollTop+=f),d&&(o.scrollLeft+=d);let y=o.scrollLeft-m,v=o.scrollTop-x;e={left:e.left-y,top:e.top-v,right:e.right-y,bottom:e.bottom-v}}let g=l?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(g))break;a=g=="absolute"?a.offsetParent:bm(a)}}function wEe(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,a=n+1;a<Math.min(innerHeight,e.bottom);a+=5){let o=t.root.elementFromPoint(s,a);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=n-20){r=o,i=l.top;break}}return{refDOM:r,refTop:i,stack:lq(t.dom)}}function lq(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=bm(r));return e}function SEe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;cq(n,r==0?0:r-e)}function cq(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let _p=null;function EEe(t){if(t.setActive)return t.setActive();if(_p)return t.focus(_p);let e=lq(t);t.focus(_p==null?{get preventScroll(){return _p={preventScroll:!0},!0}}:void 0),_p||(_p=!1,cq(e,0))}function uq(t,e){let n,r=2e8,i,s=0,a=e.top,o=e.top,l,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=Jl(d).getClientRects();else continue;for(let m=0;m<g.length;m++){let x=g[m];if(x.top<=a&&x.bottom>=o){a=Math.max(x.bottom,a),o=Math.min(x.top,o);let y=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&y&&(s=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!l&&x.left<=e.left&&x.right>=e.left&&(l=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(s=f+1)}}return!n&&l&&(n=l,i=u,r=0),n&&n.nodeType==3?MEe(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:uq(n,i)}function MEe(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=_u(r,1);if(s.top!=s.bottom&&aD(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function aD(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function AEe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function TEe(t,e,n){let{node:r,offset:i}=uq(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let a=r.getBoundingClientRect();s=a.left!=a.right&&n.left>(a.left+a.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function CEe(t,e,n,r){let i=-1;for(let s=e,a=!1;s!=t.dom;){let o=t.docView.nearestDesc(s,!0),l;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((l=o.dom.getBoundingClientRect()).width||l.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!a&&l.left>r.left||l.top>r.top?i=o.posBefore:(!a&&l.right<r.left||l.bottom<r.top)&&(i=o.posAfter),a=!0),!o.contentDOM&&i<0&&!o.node.isText))return(o.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?o.posBefore:o.posAfter;s=o.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function dq(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let a=t.childNodes[s];if(a.nodeType==1){let o=a.getClientRects();for(let l=0;l<o.length;l++){let u=o[l];if(aD(e,u))return dq(a,e,u)}}if((s=(s+1)%r)==i)break}return t}function NEe(t,e){let n=t.dom.ownerDocument,r,i=0,s=xEe(n,e.left,e.top);s&&({node:r,offset:i}=s);let a=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!a||!t.dom.contains(a.nodeType!=1?a.parentNode:a)){let u=t.dom.getBoundingClientRect();if(!aD(e,u)||(a=dq(t.dom,e,u),!a))return null}if(Ms)for(let u=a;r&&u;u=bm(u))u.draggable&&(r=void 0);if(a=AEe(a,e),r){if(to&&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;cb&&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=CEe(t,r,i,e))}o==null&&(o=TEe(t,a,e));let l=t.docView.nearestDesc(a,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function n6(t){return t.top<t.bottom||t.left<t.right}function _u(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(n6(r))return r}return Array.prototype.find.call(n,n6)||t.getBoundingClientRect()}const kEe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function hq(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),a=cb||to;if(r.nodeType==3)if(a&&(kEe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=_u(Jl(r,i,i),n);if(to&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=_u(Jl(r,i-1,i-1),-1);if(u.top==l.top){let d=_u(Jl(r,i,i+1),-1);if(d.top!=l.top)return ux(d,d.left<u.left)}}return l}else{let l=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(l--,d=1):n<0?l--:u++,ux(_u(Jl(r,l,u),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Xa(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return LT(l.getBoundingClientRect(),!1)}if(s==null&&i<Xa(r)){let l=r.childNodes[i];if(l.nodeType==1)return LT(l.getBoundingClientRect(),!0)}return LT(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Xa(r))){let l=r.childNodes[i-1],u=l.nodeType==3?Jl(l,Xa(l)-(a?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(u)return ux(_u(u,1),!1)}if(s==null&&i<Xa(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let u=l?l.nodeType==3?Jl(l,0,a?0:1):l.nodeType==1?l:null:null;if(u)return ux(_u(u,-1),!0)}return ux(_u(r.nodeType==3?Jl(r):r,-n),n>=0)}function ux(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 LT(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 fq(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 PEe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return fq(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(s,!0);if(!o)break;if(o.node.isBlock){s=o.contentDOM||o.dom;break}s=o.dom.parentNode}let a=hq(t,i.pos,1);for(let o=s.firstChild;o;o=o.nextSibling){let l;if(o.nodeType==1)l=o.getClientRects();else if(o.nodeType==3)l=Jl(o,0,o.nodeValue.length).getClientRects();else continue;for(let u=0;u<l.length;u++){let d=l[u];if(d.bottom>d.top+1&&(n=="up"?a.top-d.top>(d.bottom-a.top)*2:d.bottom-a.bottom>(a.bottom-d.top)*2))return!1}}return!0})}const REe=/[\u0590-\u08ac]/;function DEe(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,a=i==r.parent.content.size,o=t.domSelection();return o?!REe.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?s:a:fq(t,e,()=>{let{focusNode:l,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),g=o.caretBidiLevel;o.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:y}=t.domSelectionRange(),v=x&&!m.contains(x.nodeType==1?x:x.parentNode)||l==x&&u==y;try{o.collapse(d,f),l&&(l!=d||u!=f)&&o.extend&&o.extend(l,u)}catch{}return g!=null&&(o.caretBidiLevel=g),v}):r.pos==r.start()||r.pos==r.end()}let r6=null,i6=null,s6=!1;function OEe(t,e,n){return r6==e&&i6==n?s6:(r6=e,i6=n,s6=n=="up"||n=="down"?PEe(t,e,n):DEe(t,e,n))}const no=0,a6=1,ah=2,dl=3;class ub{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=no,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,a;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((a=s.pmViewDesc)&&a.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(a)+a.size:this.posAtStart}else{let s,a;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((a=s.pmViewDesc)&&a.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(a):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Zi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),a;if(s&&(!n||s.node))if(r&&(a=s.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let a=0;a<i.children.length;a++){let o=i.children[a];if(o.size){i=o;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let a=this.children[r],o=s+a.size;if(o>e||a instanceof mq){i=e-s;break}s=o}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof pq&&s.side>=0;r--);if(n<=0){let s,a=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,a=!1);return s&&n&&a&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Zi(s.dom)+1:0}}else{let s,a=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,a=!1);return s&&a&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Zi(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let a=r,o=0;;o++){let l=this.children[o],u=a+l.size;if(i==-1&&e<=u){let d=a+l.border;if(e>=d&&n<=u-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,d);e=a;for(let f=o;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=Zi(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(u>n||o==this.children.length-1)){n=u;for(let d=o+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Zi(f.dom);break}n+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}a=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let s=Math.min(e,n),a=Math.max(e,n);for(let m=0,x=0;m<this.children.length;m++){let y=this.children[m],v=x+y.size;if(s>x&&a<v)return y.setSelection(e-x-y.border,n-x-y.border,r,i);x=v}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((to||Ms)&&e==n){let{node:m,offset:x}=o;if(m.nodeType==3){if(f=!!(x&&m.nodeValue[x-1]==`
- `),f&&x==m.nodeValue.length)for(let y=m,v;y;y=y.parentNode){if(v=y.nextSibling){v.nodeName=="BR"&&(o=l={node:v.parentNode,offset:Zi(v)+1});break}let b=y.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let y=m.childNodes[x-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(to&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ms)&&Vh(o.node,o.offset,d.anchorNode,d.anchorOffset)&&Vh(l.node,l.offset,d.focusNode,d.focusOffset))return;let g=!1;if((u.extend||e==n)&&!(f&&to)){u.collapse(o.node,o.offset);try{e!=n&&u.extend(l.node,l.offset),g=!0}catch{}}if(!g){if(e>n){let x=o;o=l,l=x}let m=document.createRange();m.setEnd(l.node,l.offset),m.setStart(o.node,o.offset),u.removeAllRanges(),u.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],a=r+s.size;if(r==a?e<=a&&n>=r:e<a&&n>r){let o=r+s.border,l=a-s.border;if(e>=o&&n<=l){this.dirty=e==r||n==a?ah:a6,e==o&&n==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=dl:s.markDirty(e-o,n-o);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?ah:dl}r=a}this.dirty=ah}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?ah:a6;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class pq extends ub{constructor(e,n,r,i){let s,a=n.type.toDOM;if(typeof a=="function"&&(a=a(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(a.nodeType!=1){let o=document.createElement("span");o.appendChild(a),a=o}a.contentEditable="false",a.classList.add("ProseMirror-widget")}super(e,[],a,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==no&&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 jEe extends ub{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 Gh extends ub{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],a=s&&s(n,i,r);return(!a||!a.dom)&&(a=sf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Gh(e,n,a.dom,a.contentDOM||a.dom,a)}parseRule(){return this.dirty&dl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=dl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=no){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=no}}slice(e,n,r){let i=Gh.create(this.parent,this.mark,!0,r),s=this.children,a=this.size;n<a&&(s=Ak(s,n,a,r)),e>0&&(s=Ak(s,0,e,r));for(let o=0;o<s.length;o++)s[o].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ku extends ub{constructor(e,n,r,i,s,a,o,l,u){super(e,[],s,a),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(e,n,r,i,s,a){let o=s.nodeViews[n.type.name],l,u=o&&o(n,s,()=>{if(!l)return a;if(l.parent)return l.parent.posBeforeChild(l)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=sf.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=bq(d,r,n),u?l=new LEe(e,n,r,i,d,f||null,g,u,s,a+1):n.isText?new IS(e,n,r,i,d,g,s):new Ku(e,n,r,i,d,f||null,g,s,a+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>pt.empty)}return e}matchesNode(e,n,r){return this.dirty==no&&e.eq(this.node)&&C1(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,a=s&&s.pos>-1?s:null,o=s&&s.pos<0,l=new UEe(this,a&&a.node,e);BEe(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?l.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&l.syncToMarks(d==this.node.childCount?Qn.none:this.node.child(d).marks,r,e),l.placeWidget(u,e,i)},(u,d,f,g)=>{l.syncToMarks(u.marks,r,e);let m;l.findNodeMatch(u,d,f,g)||o&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(m=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(u,d,f,m,e)||l.updateNextNode(u,d,f,e,g,i)||l.addNode(u,d,f,e,i),i+=u.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==ah)&&(a&&this.protectLocalComposition(e,a),gq(this.contentDOM,this.children,e),vm&&HEe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof qt)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,o=$Ee(this.node.content,a,r-n,i-n);return o<0?null:{node:s,pos:o,text:a}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let a=new jEe(this,s,n,i);e.input.compositionNodes.push(a),this.children=Ak(this.children,r,r+i.length,e,a)}update(e,n,r,i){return this.dirty==dl||!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=no}updateOuterDeco(e){if(C1(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=xq(this.dom,this.nodeDOM,Mk(this.outerDeco,this.node,n),Mk(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 o6(t,e,n,r,i){bq(r,e,t);let s=new Ku(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class IS extends Ku{constructor(e,n,r,i,s,a,o){super(e,n,r,i,s,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==dl||this.dirty!=no&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=no||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=no,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new IS(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=dl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class mq extends ub{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==no&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class LEe extends Ku{constructor(e,n,r,i,s,a,o,l,u,d){super(e,n,r,i,s,a,o,u,d),this.spec=l}update(e,n,r,i){if(this.dirty==dl)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function gq(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let a=e[s],o=a.dom;if(o.parentNode==t){for(;o!=r;)r=l6(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(o,r);if(a instanceof Gh){let l=r?r.previousSibling:t.lastChild;gq(a.contentDOM,a.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=l6(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const $x=function(t){t&&(this.nodeName=t)};$x.prototype=Object.create(null);const oh=[new $x];function Mk(t,e,n){if(t.length==0)return oh;let r=n?oh[0]:new $x,i=[r];for(let s=0;s<t.length;s++){let a=t[s].type.attrs;if(a){a.nodeName&&i.push(r=new $x(a.nodeName));for(let o in a){let l=a[o];l!=null&&(n&&i.length==1&&i.push(r=new $x(e.isInline?"span":"div")),o=="class"?r.class=(r.class?r.class+" ":"")+l:o=="style"?r.style=(r.style?r.style+";":"")+l:o!="nodeName"&&(r[o]=l))}}}return i}function xq(t,e,n,r){if(n==oh&&r==oh)return e;let i=e;for(let s=0;s<r.length;s++){let a=r[s],o=n[s];if(s){let l;o&&o.nodeName==a.nodeName&&i!=t&&(l=i.parentNode)&&l.nodeName.toLowerCase()==a.nodeName||(l=document.createElement(a.nodeName),l.pmIsDeco=!0,l.appendChild(i),o=oh[0]),i=l}IEe(i,o||oh[0],a)}return i}function IEe(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function bq(t,e,n){return xq(t,t,oh,Mk(e,n,t.nodeType!=1))}function C1(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 l6(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class UEe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=FEe(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;i<a&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=no,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let u=this.top.children[l];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){o=l;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let l=Gh.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,a;if(i>=this.preMatch.index&&(a=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&a.matchesNode(e,n,r))s=this.top.children.indexOf(a,this.index);else for(let o=this.index,l=Math.min(this.top.children.length,o+5);o<l;o++){let u=this.top.children[o];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){s=o;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let a=this.top.children[i];return a.dirty==dl&&a.dom==a.contentDOM&&(a.dirty=ah),a.update(e,n,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,a){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof Ku){let u=this.preMatch.matched.get(l);if(u!=null&&u!=s)return!1;let d=l.dom,f,g=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=dl&&C1(n,l.outerDeco));if(!g&&l.update(e,n,r,i))return this.destroyBetween(this.index,o),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!g&&(f=this.recreateWrapper(l,e,n,r,i,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=ah,f.updateChildren(i,a+1),f.dirty=no),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,a){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!C1(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=Ku.create(this.top,n,r,i,s,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let l of o.children)l.parent=o}return e.destroy(),o}addNode(e,n,r,i,s){let a=Ku.create(this.top,e,n,r,i,s);a.contentDOM&&a.updateChildren(i,s+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new pq(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Gh;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof IS)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ms||us)&&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 mq(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 FEe(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,a=[];e:for(;i>0;){let o;for(;;)if(r){let u=n.children[r-1];if(u instanceof Gh)n=u,r=u.children.length;else{o=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=o.node;if(l){if(l!=t.child(i-1))break;--i,s.set(o,i),a.push(o)}}return{index:i,matched:s,matches:a.reverse()}}function zEe(t,e){return t.type.side-e.type.side}function BEe(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(s,d),u),s+=d.nodeSize}return}let a=0,o=[],l=null;for(let u=0;;){let d,f;for(;a<i.length&&i[a].to==s;){let v=i[a++];v.widget&&(d?(f||(f=[d])).push(v):d=v)}if(d)if(f){f.sort(zEe);for(let v=0;v<f.length;v++)n(f[v],u,!!l)}else n(d,u,!!l);let g,m;if(l)m=-1,g=l,l=null;else if(u<t.childCount)m=u,g=t.child(u++);else break;for(let v=0;v<o.length;v++)o[v].to<=s&&o.splice(v--,1);for(;a<i.length&&i[a].from<=s&&i[a].to>s;)o.push(i[a++]);let x=s+g.nodeSize;if(g.isText){let v=x;a<i.length&&i[a].from<v&&(v=i[a].from);for(let b=0;b<o.length;b++)o[b].to<v&&(v=o[b].to);v<x&&(l=g.cut(v-s),g=g.cut(0,v-s),x=v,m=-1)}else for(;a<i.length&&i[a].to<x;)a++;let y=g.isInline&&!g.isLeaf?o.filter(v=>!v.inline):o.slice();r(g,y,e.forChild(s,g),m),s=x}}function HEe(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 $Ee(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let a=t.child(i++),o=s;if(s+=a.nodeSize,!a.isText)continue;let l=a.text;for(;i<t.childCount;){let u=t.child(i++);if(s+=u.nodeSize,!u.isText)break;l+=u.text}if(s>=n){if(s>=r&&l.slice(r-e.length-o,r-o)==e)return r-e.length;let u=o<r?l.lastIndexOf(e,r-o-1):-1;if(u>=0&&u+e.length+o>=n)return o+u;if(n==r&&l.length>=r+e.length-o&&l.slice(r-o,r-o+e.length)==e)return r}}return-1}function Ak(t,e,n,r,i){let s=[];for(let a=0,o=0;a<t.length;a++){let l=t[a],u=o,d=o+=l.size;u>=n||d<=e?s.push(l):(u<e&&s.push(l.slice(0,e-u,r)),i&&(s.push(i),i=void 0),d>n&&s.push(l.slice(n-u,l.size,r)))}return s}function oD(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,a=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let o=r.resolve(a),l,u;if(LS(n)){for(l=a;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Ht.isSelectable(f)&&i.parent&&!(f.isInline&&mEe(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;u=new Ht(a==g?o:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=a,g=a;for(let m=0;m<n.rangeCount;m++){let x=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[l,a]=g==t.state.selection.anchor?[g,f]:[f,g],o=r.resolve(a)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!u){let f=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;u=lD(t,d,o,f)}return u}function vq(t){return t.editable?t.hasFocus():_q(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function gc(t,e=!1){let n=t.state.selection;if(yq(t,n),!!vq(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&us){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Vh(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)GEe(t);else{let{anchor:r,head:i}=n,s,a;c6&&!(n instanceof qt)&&(n.$from.parent.inlineContent||(s=u6(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=u6(t,n.to))),t.docView.setSelection(r,i,t,e),c6&&(s&&d6(s),a&&d6(a)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&VEe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const c6=Ms||us&&oq<63;function u6(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Ms&&i&&i.contentEditable=="false")return IT(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return IT(i);if(s)return IT(s)}}function IT(t){return t.contentEditable="true",Ms&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function d6(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function VEe(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(()=>{(!vq(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function GEe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Zi(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ws&&qu<=11&&(n.disabled=!0,n.disabled=!1)}function yq(t,e){if(e instanceof Ht){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(h6(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else h6(t)}function h6(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function lD(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||qt.between(e,n,r)}function f6(t){return t.editable&&!t.hasFocus()?!1:_q(t)}function _q(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 WEe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Vh(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Tk(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ln.findFrom(s,e)}function Eu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function p6(t,e,n){let r=t.state.selection;if(r instanceof qt)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let a=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Eu(t,new qt(r.$anchor,a))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Tk(t.state,e);return i&&i instanceof Ht?Eu(t,i):!1}else if(!($a&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,a;if(!s||s.isText)return!1;let o=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(a=t.docView.descAt(o))&&!a.contentDOM?Ht.isSelectable(s)?Eu(t,new Ht(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):cb?Eu(t,new qt(t.state.doc.resolve(e<0?o:o+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ht&&r.node.isInline)return Eu(t,new qt(e>0?r.$to:r.$from));{let i=Tk(t.state,e);return i?Eu(t,i):!1}}}function N1(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Vx(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function wp(t,e){return e<0?qEe(t):KEe(t)}function qEe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,a=!1;for(to&&n.nodeType==1&&r<N1(n)&&Vx(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(Vx(o,-1))i=n,s=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(wq(n))break;{let o=n.previousSibling;for(;o&&Vx(o,-1);)i=n.parentNode,s=Zi(o),o=o.previousSibling;if(o)n=o,r=N1(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}a?Ck(t,n,r):i&&Ck(t,i,s)}function KEe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=N1(n),s,a;for(;;)if(r<i){if(n.nodeType!=1)break;let o=n.childNodes[r];if(Vx(o,1))s=n,a=++r;else break}else{if(wq(n))break;{let o=n.nextSibling;for(;o&&Vx(o,1);)s=o.parentNode,a=Zi(o)+1,o=o.nextSibling;if(o)n=o,r=0,i=N1(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&Ck(t,s,a)}function wq(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function XEe(t,e){for(;t&&e==t.childNodes.length&&!lb(t);)e=Zi(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 YEe(t,e){for(;t&&!e&&!lb(t);)e=Zi(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 Ck(t,e,n){if(e.nodeType!=3){let s,a;(a=XEe(e,n))?(e=a,n=0):(s=YEe(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(LS(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&gc(t)},50)}function m6(t,e){let n=t.state.doc.resolve(e);if(!(us||bEe)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),a=(s.top+s.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),a=(s.top+s.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function g6(t,e,n){let r=t.state.selection;if(r instanceof qt&&!r.empty||n.indexOf("s")>-1||$a&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let a=Tk(t.state,e);if(a&&a instanceof Ht)return Eu(t,a)}if(!i.parent.inlineContent){let a=e<0?i:s,o=r instanceof ba?ln.near(a,e):ln.findFrom(a,e);return o?Eu(t,o):!1}return!1}function x6(t,e){if(!(t.state.selection instanceof qt))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let a=t.state.tr;return e<0?a.delete(n.pos-s.nodeSize,n.pos):a.delete(n.pos,n.pos+s.nodeSize),t.dispatch(a),!0}return!1}function b6(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function ZEe(t){if(!Ms||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;b6(t,r,"true"),setTimeout(()=>b6(t,r,"false"),20)}return!1}function QEe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function JEe(t,e){let n=e.keyCode,r=QEe(e);if(n==8||$a&&n==72&&r=="c")return x6(t,-1)||wp(t,-1);if(n==46&&!e.shiftKey||$a&&n==68&&r=="c")return x6(t,1)||wp(t,1);if(n==13||n==27)return!0;if(n==37||$a&&n==66&&r=="c"){let i=n==37?m6(t,t.state.selection.from)=="ltr"?-1:1:-1;return p6(t,i,r)||wp(t,i)}else if(n==39||$a&&n==70&&r=="c"){let i=n==39?m6(t,t.state.selection.from)=="ltr"?1:-1:1;return p6(t,i,r)||wp(t,i)}else{if(n==38||$a&&n==80&&r=="c")return g6(t,-1,r)||wp(t,-1);if(n==40||$a&&n==78&&r=="c")return ZEe(t)||g6(t,1,r)||wp(t,1);if(r==($a?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function cD(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let a=t.someProp("clipboardSerializer")||sf.fromSchema(t.state.schema),o=Cq(),l=o.createElement("div");l.appendChild(a.serializeFragment(r,{document:o}));let u=l.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Tq[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let x=o.createElement(d[m]);for(;l.firstChild;)x.appendChild(l.firstChild);l.appendChild(x),f++}u=l.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${f?` -${f}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:l,text:g,slice:e}}function Sq(t,e,n,r,i){let s=i.parent.type.spec.code,a,o;if(!n&&!e)return null;let l=!!e&&(r||s||!n);if(l){if(t.someProp("transformPastedText",g=>{e=g(e,s||r,t)}),s)return o=new Tt(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=sf.fromSchema(m);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let v=a.appendChild(document.createElement("p"));y&&v.appendChild(x.serializeNode(m.text(y,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),a=rMe(n),cb&&iMe(a);let u=a&&a.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let g=a.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;a=g}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||Bx.fromSchema(t.state.schema)).parseSlice(a,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!eMe.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)o=sMe(v6(o,+d[1],+d[2]),d[4]);else if(o=Tt.maxOpen(tMe(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=v6(o,f,g)}return t.someProp("transformPasted",f=>{o=f(o,t,l)}),o}const eMe=/^(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 tMe(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,a=[];if(t.forEach(o=>{if(!a)return;let l=i.findWrapping(o.type),u;if(!l)return a=null;if(u=a.length&&s.length&&Mq(l,s,o,a[a.length-1],0))a[a.length-1]=u;else{a.length&&(a[a.length-1]=Aq(a[a.length-1],s.length));let d=Eq(o,l);a.push(d),i=i.matchType(d.type),s=l}}),a)return pt.from(a)}return t}function Eq(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,pt.from(t));return t}function Mq(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Mq(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(pt.from(Eq(n,t,i+1))))}}function Aq(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Aq(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(pt.empty,!0);return t.copy(n.append(r))}function Nk(t,e,n,r,i,s){let a=e<0?t.firstChild:t.lastChild,o=a.content;return t.childCount>1&&(s=0),i<r-1&&(o=Nk(o,e,n,r,i+1,s)),i>=n&&(o=e<0?a.contentMatchAt(0).fillBefore(o,s<=i).append(o):o.append(a.contentMatchAt(a.childCount).fillBefore(pt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(o))}function v6(t,e,n){return e<t.openStart&&(t=new Tt(Nk(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Tt(Nk(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Tq={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 y6=null;function Cq(){return y6||(y6=document.implementation.createHTMLDocument("title"))}let UT=null;function nMe(t){let e=window.trustedTypes;return e?(UT||(UT=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),UT.createHTML(t)):t}function rMe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Cq().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Tq[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=nMe(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function iMe(t){let e=t.querySelectorAll(us?"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 sMe(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:s,openEnd:a}=t;for(let o=r.length-2;o>=0;o-=2){let l=n.nodes[r[o]];if(!l||l.hasRequiredAttrs())break;i=pt.from(l.create(r[o+1],i)),s++,a++}return new Tt(i,s,a)}const As={},Ts={},aMe={touchstart:!0,touchmove:!0};class oMe{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 lMe(t){for(let e in As){let n=As[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{uMe(t,r)&&!uD(t,r)&&(t.editable||!(r.type in Ts))&&n(t,r)},aMe[e]?{passive:!0}:void 0)}Ms&&t.dom.addEventListener("input",()=>null),kk(t)}function zu(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function cMe(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 kk(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>uD(t,r))})}function uD(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function uMe(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 dMe(t,e){!uD(t,e)&&As[e.type]&&(t.editable||!(e.type in Ts))&&As[e.type](t,e)}Ts.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!kq(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(lc&&us&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),vm&&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,rh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||JEe(t,n)?n.preventDefault():zu(t,"key")};Ts.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ts.keypress=(t,e)=>{let n=e;if(kq(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||$a&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof qt)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",a=>a(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function US(t){return{left:t.clientX,top:t.clientY}}function hMe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function dD(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let a=s.depth+1;a>0;a--)if(t.someProp(e,o=>a>s.depth?o(t,n,s.nodeAfter,s.before(a),i,!0):o(t,n,s.node(a),s.before(a),i,!1)))return!0;return!1}function Zp(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function fMe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ht.isSelectable(r)?(Zp(t,new Ht(n)),!0):!1}function pMe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ht&&(r=n.node);let s=t.state.doc.resolve(e);for(let a=s.depth+1;a>0;a--){let o=a>s.depth?s.nodeAfter:s.node(a);if(Ht.isSelectable(o)){r&&n.$from.depth>0&&a>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(a);break}}return i!=null?(Zp(t,Ht.create(t.state.doc,i)),!0):!1}function mMe(t,e,n,r,i){return dD(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?pMe(t,n):fMe(t,n))}function gMe(t,e,n,r){return dD(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function xMe(t,e,n,r){return dD(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||bMe(t,n,r)}function bMe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Zp(t,qt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let a=s>i.depth?i.nodeAfter:i.node(s),o=i.before(s);if(a.inlineContent)Zp(t,qt.create(r,o+1,o+1+a.content.size));else if(Ht.isSelectable(a))Zp(t,Ht.create(r,o));else continue;return!0}}function hD(t){return k1(t)}const Nq=$a?"metaKey":"ctrlKey";As.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=hD(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&hMe(n,t.input.lastClick)&&!n[Nq]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let a=t.posAtCoords(US(n));a&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new vMe(t,a,n,!!r)):(s=="doubleClick"?gMe:xMe)(t,a.pos,a.inside,n)?n.preventDefault():zu(t,"pointer"))};class vMe{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Nq],this.allowDefault=r.shiftKey;let s,a;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),a=n.inside;else{let d=e.state.doc.resolve(n.pos);s=d.parent,a=d.depth?d.before():0}const o=i?null:r.target,l=o?e.docView.nearestDesc(o,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof Ht&&u.from<=a&&u.to>a)&&(this.mightDrag={node:s,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&to&&!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)),zu(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(()=>gc(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(US(e))),this.updateAllowDefault(e),this.allowDefault||!n?zu(this.view,"pointer"):mMe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ms&&this.mightDrag&&!this.mightDrag.node.isAtom||us&&!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)?(Zp(this.view,ln.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):zu(this.view,"pointer")}move(e){this.updateAllowDefault(e),zu(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)}}As.touchstart=t=>{t.input.lastTouch=Date.now(),hD(t),zu(t,"pointer")};As.touchmove=t=>{t.input.lastTouch=Date.now(),zu(t,"pointer")};As.contextmenu=t=>hD(t);function kq(t,e){return t.composing?!0:Ms&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const yMe=lc?5e3:-1;Ts.compositionstart=Ts.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof qt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),k1(t,!0),t.markCursor=null;else if(k1(t,!e.selection.empty),to&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let a=s<0?i.lastChild:i.childNodes[s-1];if(!a)break;if(a.nodeType==3){let o=t.domSelection();o&&o.collapse(a,a.nodeValue.length);break}else i=a,s=-1}}t.input.composing=!0}Pq(t,yMe)};Ts.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++,Pq(t,20))};function Pq(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>k1(t),e))}function Rq(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=wMe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function _Me(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=fEe(e.focusNode,e.focusOffset),r=pEe(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let a=n.pmViewDesc;if(!(!a||!a.isText(n.nodeValue)))return r}}return n||r}function wMe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function k1(t,e=!1){if(!(lc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Rq(t),e||t.docView&&t.docView.dirty){let n=oD(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function SMe(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const N0=Ws&&qu<15||vm&&vEe<604;As.copy=Ts.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=N0?null:n.clipboardData,a=r.content(),{dom:o,text:l}=cD(t,a);s?(n.preventDefault(),s.clearData(),s.setData("text/html",o.innerHTML),s.setData("text/plain",l)):SMe(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function EMe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function MMe(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?k0(t,r.value,null,i,e):k0(t,r.textContent,r.innerHTML,i,e)},50)}function k0(t,e,n,r,i){let s=Sq(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,s||Tt.empty)))return!0;if(!s)return!1;let a=EMe(s),o=a?t.state.tr.replaceSelectionWith(a,r):t.state.tr.replaceSelection(s);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Dq(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," "):""}Ts.paste=(t,e)=>{let n=e;if(t.composing&&!lc)return;let r=N0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&k0(t,Dq(r),r.getData("text/html"),i,n)?n.preventDefault():MMe(t,n)};class Oq{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const AMe=$a?"altKey":"ctrlKey";function jq(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[AMe]}As.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(US(n)),a;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Ht?i.to-1:i.to))){if(r&&r.mightDrag)a=Ht.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(a=Ht.create(t.state.doc,f.posBefore))}}let o=(a||t.state.selection).content(),{dom:l,text:u,slice:d}=cD(t,o);(!n.dataTransfer.files.length||!us||oq>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(N0?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",N0||n.dataTransfer.setData("text/plain",u),t.dragging=new Oq(d,jq(t,n),a)};As.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ts.dragover=Ts.dragenter=(t,e)=>e.preventDefault();Ts.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(US(n));if(!i)return;let s=t.state.doc.resolve(i.pos),a=r&&r.slice;a?t.someProp("transformPasted",x=>{a=x(a,t,!1)}):a=Sq(t,Dq(n.dataTransfer),N0?null:n.dataTransfer.getData("text/html"),!1,s);let o=!!(r&&jq(t,n));if(t.someProp("handleDrop",x=>x(t,n,a||Tt.empty,o))){n.preventDefault();return}if(!a)return;n.preventDefault();let l=a?zW(t.state.doc,s.pos,a):s.pos;l==null&&(l=s.pos);let u=t.state.tr;if(o){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(l),f=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,g=u.doc;if(f?u.replaceRangeWith(d,d,a.content.firstChild):u.replaceRange(d,d,a),u.doc.eq(g))return;let m=u.doc.resolve(d);if(f&&Ht.isSelectable(a.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(a.content.firstChild))u.setSelection(new Ht(m));else{let x=u.mapping.map(l);u.mapping.maps[u.mapping.maps.length-1].forEach((y,v,b,E)=>x=E),u.setSelection(lD(t,m,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};As.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())&&gc(t)},20))};As.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)};As.beforeinput=(t,e)=>{if(us&&lc&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,rh(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 Ts)As[t]=Ts[t];function P0(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 P1{constructor(e,n){this.toDOM=e,this.spec=n||yh,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:a}=e.mapResult(n.from+i,this.side<0?-1:1);return a?null:new ws(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof P1&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&P0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Xu{constructor(e,n){this.attrs=e,this.spec=n||yh}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,a=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=a?null:new ws(s,a,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Xu&&P0(this.attrs,e.attrs)&&P0(this.spec,e.spec)}static is(e){return e.type instanceof Xu}destroy(){}}class fD{constructor(e,n){this.attrs=e,this.spec=n||yh}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let a=e.mapResult(n.to+i,-1);return a.deleted||a.pos<=s.pos?null:new ws(s.pos-r,a.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof fD&&P0(this.attrs,e.attrs)&&P0(this.spec,e.spec)}destroy(){}}class ws{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ws(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 ws(e,e,new P1(n,r))}static inline(e,n,r,i){return new ws(e,n,new Xu(r,i))}static node(e,n,r,i){return new ws(e,n,new fD(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xu}get widget(){return this.type instanceof P1}}const kp=[],yh={};class br{constructor(e,n){this.local=e.length?e:kp,this.children=n.length?n:kp}static create(e,n){return n.length?R1(n,e,0,yh):as}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=n&&o.to>=e&&(!s||s(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<n&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,n-o,r,i+o,s)}}map(e,n,r){return this==as||e.maps.length==0?this:this.mapInner(e,n,0,0,r||yh)}mapInner(e,n,r,i,s){let a;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(e,r,i);l&&l.type.valid(n,l)?(a||(a=[])).push(l):s.onRemove&&s.onRemove(this.local[o].spec)}return this.children.length?TMe(this.children,a||[],e,n,r,i,s):a?new br(a.sort(_h),kp):as}add(e,n){return n.length?this==as?br.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((o,l)=>{let u=l+r,d;if(d=Iq(n,o,u)){for(i||(i=this.children.slice());s<i.length&&i[s]<l;)s+=3;i[s]==l?i[s+2]=i[s+2].addInner(o,d,u+1):i.splice(s,0,l,l+o.nodeSize,R1(d,o,u+1,yh)),s+=3}});let a=Lq(s?Uq(n):n,-r);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||a.splice(o--,1);return new br(a.length?this.local.concat(a).sort(_h):this.local,i||this.children)}remove(e){return e.length==0||this==as?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let a,o=r[s]+n,l=r[s+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>o&&f.to<l&&(e[d]=null,(a||(a=[])).push(f));if(!a)continue;r==this.children&&(r=this.children.slice());let u=r[s+2].removeInner(a,o+1);u!=as?r[s+2]=u:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,a;s<e.length;s++)if(a=e[s])for(let o=0;o<i.length;o++)i[o].eq(a,n)&&(i==this.local&&(i=this.local.slice()),i.splice(o--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new br(i,r):as}forChild(e,n){if(this==as)return this;if(n.isLeaf)return br.empty;let r,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(r=this.children[o+2]);break}let s=e+1,a=s+n.content.size;for(let o=0;o<this.local.length;o++){let l=this.local[o];if(l.from<a&&l.to>s&&l.type instanceof Xu){let u=Math.max(s,l.from)-s,d=Math.min(a,l.to)-s;u<d&&(i||(i=[])).push(l.copy(u,d))}}if(i){let o=new br(i.sort(_h),kp);return r?new Pu([o,r]):o}return r||as}eq(e){if(this==e)return!0;if(!(e instanceof br)||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 pD(this.localsInner(e))}localsInner(e){if(this==as)return kp;if(e.inlineContent||!this.local.some(Xu.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Xu||n.push(this.local[r]);return n}forEachSet(e){e(this)}}br.empty=new br([],[]);br.removeOverlap=pD;const as=br.empty;class Pu{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,yh));return Pu.from(r)}forChild(e,n){if(n.isLeaf)return br.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=as&&(s instanceof Pu?r=r.concat(s.members):r.push(s))}return Pu.from(r)}eq(e){if(!(e instanceof Pu)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let a=0;a<s.length;a++)n.push(s[a])}}return n?pD(r?n:n.sort(_h)):kp}static from(e){switch(e.length){case 0:return as;case 1:return e[0];default:return new Pu(e.every(n=>n instanceof br)?e:e.reduce((n,r)=>n.concat(r instanceof br?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function TMe(t,e,n,r,i,s,a){let o=t.slice();for(let u=0,d=s;u<n.maps.length;u++){let f=0;n.maps[u].forEach((g,m,x,y)=>{let v=y-x-(m-g);for(let b=0;b<o.length;b+=3){let E=o[b+1];if(E<0||g>E+d-f)continue;let S=o[b]+d-f;m>=S?o[b+1]=g<=S?-2:-1:g>=d&&v&&(o[b]+=v,o[b+1]+=v)}f+=v}),d=n.maps[u].map(d,-1)}let l=!1;for(let u=0;u<o.length;u+=3)if(o[u+1]<0){if(o[u+1]==-2){l=!0,o[u+1]=-1;continue}let d=n.map(t[u]+s),f=d-i;if(f<0||f>=r.content.size){l=!0;continue}let g=n.map(t[u+1]+s,-1),m=g-i,{index:x,offset:y}=r.content.findIndex(f),v=r.maybeChild(x);if(v&&y==f&&y+v.nodeSize==m){let b=o[u+2].mapInner(n,v,d+1,t[u]+s+1,a);b!=as?(o[u]=f,o[u+1]=m,o[u+2]=b):(o[u+1]=-2,l=!0)}else l=!0}if(l){let u=CMe(o,t,e,n,i,s,a),d=R1(u,r,0,a);e=d.local;for(let f=0;f<o.length;f+=3)o[f+1]<0&&(o.splice(f,3),f-=3);for(let f=0,g=0;f<d.children.length;f+=3){let m=d.children[f];for(;g<o.length&&o[g]<m;)g+=3;o.splice(g,0,d.children[f],d.children[f+1],d.children[f+2])}}return new br(e.sort(_h),o)}function Lq(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 ws(i.from+e,i.to+e,i.type))}return n}function CMe(t,e,n,r,i,s,a){function o(l,u){for(let d=0;d<l.local.length;d++){let f=l.local[d].map(r,i,u);f?n.push(f):a.onRemove&&a.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)o(l.children[d+2],l.children[d]+u+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&o(t[l+2],e[l]+s+1);return n}function Iq(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,a;s<t.length;s++)(a=t[s])&&a.from>n&&a.to<r&&((i||(i=[])).push(a),t[s]=null);return i}function Uq(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function R1(t,e,n,r){let i=[],s=!1;e.forEach((o,l)=>{let u=Iq(t,o,l+n);if(u){s=!0;let d=R1(u,o,n+l+1,r);d!=as&&i.push(l,l+o.nodeSize,d)}});let a=Lq(s?Uq(t):t,-n).sort(_h);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||(r.onRemove&&r.onRemove(a[o].spec),a.splice(o--,1));return a.length||i.length?new br(a,i):as}function _h(t,e){return t.from-e.from||t.to-e.to}function pD(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),_6(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),_6(e,i,r.copy(s.from,r.to)));break}}}return e}function _6(t,e,n){for(;e<t.length&&_h(n,t[e])>0;)e++;t.splice(e,0,n)}function FT(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=as&&e.push(r)}),t.cursorWrapper&&e.push(br.create(t.state.doc,[t.cursorWrapper.deco])),Pu.from(e)}const NMe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},kMe=Ws&&qu<=11;class PMe{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 RMe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new PMe,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]);Ws&&qu<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),kMe&&(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,NMe)),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(f6(this.view)){if(this.suppressingSelectionUpdates)return gc(this.view);if(Ws&&qu<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vh(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=bm(s))n.add(s);for(let s=e.anchorNode;s;s=bm(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&f6(e)&&!this.ignoreSelectionChange(r),s=-1,a=-1,o=!1,l=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],l);f&&(s=s<0?f.from:Math.min(f.from,s),a=a<0?f.to:Math.max(f.to,a),f.typeOver&&(o=!0))}if(to&&l.length){let d=l.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,g]=d;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of d){let m=g.parentNode;m&&m.nodeName=="LI"&&(!f||jMe(e,f)!=m)&&g.remove()}}}let u=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&LS(r)&&(u=oD(e))&&u.eq(ln.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,gc(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,a),DMe(e)),this.handleDOMChange(s,a,o,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||gc(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Ws&&qu<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:g}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(s=g)}let a=i&&i.parentNode==e.target?Zi(i)+1:0,o=r.localPosFromDOM(e.target,a,-1),l=s&&s.parentNode==e.target?Zi(s):e.target.childNodes.length,u=r.localPosFromDOM(e.target,l,1);return{from:o,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let w6=new WeakMap,S6=!1;function DMe(t){if(!w6.has(t)&&(w6.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=to,S6)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),S6=!0}}function E6(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,a=t.domAtPos(t.state.selection.anchor);return Vh(a.node,a.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function OMe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return E6(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?E6(t,n):null}function jMe(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function LMe(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:a,to:o}=t.docView.parseRange(e,n),l=t.domSelectionRange(),u,d=l.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:l.anchorOffset}],LS(l)||u.push({node:l.focusNode,offset:l.focusOffset})),us&&t.input.lastKeyCode===8)for(let v=s;v>i;v--){let b=r.childNodes[v-1],E=b.pmViewDesc;if(b.nodeName=="BR"&&!E){s=v;break}if(!E||E.size)break}let f=t.state.doc,g=t.someProp("domParser")||Bx.fromSchema(t.state.schema),m=f.resolve(a),x=null,y=g.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:IMe,context:m});if(u&&u[0].pos!=null){let v=u[0].pos,b=u[1]&&u[1].pos;b==null&&(b=v),x={anchor:v+a,head:b+a}}return{doc:y,sel:x,from:a,to:o}}function IMe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ms&&/^(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||Ms&&/^(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 UMe=/^(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 FMe(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,I=oD(t,C);if(I&&!t.state.selection.eq(I)){if(us&&lc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,rh(13,"Enter"))))return;let N=t.state.tr.setSelection(I);C=="pointer"?N.setMeta("pointer",!0):C=="key"&&N.scrollIntoView(),s&&N.setMeta("composition",s),t.dispatch(N)}return}let a=t.state.doc.resolve(e),o=a.sharedDepth(n);e=a.before(o+1),n=t.state.doc.resolve(n).after(o+1);let l=t.state.selection,u=LMe(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=HMe(f.content,u.doc.content,u.from,g,m);if(x&&t.input.domChangeCount++,(vm&&t.input.lastIOSEnter>Date.now()-225||lc)&&i.some(C=>C.nodeType==1&&!UMe.test(C.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",C=>C(t,rh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&l instanceof qt&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:l.from,endA:l.to,endB:l.to};else{if(u.sel){let C=M6(t,t.state.doc,u.sel);if(C&&!C.eq(t.state.selection)){let I=t.state.tr.setSelection(C);s&&I.setMeta("composition",s),t.dispatch(I)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof qt&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),Ws&&qu<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>u.from&&u.doc.textBetween(x.start-u.from-1,x.start-u.from+1)==" "&&(x.start--,x.endA--,x.endB--);let y=u.doc.resolveNoCache(x.start-u.from),v=u.doc.resolveNoCache(x.endB-u.from),b=d.resolve(x.start),E=y.sameParent(v)&&y.parent.inlineContent&&b.end()>=x.endA;if((vm&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!E&&y.pos<u.doc.content.size&&(!y.sameParent(v)||!y.parent.inlineContent)&&y.pos<v.pos&&!/\S/.test(u.doc.textBetween(y.pos,v.pos,"","")))&&t.someProp("handleKeyDown",C=>C(t,rh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&BMe(d,x.start,x.endA,y,v)&&t.someProp("handleKeyDown",C=>C(t,rh(8,"Backspace")))){lc&&us&&t.domObserver.suppressSelectionUpdates();return}us&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),lc&&!E&&y.start()!=v.start()&&v.parentOffset==0&&y.depth==v.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,v=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(C){return C(t,rh(13,"Enter"))})},20));let S=x.start,A=x.endA,T=C=>{let I=C||t.state.tr.replace(S,A,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let N=M6(t,I.doc,u.sel);N&&!(us&&t.composing&&N.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(N.head==S||N.head==I.mapping.map(A)-1)||Ws&&N.empty&&N.head==S)&&I.setSelection(N)}return s&&I.setMeta("composition",s),I.scrollIntoView()},P;if(E)if(y.pos==v.pos){Ws&&qu<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>gc(t),20));let C=T(t.state.tr.delete(S,A)),I=d.resolve(x.start).marksAcross(d.resolve(x.endA));I&&C.ensureMarks(I),t.dispatch(C)}else if(x.endA==x.endB&&(P=zMe(y.parent.content.cut(y.parentOffset,v.parentOffset),b.parent.content.cut(b.parentOffset,x.endA-b.start())))){let C=T(t.state.tr);P.type=="add"?C.addMark(S,A,P.mark):C.removeMark(S,A,P.mark),t.dispatch(C)}else if(y.parent.child(y.index()).isText&&y.index()==v.index()-(v.textOffset?0:1)){let C=y.parent.textBetween(y.parentOffset,v.parentOffset),I=()=>T(t.state.tr.insertText(C,S,A));t.someProp("handleTextInput",N=>N(t,S,A,C,I))||t.dispatch(I())}else t.dispatch(T());else t.dispatch(T())}function M6(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:lD(t,e.resolve(n.anchor),e.resolve(n.head))}function zMe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,a,o,l;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)s=n[d].removeFromSet(s);if(i.length==1&&s.length==0)o=i[0],a="add",l=d=>d.mark(o.addToSet(d.marks));else if(i.length==0&&s.length==1)o=s[0],a="remove",l=d=>d.mark(o.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(l(e.child(d)));if(pt.from(u).eq(t))return{mark:o,type:a}}function BMe(t,e,n,r,i){if(n-e<=i.pos-r.pos||zT(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let o=s.nodeAfter;return o!=null&&n==e+o.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let a=t.resolve(zT(s,!0,!0));return!a.parent.isTextblock||a.pos>n||zT(a,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(a.parent.content)}function zT(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function HMe(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,s-Math.min(a,o));r-=a+l-s}if(a<s&&t.size<e.size){let l=r<=s&&r>=a?s-r:0;s-=l,s&&s<e.size&&A6(e.textBetween(s-1,s+1))&&(s+=l?1:-1),o=s+(o-a),a=s}else if(o<s){let l=r<=s&&r>=o?s-r:0;s-=l,s&&s<t.size&&A6(t.textBetween(s-1,s+1))&&(s+=l?1:-1),a=s+(a-o),o=s}return{start:s,endA:a,endB:o}}function A6(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 Fq{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 oMe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(P6),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=N6(this),C6(this),this.nodeViews=k6(this),this.docView=o6(this.state.doc,T6(this),FT(this),this.dom,this),this.domObserver=new RMe(this,(r,i,s,a)=>FMe(this,r,i,s,a)),this.domObserver.start(),lMe(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&&kk(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(P6),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,a=!1;e.storedMarks&&this.composing&&(Rq(this),a=!0),this.state=e;let o=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(o||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let m=k6(this);VMe(m,this.nodeViews)&&(this.nodeViews=m,s=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&kk(this),this.editable=N6(this),C6(this);let l=FT(this),u=T6(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,u,l);(f||!e.selection.eq(i.selection))&&(a=!0);let g=d=="preserve"&&a&&this.dom.style.overflowAnchor==null&&wEe(this);if(a){this.domObserver.stop();let m=f&&(Ws||us)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&$Me(i.selection,e.selection);if(f){let x=us?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=_Me(this)),(s||!this.docView.update(e.doc,u,l,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=o6(e.doc,u,l,this.dom,this)),x&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&WEe(this))?gc(this,m):(yq(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&&SEe(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&&t6(this,n.getBoundingClientRect(),e)}else t6(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Oq(e.slice,e.move,i<0?void 0:Ht.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let a=0;a<this.directPlugins.length;a++){let o=this.directPlugins[a].props[e];if(o!=null&&(i=n?n(o):o))return i}let s=this.state.plugins;if(s)for(let a=0;a<s.length;a++){let o=s[a].props[e];if(o!=null&&(i=n?n(o):o))return i}}hasFocus(){if(Ws){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&&EEe(this.dom),gc(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 NEe(this,e)}coordsAtPos(e,n=1){return hq(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 OEe(this,n||this.state,e)}pasteHTML(e,n){return k0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return k0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return cD(this,e)}destroy(){this.docView&&(cMe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],FT(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,dEe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return dMe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ms&&this.root.nodeType===11&&gEe(this.dom.ownerDocument)==this.dom&&OMe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Fq.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function T6(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"),[ws.node(0,t.state.doc.content.size,e)]}function C6(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:ws.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function N6(t){return!t.someProp("editable",e=>e(t.state)===!1)}function $Me(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 k6(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 VMe(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 P6(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 id={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:"'"},D1={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},GMe=typeof navigator<"u"&&/Mac/.test(navigator.platform),WMe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Qi=0;Qi<10;Qi++)id[48+Qi]=id[96+Qi]=String(Qi);for(var Qi=1;Qi<=24;Qi++)id[Qi+111]="F"+Qi;for(var Qi=65;Qi<=90;Qi++)id[Qi]=String.fromCharCode(Qi+32),D1[Qi]=String.fromCharCode(Qi);for(var BT in id)D1.hasOwnProperty(BT)||(D1[BT]=id[BT]);function qMe(t){var e=GMe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||WMe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?D1:id)[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 KMe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),XMe=typeof navigator<"u"&&/Win/.test(navigator.platform);function YMe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,a;for(let o=0;o<e.length-1;o++){let l=e[o];if(/^(cmd|meta|m)$/i.test(l))a=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))KMe?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),a&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function ZMe(t){let e=Object.create(null);for(let n in t)e[YMe(n)]=t[n];return e}function HT(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 QMe(t){return new _r({props:{handleKeyDown:zq(t)}})}function zq(t){let e=ZMe(t);return function(n,r){let i=qMe(r),s,a=e[HT(i,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let o=e[HT(i,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(XMe&&r.ctrlKey&&r.altKey)&&(s=id[r.keyCode])&&s!=i){let o=e[HT(s,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var JMe=Object.defineProperty,mD=(t,e)=>{for(var n in e)JMe(t,n,{get:e[n],enumerable:!0})};function FS(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var zS=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([a,o])=>[a,(...u)=>{const d=o(...u)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,a=[],o=!!t,l=t||i.tr,u=()=>(!o&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),a.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...x)=>{const y=this.buildProps(l,e),v=g(...x)(y);return a.push(v),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([o,l])=>[o,(...u)=>l(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,a={tr:t,editor:r,view:s,state:FS({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...u)=>l(...u)(a)]))}};return a}},Bq={};mD(Bq,{blur:()=>e2e,clearContent:()=>t2e,clearNodes:()=>n2e,command:()=>r2e,createParagraphNear:()=>i2e,cut:()=>s2e,deleteCurrentNode:()=>a2e,deleteNode:()=>o2e,deleteRange:()=>l2e,deleteSelection:()=>c2e,enter:()=>u2e,exitCode:()=>d2e,extendMarkRange:()=>h2e,first:()=>f2e,focus:()=>m2e,forEach:()=>g2e,insertContent:()=>x2e,insertContentAt:()=>y2e,joinBackward:()=>S2e,joinDown:()=>w2e,joinForward:()=>E2e,joinItemBackward:()=>M2e,joinItemForward:()=>A2e,joinTextblockBackward:()=>T2e,joinTextblockForward:()=>C2e,joinUp:()=>_2e,keyboardShortcut:()=>k2e,lift:()=>P2e,liftEmptyBlock:()=>R2e,liftListItem:()=>D2e,newlineInCode:()=>O2e,resetAttributes:()=>j2e,scrollIntoView:()=>L2e,selectAll:()=>I2e,selectNodeBackward:()=>U2e,selectNodeForward:()=>F2e,selectParentNode:()=>z2e,selectTextblockEnd:()=>B2e,selectTextblockStart:()=>H2e,setContent:()=>$2e,setMark:()=>oAe,setMeta:()=>lAe,setNode:()=>cAe,setNodeSelection:()=>uAe,setTextDirection:()=>dAe,setTextSelection:()=>hAe,sinkListItem:()=>fAe,splitBlock:()=>pAe,splitListItem:()=>mAe,toggleList:()=>gAe,toggleMark:()=>xAe,toggleNode:()=>bAe,toggleWrap:()=>vAe,undoInputRule:()=>yAe,unsetAllMarks:()=>_Ae,unsetMark:()=>wAe,unsetTextDirection:()=>SAe,updateAttributes:()=>EAe,wrapIn:()=>MAe,wrapInList:()=>AAe});var e2e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),t2e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),n2e=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:a})=>{t.doc.nodesBetween(s.pos,a.pos,(o,l)=>{if(o.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(l)),g=u.resolve(d.map(l+o.nodeSize)),m=f.blockRange(g);if(!m)return;const x=$m(m);if(o.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(m.start,y)}(x||x===0)&&e.lift(m,x)})}),!0},r2e=t=>e=>t(e),i2e=()=>({state:t,dispatch:e})=>nq(t,e),s2e=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const a=r.mapping.map(e);return r.insert(a,s.content),r.setSelection(new qt(r.doc.resolve(Math.max(a-1,0)))),!0},a2e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const o=i.before(s),l=i.after(s);t.delete(o,l).scrollIntoView()}return!0}return!1};function ni(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 o2e=t=>({tr:e,state:n,dispatch:r})=>{const i=ni(t,n.schema),s=e.selection.$anchor;for(let a=s.depth;a>0;a-=1)if(s.node(a).type===i){if(r){const l=s.before(a),u=s.after(a);e.delete(l,u).scrollIntoView()}return!0}return!1},l2e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},c2e=()=>({state:t,dispatch:e})=>tD(t,e),u2e=()=>({commands:t})=>t.keyboardShortcut("Enter"),d2e=()=>({state:t,dispatch:e})=>YSe(t,e);function gD(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function O1(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:gD(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Hq(t,e,n={}){return t.find(r=>r.type===e&&O1(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function R6(t,e,n={}){return!!Hq(t,e,n)}function xD(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),!Hq([...i.node.marks],e,n)))return;let a=i.index,o=t.start()+i.offset,l=a+1,u=o+i.node.nodeSize;for(;a>0&&R6([...t.parent.child(a-1).marks],e,n);)a-=1,o-=t.parent.child(a).nodeSize;for(;l<t.parent.childCount&&R6([...t.parent.child(l).marks],e,n);)u+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:u}}function Nc(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 h2e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Nc(t,r.schema),{doc:a,selection:o}=n,{$from:l,from:u,to:d}=o;if(i){const f=xD(l,s,e);if(f&&f.from<=u&&f.to>=d){const g=qt.create(a,f.from,f.to);n.setSelection(g)}}return!0},f2e=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 $q(t){return t instanceof qt}function lh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Vq(t,e=null){if(!e)return null;const n=ln.atStart(t),r=ln.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?qt.create(t,lh(0,i,s),lh(t.content.size,i,s)):qt.create(t,lh(e,i,s),lh(e,i,s))}function p2e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function bD(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var m2e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const a=()=>{(bD()||p2e())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!$q(n.state.selection))return a(),!0;const o=Vq(i.doc,t)||n.state.selection,l=n.state.selection.eq(o);return s&&(l||i.setSelection(o),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),a()),!0},g2e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),x2e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Gq=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&&Gq(r)}return t};function r_(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 Gq(n)}function R0(t,e,n){if(t instanceof Wu||t instanceof pt)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return pt.fromArray(t.map(o=>e.nodeFromJSON(o)));const a=e.nodeFromJSON(t);return n.errorOnInvalidContent&&a.check(),a}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),R0("",e,n)}if(i){if(n.errorOnInvalidContent){let a=!1,o="";const l=new NW({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(a=!0,o=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?Bx.fromSchema(l).parseSlice(r_(t),n.parseOptions):Bx.fromSchema(l).parse(r_(t),n.parseOptions),n.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const s=Bx.fromSchema(e);return n.slice?s.parseSlice(r_(t),n.parseOptions).content:s.parse(r_(t),n.parseOptions)}return R0("",e,n)}function b2e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ri||i instanceof Oi))return;const s=t.mapping.maps[r];let a=0;s.forEach((o,l,u,d)=>{a===0&&(a=d)}),t.setSelection(ln.near(t.doc.resolve(a),n))}var v2e=t=>!("type"in t),y2e=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var a;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const l=v=>{s.emit("contentError",{editor:s,error:v,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{R0(e,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(v){l(v)}try{o=R0(e,s.schema,{parseOptions:u,errorOnInvalidContent:(a=n.errorOnInvalidContent)!=null?a:s.options.enableContentCheck})}catch(v){return l(v),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,m=!0;if((v2e(o)?o:[o]).forEach(v=>{v.check(),g=g?v.isText&&v.marks.length===0:!1,m=m?v.isBlock:!1}),d===f&&m){const{parent:v}=r.doc.resolve(d);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(d-=1,f+=1)}let y;if(g){if(Array.isArray(e))y=e.map(v=>v.text||"").join("");else if(e instanceof pt){let v="";e.forEach(b=>{b.text&&(v+=b.text)}),y=v}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,f)}else{y=o;const v=r.doc.resolve(d),b=v.node(),E=v.parentOffset===0,S=b.isText||b.isTextblock,A=b.content.size>0;E&&S&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&b2e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},_2e=()=>({state:t,dispatch:e})=>qSe(t,e),w2e=()=>({state:t,dispatch:e})=>KSe(t,e),S2e=()=>({state:t,dispatch:e})=>XW(t,e),E2e=()=>({state:t,dispatch:e})=>JW(t,e),M2e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=DS(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},A2e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=DS(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},T2e=()=>({state:t,dispatch:e})=>GSe(t,e),C2e=()=>({state:t,dispatch:e})=>WSe(t,e);function Wq(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function N2e(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,a;for(let o=0;o<e.length-1;o+=1){const l=e[o];if(/^(cmd|meta|m)$/i.test(l))a=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))bD()||Wq()?a=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),a&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var k2e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=N2e(t).split(/-(?!$)/),a=s.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),o=new KeyboardEvent("keydown",{key:a==="Space"?" ":a,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,o))});return l?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function sd(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,a=e?ni(e,t.schema):null,o=[];t.doc.nodesBetween(r,i,(f,g)=>{if(f.isText)return;const m=Math.max(r,g),x=Math.min(i,g+f.nodeSize);o.push({node:f,from:m,to:x})});const l=i-r,u=o.filter(f=>a?a.name===f.node.type.name:!0).filter(f=>O1(f.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=l}var P2e=(t,e={})=>({state:n,dispatch:r})=>{const i=ni(t,n.schema);return sd(n,i,e)?XSe(n,r):!1},R2e=()=>({state:t,dispatch:e})=>rq(t,e),D2e=t=>({state:e,dispatch:n})=>{const r=ni(t,e.schema);return oEe(r)(e,n)},O2e=()=>({state:t,dispatch:e})=>tq(t,e);function BS(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function D6(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 j2e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,a=null;const o=BS(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(s=ni(t,r.schema)),o==="mark"&&(a=Nc(t,r.schema));let l=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{s&&s===d.type&&(l=!0,i&&n.setNodeMarkup(f,void 0,D6(d.attrs,e))),a&&d.marks.length&&d.marks.forEach(g=>{a===g.type&&(l=!0,i&&n.addMark(f,f+d.nodeSize,a.create(D6(g.attrs,e))))})})}),l},L2e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),I2e=()=>({tr:t,dispatch:e})=>{if(e){const n=new ba(t.doc);t.setSelection(n)}return!0},U2e=()=>({state:t,dispatch:e})=>ZW(t,e),F2e=()=>({state:t,dispatch:e})=>eq(t,e),z2e=()=>({state:t,dispatch:e})=>JSe(t,e),B2e=()=>({state:t,dispatch:e})=>nEe(t,e),H2e=()=>({state:t,dispatch:e})=>tEe(t,e);function Pk(t,e,n={},r={}){return R0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var $2e=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:a,commands:o})=>{const{doc:l}=s;if(r.preserveWhitespace!=="full"){const u=Pk(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return a&&s.replaceWith(0,l.content.size,u).setMeta("preventUpdate",!n),!0}return a&&s.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function qq(t,e){const n=Nc(e,t.schema),{from:r,to:i,empty:s}=t.selection,a=[];s?(t.storedMarks&&a.push(...t.storedMarks),a.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{a.push(...l.marks)});const o=a.find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function Kq(t,e){const n=new GW(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function V2e(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 G2e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function W2e(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 HS(t){return e=>W2e(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 vD(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Bt(e,"addExtensions",n);return r?[e,...vD(r())]:e}).flat(10)}function yD(t,e){const n=sf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Xq(t){return typeof t=="function"}function Ln(t,e=void 0,...n){return Xq(t)?e?t.bind(e)(...n):t(...n):t}function q2e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ym(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 Yq(t){const e=[],{nodeExtensions:n,markExtensions:r}=ym(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(a=>{const o={name:a.name,options:a.options,storage:a.storage,extensions:i},l=Bt(a,"addGlobalAttributes",o);if(!l)return;l().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([g,m])=>{e.push({type:f,name:g,attribute:{...s,...m}})})})})}),i.forEach(a=>{const o={name:a.name,options:a.options,storage:a.storage},l=Bt(a,"addAttributes",o);if(!l)return;const u=l();Object.entries(u).forEach(([d,f])=>{const g={...s,...f};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:a.name,name:d,attribute:g})})}),e}function Nr(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const o=s?String(s).split(" "):[],l=r[i]?r[i].split(" "):[],u=o.filter(d=>!l.includes(d));r[i]=[...l,...u].join(" ")}else if(i==="style"){const o=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;l.forEach(d=>{const[f,g]=d.split(":").map(m=>m.trim());u.set(f,g)}),o.forEach(d=>{const[f,g]=d.split(":").map(m=>m.trim());u.set(f,g)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=s}),r},{})}function j1(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)=>Nr(n,r),{})}function K2e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function O6(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((s,a)=>{const o=a.attribute.parseHTML?a.attribute.parseHTML(n):K2e(n.getAttribute(a.name));return o==null?s:{...s,[a.name]:o}},{});return{...r,...i}}}}function j6(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&q2e(n)?!1:n!=null))}function L6(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 X2e(t,e){var n;const r=Yq(t),{nodeExtensions:i,markExtensions:s}=ym(t),a=(n=i.find(u=>Bt(u,"topNode")))==null?void 0:n.name,o=Object.fromEntries(i.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((b,E)=>{const S=Bt(E,"extendNodeSchema",f);return{...b,...S?S(u):{}}},{}),m=j6({...g,content:Ln(Bt(u,"content",f)),marks:Ln(Bt(u,"marks",f)),group:Ln(Bt(u,"group",f)),inline:Ln(Bt(u,"inline",f)),atom:Ln(Bt(u,"atom",f)),selectable:Ln(Bt(u,"selectable",f)),draggable:Ln(Bt(u,"draggable",f)),code:Ln(Bt(u,"code",f)),whitespace:Ln(Bt(u,"whitespace",f)),linebreakReplacement:Ln(Bt(u,"linebreakReplacement",f)),defining:Ln(Bt(u,"defining",f)),isolating:Ln(Bt(u,"isolating",f)),attrs:Object.fromEntries(d.map(L6))}),x=Ln(Bt(u,"parseHTML",f));x&&(m.parseDOM=x.map(b=>O6(b,d)));const y=Bt(u,"renderHTML",f);y&&(m.toDOM=b=>y({node:b,HTMLAttributes:j1(b,d)}));const v=Bt(u,"renderText",f);return v&&(m.toText=v),[u.name,m]})),l=Object.fromEntries(s.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((v,b)=>{const E=Bt(b,"extendMarkSchema",f);return{...v,...E?E(u):{}}},{}),m=j6({...g,inclusive:Ln(Bt(u,"inclusive",f)),excludes:Ln(Bt(u,"excludes",f)),group:Ln(Bt(u,"group",f)),spanning:Ln(Bt(u,"spanning",f)),code:Ln(Bt(u,"code",f)),attrs:Object.fromEntries(d.map(L6))}),x=Ln(Bt(u,"parseHTML",f));x&&(m.parseDOM=x.map(v=>O6(v,d)));const y=Bt(u,"renderHTML",f);return y&&(m.toDOM=v=>y({mark:v,HTMLAttributes:j1(v,d)})),[u.name,m]}));return new NW({topNode:a,nodes:o,marks:l})}function Y2e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function _D(t){return t.sort((n,r)=>{const i=Bt(n,"priority")||100,s=Bt(r,"priority")||100;return i>s?-1:i<s?1:0})}function Zq(t){const e=_D(vD(t)),n=Y2e(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 Qq(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
- `,textSerializers:a={}}=n||{};let o="";return t.nodesBetween(r,i,(l,u,d,f)=>{var g;l.isBlock&&u>r&&(o+=s);const m=a?.[l.type.name];if(m)return d&&(o+=m({node:l,pos:u,parent:d,index:f,range:e})),!1;l.isText&&(o+=(g=l?.text)==null?void 0:g.slice(Math.max(r,u)-u,i-u))}),o}function Z2e(t,e){const n={from:0,to:t.content.size};return Qq(t,n,e)}function Jq(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Q2e(t,e){const n=ni(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,o=>{s.push(o)});const a=s.reverse().find(o=>o.type.name===n.name);return a?{...a.attrs}:{}}function eK(t,e){const n=BS(typeof e=="string"?e:e.name,t.schema);return n==="node"?Q2e(t,e):n==="mark"?qq(t,e):{}}function J2e(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 eAe(t){const e=J2e(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,a)=>a!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function tK(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const a=[];if(i.ranges.length)i.forEach((o,l)=>{a.push({from:o,to:l})});else{const{from:o,to:l}=n[s];if(o===void 0||l===void 0)return;a.push({from:o,to:l})}a.forEach(({from:o,to:l})=>{const u=e.slice(s).map(o,-1),d=e.slice(s).map(l),f=e.invert().map(u,-1),g=e.invert().map(d);r.push({oldRange:{from:f,to:g},newRange:{from:u,to:d}})})}),eAe(r)}function wD(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),a=xD(s,i.type);a&&r.push({mark:i,...a})}):n.nodesBetween(t,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(a=>({from:s,to:s+i.nodeSize,mark:a})))}),r}var tAe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,a=null;for(;s>0&&a===null;){const o=i.node(s);o?.type.name===e?a=o:s-=1}return[a,s]};function $T(t,e){return e.nodes[t]||e.marks[t]||null}function W_(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var nAe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,a,o)=>{var l,u;const d=((u=(l=i.type.spec).toText)==null?void 0:u.call(l,{node:i,pos:s,parent:a,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-s))}),n};function Rk(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Nc(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>O1(f.attrs,n,{strict:!1}));let a=0;const o=[];if(i.forEach(({$from:f,$to:g})=>{const m=f.pos,x=g.pos;t.doc.nodesBetween(m,x,(y,v)=>{if(!y.isText&&!y.marks.length)return;const b=Math.max(m,v),E=Math.min(x,v+y.nodeSize),S=E-b;a+=S,o.push(...y.marks.map(A=>({mark:A,from:b,to:E})))})}),a===0)return!1;const l=o.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>O1(f.mark.attrs,n,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),u=o.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,g)=>f+g.to-g.from,0);return(l>0?l+u:l)>=a}function rAe(t,e,n={}){if(!e)return sd(t,null,n)||Rk(t,null,n);const r=BS(e,t.schema);return r==="node"?sd(t,e,n):r==="mark"?Rk(t,e,n):!1}var iAe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=HS(o=>o.type.name===e)(t.selection);if(!s)return!1;const a=t.doc.resolve(s.pos+1);return i.pos+1===a.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},sAe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function I6(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function U6(t,e){const{nodeExtensions:n}=ym(e),r=n.find(a=>a.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=Ln(Bt(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function $S(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(s=>{i!==!1&&($S(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function nK(t){return t instanceof Ht}function aAe(t,e,n){var r;const{selection:i}=e;let s=null;if($q(i)&&(s=i.$cursor),s){const o=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(u=>u.type.excludes(n)))}const{ranges:a}=i;return a.some(({$from:o,$to:l})=>{let u=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,l.pos,(d,f,g)=>{if(u)return!1;if(d.isInline){const m=!g||g.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=m&&x}return!u}),u})}var oAe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:a,ranges:o}=s,l=Nc(t,r.schema);if(i)if(a){const u=qq(r,l);n.addStoredMark(l.create({...u,...e}))}else o.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(g,m)=>{const x=Math.max(m,d),y=Math.min(m+g.nodeSize,f);g.marks.find(b=>b.type===l)?g.marks.forEach(b=>{l===b.type&&n.addMark(x,y,l.create({...b.attrs,...e}))}):n.addMark(x,y,l.create(e))})});return aAe(r,n,l)},lAe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),cAe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=ni(t,n.schema);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:o})=>QB(s,{...a,...e})(n)?!0:o.clearNodes()).command(({state:o})=>QB(s,{...a,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},uAe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=lh(t,0,r.content.size),s=Ht.create(r,i);e.setSelection(s)}return!0},dAe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=r;let a,o;return typeof e=="number"?(a=e,o=e):e&&"from"in e&&"to"in e?(a=e.from,o=e.to):(a=s.from,o=s.to),i&&n.doc.nodesBetween(a,o,(l,u)=>{l.isText||n.setNodeMarkup(u,void 0,{...l.attrs,dir:t})}),!0},hAe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,a=qt.atStart(r).from,o=qt.atEnd(r).to,l=lh(i,a,o),u=lh(s,a,o),d=qt.create(r,l,u);e.setSelection(d)}return!0},fAe=t=>({state:e,dispatch:n})=>{const r=ni(t,e.schema);return uEe(r)(e,n)};function F6(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 pAe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:a}=e,{$from:o,$to:l}=s,u=i.extensionManager.attributes,d=W_(u,o.node().type.name,o.node().attrs);if(s instanceof Ht&&s.node.isBlock)return!o.parentOffset||!mc(a,o.pos)?!1:(r&&(t&&F6(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const f=l.parentOffset===l.parent.content.size,g=o.depth===0?void 0:V2e(o.node(-1).contentMatchAt(o.indexAfter(-1)));let m=f&&g?[{type:g,attrs:d}]:void 0,x=mc(e.doc,e.mapping.map(o.pos),1,m);if(!m&&!x&&mc(e.doc,e.mapping.map(o.pos),1,g?[{type:g}]:void 0)&&(x=!0,m=g?[{type:g,attrs:d}]:void 0),r){if(x&&(s instanceof qt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,m),g&&!f&&!o.parentOffset&&o.parent.type!==g)){const y=e.mapping.map(o.before()),v=e.doc.resolve(y);o.node(-1).canReplaceWith(v.index(),v.index()+1,g)&&e.setNodeMarkup(e.mapping.map(o.before()),g)}t&&F6(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},mAe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var a;const o=ni(t,r.schema),{$from:l,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(u))return!1;const f=l.node(-1);if(f.type!==o)return!1;const g=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let b=pt.empty;const E=l.index(-1)?1:l.index(-2)?2:3;for(let I=l.depth-E;I>=l.depth-3;I-=1)b=pt.from(l.node(I).copy(b));const S=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,A={...W_(g,l.node().type.name,l.node().attrs),...e},T=((a=o.contentMatch.defaultType)==null?void 0:a.createAndFill(A))||void 0;b=b.append(pt.from(o.createAndFill(null,T)||void 0));const P=l.before(l.depth-(E-1));n.replace(P,l.after(-S),new Tt(b,4-E,0));let C=-1;n.doc.nodesBetween(P,n.doc.content.size,(I,N)=>{if(C>-1)return!1;I.isTextblock&&I.content.size===0&&(C=N+1)}),C>-1&&n.setSelection(qt.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const m=u.pos===l.end()?f.contentMatchAt(0).defaultType:null,x={...W_(g,f.type.name,f.attrs),...e},y={...W_(g,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,u.pos);const v=m?[{type:o,attrs:x},{type:m,attrs:y}]:[{type:o,attrs:x}];if(!mc(n.doc,l.pos,2))return!1;if(i){const{selection:b,storedMarks:E}=r,{splittableMarks:S}=s.extensionManager,A=E||b.$to.parentOffset&&b.$from.marks();if(n.split(l.pos,2,v).scrollIntoView(),!A||!i)return!0;const T=A.filter(P=>S.includes(P.type.name));n.ensureMarks(T)}return!0},VT=(t,e)=>{const n=HS(a=>a.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&pd(t.doc,n.pos)&&t.join(n.pos),!0},GT=(t,e)=>{const n=HS(a=>a.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&pd(t.doc,r)&&t.join(r),!0},gAe=(t,e,n,r={})=>({editor:i,tr:s,state:a,dispatch:o,chain:l,commands:u,can:d})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,m=ni(t,a.schema),x=ni(e,a.schema),{selection:y,storedMarks:v}=a,{$from:b,$to:E}=y,S=b.blockRange(E),A=v||y.$to.parentOffset&&y.$from.marks();if(!S)return!1;const T=HS(P=>U6(P.type.name,f))(y);if(S.depth>=1&&T&&S.depth-T.depth<=1){if(T.node.type===m)return u.liftListItem(x);if(U6(T.node.type.name,f)&&m.validContent(T.node.content)&&o)return l().command(()=>(s.setNodeMarkup(T.pos,m),!0)).command(()=>VT(s,m)).command(()=>GT(s,m)).run()}return!n||!A||!o?l().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>VT(s,m)).command(()=>GT(s,m)).run():l().command(()=>{const P=d().wrapInList(m,r),C=A.filter(I=>g.includes(I.type.name));return s.ensureMarks(C),P?!0:u.clearNodes()}).wrapInList(m,r).command(()=>VT(s,m)).command(()=>GT(s,m)).run()},xAe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,a=Nc(t,r.schema);return Rk(r,a,e)?i.unsetMark(a,{extendEmptyMarkRange:s}):i.setMark(a,e)},bAe=(t,e,n={})=>({state:r,commands:i})=>{const s=ni(t,r.schema),a=ni(e,r.schema),o=sd(r,s,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),o?i.setNode(a,l):i.setNode(s,{...l,...n})},vAe=(t,e={})=>({state:n,commands:r})=>{const i=ni(t,n.schema);return sd(n,i,e)?r.lift(i):r.wrapIn(i,e)},yAe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const a=t.tr,o=s.transform;for(let l=o.steps.length-1;l>=0;l-=1)a.step(o.steps[l].invert(o.docs[l]));if(s.text){const l=a.doc.resolve(s.from).marks();a.replaceWith(s.from,s.to,t.schema.text(s.text,l))}else a.delete(s.from,s.to)}return!0}}return!1},_Ae=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},wAe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:a=!1}=e,{selection:o}=n,l=Nc(t,r.schema),{$from:u,empty:d,ranges:f}=o;if(!i)return!0;if(d&&a){let{from:g,to:m}=o;const x=(s=u.marks().find(v=>v.type===l))==null?void 0:s.attrs,y=xD(u,l,x);y&&(g=y.from,m=y.to),n.removeMark(g,m,l)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,l)});return n.removeStoredMark(l),!0},SAe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,a;return typeof t=="number"?(s=t,a=t):t&&"from"in t&&"to"in t?(s=t.from,a=t.to):(s=i.from,a=i.to),r&&e.doc.nodesBetween(s,a,(o,l)=>{if(o.isText)return;const u={...o.attrs};delete u.dir,e.setNodeMarkup(l,void 0,u)}),!0},EAe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,a=null;const o=BS(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(s=ni(t,r.schema)),o==="mark"&&(a=Nc(t,r.schema));let l=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let g,m,x,y;n.selection.empty?r.doc.nodesBetween(d,f,(v,b)=>{s&&s===v.type&&(l=!0,x=Math.max(b,d),y=Math.min(b+v.nodeSize,f),g=b,m=v)}):r.doc.nodesBetween(d,f,(v,b)=>{b<d&&s&&s===v.type&&(l=!0,x=Math.max(b,d),y=Math.min(b+v.nodeSize,f),g=b,m=v),b>=d&&b<=f&&(s&&s===v.type&&(l=!0,i&&n.setNodeMarkup(b,void 0,{...v.attrs,...e})),a&&v.marks.length&&v.marks.forEach(E=>{if(a===E.type&&(l=!0,i)){const S=Math.max(b,d),A=Math.min(b+v.nodeSize,f);n.addMark(S,A,a.create({...E.attrs,...e}))}}))}),m&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...m.attrs,...e}),a&&m.marks.length&&m.marks.forEach(v=>{a===v.type&&i&&n.addMark(x,y,a.create({...v.attrs,...e}))}))}),l},MAe=(t,e={})=>({state:n,dispatch:r})=>{const i=ni(t,n.schema);return rEe(i,e)(n,r)},AAe=(t,e={})=>({state:n,dispatch:r})=>{const i=ni(t,n.schema);return iEe(i,e)(n,r)},TAe=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}once(e,n){const r=(...i)=>{this.off(e,r),n.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}},VS=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},CAe=(t,e)=>{if(gD(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 i_(t){var e;const{editor:n,from:r,to:i,text:s,rules:a,plugin:o}=t,{view:l}=n;if(l.composing)return!1;const u=l.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let d=!1;const f=nAe(u)+s;return a.forEach(g=>{if(d)return;const m=CAe(f,g.find);if(!m)return;const x=l.state.tr,y=FS({state:l.state,transaction:x}),v={from:r-(m[0].length-s.length),to:i},{commands:b,chain:E,can:S}=new zS({editor:n,state:y});g.handler({state:y,range:v,match:m,commands:b,chain:E,can:S})===null||!x.steps.length||(g.undoable&&x.setMeta(o,{transform:x,from:r,to:i,text:s}),l.dispatch(x),d=!0)}),d}function NAe(t){const{editor:e,rules:n}=t,r=new _r({state:{init(){return null},apply(i,s,a){const o=i.getMeta(r);if(o)return o;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=yD(pt.from(d),a.schema);const{from:f}=l,g=f+d.length;i_({editor:e,from:f,to:g,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,a,o){return i_({editor:e,from:s,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&i_({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:a}=i.state.selection;return a?i_({editor:e,from:a.pos,to:a.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function kAe(t){return Object.prototype.toString.call(t).slice(8,-1)}function s_(t){return kAe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function rK(t,e){const n={...t};return s_(t)&&s_(e)&&Object.keys(e).forEach(r=>{s_(e[r])&&s_(t[r])?n[r]=rK(t[r],e[r]):n[r]=e[r]}),n}var SD=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Ln(Bt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ln(Bt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>rK(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}},gd=class iK extends SD{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new iK(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const a=i.marks();if(!!!a.find(u=>u?.type.name===n.name))return!1;const l=a.find(u=>u?.type.name===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function PAe(t){return typeof t=="number"}var RAe=class{constructor(t){this.find=t.find,this.handler=t.handler}},DAe=(t,e,n)=>{if(gD(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function OAe(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:a,dropEvent:o}=t,{commands:l,chain:u,can:d}=new zS({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(m,x)=>{var y,v,b,E,S;if((v=(y=m.type)==null?void 0:y.spec)!=null&&v.code||!(m.isText||m.isTextblock||m.isInline))return;const A=(S=(E=(b=m.content)==null?void 0:b.size)!=null?E:m.nodeSize)!=null?S:0,T=Math.max(r,x),P=Math.min(i,x+A);if(T>=P)return;const C=m.isText?m.text||"":m.textBetween(T-x,P-x,void 0,"");DAe(C,s.find,a).forEach(N=>{if(N.index===void 0)return;const D=T+N.index+1,F=D+N[0].length,L={from:n.tr.mapping.map(D),to:n.tr.mapping.map(F)},q=s.handler({state:n,range:L,match:N,commands:l,chain:u,can:d,pasteEvent:a,dropEvent:o});f.push(q)})}),f.every(m=>m!==null)}var a_=null,jAe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function LAe(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const l=({state:d,from:f,to:g,rule:m,pasteEvt:x})=>{const y=d.tr,v=FS({state:d,transaction:y});if(!(!OAe({editor:e,state:v,from:Math.max(f-1,0),to:g.b-1,rule:m,pasteEvent:x,dropEvent:o})||!y.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new _r({view(f){const g=x=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(x.target)?f.dom.parentElement:null,r&&(a_=e)},m=()=>{a_&&(a_=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(s=r===f.dom.parentElement,o=g,!s){const m=a_;m?.isEditable&&setTimeout(()=>{const x=m.state.selection;x&&m.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,g)=>{var m;const x=(m=g.clipboardData)==null?void 0:m.getData("text/html");return a=g,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,m)=>{const x=f[0],y=x.getMeta("uiEvent")==="paste"&&!i,v=x.getMeta("uiEvent")==="drop"&&!s,b=x.getMeta("applyPasteRules"),E=!!b;if(!y&&!v&&!E)return;if(E){let{text:T}=b;typeof T=="string"?T=T:T=yD(pt.from(T),m.schema);const{from:P}=b,C=P+T.length,I=jAe(T);return l({rule:d,state:m,from:P,to:{b:C},pasteEvt:I})}const S=g.doc.content.findDiffStart(m.doc.content),A=g.doc.content.findDiffEnd(m.doc.content);if(!(!PAe(S)||!A||S===A.b))return l({rule:d,state:m,from:S,to:A,pasteEvt:a})}}))}var GS=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Zq(t),this.schema=X2e(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:$T(e.name,this.schema)},r=Bt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return _D([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:$T(r.name,this.schema)},s=[],a=Bt(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&Bt(r,"exitable",i)&&(o.ArrowRight=()=>gd.handleExit({editor:t,mark:r})),a){const g=Object.fromEntries(Object.entries(a()).map(([m,x])=>[m,()=>x({editor:t})]));o={...o,...g}}const l=QMe(o);s.push(l);const u=Bt(r,"addInputRules",i);if(I6(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const m=NAe({editor:t,rules:g}),x=Array.isArray(m)?m:[m];s.push(...x)}}const d=Bt(r,"addPasteRules",i);if(I6(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const m=LAe({editor:t,rules:g});s.push(...m)}}const f=Bt(r,"addProseMirrorPlugins",i);if(f){const g=f();s.push(...g)}return s})}get attributes(){return Yq(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ym(this.extensions);return Object.fromEntries(e.filter(n=>!!Bt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ni(n.name,this.schema)},s=Bt(n,"addNodeView",i);if(!s)return[];const a=s();if(!a)return[];const o=(l,u,d,f,g)=>{const m=j1(l,r);return a({node:l,view:u,getPos:d,decorations:f,innerDecorations:g,editor:t,extension:n,HTMLAttributes:m})};return[n.name,o]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=ym(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:Nc(n.name,this.schema)},s=Bt(n,"addMarkView",i);if(!s)return[];const a=(o,l,u)=>{const d=j1(o,r);return s()({mark:o,view:l,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{ZAe(o,t,f)}})};return[n.name,a]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:$T(e.name,this.schema)};e.type==="mark"&&((n=Ln(Bt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Bt(e,"onBeforeCreate",r),s=Bt(e,"onCreate",r),a=Bt(e,"onUpdate",r),o=Bt(e,"onSelectionUpdate",r),l=Bt(e,"onTransaction",r),u=Bt(e,"onFocus",r),d=Bt(e,"onBlur",r),f=Bt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),a&&this.editor.on("update",a),o&&this.editor.on("selectionUpdate",o),l&&this.editor.on("transaction",l),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};GS.resolve=Zq;GS.sort=_D;GS.flatten=vD;var IAe={};mD(IAe,{ClipboardTextSerializer:()=>aK,Commands:()=>oK,Delete:()=>lK,Drop:()=>cK,Editable:()=>uK,FocusEvents:()=>hK,Keymap:()=>fK,Paste:()=>pK,Tabindex:()=>mK,TextDirection:()=>gK,focusEventsPluginKey:()=>dK});var qn=class sK extends SD{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new sK(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},aK=qn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new _r({key:new gi("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,a=Math.min(...s.map(d=>d.$from.pos)),o=Math.max(...s.map(d=>d.$to.pos)),l=Jq(n);return Qq(r,{from:a,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),oK=qn.create({name:"commands",addCommands(){return{...Bq}}}),lK=qn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var a,o,l,u;if((u=(l=(o=(a=this.editor.options.coreExtensionOptions)==null?void 0:a.delete)==null?void 0:o.filterTransaction)==null?void 0:l.call(o,t))!=null?u:t.getMeta("y-sync$"))return;const d=Kq(t.before,[t,...e]);tK(d).forEach(m=>{d.mapping.mapResult(m.oldRange.from).deletedAfter&&d.mapping.mapResult(m.oldRange.to).deletedBefore&&d.before.nodesBetween(m.oldRange.from,m.oldRange.to,(x,y)=>{const v=y+x.nodeSize-2,b=m.oldRange.from<=y&&v<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:y,to:v,newFrom:d.mapping.map(y),newTo:d.mapping.map(v),deletedRange:m.oldRange,newRange:m.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((m,x)=>{var y,v;if(m instanceof ko){const b=g.slice(x).map(m.from,-1),E=g.slice(x).map(m.to),S=g.invert().map(b,-1),A=g.invert().map(E),T=(y=d.doc.nodeAt(b-1))==null?void 0:y.marks.some(C=>C.eq(m.mark)),P=(v=d.doc.nodeAt(E))==null?void 0:v.marks.some(C=>C.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:S,to:A},newRange:{from:b,to:E},partial:!!(P||T),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),cK=qn.create({name:"drop",addProseMirrorPlugins(){return[new _r({key:new gi("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),uK=qn.create({name:"editable",addProseMirrorPlugins(){return[new _r({key:new gi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),dK=new gi("focusEvents"),hK=qn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new _r({key:dK,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}}}})]}}),fK=qn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:o})=>{const{selection:l,doc:u}=o,{empty:d,$anchor:f}=l,{pos:g,parent:m}=f,x=f.parent.isTextblock&&g>0?o.doc.resolve(g-1):f,y=x.parent.type.spec.isolating,v=f.pos-f.parentOffset,b=y&&x.parent.childCount===1?v===f.pos:ln.atStart(u).from===g;return!d||!m.type.isTextblock||m.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return bD()||Wq()?s:i},addProseMirrorPlugins(){return[new _r({key:new gi("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:a,to:o}=e.selection,l=ln.atStart(e.doc).from,u=ln.atEnd(e.doc).to;if(s||!(a===l&&o===u)||!$S(n.doc))return;const g=n.tr,m=FS({state:n,transaction:g}),{commands:x}=new zS({editor:this.editor,state:m});if(x.clearNodes(),!!g.steps.length)return g}})]}}),pK=qn.create({name:"paste",addProseMirrorPlugins(){return[new _r({key:new gi("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),mK=qn.create({name:"tabindex",addProseMirrorPlugins(){return[new _r({key:new gi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),gK=qn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ym(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 _r({key:new gi("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),UAe=class Pp{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 Pp(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 Pp(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 Pp(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,a=this.pos+r+(s?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const o=this.resolvedPos.doc.resolve(a);if(!i&&o.depth<=this.depth)return;const l=new Pp(o,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new Pp(o,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,a=Object.keys(n);for(let o=0;o<a.length;o+=1){const l=a[o];if(s[l]!==n[l])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(a=>{r&&i.length>0||(a.node.type.name===e&&s.every(l=>n[l]===a.node.attrs[l])&&i.push(a),!(r&&i.length>0)&&(i=i.concat(a.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},FAe=`.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 zAe(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 BAe=class extends TAe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Vq(e,this.options.autofocus);this.editorState=Ip.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=zAe(FAe,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=Xq(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const s=typeof i=="string"?`${i}$`:i.key;n=n.filter(a=>!a.key.startsWith(s))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[uK,aK.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),oK,hK,fK,mK,cK,pK,lK,gK.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 GS(r,this)}createCommandManager(){this.commandManager=new zS({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Pk(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=Pk(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Fq(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const a=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),o=a?.getMeta("focus"),l=a?.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:a}),l&&this.emit("blur",{editor:this,event:l.event,transaction:a}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return eK(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return rAe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return yD(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return Z2e(this.state.doc,{blockSeparator:e,textSerializers:{...Jq(this.schema),...n}})}get isEmpty(){return $S(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 UAe(e,this)}get $doc(){return this.$pos(0)}};function _m(t){return new VS({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ln(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,a=r[r.length-1],o=r[0];if(a){const l=o.search(/\S/),u=n.from+o.indexOf(a),d=u+a.length;if(wD(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>u).length)return null;d<n.to&&s.delete(d,n.to),u>n.from&&s.delete(n.from+l,u);const g=n.from+l+a.length;s.addMark(n.from+l,g,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function xK(t){return new VS({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ln(t.getAttributes,void 0,r)||{},{tr:s}=e,a=n.from;let o=n.to;const l=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=a+u;d>o?d=o:o=d+r[1].length;const f=r[0][r[0].length-1];s.insertText(f,a+r[0].length-1),s.replaceWith(d,o,l)}else if(r[0]){const u=t.type.isInline?a:a-1;s.insert(u,t.type.create(i)).delete(s.mapping.map(a),s.mapping.map(o))}s.scrollIntoView()},undoable:t.undoable})}function Dk(t){return new VS({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=Ln(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function wm(t){return new VS({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=Ln(t.getAttributes,void 0,r)||{},a=e.tr.delete(n.from,n.to),l=a.doc.resolve(n.from).blockRange(),u=l&&JR(l,t.type,s);if(!u)return null;if(a.wrap(l,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=e,{splittableMarks:m}=t.editor.extensionManager,x=g||f.$to.parentOffset&&f.$from.marks();if(x){const y=x.filter(v=>m.includes(v.type.name));a.ensureMarks(y)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,s).run()}const d=a.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&pd(a.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&a.join(n.from-1)},undoable:t.undoable})}var HAe=t=>"touches"in t,$Ae=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=a=>{if(!this.isResizing||!this.activeHandle)return;const o=a.clientX-this.startX,l=a.clientY-this.startY;this.handleResize(o,l)},this.handleTouchMove=a=>{if(!this.isResizing||!this.activeHandle)return;const o=a.touches[0];if(!o)return;const l=o.clientX-this.startX,u=o.clientY-this.startY;this.handleResize(l,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const a=this.element.offsetWidth,o=this.element.offsetHeight;this.onCommit(a,o),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,s;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(s=t.options)!=null&&s.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),s&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,HAe(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const s=t.includes("right"),a=t.includes("left"),o=t.includes("bottom"),l=t.includes("top");return s?r=this.startWidth+e:a&&(r=this.startWidth-e),o?i=this.startHeight+n:l&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(s?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(o?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,s,a;if(!n){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let o=t,l=e;return o<this.minSize.width&&(o=this.minSize.width,l=o/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,o=l*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&o>this.maxSize.width&&(o=this.maxSize.width,l=o/this.aspectRatio),(a=this.maxSize)!=null&&a.height&&l>this.maxSize.height&&(l=this.maxSize.height,o=l*this.aspectRatio),{width:o,height:l}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function VAe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ht){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var GAe={};mD(GAe,{createAtomBlockMarkdownSpec:()=>WAe,createBlockMarkdownSpec:()=>qAe,createInlineMarkdownSpec:()=>YAe,parseAttributes:()=>ED,parseIndentedBlocks:()=>Ok,renderNestedMarkdownContent:()=>AD,serializeAttributes:()=>MD});function ED(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const a=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(a)).forEach(([,u,d])=>{var f;const g=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),m=n[g];m&&(e[u]=m.slice(1,-1))});const l=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return l&&l.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function MD(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 WAe(t){const{nodeName:e,name:n,parseAttributes:r=ED,serializeAttributes:i=MD,defaultAttributes:s={},requiredAttributes:a=[],allowedAttributes:o}=t,l=n||e,u=d=>{if(!o)return d;const f={};return o.forEach(g=>{g in d&&(f[g]=d[g])}),f};return{parseMarkdown:(d,f)=>{const g={...s,...d.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const g=new RegExp(`^:::${l}(?:\\s|$)`,"m"),m=(f=d.match(g))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,g){const m=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(m);if(!x)return;const y=x[1]||"",v=r(y);if(!a.find(E=>!(E in v)))return{type:e,raw:x[0],attributes:v}}},renderMarkdown:d=>{const f=u(d.attrs||{}),g=i(f),m=g?` {${g}}`:"";return`:::${l}${m} :::`}}}function qAe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=ED,serializeAttributes:s=MD,defaultAttributes:a={},content:o="block",allowedAttributes:l}=t,u=n||e,d=f=>{if(!l)return f;const g={};return l.forEach(m=>{m in f&&(g[m]=f[m])}),g};return{parseMarkdown:(f,g)=>{let m;if(r){const y=r(f);m=typeof y=="string"?[{type:"text",text:y}]:y}else o==="block"?m=g.parseChildren(f.tokens||[]):m=g.parseInline(f.tokens||[]);const x={...a,...f.attributes};return g.createNode(e,x,m)},markdownTokenizer:{name:e,level:"block",start(f){var g;const m=new RegExp(`^:::${u}`,"m"),x=(g=f.match(m))==null?void 0:g.index;return x!==void 0?x:-1},tokenize(f,g,m){var x;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=f.match(y);if(!v)return;const[b,E=""]=v,S=i(E);let A=1;const T=b.length;let P="";const C=/^:::([\w-]*)(\s.*)?/gm,I=f.slice(T);for(C.lastIndex=0;;){const N=C.exec(I);if(N===null)break;const D=N.index,F=N[1];if(!((x=N[2])!=null&&x.endsWith(":::"))){if(F)A+=1;else if(A-=1,A===0){const L=I.slice(0,D);P=L.trim();const q=f.slice(0,T+D+N[0].length);let R=[];if(P)if(o==="block")for(R=m.blockTokens(L),R.forEach(V=>{V.text&&(!V.tokens||V.tokens.length===0)&&(V.tokens=m.inlineTokens(V.text))});R.length>0;){const V=R[R.length-1];if(V.type==="paragraph"&&(!V.text||V.text.trim()===""))R.pop();else break}else R=m.inlineTokens(P);return{type:e,raw:q,attributes:S,content:P,tokens:R}}}}}},renderMarkdown:(f,g)=>{const m=d(f.attrs||{}),x=s(m),y=x?` {${x}}`:"",v=g.renderChildren(f.content||[],`
- `);return`:::${u}${y}
- ${v}
- :::`}}}function KAe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,a]=r;e[i]=s||a,r=n.exec(t)}return e}function XAe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function YAe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=KAe,serializeAttributes:s=XAe,defaultAttributes:a={},selfClosing:o=!1,allowedAttributes:l}=t,u=n||e,d=g=>{if(!l)return g;const m={};return l.forEach(x=>{x in g&&(m[x]=g[x])}),m},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,m)=>{const x={...a,...g.attributes};if(o)return m.createNode(e,x);const y=r?r(g):g.content||"";return y?m.createNode(e,x,[m.createTextNode(y)]):m.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(g){const m=o?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=g.match(m),y=x?.index;return y!==void 0?y:-1},tokenize(g,m,x){const y=o?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),v=g.match(y);if(!v)return;let b="",E="";if(o){const[,A]=v;E=A}else{const[,A,T]=v;E=A,b=T||""}const S=i(E.trim());return{type:e,raw:v[0],content:b.trim(),attributes:S}}},renderMarkdown:g=>{let m="";r?m=r(g):g.content&&g.content.length>0&&(m=g.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const x=d(g.attrs||{}),y=s(x),v=y?` ${y}`:"";return o?`[${u}${v}]`:`[${u}${v}]${m}[/${u}]`}}}function Ok(t,e,n){var r,i,s,a;const o=t.split(`
- `),l=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<o.length;){const g=o[d],m=g.match(e.itemPattern);if(!m){if(l.length>0)break;if(g.trim()===""){d+=1,u=`${u}${g}
- `;continue}else return}const x=e.extractItemData(m),{indentLevel:y,mainContent:v}=x;u=`${u}${g}
- `;const b=[v];for(d+=1;d<o.length;){const T=o[d];if(T.trim()===""){const C=o.slice(d+1).findIndex(D=>D.trim()!=="");if(C===-1)break;if((((i=(r=o[d+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){b.push(T),u=`${u}${T}
- `,d+=1;continue}else break}if((((a=(s=T.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:a.length)||0)>y)b.push(T),u=`${u}${T}
- `,d+=1;else break}let E;const S=b.slice(1);if(S.length>0){const T=S.map(P=>P.slice(y+f)).join(`
- `);T.trim()&&(e.customNestedParser?E=e.customNestedParser(T):E=n.blockTokens(T))}const A=e.createToken(x,E);l.push(A)}if(l.length!==0)return{items:l,raw:u}}function AD(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...a]=t.content,o=e.renderChildren([s]),l=[`${i}${o}`];return a&&a.length>0&&a.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(g=>g?e.indent(g):"").join(`
- `);l.push(f)}}),l.join(`
- `)}function ZAe(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,a=t;i.descendants((o,l)=>{const u=s.mapping.map(l),d=s.mapping.map(l)+o.nodeSize;let f=null;if(o.marks.forEach(m=>{if(m!==a)return!1;f=m}),!f)return;let g=!1;if(Object.keys(n).forEach(m=>{n[m]!==f.attrs[m]&&(g=!0)}),g){const m=t.type.create({...t.attrs,...n});s.removeMark(u,d,t.type),s.addMark(u,d,m)}}),s.docChanged&&e.view.dispatch(s)}var Xs=class bK extends SD{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new bK(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Wh(t){return new RAe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=Ln(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:a}=e,o=r[r.length-1],l=r[0];let u=n.to;if(o){const d=l.search(/\S/),f=n.from+l.indexOf(o),g=f+o.length;if(wD(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(v=>v===t.type&&v!==x.mark.type)).filter(x=>x.to>f).length)return null;g<n.to&&a.delete(g,n.to),f>n.from&&a.delete(n.from+d,f),u=n.from+d+o.length,a.addMark(n.from+d,u,t.type.create(s||{})),a.removeStoredMark(t.type)}}})}var WT,z6;function QAe(){return z6||(z6=1,WT=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var a=s[i];if(!(a==="_owner"&&e.$$typeof)&&!t(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}),WT}var JAe=QAe();const eTe=oo(JAe);var qT={exports:{}},KT={};var B6;function tTe(){if(B6)return KT;B6=1;var t=Dm(),e=X9();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,s=t.useRef,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return KT.useSyncExternalStoreWithSelector=function(u,d,f,g,m){var x=s(null);if(x.current===null){var y={hasValue:!1,value:null};x.current=y}else y=x.current;x=o(function(){function b(P){if(!E){if(E=!0,S=P,P=g(P),m!==void 0&&y.hasValue){var C=y.value;if(m(C,P))return A=C}return A=P}if(C=A,r(S,P))return C;var I=g(P);return m!==void 0&&m(C,I)?(S=P,C):(S=P,A=I)}var E=!1,S,A,T=f===void 0?null:f;return[function(){return b(d())},T===null?void 0:function(){return b(T())}]},[d,f,g,m]);var v=i(u,x[0],x[1]);return a(function(){y.hasValue=!0,y.value=v},[v]),l(v),v},KT}var H6;function nTe(){return H6||(H6=1,qT.exports=tTe()),qT.exports}var vK=nTe(),rTe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},iTe=({contentComponent:t})=>{const e=rR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return c.jsx(c.Fragment,{children:Object.values(e)})};function sTe(){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 aTe=class extends pr.Component{constructor(t){var e;super(t),this.editorContentRef=pr.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=sTe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return c.jsxs(c.Fragment,{children:[c.jsx("div",{ref:rTe(e,this.editorContentRef),...n}),t?.contentComponent&&c.jsx(iTe,{contentComponent:t.contentComponent})]})}},oTe=M.forwardRef((t,e)=>{const n=pr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return pr.createElement(aTe,{key:n,innerRef:e,...t})}),lTe=pr.memo(oTe),cTe=typeof window<"u"?M.useLayoutEffect:M.useEffect,uTe=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 dTe(t){var e;const[n]=M.useState(()=>new uTe(t.editor)),r=vK.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:eTe);return cTe(()=>n.watch(t.editor),[t.editor,n]),M.useDebugValue(r),r}var hTe=!1,jk=typeof window>"u",fTe=jk||!!(typeof window<"u"&&window.next),pTe=class yK{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?jk||fTe?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)}};return new BAe(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,s)=>{var a;return i===((a=n.extensions)==null?void 0:a[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?yK.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 mTe(t={},e=[]){const n=M.useRef(t);n.current=t;const[r]=M.useState(()=>new pTe(n)),i=rR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return M.useDebugValue(i),M.useEffect(r.onRender(e)),dTe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var gTe=M.createContext({editor:null});gTe.Consumer;var xTe=M.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),bTe=()=>M.useContext(xTe);pr.forwardRef((t,e)=>{const{onDragStart:n}=bTe(),r=t.as||"div";return c.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});pr.createContext({markViewContentRef:()=>{}});var L1=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},vTe=/^\s*>\s$/,yTe=Xs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return L1("blockquote",{...Nr(this.options.HTMLAttributes,t),children:L1("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const o=e.renderChildren([i]).split(`
- `).map(l=>l.trim()===""?n:`${n} ${l}`);r.push(o.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[wm({find:vTe,type:this.type})]}}),_Te=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,wTe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,STe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,ETe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,MTe=gd.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 L1("strong",{...Nr(this.options.HTMLAttributes,t),children:L1("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[_m({find:_Te,type:this.type}),_m({find:STe,type:this.type})]},addPasteRules(){return[Wh({find:wTe,type:this.type}),Wh({find:ETe,type:this.type})]}}),ATe=/(^|[^`])`([^`]+)`(?!`)$/,TTe=/(^|[^`])`([^`]+)`(?!`)/g,CTe=gd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Nr(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[_m({find:ATe,type:this.type})]},addPasteRules(){return[Wh({find:TTe,type:this.type})]}}),XT=4,NTe=/^```([a-z]+)?[\s\n]$/,kTe=/^~~~([a-z]+)?[\s\n]$/,PTe=Xs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:XT,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(a=>a.startsWith(n)).map(a=>a.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Nr(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:XT,{state:r}=t,{selection:i}=r,{$from:s,empty:a}=i;if(s.parent.type!==this.type)return!1;const o=" ".repeat(n);return a?t.commands.insertContent(o):t.commands.command(({tr:l})=>{const{from:u,to:d}=i,m=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(x=>o+x).join(`
- `);return l.replaceWith(u,d,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:XT,{state:r}=t,{selection:i}=r,{$from:s,empty:a}=i;return s.parent.type!==this.type?!1:a?t.commands.command(({tr:o})=>{var l;const{pos:u}=s,d=s.start(),f=s.end(),m=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let x=0,y=0;const v=u-d;for(let P=0;P<m.length;P+=1){if(y+m[P].length>=v){x=P;break}y+=m[P].length+1}const E=((l=m[x].match(/^ */))==null?void 0:l[0])||"",S=Math.min(E.length,n);if(S===0)return!0;let A=d;for(let P=0;P<x;P+=1)A+=m[P].length+1;return o.delete(A,A+S),u-A<=S&&o.setSelection(qt.create(o.doc,A)),!0}):t.commands.command(({tr:o})=>{const{from:l,to:u}=i,g=r.doc.textBetween(l,u,`
- `,`
- `).split(`
- `).map(m=>{var x;const y=((x=m.match(/^ */))==null?void 0:x[0])||"",v=Math.min(y.length,n);return m.slice(v)}).join(`
- `);return o.replaceWith(l,u,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith(`
- `);return!s||!a?!1:t.chain().command(({tr:o})=>(o.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const o=i.after();return o===void 0?!1:r.nodeAt(o)?t.commands.command(({tr:u})=>(u.setSelection(ln.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[Dk({find:NTe,type:this.type,getAttributes:t=>({language:t[1]})}),Dk({find:kTe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new _r({key:new gi("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!n||!s)return!1;const{tr:a,schema:o}=t.state,l=o.text(n.replace(/\r\n?/g,`
- `));return a.replaceSelectionWith(this.type.create({language:s},l)),a.selection.$from.parent.type!==this.type&&a.setSelection(qt.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),t.dispatch(a),!0}}})]}}),RTe=Xs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),DTe=Xs.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",Nr(this.options.HTMLAttributes,t)]},renderText(){return`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,l=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&l&&a){const f=l.filter(g=>o.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),OTe=Xs.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]}`,Nr(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=>Dk({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),jTe=Xs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Nr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!VAe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return nK(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:a,dispatch:o})=>{if(o){const{$to:l}=a.selection,u=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?a.setSelection(qt.create(a.doc,l.pos+1)):l.nodeAfter.isBlock?a.setSelection(Ht.create(a.doc,l.pos)):a.setSelection(qt.create(a.doc,l.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,f=d?.create();f&&(a.insert(u,f),a.setSelection(qt.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[xK({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),LTe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ITe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,UTe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,FTe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,zTe=gd.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",Nr(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[_m({find:LTe,type:this.type}),_m({find:UTe,type:this.type})]},addPasteRules(){return[Wh({find:ITe,type:this.type}),Wh({find:FTe,type:this.type})]}});const BTe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",HTe="ελ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",Lk="numeric",Ik="ascii",Uk="alpha",Gx="asciinumeric",Cx="alphanumeric",Fk="domain",_K="emoji",$Te="scheme",VTe="slashscheme",YT="whitespace";function GTe(t,e){return t in e||(e[t]=[]),e[t]}function ch(t,e,n){e[Lk]&&(e[Gx]=!0,e[Cx]=!0),e[Ik]&&(e[Gx]=!0,e[Uk]=!0),e[Gx]&&(e[Cx]=!0),e[Uk]&&(e[Cx]=!0),e[Cx]&&(e[Fk]=!0),e[_K]&&(e[Fk]=!0);for(const r in e){const i=GTe(r,n);i.indexOf(t)<0&&i.push(t)}}function WTe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Bs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Bs.groups={};Bs.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Bs.groups;let i;return e&&e.j?i=e:(i=new Bs(e),n&&r&&ch(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let a=0;a<s-1;a++)i=i.tt(t[a]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Bs.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let a,o=i.go(t);if(o?(a=new Bs,Object.assign(a.j,o.j),a.jr.push.apply(a.jr,o.jr),a.jd=o.jd,a.t=o.t):a=new Bs,s){if(r)if(a.t&&typeof a.t=="string"){const l=Object.assign(WTe(a.t,r),n);ch(s,l,r)}else n&&ch(s,n,r);a.t=s}return i.j[t]=a,a}};const rn=(t,e,n,r,i)=>t.ta(e,n,r,i),Ar=(t,e,n,r,i)=>t.tr(e,n,r,i),$6=(t,e,n,r,i)=>t.ts(e,n,r,i),gt=(t,e,n,r,i)=>t.tt(e,n,r,i),Ql="WORD",zk="UWORD",wK="ASCIINUMERICAL",SK="ALPHANUMERICAL",D0="LOCALHOST",Bk="TLD",Hk="UTLD",q_="SCHEME",Rp="SLASH_SCHEME",TD="NUM",$k="WS",CD="NL",Wx="OPENBRACE",qx="CLOSEBRACE",I1="OPENBRACKET",U1="CLOSEBRACKET",F1="OPENPAREN",z1="CLOSEPAREN",B1="OPENANGLEBRACKET",H1="CLOSEANGLEBRACKET",$1="FULLWIDTHLEFTPAREN",V1="FULLWIDTHRIGHTPAREN",G1="LEFTCORNERBRACKET",W1="RIGHTCORNERBRACKET",q1="LEFTWHITECORNERBRACKET",K1="RIGHTWHITECORNERBRACKET",X1="FULLWIDTHLESSTHAN",Y1="FULLWIDTHGREATERTHAN",Z1="AMPERSAND",Q1="APOSTROPHE",J1="ASTERISK",Mu="AT",ew="BACKSLASH",tw="BACKTICK",nw="CARET",Ru="COLON",ND="COMMA",rw="DOLLAR",Xo="DOT",iw="EQUALS",kD="EXCLAMATION",Ua="HYPHEN",Kx="PERCENT",sw="PIPE",aw="PLUS",ow="POUND",Xx="QUERY",PD="QUOTE",EK="FULLWIDTHMIDDLEDOT",RD="SEMI",Yo="SLASH",Yx="TILDE",lw="UNDERSCORE",MK="EMOJI",cw="SYM";var AK=Object.freeze({__proto__:null,ALPHANUMERICAL:SK,AMPERSAND:Z1,APOSTROPHE:Q1,ASCIINUMERICAL:wK,ASTERISK:J1,AT:Mu,BACKSLASH:ew,BACKTICK:tw,CARET:nw,CLOSEANGLEBRACKET:H1,CLOSEBRACE:qx,CLOSEBRACKET:U1,CLOSEPAREN:z1,COLON:Ru,COMMA:ND,DOLLAR:rw,DOT:Xo,EMOJI:MK,EQUALS:iw,EXCLAMATION:kD,FULLWIDTHGREATERTHAN:Y1,FULLWIDTHLEFTPAREN:$1,FULLWIDTHLESSTHAN:X1,FULLWIDTHMIDDLEDOT:EK,FULLWIDTHRIGHTPAREN:V1,HYPHEN:Ua,LEFTCORNERBRACKET:G1,LEFTWHITECORNERBRACKET:q1,LOCALHOST:D0,NL:CD,NUM:TD,OPENANGLEBRACKET:B1,OPENBRACE:Wx,OPENBRACKET:I1,OPENPAREN:F1,PERCENT:Kx,PIPE:sw,PLUS:aw,POUND:ow,QUERY:Xx,QUOTE:PD,RIGHTCORNERBRACKET:W1,RIGHTWHITECORNERBRACKET:K1,SCHEME:q_,SEMI:RD,SLASH:Yo,SLASH_SCHEME:Rp,SYM:cw,TILDE:Yx,TLD:Bk,UNDERSCORE:lw,UTLD:Hk,UWORD:zk,WORD:Ql,WS:$k});const Kl=/[a-z]/,dx=new RegExp("\\p{L}","u"),ZT=new RegExp("\\p{Emoji}","u"),Xl=/\d/,QT=/\s/,V6="\r",JT=`
- `,qTe="️",KTe="",eC="";let o_=null,l_=null;function XTe(t=[]){const e={};Bs.groups=e;const n=new Bs;o_==null&&(o_=G6(BTe)),l_==null&&(l_=G6(HTe)),gt(n,"'",Q1),gt(n,"{",Wx),gt(n,"}",qx),gt(n,"[",I1),gt(n,"]",U1),gt(n,"(",F1),gt(n,")",z1),gt(n,"<",B1),gt(n,">",H1),gt(n,"(",$1),gt(n,")",V1),gt(n,"「",G1),gt(n,"」",W1),gt(n,"『",q1),gt(n,"』",K1),gt(n,"<",X1),gt(n,">",Y1),gt(n,"&",Z1),gt(n,"*",J1),gt(n,"@",Mu),gt(n,"`",tw),gt(n,"^",nw),gt(n,":",Ru),gt(n,",",ND),gt(n,"$",rw),gt(n,".",Xo),gt(n,"=",iw),gt(n,"!",kD),gt(n,"-",Ua),gt(n,"%",Kx),gt(n,"|",sw),gt(n,"+",aw),gt(n,"#",ow),gt(n,"?",Xx),gt(n,'"',PD),gt(n,"/",Yo),gt(n,";",RD),gt(n,"~",Yx),gt(n,"_",lw),gt(n,"\\",ew),gt(n,"・",EK);const r=Ar(n,Xl,TD,{[Lk]:!0});Ar(r,Xl,r);const i=Ar(r,Kl,wK,{[Gx]:!0}),s=Ar(r,dx,SK,{[Cx]:!0}),a=Ar(n,Kl,Ql,{[Ik]:!0});Ar(a,Xl,i),Ar(a,Kl,a),Ar(i,Xl,i),Ar(i,Kl,i);const o=Ar(n,dx,zk,{[Uk]:!0});Ar(o,Kl),Ar(o,Xl,s),Ar(o,dx,o),Ar(s,Xl,s),Ar(s,Kl),Ar(s,dx,s);const l=gt(n,JT,CD,{[YT]:!0}),u=gt(n,V6,$k,{[YT]:!0}),d=Ar(n,QT,$k,{[YT]:!0});gt(n,eC,d),gt(u,JT,l),gt(u,eC,d),Ar(u,QT,d),gt(d,V6),gt(d,JT),Ar(d,QT,d),gt(d,eC,d);const f=Ar(n,ZT,MK,{[_K]:!0});gt(f,"#"),Ar(f,ZT,f),gt(f,qTe,f);const g=gt(f,KTe);gt(g,"#"),Ar(g,ZT,f);const m=[[Kl,a],[Xl,i]],x=[[Kl,null],[dx,o],[Xl,s]];for(let y=0;y<o_.length;y++)yu(n,o_[y],Bk,Ql,m);for(let y=0;y<l_.length;y++)yu(n,l_[y],Hk,zk,x);ch(Bk,{tld:!0,ascii:!0},e),ch(Hk,{utld:!0,alpha:!0},e),yu(n,"file",q_,Ql,m),yu(n,"mailto",q_,Ql,m),yu(n,"http",Rp,Ql,m),yu(n,"https",Rp,Ql,m),yu(n,"ftp",Rp,Ql,m),yu(n,"ftps",Rp,Ql,m),ch(q_,{scheme:!0,ascii:!0},e),ch(Rp,{slashscheme:!0,ascii:!0},e),t=t.sort((y,v)=>y[0]>v[0]?1:-1);for(let y=0;y<t.length;y++){const v=t[y][0],E=t[y][1]?{[$Te]:!0}:{[VTe]:!0};v.indexOf("-")>=0?E[Fk]=!0:Kl.test(v)?Xl.test(v)?E[Gx]=!0:E[Ik]=!0:E[Lk]=!0,$6(n,v,v,E)}return $6(n,"localhost",D0,{ascii:!0}),n.jd=new Bs(cw),{start:n,tokens:Object.assign({groups:e},AK)}}function TK(t,e){const n=YTe(e.replace(/[A-Z]/g,o=>o.toLowerCase())),r=n.length,i=[];let s=0,a=0;for(;a<r;){let o=t,l=null,u=0,d=null,f=-1,g=-1;for(;a<r&&(l=o.go(n[a]));)o=l,o.accepts()?(f=0,g=0,d=o):f>=0&&(f+=n[a].length,g++),u+=n[a].length,s+=n[a].length,a++;s-=f,a-=g,u-=f,i.push({t:d.t,v:e.slice(s-u,s),s:s-u,e:s})}return i}function YTe(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,a=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(a),r+=a.length}return e}function yu(t,e,n,r,i){let s;const a=e.length;for(let o=0;o<a-1;o++){const l=e[o];t.j[l]?s=t.j[l]:(s=new Bs(r),s.jr=i.slice(),t.j[l]=s),t=s}return s=new Bs(n),s.jr=i.slice(),t.j[e[a-1]]=s,s}function G6(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let a=parseInt(t.substring(r,r+s),10);a>0;a--)n.pop();r+=s}else n.push(t[r]),r++}return e}const O0={defaultProtocol:"http",events:null,format:W6,formatHref:W6,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function DD(t,e=null){let n=Object.assign({},O0);t&&(n=Object.assign(n,t instanceof DD?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}DD.prototype={o:O0,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]:O0[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 W6(t){return t}function CK(t,e){this.t="token",this.v=t,this.tk=e}CK.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=O0.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),a={},o=t.get("className",n,e),l=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return a.href=r,o&&(a.class=o),l&&(a.target=l),u&&(a.rel=u),d&&Object.assign(a,d),{tagName:i,attributes:a,content:s,eventListeners:f}}};function WS(t,e){class n extends CK{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const q6=WS("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),K6=WS("text"),ZTe=WS("nl"),c_=WS("url",{isLink:!0,toHref(t=O0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==D0&&t[1].t===Ru}}),Da=t=>new Bs(t);function QTe({groups:t}){const e=t.domain.concat([Z1,J1,Mu,ew,tw,nw,rw,iw,Ua,TD,Kx,sw,aw,ow,Yo,cw,Yx,lw]),n=[Q1,Ru,ND,Xo,kD,Kx,Xx,PD,RD,B1,H1,Wx,qx,U1,I1,F1,z1,$1,V1,G1,W1,q1,K1,X1,Y1],r=[Z1,Q1,J1,ew,tw,nw,rw,iw,Ua,Wx,qx,Kx,sw,aw,ow,Xx,Yo,cw,Yx,lw],i=Da(),s=gt(i,Yx);rn(s,r,s),rn(s,t.domain,s);const a=Da(),o=Da(),l=Da();rn(i,t.domain,a),rn(i,t.scheme,o),rn(i,t.slashscheme,l),rn(a,r,s),rn(a,t.domain,a);const u=gt(a,Mu);gt(s,Mu,u),gt(o,Mu,u),gt(l,Mu,u);const d=gt(s,Xo);rn(d,r,s),rn(d,t.domain,s);const f=Da();rn(u,t.domain,f),rn(f,t.domain,f);const g=gt(f,Xo);rn(g,t.domain,f);const m=Da(q6);rn(g,t.tld,m),rn(g,t.utld,m),gt(u,D0,m);const x=gt(f,Ua);gt(x,Ua,x),rn(x,t.domain,f),rn(m,t.domain,f),gt(m,Xo,g),gt(m,Ua,x);const y=gt(m,Ru);rn(y,t.numeric,q6);const v=gt(a,Ua),b=gt(a,Xo);gt(v,Ua,v),rn(v,t.domain,a),rn(b,r,s),rn(b,t.domain,a);const E=Da(c_);rn(b,t.tld,E),rn(b,t.utld,E),rn(E,t.domain,a),rn(E,r,s),gt(E,Xo,b),gt(E,Ua,v),gt(E,Mu,u);const S=gt(E,Ru),A=Da(c_);rn(S,t.numeric,A);const T=Da(c_),P=Da();rn(T,e,T),rn(T,n,P),rn(P,e,T),rn(P,n,P),gt(E,Yo,T),gt(A,Yo,T);const C=gt(o,Ru),I=gt(l,Ru),N=gt(I,Yo),D=gt(N,Yo);rn(o,t.domain,a),gt(o,Xo,b),gt(o,Ua,v),rn(l,t.domain,a),gt(l,Xo,b),gt(l,Ua,v),rn(C,t.domain,T),gt(C,Yo,T),gt(C,Xx,T),rn(D,t.domain,T),rn(D,e,T),gt(D,Yo,T);const F=[[Wx,qx],[I1,U1],[F1,z1],[B1,H1],[$1,V1],[G1,W1],[q1,K1],[X1,Y1]];for(let L=0;L<F.length;L++){const[q,R]=F[L],V=gt(T,q);gt(P,q,V),gt(V,R,T);const K=Da(c_);rn(V,e,K);const W=Da();rn(V,n),rn(K,e,K),rn(K,n,W),rn(W,e,K),rn(W,n,W),gt(K,R,T),gt(W,R,T)}return gt(i,D0,E),gt(i,CD,ZTe),{start:i,tokens:AK}}function JTe(t,e,n){let r=n.length,i=0,s=[],a=[];for(;i<r;){let o=t,l=null,u=null,d=0,f=null,g=-1;for(;i<r&&!(l=o.go(n[i].t));)a.push(n[i++]);for(;i<r&&(u=l||o.go(n[i].t));)l=null,o=u,o.accepts()?(g=0,f=o):g>=0&&g++,i++,d++;if(g<0)i-=d,i<r&&(a.push(n[i]),i++);else{a.length>0&&(s.push(tC(K6,e,a)),a=[]),i-=g,d-=g;const m=f.t,x=n.slice(i-d,i);s.push(tC(m,e,x))}}return a.length>0&&s.push(tC(K6,e,a)),s}function tC(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const eCe=typeof console<"u"&&console&&console.warn||(()=>{}),tCe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",or={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function nCe(){return Bs.groups={},or.scanner=null,or.parser=null,or.tokenQueue=[],or.pluginQueue=[],or.customSchemes=[],or.initialized=!1,or}function X6(t,e=!1){if(or.initialized&&eCe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${tCe}`),!/^[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`);or.customSchemes.push([t,e])}function rCe(){or.scanner=XTe(or.customSchemes);for(let t=0;t<or.tokenQueue.length;t++)or.tokenQueue[t][1]({scanner:or.scanner});or.parser=QTe(or.scanner.tokens);for(let t=0;t<or.pluginQueue.length;t++)or.pluginQueue[t][1]({scanner:or.scanner,parser:or.parser});return or.initialized=!0,or}function OD(t){return or.initialized||rCe(),JTe(or.parser.start,t,TK(or.scanner.start,t))}OD.scan=TK;function NK(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 DD(n),i=OD(t),s=[];for(let a=0;a<i.length;a++){const o=i[a];o.isLink&&(!e||o.t===e)&&r.check(o)&&s.push(o.toFormattedObject(r))}return s}var jD="[\0- -\u2029 ]",iCe=new RegExp(jD),sCe=new RegExp(`${jD}$`),aCe=new RegExp(jD,"g");function oCe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function lCe(t){return new _r({key:new gi("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),s=e.some(u=>u.getMeta("preventAutolink"));if(!i||s)return;const{tr:a}=r,o=Kq(n.doc,[...e]);if(tK(o).forEach(({newRange:u})=>{const d=G2e(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(!sCe.test(m))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const m=g.split(iCe).filter(Boolean);if(m.length<=0)return!1;const x=m[m.length-1],y=f.pos+g.lastIndexOf(x);if(!x)return!1;const v=OD(x).map(b=>b.toObject(t.defaultProtocol));if(!oCe(v))return!1;v.filter(b=>b.isLink).map(b=>({...b,from:y+b.start+1,to:y+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{wD(b.from,b.to,r.doc).some(E=>E.mark.type===t.type)||a.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!a.steps.length)return a}})}function cCe(t){return new _r({key:new gi("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let a=null;if(r.target instanceof HTMLAnchorElement)a=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;a=f.find(g=>g.nodeName==="A")}if(!a)return!1;const o=eK(e.state,t.type.name),l=(i=a?.href)!=null?i:o.href,u=(s=a?.target)!=null?s:o.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),a&&l?(window.open(l,u),!0):!1}}})}function uCe(t){return new _r({key:new gi("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:a}=s,{empty:o}=a;if(o)return!1;let l="";r.content.forEach(d=>{l+=d.textContent});const u=NK(l,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===l);return!l||!u||i!==void 0&&!i(u.href)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function qd(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(aCe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var kK=gd.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"){X6(t);return}X6(t.scheme,t.optionalSlashes)})},onDestroy(){nCe()},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)=>!!qd(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=>!!qd(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=>!!qd(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Nr(this.options.HTMLAttributes,t),0]:["a",Nr(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=>!!qd(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=>!!qd(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[Wh({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=NK(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:a=>!!qd(a,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(lCe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!qd(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(cCe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(uCe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),dCe=kK,hCe=Object.defineProperty,fCe=(t,e)=>{for(var n in e)hCe(t,n,{get:e[n],enumerable:!0})},pCe="listItem",Y6="textStyle",Z6=/^\s*([-+*])\s$/,PK=Xs.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",Nr(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(pCe,this.editor.getAttributes(Y6)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=wm({find:Z6,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=wm({find:Z6,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Y6),editor:this.editor})),[t]}}),RK=Xs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Nr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const a=t.tokens.slice(1),o=e.parseChildren(a);n.push(...o)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>AD(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)}}}),mCe={};fCe(mCe,{findListItemPos:()=>db,getNextListDepth:()=>LD,handleBackspace:()=>Vk,handleDelete:()=>Gk,hasListBefore:()=>DK,hasListItemAfter:()=>gCe,hasListItemBefore:()=>OK,listItemHasSubList:()=>jK,nextListIsDeeper:()=>LK,nextListIsHigher:()=>IK});var db=(t,e)=>{const{$from:n}=e.selection,r=ni(t,e.schema);let i=null,s=n.depth,a=n.pos,o=null;for(;s>0&&o===null;)i=n.node(s),i.type===r?o=s:(s-=1,a-=1);return o===null?null:{$pos:e.doc.resolve(a),depth:o}},LD=(t,e)=>{const n=db(t,e);if(!n)return!1;const[,r]=tAe(e,t,n.$pos.pos+4);return r},DK=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},OK=(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)},jK=(t,e,n)=>{if(!n)return!1;const r=ni(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},Vk=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!sd(t.state,e)&&DK(t.state,e,n)){const{$anchor:o}=t.state.selection,l=t.state.doc.resolve(o.before()-1),u=[];l.node().descendants((g,m)=>{g.type.name===e&&u.push({node:g,pos:m})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(l.start()+d.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},f.end()).joinForward().run()}if(!sd(t.state,e)||!sAe(t.state))return!1;const r=db(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),a=jK(e,t.state,s);return OK(e,t.state)&&!a?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},LK=(t,e)=>{const n=LD(t,e),r=db(t,e);return!r||!n?!1:n>r.depth},IK=(t,e)=>{const n=LD(t,e),r=db(t,e);return!r||!n?!1:n<r.depth},Gk=(t,e)=>{if(!sd(t.state,e)||!iAe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:LK(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():IK(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},gCe=(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)},UK=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&&Gk(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&&Gk(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&&Vk(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&&Vk(t,n,r)&&(e=!0)}),e}}}}),Q6=/^(\s*)(\d+)\.\s+(.*)$/,xCe=/^\s/;function bCe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(Q6);if(!s)break;const[,a,o,l]=s,u=a.length;let d=l,f=n+1;const g=[i];for(;f<t.length;){const m=t[f];if(m.match(Q6))break;if(m.trim()==="")g.push(m),d+=`
- `,f+=1;else if(m.match(xCe))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 FK(t,e,n){var r;const i=[];let s=0;for(;s<t.length;){const a=t[s];if(a.indent===e){const o=a.content.split(`
- `),l=((r=o[0])==null?void 0:r.trim())||"",u=[];l&&u.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const d=o.slice(1).join(`
- `).trim();if(d){const m=n.blockTokens(d);u.push(...m)}let f=s+1;const g=[];for(;f<t.length&&t[f].indent>e;)g.push(t[f]),f+=1;if(g.length>0){const m=Math.min(...g.map(y=>y.indent)),x=FK(g,m,n);u.push({type:"list",ordered:!0,start:g[0].number,items:x,raw:g.map(y=>y.raw).join(`
- `)})}i.push({type:"list_item",raw:a.raw,tokens:u}),s=f}else s+=1}return i}function vCe(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var yCe="listItem",J6="textStyle",e8=/^(\d+)\.\s$/,zK=Xs.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",Nr(this.options.HTMLAttributes,n),0]:["ol",Nr(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?vCe(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
- `),[s,a]=bCe(i);if(s.length===0)return;const o=FK(s,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:o,raw:i.slice(0,a).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(yCe,this.editor.getAttributes(J6)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=wm({find:e8,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=wm({find:e8,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(J6)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),_Ce=/^\s*(\[([( |x])?\])\s$/,wCe=Xs.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",Nr(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 AD(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),a=document.createElement("span"),o=document.createElement("input"),l=document.createElement("div"),u=d=>{var f,g;o.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,d,o.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),s.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",d=>d.preventDefault()),o.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const m=n();if(typeof m!="number")return!1;const x=g.doc.nodeAt(m);return g.setNodeMarkup(m,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,s.append(o,a),i.append(s,l),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:l,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,o.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[wm({find:_Ce,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),SCe=Xs.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",Nr(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=s=>{const a=Ok(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:r},n);return a?[{type:"taskList",raw:a.raw,items:a.items}]:n.blockTokens(s)},i=Ok(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,a)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:a}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});qn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(PK.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(RK.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(UK.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(zK.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(wCe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(SCe.configure(this.options.taskList)),t}});var ECe=Xs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Nr(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()}}}),MCe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,ACe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,TCe=gd.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",Nr(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[_m({find:MCe,type:this.type})]},addPasteRules(){return[Wh({find:ACe,type:this.type})]}}),CCe=Xs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),BK=gd.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",Nr(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),NCe=BK;function kCe(t={}){return new _r({view(e){return new PCe(e,t)}})}class PCe{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=a=>{this[i](a)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),a=s.width/i.offsetWidth,o=s.height/i.offsetHeight;if(n){let f=e.nodeBefore,g=e.nodeAfter;if(f||g){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let x=m.getBoundingClientRect(),y=f?x.bottom:x.top;f&&g&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*o;r={left:x.left,right:x.right,top:y-v,bottom:y+v}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*a;r={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=l.getBoundingClientRect(),g=f.width/l.offsetWidth,m=f.height/l.offsetHeight;u=f.left-l.scrollLeft*g,d=f.top-l.scrollTop*m}this.element.style.left=(r.left-u)/a+"px",this.element.style.top=(r.top-d)/o+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=zW(this.editorView.state.doc,a,this.editorView.dragging.slice);o!=null&&(a=o)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Cr extends ln{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Cr.valid(r)?new Cr(r):ln.near(r)}content(){return Tt.empty}eq(e){return e instanceof Cr&&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 Cr(e.resolve(n.pos))}getBookmark(){return new ID(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!RCe(e)||!DCe(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&&Cr.valid(e))return e;let i=e.pos,s=null;for(let a=e.depth;;a--){let o=e.node(a);if(n>0?e.indexAfter(a)<o.childCount:e.index(a)>0){s=o.child(n>0?e.indexAfter(a):e.index(a)-1);break}else if(a==0)return null;i+=n;let l=e.doc.resolve(i);if(Cr.valid(l))return l}for(;;){let a=n>0?s.firstChild:s.lastChild;if(!a){if(s.isAtom&&!s.isText&&!Ht.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=a,i+=n;let o=e.doc.resolve(i);if(Cr.valid(o))return o}return null}}}Cr.prototype.visible=!1;Cr.findFrom=Cr.findGapCursorFrom;ln.jsonID("gapcursor",Cr);class ID{constructor(e){this.pos=e}map(e){return new ID(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Cr.valid(n)?new Cr(n):ln.near(n)}}function HK(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function RCe(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||HK(i.type))return!0;if(i.inlineContent)return!1}}return!0}function DCe(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||HK(i.type))return!0;if(i.inlineContent)return!1}}return!0}function OCe(){return new _r({props:{decorations:UCe,createSelectionBetween(t,e,n){return e.pos==n.pos&&Cr.valid(n)?new Cr(n):null},handleClick:LCe,handleKeyDown:jCe,handleDOMEvents:{beforeinput:ICe}}})}const jCe=zq({ArrowLeft:u_("horiz",-1),ArrowRight:u_("horiz",1),ArrowUp:u_("vert",-1),ArrowDown:u_("vert",1)});function u_(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let a=r.selection,o=e>0?a.$to:a.$from,l=a.empty;if(a instanceof qt){if(!s.endOfTextblock(n)||o.depth==0)return!1;l=!1,o=r.doc.resolve(e>0?o.after():o.before())}let u=Cr.findGapCursorFrom(o,e,l);return u?(i&&i(r.tr.setSelection(new Cr(u))),!0):!1}}function LCe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Cr.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 Cr(r))),!0)}function ICe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Cr))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=pt.empty;for(let a=r.length-1;a>=0;a--)i=pt.from(r[a].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new Tt(i,0,0));return s.setSelection(qt.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function UCe(t){if(!(t.selection instanceof Cr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",br.create(t.doc,[ws.widget(t.selection.head,e,{key:"gapcursor"})])}var uw=200,ji=function(){};ji.prototype.append=function(e){return e.length?(e=ji.from(e),!this.length&&e||e.length<uw&&this.leafAppend(e)||this.length<uw&&e.leafPrepend(this)||this.appendInner(e)):this};ji.prototype.prepend=function(e){return e.length?ji.from(e).append(this):this};ji.prototype.appendInner=function(e){return new FCe(this,e)};ji.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ji.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ji.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ji.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)};ji.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,a){return i.push(e(s,a))},n,r),i};ji.from=function(e){return e instanceof ji?e:e&&e.length?new $K(e):ji.empty};var $K=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,a,o){for(var l=s;l<a;l++)if(i(this.values[l],o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,a,o){for(var l=s-1;l>=a;l--)if(i(this.values[l],o+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=uw)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=uw)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})(ji);ji.empty=new $K([]);var FCe=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,a){var o=this.left.length;if(i<o&&this.left.forEachInner(r,i,Math.min(s,o),a)===!1||s>o&&this.right.forEachInner(r,Math.max(i-o,0),Math.min(this.length,s)-o,a+o)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,a){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(r,i-o,Math.max(s,o)-o,a+o)===!1||s<o&&this.left.forEachInvertedInner(r,Math.min(i,o),s,a)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ji);const zCe=500;class So{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let a=e.tr,o,l,u=[],d=[];return this.items.forEach((f,g)=>{if(!f.step){i||(i=this.remapping(r,g+1),s=i.maps.length),s--,d.push(f);return}if(i){d.push(new Zo(f.map));let m=f.step.map(i.slice(s)),x;m&&a.maybeStep(m).doc&&(x=a.mapping.maps[a.mapping.maps.length-1],u.push(new Zo(x,void 0,void 0,u.length+d.length))),s--,x&&i.appendMap(x,s)}else a.maybeStep(f.step);if(f.selection)return o=i?f.selection.map(i.slice(s)):f.selection,l=new So(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:a,selection:o}}addTransform(e,n,r,i){let s=[],a=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),g=new Zo(e.mapping.maps[d],f,n),m;(m=l&&l.merge(g))&&(g=m,d?s.pop():o=o.slice(0,o.length-1)),s.push(g),n&&(a++,n=void 0),i||(l=g)}let u=a-r.depth;return u>HCe&&(o=BCe(o,u),a-=u),new So(o.append(s),a)}remapping(e,n){let r=new T0;return this.items.forEach((i,s)=>{let a=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,a)},e,n),r}addMaps(e){return this.eventCount==0?this:new So(this.items.append(e.map(n=>new Zo(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,a=e.steps.length,o=this.eventCount;this.items.forEach(g=>{g.selection&&o--},i);let l=n;this.items.forEach(g=>{let m=s.getMirror(--l);if(m==null)return;a=Math.min(a,m);let x=s.maps[m];if(g.step){let y=e.steps[m].invert(e.docs[m]),v=g.selection&&g.selection.map(s.slice(l+1,m));v&&o++,r.push(new Zo(x,y,v))}else r.push(new Zo(x))},i);let u=[];for(let g=n;g<a;g++)u.push(new Zo(s.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new So(d,o);return f.emptyItemCount()>zCe&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],s=0;return this.items.forEach((a,o)=>{if(o>=e)i.push(a),a.selection&&s++;else if(a.step){let l=a.step.map(n.slice(r)),u=l&&l.getMap();if(r--,u&&n.appendMap(u,r),l){let d=a.selection&&a.selection.map(n.slice(r));d&&s++;let f=new Zo(u.invert(),l,d),g,m=i.length-1;(g=i.length&&i[m].merge(f))?i[m]=g:i.push(f)}}else a.map&&r--},this.items.length,0),new So(ji.from(i.reverse()),s)}}So.empty=new So(ji.empty,0);function BCe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Zo{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 Zo(n.getMap().invert(),n,this.selection)}}}class Au{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const HCe=20;function $Ce(t,e,n,r){let i=n.getMeta(wh),s;if(i)return i.historyState;n.getMeta(WCe)&&(t=new Au(t.done,t.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(a&&a.getMeta(wh))return a.getMeta(wh).redo?new Au(t.done.addTransform(n,void 0,r,K_(e)),t.undone,t8(n.mapping.maps),t.prevTime,t.prevComposition):new Au(t.done,t.undone.addTransform(n,void 0,r,K_(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),l=t.prevTime==0||!a&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!VCe(n,t.prevRanges)),u=a?nC(t.prevRanges,n.mapping):t8(n.mapping.maps);return new Au(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,K_(e)),So.empty,u,n.time,o??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Au(t.done.rebased(n,s),t.undone.rebased(n,s),nC(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Au(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),nC(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function VCe(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function t8(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,a)=>e.push(s,a));return e}function nC(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function GCe(t,e,n){let r=K_(e),i=wh.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let a=s.selection.resolve(s.transform.doc),o=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),l=new Au(n?o:s.remaining,n?s.remaining:o,null,0,-1);return s.transform.setSelection(a).setMeta(wh,{redo:n,historyState:l})}let rC=!1,n8=null;function K_(t){let e=t.plugins;if(n8!=e){rC=!1,n8=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){rC=!0;break}}return rC}const wh=new gi("history"),WCe=new gi("closeHistory");function qCe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new _r({key:wh,state:{init(){return new Au(So.empty,So.empty,null,0,-1)},apply(e,n,r){return $Ce(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?GK:r=="historyRedo"?WK:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function VK(t,e){return(n,r)=>{let i=wh.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=GCe(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const GK=VK(!1,!0),WK=VK(!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 _r({key:new gi("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const a=s-i,o=0,l=a;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(o,l);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=s-r,u=o-l,d=o;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var KCe=qn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[kCe(this.options)]}});qn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new _r({key:new gi("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return br.create(t,[]);let a=0;this.options.mode==="deepest"&&t.descendants((l,u)=>{if(l.isText)return;if(!(i>=u&&i<=u+l.nodeSize-1))return!1;a+=1});let o=0;return t.descendants((l,u)=>{if(l.isText||!(i>=u&&i<=u+l.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&a-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";s.push(ws.node(u,u+l.nodeSize,{class:this.options.className}))}),br.create(t,s)}}})]}});var XCe=qn.create({name:"gapCursor",addProseMirrorPlugins(){return[OCe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ln(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 _r({key:new gi("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const s=this.editor.isEmpty;return t.descendants((a,o)=>{const l=r>=o&&r<=o+a.nodeSize,u=!a.isLeaf&&$S(a);if((l||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const f=ws.node(o,o+a.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:o,hasAnchor:l}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),br.create(t,i)}}})]}});qn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new _r({key:new gi("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||nK(n.selection)||t.view.dragging?null:br.create(n.doc,[ws.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function r8({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var YCe=qn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new gi(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 _r({key:e,appendTransaction:(i,s,a)=>{const{doc:o,tr:l,schema:u}=a,d=e.getState(a),f=o.content.size,g=u.nodes[n];if(d)return l.insert(f,g.create())},state:{init:(i,s)=>{const a=s.tr.doc.lastChild;return!r8({node:a,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const a=i.doc.lastChild;return!r8({node:a,types:r})}}})]}}),ZCe=qn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>GK(t,e),redo:()=>({state:t,dispatch:e})=>WK(t,e)}},addProseMirrorPlugins(){return[qCe(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()}}}),QCe=qn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(MTe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(yTe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(PK.configure(this.options.bulletList)),this.options.code!==!1&&i.push(CTe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(PTe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(RTe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(KCe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(XCe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(DTe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(OTe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(ZCe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(jTe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(zTe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(RK.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(UK.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(kK.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(zK.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(ECe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(TCe.configure(this.options.strike)),this.options.text!==!1&&i.push(CCe.configure(this.options.text)),this.options.underline!==!1&&i.push(BK.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(YCe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),JCe=QCe,eNe=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")}}}),tNe=eNe,nNe=20,qK=(t,e=0)=>{const n=[];return!t.children.length||e>nNe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...qK(r,e+1))}),n},rNe=t=>{if(!t.children.length)return;const e=qK(t);e&&e.forEach(n=>{var r,i;const s=n.getAttribute("style"),a=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${a};${s}`)})},KK=gd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&rNe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Nr(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),iNe=qn.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const a=s[0].trim().toLowerCase(),o=s.slice(1).join(":").trim();if(a==="background-color")return o.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),XK=qn.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const a=s[0].trim().toLowerCase(),o=s.slice(1).join(":").trim();if(a==="color")return o.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),sNe=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()}}}),aNe=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()}}}),oNe=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(iNe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(XK.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(sNe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(aNe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(oNe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(KK.configure(this.options.textStyle)),t}});var lNe=XK,cNe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,uNe=Xs.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",Nr(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,s,a;const o=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",l=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(a=(s=t.attrs)==null?void 0:s.title)!=null?a:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:a})=>{const o=document.createElement("img");Object.entries(a).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:o.setAttribute(d,f);break}}),o.src=a.src;const l=new $Ae({element:o,node:i,getPos:s,onResize:(d,f)=>{o.style.width=`${d}px`,o.style.height=`${f}px`},onCommit:(d,f)=>{const g=s();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,g)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=l.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",o.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},l}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[xK({find:cNe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),dNe=uNe;function i8({content:t,onChange:e,placeholder:n}){const r=mTe({extensions:[JCe.configure({heading:!1,codeBlock:!1,code:!1}),NCe,dCe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),tNe.configure({types:["paragraph"]}),KK,lNe,dNe.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:a})=>{e(a.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!r)return null;const i=({onClick:a,isActive:o=!1,children:l,title:u})=>c.jsx("button",{type:"button",onClick:a,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${o?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:l}),s=()=>{const a=window.prompt("Enter URL:");a&&r.chain().focus().setLink({href:a}).run()};return c.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[c.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[c.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:c.jsx(bae,{className:"w-4 h-4"})}),c.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:c.jsx(Koe,{className:"w-4 h-4"})}),c.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:c.jsx(zce,{className:"w-4 h-4"})}),c.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),c.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:c.jsx(bR,{className:"w-4 h-4"})}),c.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:c.jsx(jG,{className:"w-4 h-4"})}),c.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),c.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:c.jsx(kce,{className:"w-4 h-4"})}),c.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:c.jsx(Ace,{className:"w-4 h-4"})}),c.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:c.jsx(Cce,{className:"w-4 h-4"})}),c.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),c.jsx(i,{onClick:s,isActive:r.isActive("link"),title:"Add Link",children:c.jsx(xS,{className:"w-4 h-4"})}),r.isActive("link")&&c.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:c.jsx(FG,{className:"w-4 h-4"})})]}),c.jsx(lTe,{editor:r})]})}function hNe({archiveId:t,archiveName:e,onClose:n}){const r=Sn(),[i,s]=M.useState(!1),[a,o]=M.useState(null),[l,u]=M.useState({}),{data:d,isLoading:f,error:g}=yt({queryKey:["archive-project-page",t],queryFn:()=>Pe.getArchiveProjectPage(t)}),m=_t({mutationFn:T=>Pe.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),u({})}});M.useEffect(()=>{const T=P=>{P.key==="Escape"&&(a!==null?o(null):i?b():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[a,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),s(!0)},v=()=>{m.mutate(l)},b=()=>{s(!1),u({})},E=T=>{const P=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],C=new DOMParser().parseFromString(T,"text/html"),I=N=>{if(N.nodeType===Node.TEXT_NODE)return N.textContent||"";if(N.nodeType===Node.ELEMENT_NODE){const D=N,F=D.tagName.toLowerCase();if(!P.includes(F))return Array.from(D.childNodes).map(I).join("");let L="";if(F==="a"&&D.getAttribute("href")){const R=D.getAttribute("href");R?.toLowerCase().startsWith("http")&&(L=` href="${R}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const R=D.getAttribute("src");if(!R?.toLowerCase().startsWith("http"))return"";L=` src="${R}" style="max-width: 100%; height: auto;"`}const q=Array.from(D.childNodes).map(I).join("");return["br","img"].includes(F)?`<${F}${L} />`:`<${F}${L}>${q}</${F}>`}return""};return Array.from(C.body.childNodes).map(I).join("")},S=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),A=T=>{T.target===T.currentTarget&&n()};return c.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Ya,{className:"w-5 h-5 text-bambu-green"}),c.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&c.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[!i&&S&&c.jsxs(Ie,{variant:"ghost",size:"sm",onClick:y,children:[c.jsx(d0,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&c.jsxs(c.Fragment,{children:[c.jsx(Ie,{variant:"ghost",size:"sm",onClick:b,children:"Cancel"}),c.jsxs(Ie,{variant:"primary",size:"sm",onClick:v,disabled:m.isPending,children:[c.jsx(To,{className:"w-4 h-4 mr-1"}),"Save"]})]}),c.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&c.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!S&&c.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[c.jsx(Ya,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),c.jsx("p",{children:"No project page data found in this 3MF file."}),c.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&S&&c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-4",children:[i?c.jsx("input",{type:"text",value:l.title||"",onChange:T=>u({...l,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&c.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),c.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(u3,{className:"w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:l.designer||"",onChange:T=>u({...l,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[c.jsx(u3,{className:"w-4 h-4"}),c.jsx("span",{children:d.designer}),d.designer_user_id&&c.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:c.jsx(ro,{className:"w-3 h-3"})})]}),d.creation_date&&c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[c.jsx(qr,{className:"w-4 h-4"}),c.jsx("span",{children:d.creation_date})]}),i?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ya,{className:"w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:l.license||"",onChange:T=>u({...l,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[c.jsx(Ya,{className:"w-4 h-4"}),c.jsx("span",{children:d.license})]}),d.origin&&c.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?c.jsx(i8,{content:l.description||"",onChange:T=>u({...l,description:T}),placeholder:"Enter description..."}):c.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&c.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[c.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?c.jsxs("div",{className:"space-y-2",children:[c.jsx("input",{type:"text",value:l.profile_title||"",onChange:T=>u({...l,profile_title:T.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),c.jsx(i8,{content:l.profile_description||"",onChange:T=>u({...l,profile_description:T}),placeholder:"Profile description..."})]}):c.jsxs(c.Fragment,{children:[d.profile_title&&c.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&c.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.profile_description)}}),d.profile_user_name&&c.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[c.jsx(rb,{className:"w-4 h-4"}),"Images (",x.length,")"]}),c.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((T,P)=>c.jsx("button",{onClick:()=>o(P),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:c.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),d.design_model_id&&c.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:c.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[c.jsx(ro,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),a!==null&&x[a]&&c.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[c.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.max(0,a-1))},disabled:a===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:c.jsx(Rh,{className:"w-6 h-6 text-white"})}),c.jsx("img",{src:x[a].url,alt:x[a].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),c.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(x.length-1,a+1))},disabled:a===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:c.jsx(tf,{className:"w-6 h-6 text-white"})}),c.jsx("button",{onClick:()=>o(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:c.jsx(Gt,{className:"w-6 h-6 text-white"})}),c.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[a+1," / ",x.length]})]})]})}const fNe=[.25,.5,.75,1,1.5,2,3,4];function pNe({src:t,title:e,downloadFilename:n,onClose:r}){const i=M.useRef(null),[s,a]=M.useState(!0),[o,l]=M.useState(.5),[u,d]=M.useState(0),[f,g]=M.useState(0);M.useEffect(()=>{const S=i.current;S&&(S.playbackRate=o)},[o]),M.useEffect(()=>{const S=A=>{A.key==="Escape"&&r()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[r]),M.useEffect(()=>{const S=i.current;if(!S)return;const A=()=>d(S.currentTime),T=()=>g(S.duration),P=()=>a(!0),C=()=>a(!1);return S.addEventListener("timeupdate",A),S.addEventListener("durationchange",T),S.addEventListener("play",P),S.addEventListener("pause",C),()=>{S.removeEventListener("timeupdate",A),S.removeEventListener("durationchange",T),S.removeEventListener("play",P),S.removeEventListener("pause",C)}},[]);const m=()=>{const S=i.current;S&&(s?S.pause():S.play())},x=S=>{const A=i.current;A&&(A.currentTime=parseFloat(S.target.value))},y=()=>{const S=i.current;S&&(S.currentTime=Math.max(0,S.currentTime-5))},v=()=>{const S=i.current;S&&(S.currentTime=Math.min(f,S.currentTime+5))},b=S=>{const A=Math.floor(S/60),T=Math.floor(S%60);return`${A}:${T.toString().padStart(2,"0")}`},E=()=>{const S=document.createElement("a");S.href=t,S.download=n,S.click()};return c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:c.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(Bp,{className:"w-5 h-5 text-bambu-green"}),e]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:E,children:[c.jsx(ya,{className:"w-4 h-4"}),"Download"]}),c.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:c.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),c.jsxs("div",{className:"p-4",children:[c.jsx("video",{ref:i,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:m}),c.jsxs("div",{className:"mt-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:b(u)}),c.jsx("input",{type:"range",min:0,max:f||100,value:u,onChange:x,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),c.jsx("span",{className:"text-xs text-bambu-gray w-12",children:b(f)})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:c.jsx(fce,{className:"w-5 h-5 text-bambu-gray"})}),c.jsx("button",{onClick:m,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:s?c.jsx(jle,{className:"w-5 h-5 text-white"}):c.jsx(bS,{className:"w-5 h-5 text-white"})}),c.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:c.jsx(c1,{className:"w-5 h-5 text-bambu-gray"})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),c.jsx("div",{className:"flex gap-1",children:fNe.map(S=>c.jsxs("button",{onClick:()=>l(S),className:`px-2 py-1 text-xs rounded transition-colors ${o===S?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[S,"x"]},S))})]})]})]})]})]})})}function mNe({archiveId:t,archiveName:e,onClose:n}){const r=Sn(),{showToast:i}=ri(),[s,a]=M.useState(null),[o,l]=M.useState("asap"),[u,d]=M.useState(""),[f,g]=M.useState(!1),[m,x]=M.useState(!1),{data:y}=yt({queryKey:["printers"],queryFn:()=>Pe.getPrinters()});M.useEffect(()=>{y?.length===1&&!s&&a(y[0].id)},[y,s]),M.useEffect(()=>{const S=A=>{A.key==="Escape"&&n()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[n]);const v=_t({mutationFn:S=>Pe.addToQueue(S),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:S=>{i(S.message||"Failed to add to queue","error")}}),b=S=>{if(S.preventDefault(),!s){i("Please select a printer","error");return}const A={printer_id:s,archive_id:t,require_previous_success:f,auto_off_after:m};o==="scheduled"&&u&&(A.scheduled_time=new Date(u).toISOString()),v.mutate(A)},E=()=>{const S=new Date;return S.setMinutes(S.getMinutes()+1),S.toISOString().slice(0,16)};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:c.jsx(Nt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(qr,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),c.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),c.jsx("p",{className:"text-white font-medium truncate",children:e})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?c.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[c.jsx(Oo,{className:"w-4 h-4"}),"No printers configured"]}):c.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s||"",onChange:S=>a(S.target.value?Number(S.target.value):null),required:!0,children:[c.jsx("option",{value:"",children:"Select printer..."}),y?.map(S=>c.jsx("option",{value:S.id,children:S.name},S.id))]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("asap"),children:[c.jsx(ti,{className:"w-4 h-4"}),"ASAP (when idle)"]}),c.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("scheduled"),children:[c.jsx(qr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),c.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:S=>d(S.target.value),min:E(),required:!0})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:S=>g(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),c.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:S=>x(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),c.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[c.jsx(fd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{type:"submit",className:"flex-1",disabled:v.isPending||!s||y?.length===0,children:v.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function gNe({archiveIds:t,onClose:e}){M.useEffect(()=>{const s=a=>{a.key==="Escape"&&e()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e]);const{data:n,isLoading:r,error:i}=yt({queryKey:["archive-comparison",t],queryFn:()=>Pe.compareArchives(t)});return c.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:s=>s.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?c.jsxs("div",{className:"text-center py-12 text-red-400",children:[c.jsx(Qr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),c.jsx("p",{children:"Failed to load comparison"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?c.jsx(xNe,{comparison:n}):null}),c.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:c.jsx(Ie,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function xNe({comparison:t}){return c.jsxs("div",{className:"space-y-6",children:[c.jsx("div",{className:"overflow-x-auto",children:c.jsxs("table",{className:"w-full",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>c.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[c.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),c.jsx("div",{className:`text-xs ${e.status==="completed"?"text-bambu-green":e.status==="failed"?"text-red-400":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),c.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>c.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[c.jsx("td",{className:"py-2 pr-4 text-sm",children:c.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&c.jsx(Qr,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),c.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>c.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??c.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&c.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&c.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[c.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[c.jsx(Qr,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),c.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>c.jsxs("li",{children:[c.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&c.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?c.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[c.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[c.jsx(Ph,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),c.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[c.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),c.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?c.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>c.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[c.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",c.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):c.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):c.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:c.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function Wk(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function hx(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function s8(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function bNe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s}){const a=Sn(),{showToast:o}=ri(),l=VG(),[u,d]=M.useState(!1),[f,g]=M.useState(!1),[m,x]=M.useState(!1),[y,v]=M.useState(!1),[b,E]=M.useState(!1),[S,A]=M.useState(!1),[T,P]=M.useState([]),[C,I]=M.useState(!1),[N,D]=M.useState(!1),[F,L]=M.useState(!1),[q,R]=M.useState(!1),[V,K]=M.useState(!1),[W,ne]=M.useState(null),Y=M.useRef(null),Z=_t({mutationFn:se=>Pe.uploadSource3mf(t.id,se),onSuccess:se=>{a.invalidateQueries({queryKey:["archives"]}),o(`Source 3MF attached: ${se.filename}`)},onError:se=>{o(se.message||"Failed to upload source 3MF","error")}}),U=_t({mutationFn:()=>Pe.deleteSource3mf(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),o("Source 3MF removed")},onError:se=>{o(se.message||"Failed to remove source 3MF","error")}}),$=_t({mutationFn:()=>Pe.scanArchiveTimelapse(t.id),onSuccess:se=>{se.status==="attached"?(a.invalidateQueries({queryKey:["archives"]}),o(`Timelapse attached: ${se.filename}`)):se.status==="exists"?o("Timelapse already attached"):se.status==="not_found"&&se.available_files&&se.available_files.length>0?(P(se.available_files),A(!0)):o(se.message||"No matching timelapse found","warning")},onError:se=>{o(se.message||"Failed to scan for timelapse","error")}}),ee=_t({mutationFn:se=>Pe.selectArchiveTimelapse(t.id,se),onSuccess:se=>{a.invalidateQueries({queryKey:["archives"]}),o(`Timelapse attached: ${se.filename}`),A(!1),P([])},onError:se=>{o(se.message||"Failed to attach timelapse","error")}}),ae=_t({mutationFn:()=>Pe.deleteArchive(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),o("Archive deleted")},onError:()=>{o("Failed to delete archive","error")}}),fe=_t({mutationFn:()=>Pe.toggleFavorite(t.id),onSuccess:se=>{a.invalidateQueries({queryKey:["archives"]}),o(se.is_favorite?"Added to favorites":"Removed from favorites")}}),ue=_t({mutationFn:se=>Pe.updateArchive(t.id,{project_id:se}),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),a.invalidateQueries({queryKey:["projects"]}),o("Project updated")},onError:()=>{o("Failed to update project","error")}}),xe=se=>{se.preventDefault(),ne({x:se.clientX,y:se.clientY})},Me=[{label:"Print",icon:c.jsx(jo,{className:"w-4 h-4"}),onClick:()=>g(!0)},{label:"Schedule",icon:c.jsx(qr,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:"Open in Bambu Studio",icon:c.jsx(ro,{className:"w-4 h-4"}),onClick:()=>{const se=t.print_name||t.filename||"model",ve=`${window.location.origin}${Pe.getArchiveForSlicer(t.id,se)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`}},{label:"View on MakerWorld",icon:c.jsx(l0,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:c.jsx(rm,{className:"w-4 h-4"}),onClick:()=>d(!0)},{label:"View Timelapse",icon:c.jsx(Bp,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:c.jsx(tce,{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:c.jsx(w5,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const se=document.createElement("a");se.href=Pe.getSource3mfDownloadUrl(t.id),se.download=`${t.print_name||t.filename}_source.3mf`,se.click()}else Y.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:c.jsx(ma,{className:"w-4 h-4"}),onClick:()=>Y.current?.click()},{label:"Remove Source 3MF",icon:c.jsx(kn,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:c.jsx(ya,{className:"w-4 h-4"}),onClick:()=>{const se=document.createElement("a");se.href=Pe.getArchiveDownload(t.id),se.download=`${t.print_name||t.filename}.3mf`,se.click()}},{label:"Copy Download Link",icon:c.jsx(Dh,{className:"w-4 h-4"}),onClick:()=>{const se=`${window.location.origin}${Pe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(se).then(()=>{o("Link copied to clipboard")}).catch(()=>{o("Failed to copy link","error")})}},{label:"QR Code",icon:c.jsx(Kle,{className:"w-4 h-4"}),onClick:()=>I(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:c.jsx(a0,{className:"w-4 h-4"}),onClick:()=>D(!0),disabled:!t.photos?.length},{label:"Project Page",icon:c.jsx(Ya,{className:"w-4 h-4"}),onClick:()=>L(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:c.jsx(sm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>fe.mutate()},{label:"Edit",icon:c.jsx(Zu,{className:"w-4 h-4"}),onClick:()=>v(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:c.jsx(ph,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:c.jsx(ph,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const se=[];if(t.project_id&&se.push({label:"Remove from Project",icon:c.jsx(Gt,{className:"w-4 h-4"}),onClick:()=>ue.mutate(null)}),!s)se.push({label:"Loading...",icon:c.jsx(At,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const ve=s.filter(je=>je.status==="active");ve.length===0?se.push({label:"No projects available",icon:c.jsx(ph,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):ve.forEach(je=>{se.push({label:je.name,icon:c.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:je.color||"#888"}}),onClick:()=>ue.mutate(je.id),disabled:t.project_id===je.id})})}return se})()},{label:n?"Deselect":"Select",icon:n?c.jsx(jh,{className:"w-4 h-4"}):c.jsx(im,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:c.jsx(kn,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return c.jsxs(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&&c.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:se=>{se.stopPropagation(),r(t.id)},children:n?c.jsx(jh,{className:"w-5 h-5 text-bambu-green"}):c.jsx(im,{className:"w-5 h-5 text-white"})}),c.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?c.jsx("img",{src:Pe.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):c.jsx("div",{className:"w-full h-full flex items-center justify-center",children:c.jsx(rb,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),l&&c.jsx("button",{className:"absolute top-2 right-10 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:se=>{se.stopPropagation();const ve=se.currentTarget.getBoundingClientRect();ne({x:ve.left,y:ve.bottom+4})},title:"Menu",children:c.jsx(NG,{className:"w-5 h-5 text-white"})}),c.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:se=>{se.stopPropagation(),fe.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:c.jsx(sm,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),t.status==="failed"&&c.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:"failed"}),t.duplicate_count>0&&c.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:"This model has been printed before",children:[c.jsx(Dh,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&c.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:se=>{se.stopPropagation();const ve=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",je=`${window.location.origin}${Pe.getSource3mfForSlicer(t.id,ve)}`;window.location.href=`bambustudioopen://${encodeURIComponent(je)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:c.jsx(w5,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&c.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:se=>{se.stopPropagation(),E(!0)},title:"View timelapse",children:c.jsx(Bp,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&c.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:se=>{se.stopPropagation(),D(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[c.jsx(a0,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&c.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]})]}),c.jsxs(Dt,{className:"p-4 flex-1 flex flex-col",children:[c.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:e}),t.project_name&&c.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${s?.find(se=>se.id===t.project_id)?.color||"#6b7280"}20`,color:s?.find(se=>se.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&c.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${hx(t.print_time_seconds||0)}
- Actual: ${hx(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${hx(t.actual_time_seconds)}`:`Estimated: ${hx(t.print_time_seconds||0)}`,children:[c.jsx(ti,{className:"w-3 h-3"}),hx(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&c.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&c.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[c.jsx(u0,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&c.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[c.jsx(Oh,{className:"w-3 h-3"}),t.total_layers&&c.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&c.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&c.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&c.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[c.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&c.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((se,ve)=>c.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:se},title:se},ve))})]})]}),(t.tags||t.notes)&&c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&c.jsx("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs",title:t.notes,children:c.jsx(LG,{className:"w-3 h-3"})}),t.tags?.split(",").map((se,ve)=>c.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:se.trim()},ve))]}),c.jsx("div",{className:"flex-1"}),c.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[c.jsx("span",{children:s8(t.created_at)}),c.jsx("span",{children:Wk(t.file_size)})]}),c.jsxs("div",{className:"flex gap-1 mt-3",children:[c.jsxs(Ie,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>g(!0),children:[c.jsx(jo,{className:"w-3 h-3 flex-shrink-0"}),c.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),c.jsx(Ie,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const se=t.print_name||t.filename||"model",ve=`${window.location.origin}${Pe.getArchiveForSlicer(t.id,se)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`},title:"Open in Bambu Studio",children:c.jsx(ro,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),c.jsx(Ie,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url,title:t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"Not from MakerWorld",children:c.jsx(l0,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),c.jsx(Ie,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>d(!0),title:"3D Preview",children:c.jsx(rm,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),c.jsx(Ie,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const se=document.createElement("a");se.href=Pe.getArchiveDownload(t.id),se.download=`${t.print_name||t.filename}.3mf`,se.click()},title:"Download",children:c.jsx(ya,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>v(!0),title:"Edit",children:c.jsx(Zu,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:c.jsx(kn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),y&&c.jsx(zwe,{archive:t,onClose:()=>v(!1)}),u&&c.jsx(Lwe,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>d(!1)}),f&&c.jsx(Iwe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>g(!1),onSuccess:()=>{}}),m&&c.jsx(Kr,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{ae.mutate(),x(!1)},onCancel:()=>x(!1)}),V&&c.jsx(Kr,{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)}),W&&c.jsx(Bwe,{x:W.x,y:W.y,items:Me,onClose:()=>ne(null)}),b&&t.timelapse_path&&c.jsx(pNe,{src:Pe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,onClose:()=>E(!1)}),S&&T.length>0&&c.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),c.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),c.jsx("button",{onClick:()=>{A(!1),P([])},className:"text-gray-400 hover:text-white p-1",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(se=>c.jsxs("button",{onClick:()=>ee.mutate(se.name),disabled:ee.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[c.jsx(Bp,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-white font-medium truncate",children:se.name}),c.jsxs("p",{className:"text-sm text-gray-400",children:[Wk(se.size),se.mtime&&` • ${s8(se.mtime)}`]})]})]},se.name))}),c.jsx("div",{className:"p-4 border-t border-gray-700",children:c.jsx(Ie,{variant:"secondary",onClick:()=>{A(!1),P([])},className:"w-full",children:"Cancel"})})]})}),C&&c.jsx(Kwe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),N&&t.photos&&t.photos.length>0&&c.jsx(Xwe,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>D(!1),onDelete:async se=>{try{await Pe.deleteArchivePhoto(t.id,se),a.invalidateQueries({queryKey:["archives"]}),o("Photo deleted")}catch{o("Failed to delete photo","error")}}}),F&&c.jsx(hNe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>L(!1)}),q&&c.jsx(mNe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),c.jsx("input",{ref:Y,type:"file",accept:".3mf",className:"hidden",onChange:se=>{const ve=se.target.files?.[0];ve&&Z.mutate(ve),se.target.value=""}})]})}const vNe=[{id:"all",label:"All Archives",icon:c.jsx(Noe,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:c.jsx(ti,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:c.jsx(qr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:c.jsx(qr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:c.jsx(sm,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:c.jsx(Oo,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:c.jsx(Dh,{className:"w-4 h-4"})}];function yNe(){const t=Sn(),{showToast:e}=ri(),n=M.useRef(null),[r,i]=M.useState(""),[s,a]=M.useState(null),[o,l]=M.useState(null),[u,d]=M.useState(new Set),[f,g]=M.useState("or"),[m,x]=M.useState(!1),[y,v]=M.useState(null),[b,E]=M.useState(!1),[S,A]=M.useState([]),[T,P]=M.useState(!1),[C,I]=M.useState(new Set),[N,D]=M.useState(!1),[F,L]=M.useState(!1),[q,R]=M.useState(!1),[V,K]=M.useState("grid"),[W,ne]=M.useState("date-desc"),[Y,Z]=M.useState("all"),[U,$]=M.useState(!1),[ee,ae]=M.useState(!1),[fe,ue]=M.useState(!1),{data:xe,isLoading:Me}=yt({queryKey:["archives",s],queryFn:()=>Pe.getArchives(s||void 0)}),{data:se}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:ve}=yt({queryKey:["projects"],queryFn:()=>Pe.getProjects()}),je=_t({mutationFn:async me=>(await Promise.all(me.map(Ae=>Pe.deleteArchive(Ae))),me.length),onSuccess:me=>{t.invalidateQueries({queryKey:["archives"]}),I(new Set),e(`${me} archive${me!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}}),de=new Map(se?.map(me=>[me.id,me.name])||[]),ut=[...new Set(xe?.flatMap(me=>me.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),H=[...new Set(xe?.flatMap(me=>me.filament_color?.split(",")||[]).filter(Boolean)||[])],z=[...new Set(xe?.flatMap(me=>me.tags?.split(",").map(Ae=>Ae.trim())||[]).filter(Boolean)||[])].sort(),re=xe?.filter(me=>{const Ae=new Date,ze=new Date(me.created_at);let st=!0;switch(Y){case"recent":st=Ae.getTime()-ze.getTime()<1440*60*1e3;break;case"this-week":st=Ae.getTime()-ze.getTime()<10080*60*1e3;break;case"this-month":st=ze.getMonth()===Ae.getMonth()&&ze.getFullYear()===Ae.getFullYear();break;case"favorites":st=me.is_favorite===!0;break;case"failed":st=me.status==="failed";break;case"duplicates":st=me.duplicate_count>0;break}const Ve=(me.print_name||me.filename).toLowerCase().includes(r.toLowerCase()),ce=!o||me.filament_type?.split(", ").includes(o),Ye=me.filament_color?.split(",")||[],$e=u.size===0||(f==="or"?Ye.some(Fe=>u.has(Fe)):[...u].every(Fe=>Ye.includes(Fe))),Ze=Y==="favorites"||!m||me.is_favorite,at=me.tags?.split(",").map(Fe=>Fe.trim())||[],Q=!y||at.includes(y);return st&&Ve&&ce&&$e&&Ze&&Q}).sort((me,Ae)=>{switch(W){case"date-desc":return new Date(Ae.created_at).getTime()-new Date(me.created_at).getTime();case"date-asc":return new Date(me.created_at).getTime()-new Date(Ae.created_at).getTime();case"name-asc":return(me.print_name||me.filename).localeCompare(Ae.print_name||Ae.filename);case"name-desc":return(Ae.print_name||Ae.filename).localeCompare(me.print_name||me.filename);case"size-desc":return Ae.file_size-me.file_size;case"size-asc":return me.file_size-Ae.file_size;default:return 0}}),G=N||C.size>0,J=me=>{I(Ae=>{const ze=new Set(Ae);return ze.has(me)?ze.delete(me):ze.add(me),ze})},le=()=>{re&&I(new Set(re.map(me=>me.id)))},ke=()=>{I(new Set),D(!1)},Ne=me=>{d(Ae=>{const ze=new Set(Ae);return ze.has(me)?ze.delete(me):ze.add(me),ze})},we=()=>{d(new Set)},B=()=>{i(""),a(null),l(null),x(!1),v(null)},j=r||s||o||m||y,te=M.useCallback(me=>{me.preventDefault(),me.dataTransfer.types.includes("Files")&&P(!0)},[]),be=M.useCallback(me=>{me.preventDefault(),me.currentTarget===me.target&&P(!1)},[]),_e=M.useCallback(me=>{me.preventDefault(),P(!1);const Ae=Array.from(me.dataTransfer.files).filter(ze=>ze.name.endsWith(".3mf"));Ae.length>0?(A(Ae),E(!0)):me.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ge=M.useCallback(me=>{const Ae=me.target;if(Ae.tagName==="INPUT"||Ae.tagName==="TEXTAREA"||Ae.isContentEditable){me.key==="Escape"&&Ae.blur();return}switch(me.key){case"/":me.preventDefault(),n.current?.focus();break;case"u":case"U":!me.metaKey&&!me.ctrlKey&&(me.preventDefault(),E(!0));break;case"Escape":G&&ke();break}},[G]);return M.useEffect(()=>(document.addEventListener("keydown",ge),()=>document.removeEventListener("keydown",ge)),[ge]),c.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:te,onDragLeave:be,onDrop:_e,children:[T&&c.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:c.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[c.jsx(ma,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),c.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),c.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),G&&c.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:ke,children:[c.jsx(Gt,{className:"w-4 h-4"}),"Close"]}),c.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),c.jsxs("span",{className:"text-white font-medium",children:[C.size," selected"]}),c.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:le,children:"Select All"}),c.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>R(!0),children:[c.jsx(f0,{className:"w-4 h-4"}),"Tags"]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>{const me=Array.from(C);Promise.all(me.map(Ae=>Pe.toggleFavorite(Ae))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${me.length} archive${me.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[c.jsx(sm,{className:"w-4 h-4"}),"Favorite"]}),c.jsxs(Ie,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>L(!0),children:[c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]}),c.jsxs("div",{className:"flex items-center justify-between mb-8",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),c.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:Y,onChange:me=>Z(me.target.value),children:vNe.map(me=>c.jsx("option",{value:me.id,children:me.label},me.id))})]}),c.jsxs("p",{className:"text-bambu-gray",children:[re?.length||0," of ",xe?.length||0," prints"]})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"relative",children:[c.jsxs(Ie,{variant:"secondary",onClick:()=>$(!U),disabled:ee,children:[ee?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(o1,{className:"w-4 h-4"}),"Export"]}),U&&c.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[c.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{$(!1),ae(!0);try{const{blob:me,filename:Ae}=await Pe.exportArchives({format:"csv",printerId:s||void 0,status:Y==="failed"?"failed":void 0,search:r||void 0}),ze=URL.createObjectURL(me),st=document.createElement("a");st.href=ze,st.download=Ae,st.click(),URL.revokeObjectURL(ze),e("Export downloaded")}catch{e("Export failed","error")}finally{ae(!1)}},children:[c.jsx(Ya,{className:"w-4 h-4"}),"Export as CSV"]}),c.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{$(!1),ae(!0);try{const{blob:me,filename:Ae}=await Pe.exportArchives({format:"xlsx",printerId:s||void 0,status:Y==="failed"?"failed":void 0,search:r||void 0}),ze=URL.createObjectURL(me),st=document.createElement("a");st.href=ze,st.download=Ae,st.click(),URL.revokeObjectURL(ze),e("Export downloaded")}catch{e("Export failed","error")}finally{ae(!1)}},children:[c.jsx(o1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),C.size>=2&&C.size<=5&&c.jsxs(Ie,{variant:"secondary",onClick:()=>ue(!0),children:[c.jsx(Hp,{className:"w-4 h-4"}),"Compare (",C.size,")"]}),!G&&c.jsxs(Ie,{variant:"secondary",onClick:()=>D(!0),children:[c.jsx(jh,{className:"w-4 h-4"}),"Select"]}),c.jsxs(Ie,{onClick:()=>E(!0),children:[c.jsx(ma,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),c.jsx(Nt,{className:"mb-6",children:c.jsxs(Dt,{className:"py-4",children:[c.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[c.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[c.jsx(Qu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:me=>i(me.target.value)})]}),c.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx(gR,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),c.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s||"",onChange:me=>a(me.target.value?Number(me.target.value):null),children:[c.jsx("option",{value:"",children:"All Printers"}),se?.map(me=>c.jsx("option",{value:me.id,children:me.name},me.id))]})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx(u0,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),c.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o||"",onChange:me=>l(me.target.value||null),children:[c.jsx("option",{value:"",children:"All Materials"}),ut.map(me=>c.jsx("option",{value:me,children:me},me))]})]}),c.jsxs("button",{onClick:()=>x(!m),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${m?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:m?"Show all":"Show favorites only",children:[c.jsx(sm,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),c.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),z.length>0&&c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx(f0,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),c.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:y||"",onChange:me=>v(me.target.value||null),children:[c.jsx("option",{value:"",children:"All Tags"}),z.map(me=>c.jsx("option",{value:me,children:me},me))]})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx(pae,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),c.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:W,onChange:me=>ne(me.target.value),children:[c.jsx("option",{value:"date-desc",children:"Newest first"}),c.jsx("option",{value:"date-asc",children:"Oldest first"}),c.jsx("option",{value:"name-asc",children:"Name A-Z"}),c.jsx("option",{value:"name-desc",children:"Name Z-A"}),c.jsx("option",{value:"size-desc",children:"Largest first"}),c.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),c.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[c.jsx("button",{className:`p-2 ${V==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("grid"),title:"Grid view",children:c.jsx(OG,{className:"w-4 h-4"})}),c.jsx("button",{className:`p-2 ${V==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("list"),title:"List view",children:c.jsx(bR,{className:"w-4 h-4"})}),c.jsx("button",{className:`p-2 ${V==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("calendar"),title:"Calendar view",children:c.jsx(Tae,{className:"w-4 h-4"})})]})]}),j&&c.jsxs(Ie,{variant:"ghost",size:"sm",onClick:B,className:"text-bambu-gray hover:text-white",children:[c.jsx(Gt,{className:"w-4 h-4"}),"Reset"]})]}),H.length>0&&c.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&c.jsx("button",{onClick:()=>g(me=>me==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),c.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:H.map(me=>c.jsx("button",{onClick:()=>Ne(me),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(me)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:me},title:me},me))}),u.size>0&&c.jsxs("button",{onClick:we,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[c.jsx(Gt,{className:"w-3 h-3"}),"Clear"]})]})]})}),Me?c.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):re?.length===0?c.jsx(Nt,{children:c.jsxs(Dt,{className:"text-center py-12",children:[c.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):V==="calendar"?c.jsx(Nt,{className:"p-6",children:c.jsx(qwe,{archives:re||[],onArchiveClick:me=>{i(me.print_name||me.filename),K("grid")}})}):V==="grid"?c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:re?.map(me=>c.jsx(bNe,{archive:me,printerName:me.printer_id?de.get(me.printer_id)||"Unknown":"No Printer",isSelected:C.has(me.id),onSelect:J,selectionMode:G,projects:ve},me.id))}):V==="list"?c.jsx(Nt,{children:c.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[c.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[c.jsx("div",{className:"col-span-1"}),c.jsx("div",{className:"col-span-4",children:"Name"}),c.jsx("div",{className:"col-span-2",children:"Printer"}),c.jsx("div",{className:"col-span-2",children:"Date"}),c.jsx("div",{className:"col-span-1",children:"Size"}),c.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),re?.map(me=>c.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${C.has(me.id)?"bg-bambu-green/10":""}`,children:[c.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[G&&c.jsx("button",{onClick:()=>J(me.id),children:C.has(me.id)?c.jsx(jh,{className:"w-4 h-4 text-bambu-green"}):c.jsx(im,{className:"w-4 h-4 text-bambu-gray"})}),me.thumbnail_path?c.jsx("img",{src:Pe.getArchiveThumbnail(me.id),alt:"",className:"w-10 h-10 object-cover rounded"}):c.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:c.jsx(rb,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),c.jsxs("div",{className:"col-span-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"text-white text-sm truncate",children:me.print_name||me.filename}),me.timelapse_path&&c.jsx("span",{title:"Has timelapse",children:c.jsx(Bp,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),me.filament_type&&c.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:me.filament_type}),me.filament_color&&c.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:me.filament_color.split(",").map((Ae,ze)=>c.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:Ae},title:Ae},ze))})]})]}),c.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:me.printer_id?de.get(me.printer_id)||"Unknown":"No Printer"}),c.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(me.created_at).toLocaleDateString()}),c.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:Wk(me.file_size)}),c.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{const Ae=me.print_name||me.filename||"model",ze=`${window.location.origin}${Pe.getArchiveForSlicer(me.id,Ae)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ze)}`},title:"Open in Slicer",children:c.jsx(ro,{className:"w-4 h-4"})}),me.makerworld_url&&c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>window.open(me.makerworld_url,"_blank"),title:"MakerWorld",children:c.jsx(l0,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{const Ae=document.createElement("a");Ae.href=Pe.getArchiveDownload(me.id),Ae.download=`${me.print_name||me.filename}.3mf`,Ae.click()},title:"Download",children:c.jsx(ya,{className:"w-4 h-4"})})]})]},me.id))]})}):null,b&&c.jsx(Uwe,{onClose:()=>{E(!1),A([])},initialFiles:S}),F&&c.jsx(Kr,{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:()=>{je.mutate(Array.from(C)),L(!1)},onCancel:()=>L(!1)}),q&&c.jsx(Hwe,{selectedIds:Array.from(C),existingTags:z,onClose:()=>R(!1)}),fe&&C.size>=2&&C.size<=5&&c.jsx(gNe,{archiveIds:Array.from(C),onClose:()=>{ue(!1),I(new Set),D(!1)}})]})}function _Ne(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const qS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vm(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function UD(t){return"nodeType"in t}function Ys(t){var e,n;return t?Vm(t)?t:UD(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function FD(t){const{Document:e}=Ys(t);return t instanceof e}function hb(t){return Vm(t)?!1:t instanceof Ys(t).HTMLElement}function YK(t){return t instanceof Ys(t).SVGElement}function Gm(t){return t?Vm(t)?t.document:UD(t)?FD(t)?t:hb(t)||YK(t)?t.ownerDocument:document:document:document}const hl=qS?M.useLayoutEffect:M.useEffect;function zD(t){const e=M.useRef(t);return hl(()=>{e.current=t}),M.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function wNe(){const t=M.useRef(null),e=M.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=M.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function j0(t,e){e===void 0&&(e=[t]);const n=M.useRef(t);return hl(()=>{n.current!==t&&(n.current=t)},e),n}function fb(t,e){const n=M.useRef();return M.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function dw(t){const e=zD(t),n=M.useRef(null),r=M.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function qk(t){const e=M.useRef();return M.useEffect(()=>{e.current=t},[t]),e.current}let iC={};function pb(t,e){return M.useMemo(()=>{if(e)return e;const n=iC[t]==null?0:iC[t]+1;return iC[t]=n,t+"-"+n},[t,e])}function ZK(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,a)=>{const o=Object.entries(a);for(const[l,u]of o){const d=s[l];d!=null&&(s[l]=d+t*u)}return s},{...e})}}const Qp=ZK(1),L0=ZK(-1);function SNe(t){return"clientX"in t&&"clientY"in t}function BD(t){if(!t)return!1;const{KeyboardEvent:e}=Ys(t.target);return e&&t instanceof e}function ENe(t){if(!t)return!1;const{TouchEvent:e}=Ys(t.target);return e&&t instanceof e}function Kk(t){if(ENe(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 SNe(t)?{x:t.clientX,y:t.clientY}:null}const Sm=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[Sm.Translate.toString(t),Sm.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),a8="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function MNe(t){return t.matches(a8)?t:t.querySelector(a8)}const ANe={display:"none"};function TNe(t){let{id:e,value:n}=t;return pr.createElement("div",{id:e,style:ANe},n)}function CNe(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 pr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function NNe(){const[t,e]=M.useState("");return{announce:M.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const QK=M.createContext(null);function kNe(t){const e=M.useContext(QK);M.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function PNe(){const[t]=M.useState(()=>new Set),e=M.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[M.useCallback(r=>{let{type:i,event:s}=r;t.forEach(a=>{var o;return(o=a[i])==null?void 0:o.call(a,s)})},[t]),e]}const RNe={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.
- `},DNe={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 ONe(t){let{announcements:e=DNe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=RNe}=t;const{announce:s,announcement:a}=NNe(),o=pb("DndLiveRegion"),[l,u]=M.useState(!1);if(M.useEffect(()=>{u(!0)},[]),kNe(M.useMemo(()=>({onDragStart(f){let{active:g}=f;s(e.onDragStart({active:g}))},onDragMove(f){let{active:g,over:m}=f;e.onDragMove&&s(e.onDragMove({active:g,over:m}))},onDragOver(f){let{active:g,over:m}=f;s(e.onDragOver({active:g,over:m}))},onDragEnd(f){let{active:g,over:m}=f;s(e.onDragEnd({active:g,over:m}))},onDragCancel(f){let{active:g,over:m}=f;s(e.onDragCancel({active:g,over:m}))}}),[s,e])),!l)return null;const d=pr.createElement(pr.Fragment,null,pr.createElement(TNe,{id:r,value:i.draggable}),pr.createElement(CNe,{id:o,announcement:a}));return n?ic.createPortal(d,n):d}var ui;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(ui||(ui={}));function hw(){}function fw(t,e){return M.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function JK(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Lo=Object.freeze({x:0,y:0});function eX(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function tX(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function jNe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function o8(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 nX(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function l8(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 rX=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=l8(e,e.left,e.top),s=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const u=eX(l8(l),i);s.push({id:o,data:{droppableContainer:a,value:u}})}}return s.sort(tX)},LNe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=o8(e),s=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const u=o8(l),d=i.reduce((g,m,x)=>g+eX(u[x],m),0),f=Number((d/4).toFixed(4));s.push({id:o,data:{droppableContainer:a,value:f}})}}return s.sort(tX)};function INe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),a=i-r,o=s-n;if(r<i&&n<s){const l=e.width*e.height,u=t.width*t.height,d=a*o,f=d/(l+u-d);return Number(f.toFixed(4))}return 0}const UNe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const s of r){const{id:a}=s,o=n.get(a);if(o){const l=INe(o,e);l>0&&i.push({id:a,data:{droppableContainer:s,value:l}})}}return i.sort(jNe)};function FNe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function iX(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Lo}function zNe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];return i.reduce((a,o)=>({...a,top:a.top+t*o.y,bottom:a.bottom+t*o.y,left:a.left+t*o.x,right:a.right+t*o.x}),{...n})}}const BNe=zNe(1);function HNe(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 $Ne(t,e,n){const r=HNe(e);if(!r)return t;const{scaleX:i,scaleY:s,x:a,y:o}=r,l=t.left-a-(1-i)*parseFloat(n),u=t.top-o-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=s?t.height/s:t.height;return{width:d,height:f,top:u,right:l+d,bottom:u+f,left:l}}const VNe={ignoreTransform:!1};function Wm(t,e){e===void 0&&(e=VNe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Ys(t).getComputedStyle(t);u&&(n=$Ne(n,u,d))}const{top:r,left:i,width:s,height:a,bottom:o,right:l}=n;return{top:r,left:i,width:s,height:a,bottom:o,right:l}}function c8(t){return Wm(t,{ignoreTransform:!0})}function GNe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function WNe(t,e){return e===void 0&&(e=Ys(t).getComputedStyle(t)),e.position==="fixed"}function qNe(t,e){e===void 0&&(e=Ys(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=e[i];return typeof s=="string"?n.test(s):!1})}function KS(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(FD(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!hb(i)||YK(i)||n.includes(i))return n;const s=Ys(t).getComputedStyle(i);return i!==t&&qNe(i,s)&&n.push(i),WNe(i,s)?n:r(i.parentNode)}return t?r(t):n}function sX(t){const[e]=KS(t,1);return e??null}function sC(t){return!qS||!t?null:Vm(t)?t:UD(t)?FD(t)||t===Gm(t).scrollingElement?window:hb(t)?t:null:null}function aX(t){return Vm(t)?t.scrollX:t.scrollLeft}function oX(t){return Vm(t)?t.scrollY:t.scrollTop}function Xk(t){return{x:aX(t),y:oX(t)}}var Pi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Pi||(Pi={}));function lX(t){return!qS||!t?!1:t===document.scrollingElement}function cX(t){const e={x:0,y:0},n=lX(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,s=t.scrollLeft<=e.x,a=t.scrollTop>=r.y,o=t.scrollLeft>=r.x;return{isTop:i,isLeft:s,isBottom:a,isRight:o,maxScroll:r,minScroll:e}}const KNe={x:.2,y:.2};function XNe(t,e,n,r,i){let{top:s,left:a,right:o,bottom:l}=n;r===void 0&&(r=10),i===void 0&&(i=KNe);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=cX(t),m={x:0,y:0},x={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&s<=e.top+y.height?(m.y=Pi.Backward,x.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&l>=e.bottom-y.height&&(m.y=Pi.Forward,x.y=r*Math.abs((e.bottom-y.height-l)/y.height)),!g&&o>=e.right-y.width?(m.x=Pi.Forward,x.x=r*Math.abs((e.right-y.width-o)/y.width)):!f&&a<=e.left+y.width&&(m.x=Pi.Backward,x.x=r*Math.abs((e.left+y.width-a)/y.width)),{direction:m,speed:x}}function YNe(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:a}=window;return{top:0,left:0,right:s,bottom:a,width:s,height:a}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function uX(t){return t.reduce((e,n)=>Qp(e,Xk(n)),Lo)}function ZNe(t){return t.reduce((e,n)=>e+aX(n),0)}function QNe(t){return t.reduce((e,n)=>e+oX(n),0)}function JNe(t,e){if(e===void 0&&(e=Wm),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);sX(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const e3e=[["x",["left","right"],ZNe],["y",["top","bottom"],QNe]];class HD{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=KS(n),i=uX(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,a,o]of e3e)for(const l of a)Object.defineProperty(this,l,{get:()=>{const u=o(r),d=i[s]-u;return this.rect[l]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Zx{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 t3e(t){const{EventTarget:e}=Ys(t);return t instanceof e?t:Gm(t)}function aC(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 Va;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Va||(Va={}));function u8(t){t.preventDefault()}function n3e(t){t.stopPropagation()}var _n;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(_n||(_n={}));const dX={start:[_n.Space,_n.Enter],cancel:[_n.Esc],end:[_n.Space,_n.Enter,_n.Tab]},r3e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case _n.Right:return{...n,x:n.x+25};case _n.Left:return{...n,x:n.x-25};case _n.Down:return{...n,y:n.y+25};case _n.Up:return{...n,y:n.y-25}}};class XS{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 Zx(Gm(n)),this.windowListeners=new Zx(Ys(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Va.Resize,this.handleCancel),this.windowListeners.add(Va.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Va.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&JNe(r),n(Lo)}handleKeyDown(e){if(BD(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=dX,coordinateGetter:a=r3e,scrollBehavior:o="smooth"}=i,{code:l}=e;if(s.end.includes(l)){this.handleEnd(e);return}if(s.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Lo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=a(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=L0(f,d),m={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const v=e.code,{isTop:b,isRight:E,isLeft:S,isBottom:A,maxScroll:T,minScroll:P}=cX(y),C=YNe(y),I={x:Math.min(v===_n.Right?C.right-C.width/2:C.right,Math.max(v===_n.Right?C.left:C.left+C.width/2,f.x)),y:Math.min(v===_n.Down?C.bottom-C.height/2:C.bottom,Math.max(v===_n.Down?C.top:C.top+C.height/2,f.y))},N=v===_n.Right&&!E||v===_n.Left&&!S,D=v===_n.Down&&!A||v===_n.Up&&!b;if(N&&I.x!==f.x){const F=y.scrollLeft+g.x,L=v===_n.Right&&F<=T.x||v===_n.Left&&F>=P.x;if(L&&!g.y){y.scrollTo({left:F,behavior:o});return}L?m.x=y.scrollLeft-F:m.x=v===_n.Right?y.scrollLeft-T.x:y.scrollLeft-P.x,m.x&&y.scrollBy({left:-m.x,behavior:o});break}else if(D&&I.y!==f.y){const F=y.scrollTop+g.y,L=v===_n.Down&&F<=T.y||v===_n.Up&&F>=P.y;if(L&&!g.x){y.scrollTo({top:F,behavior:o});return}L?m.y=y.scrollTop-F:m.y=v===_n.Down?y.scrollTop-T.y:y.scrollTop-P.y,m.y&&y.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,Qp(L0(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()}}XS.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=dX,onActivation:i}=e,{active:s}=n;const{code:a}=t.nativeEvent;if(r.start.includes(a)){const o=s.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function d8(t){return!!(t&&"distance"in t)}function h8(t){return!!(t&&"delay"in t)}class $D{constructor(e,n,r){var i;r===void 0&&(r=t3e(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:s}=e,{target:a}=s;this.props=e,this.events=n,this.document=Gm(a),this.documentListeners=new Zx(this.document),this.listeners=new Zx(r),this.windowListeners=new Zx(Ys(a)),this.initialCoordinates=(i=Kk(s))!=null?i:Lo,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(Va.Resize,this.handleCancel),this.windowListeners.add(Va.DragStart,u8),this.windowListeners.add(Va.VisibilityChange,this.handleCancel),this.windowListeners.add(Va.ContextMenu,u8),this.documentListeners.add(Va.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(h8(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(d8(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(Va.Click,n3e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Va.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:s}=this,{onMove:a,options:{activationConstraint:o}}=s;if(!i)return;const l=(n=Kk(e))!=null?n:Lo,u=L0(i,l);if(!r&&o){if(d8(o)){if(o.tolerance!=null&&aC(u,o.tolerance))return this.handleCancel();if(aC(u,o.distance))return this.handleStart()}if(h8(o)&&aC(u,o.tolerance))return this.handleCancel();this.handlePending(o,u);return}e.cancelable&&e.preventDefault(),a(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===_n.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const i3e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class YS extends $D{constructor(e){const{event:n}=e,r=Gm(n.target);super(e,i3e,r)}}YS.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 s3e={move:{name:"mousemove"},end:{name:"mouseup"}};var Yk;(function(t){t[t.RightClick=2]="RightClick"})(Yk||(Yk={}));class a3e extends $D{constructor(e){super(e,s3e,Gm(e.event.target))}}a3e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===Yk.RightClick?!1:(r?.({event:n}),!0)}}];const oC={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class o3e extends $D{constructor(e){super(e,oC)}static setup(){return window.addEventListener(oC.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(oC.move.name,e)};function e(){}}}o3e.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 Qx;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Qx||(Qx={}));var pw;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(pw||(pw={}));function l3e(t){let{acceleration:e,activator:n=Qx.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:a=5,order:o=pw.TreeOrder,pointerCoordinates:l,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const m=u3e({delta:f,disabled:!s}),[x,y]=wNe(),v=M.useRef({x:0,y:0}),b=M.useRef({x:0,y:0}),E=M.useMemo(()=>{switch(n){case Qx.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Qx.DraggableRect:return i}},[n,i,l]),S=M.useRef(null),A=M.useCallback(()=>{const P=S.current;if(!P)return;const C=v.current.x*b.current.x,I=v.current.y*b.current.y;P.scrollBy(C,I)},[]),T=M.useMemo(()=>o===pw.TreeOrder?[...u].reverse():u,[o,u]);M.useEffect(()=>{if(!s||!u.length||!E){y();return}for(const P of T){if(r?.(P)===!1)continue;const C=u.indexOf(P),I=d[C];if(!I)continue;const{direction:N,speed:D}=XNe(P,I,E,e,g);for(const F of["x","y"])m[F][N[F]]||(D[F]=0,N[F]=0);if(D.x>0||D.y>0){y(),S.current=P,x(A,a),v.current=D,b.current=N;return}}v.current={x:0,y:0},b.current={x:0,y:0},y()},[e,A,r,y,s,a,JSON.stringify(E),JSON.stringify(m),x,u,T,d,JSON.stringify(g)])}const c3e={x:{[Pi.Backward]:!1,[Pi.Forward]:!1},y:{[Pi.Backward]:!1,[Pi.Forward]:!1}};function u3e(t){let{delta:e,disabled:n}=t;const r=qk(e);return fb(i=>{if(n||!r||!i)return c3e;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Pi.Backward]:i.x[Pi.Backward]||s.x===-1,[Pi.Forward]:i.x[Pi.Forward]||s.x===1},y:{[Pi.Backward]:i.y[Pi.Backward]||s.y===-1,[Pi.Forward]:i.y[Pi.Forward]||s.y===1}}},[n,e,r])}function d3e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return fb(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function h3e(t,e){return M.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,s=i.activators.map(a=>({eventName:a.eventName,handler:e(a.handler,r)}));return[...n,...s]},[]),[t,e])}var I0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(I0||(I0={}));var Zk;(function(t){t.Optimized="optimized"})(Zk||(Zk={}));const f8=new Map;function f3e(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,a]=M.useState(null),{frequency:o,measure:l,strategy:u}=i,d=M.useRef(t),f=v(),g=j0(f),m=M.useCallback(function(b){b===void 0&&(b=[]),!g.current&&a(E=>E===null?b:E.concat(b.filter(S=>!E.includes(S))))},[g]),x=M.useRef(null),y=fb(b=>{if(f&&!n)return f8;if(!b||b===f8||d.current!==t||s!=null){const E=new Map;for(let S of t){if(!S)continue;if(s&&s.length>0&&!s.includes(S.id)&&S.rect.current){E.set(S.id,S.rect.current);continue}const A=S.node.current,T=A?new HD(l(A),A):null;S.rect.current=T,T&&E.set(S.id,T)}return E}return b},[t,s,n,f,l]);return M.useEffect(()=>{d.current=t},[t]),M.useEffect(()=>{f||m()},[n,f]),M.useEffect(()=>{s&&s.length>0&&a(null)},[JSON.stringify(s)]),M.useEffect(()=>{f||typeof o!="number"||x.current!==null||(x.current=setTimeout(()=>{m(),x.current=null},o))},[o,f,m,...r]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:s!=null};function v(){switch(u){case I0.Always:return!1;case I0.BeforeDragging:return n;default:return!n}}}function hX(t,e){return fb(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function p3e(t,e){return hX(t,e)}function m3e(t){let{callback:e,disabled:n}=t;const r=zD(e),i=M.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return M.useEffect(()=>()=>i?.disconnect(),[i]),i}function ZS(t){let{callback:e,disabled:n}=t;const r=zD(e),i=M.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return M.useEffect(()=>()=>i?.disconnect(),[i]),i}function g3e(t){return new HD(Wm(t),t)}function p8(t,e,n){e===void 0&&(e=g3e);const[r,i]=M.useState(null);function s(){i(l=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=l??n)!=null?u:null}const d=e(t);return JSON.stringify(l)===JSON.stringify(d)?l:d})}const a=m3e({callback(l){if(t)for(const u of l){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){s();break}}}}),o=ZS({callback:s});return hl(()=>{s(),t?(o?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),a?.disconnect())},[t]),r}function x3e(t){const e=hX(t);return iX(t,e)}const m8=[];function b3e(t){const e=M.useRef(t),n=fb(r=>t?r&&r!==m8&&t&&e.current&&t.parentNode===e.current.parentNode?r:KS(t):m8,[t]);return M.useEffect(()=>{e.current=t},[t]),n}function v3e(t){const[e,n]=M.useState(null),r=M.useRef(t),i=M.useCallback(s=>{const a=sC(s.target);a&&n(o=>o?(o.set(a,Xk(a)),new Map(o)):null)},[]);return M.useEffect(()=>{const s=r.current;if(t!==s){a(s);const o=t.map(l=>{const u=sC(l);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,Xk(u)]):null}).filter(l=>l!=null);n(o.length?new Map(o):null),r.current=t}return()=>{a(t),a(s)};function a(o){o.forEach(l=>{const u=sC(l);u?.removeEventListener("scroll",i)})}},[i,t]),M.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,a)=>Qp(s,a),Lo):uX(t):Lo,[t,e])}function g8(t,e){e===void 0&&(e=[]);const n=M.useRef(null);return M.useEffect(()=>{n.current=null},e),M.useEffect(()=>{const r=t!==Lo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?L0(t,n.current):Lo}function y3e(t){M.useEffect(()=>{if(!qS)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 _3e(t,e){return M.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=a=>{s(a,e)},n},{}),[t,e])}function fX(t){return M.useMemo(()=>t?GNe(t):null,[t])}const x8=[];function w3e(t,e){e===void 0&&(e=Wm);const[n]=t,r=fX(n?Ys(n):null),[i,s]=M.useState(x8);function a(){s(()=>t.length?t.map(l=>lX(l)?r:new HD(e(l),l)):x8)}const o=ZS({callback:a});return hl(()=>{o?.disconnect(),a(),t.forEach(l=>o?.observe(l))},[t]),i}function S3e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return hb(e)?e:t}function E3e(t){let{measure:e}=t;const[n,r]=M.useState(null),i=M.useCallback(u=>{for(const{target:d}of u)if(hb(d)){r(f=>{const g=e(d);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),s=ZS({callback:i}),a=M.useCallback(u=>{const d=S3e(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[o,l]=dw(a);return M.useMemo(()=>({nodeRef:o,rect:n,setRef:l}),[n,o,l])}const M3e=[{sensor:YS,options:{}},{sensor:XS,options:{}}],A3e={current:{}},X_={draggable:{measure:c8},droppable:{measure:c8,strategy:I0.WhileDragging,frequency:Zk.Optimized},dragOverlay:{measure:Wm}};class Jx 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 T3e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Jx,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:hw},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:X_,measureDroppableContainers:hw,windowRect:null,measuringScheduled:!1},C3e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:hw,draggableNodes:new Map,over:null,measureDroppableContainers:hw},QS=M.createContext(C3e),pX=M.createContext(T3e);function N3e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Jx}}}function k3e(t,e){switch(e.type){case ui.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ui.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case ui.DragEnd:case ui.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ui.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Jx(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case ui.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,s=t.droppable.containers.get(n);if(!s||r!==s.key)return t;const a=new Jx(t.droppable.containers);return a.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:a}}}case ui.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new Jx(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function P3e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=M.useContext(QS),s=qk(r),a=qk(n?.id);return M.useEffect(()=>{if(!e&&!r&&s&&a!=null){if(!BD(s)||document.activeElement===s.target)return;const o=i.get(a);if(!o)return;const{activatorNode:l,node:u}=o;if(!l.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[l.current,u.current]){if(!d)continue;const f=MNe(d);if(f){f.focus();break}}})}},[r,e,i,a,s]),null}function R3e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function D3e(t){return M.useMemo(()=>({draggable:{...X_.draggable,...t?.draggable},droppable:{...X_.droppable,...t?.droppable},dragOverlay:{...X_.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function O3e(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=M.useRef(!1),{x:a,y:o}=typeof i=="boolean"?{x:i,y:i}:i;hl(()=>{if(!a&&!o||!e){s.current=!1;return}if(s.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=iX(d,r);if(a||(f.x=0),o||(f.y=0),s.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=sX(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,a,o,r,n])}const mX=M.createContext({...Lo,scaleX:1,scaleY:1});var Tu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Tu||(Tu={}));const gX=M.memo(function(e){var n,r,i,s;let{id:a,accessibility:o,autoScroll:l=!0,children:u,sensors:d=M3e,collisionDetection:f=UNe,measuring:g,modifiers:m,...x}=e;const y=M.useReducer(k3e,void 0,N3e),[v,b]=y,[E,S]=PNe(),[A,T]=M.useState(Tu.Uninitialized),P=A===Tu.Initialized,{draggable:{active:C,nodes:I,translate:N},droppable:{containers:D}}=v,F=C!=null?I.get(C):null,L=M.useRef({initial:null,translated:null}),q=M.useMemo(()=>{var Ue;return C!=null?{id:C,data:(Ue=F?.data)!=null?Ue:A3e,rect:L}:null},[C,F]),R=M.useRef(null),[V,K]=M.useState(null),[W,ne]=M.useState(null),Y=j0(x,Object.values(x)),Z=pb("DndDescribedBy",a),U=M.useMemo(()=>D.getEnabled(),[D]),$=D3e(g),{droppableRects:ee,measureDroppableContainers:ae,measuringScheduled:fe}=f3e(U,{dragging:P,dependencies:[N.x,N.y],config:$.droppable}),ue=d3e(I,C),xe=M.useMemo(()=>W?Kk(W):null,[W]),Me=pe(),se=p3e(ue,$.draggable.measure);O3e({activeNode:C!=null?I.get(C):null,config:Me.layoutShiftCompensation,initialRect:se,measure:$.draggable.measure});const ve=p8(ue,$.draggable.measure,se),je=p8(ue?ue.parentElement:null),de=M.useRef({activatorEvent:null,active:null,activeNode:ue,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:I,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ut=D.getNodeFor((n=de.current.over)==null?void 0:n.id),H=E3e({measure:$.dragOverlay.measure}),z=(r=H.nodeRef.current)!=null?r:ue,re=P?(i=H.rect)!=null?i:ve:null,G=!!(H.nodeRef.current&&H.rect),J=x3e(G?null:ve),le=fX(z?Ys(z):null),ke=b3e(P?ut??ue:null),Ne=w3e(ke),we=R3e(m,{transform:{x:N.x-J.x,y:N.y-J.y,scaleX:1,scaleY:1},activatorEvent:W,active:q,activeNodeRect:ve,containerNodeRect:je,draggingNodeRect:re,over:de.current.over,overlayNodeRect:H.rect,scrollableAncestors:ke,scrollableAncestorRects:Ne,windowRect:le}),B=xe?Qp(xe,N):null,j=v3e(ke),te=g8(j),be=g8(j,[ve]),_e=Qp(we,te),ge=re?BNe(re,we):null,me=q&&ge?f({active:q,collisionRect:ge,droppableRects:ee,droppableContainers:U,pointerCoordinates:B}):null,Ae=nX(me,"id"),[ze,st]=M.useState(null),Ve=G?we:Qp(we,be),ce=FNe(Ve,(s=ze?.rect)!=null?s:null,ve),Ye=M.useRef(null),$e=M.useCallback((Ue,Ce)=>{let{sensor:ye,options:He}=Ce;if(R.current==null)return;const ht=I.get(R.current);if(!ht)return;const wt=Ue.nativeEvent,Ot=new ye({active:R.current,activeNode:ht,event:wt,options:He,context:de,onAbort(It){if(!I.get(It))return;const{onDragAbort:Kn}=Y.current,_i={id:It};Kn?.(_i),E({type:"onDragAbort",event:_i})},onPending(It,Rn,Kn,_i){if(!I.get(It))return;const{onDragPending:wi}=Y.current,Ii={id:It,constraint:Rn,initialCoordinates:Kn,offset:_i};wi?.(Ii),E({type:"onDragPending",event:Ii})},onStart(It){const Rn=R.current;if(Rn==null)return;const Kn=I.get(Rn);if(!Kn)return;const{onDragStart:_i}=Y.current,si={activatorEvent:wt,active:{id:Rn,data:Kn.data,rect:L}};ic.unstable_batchedUpdates(()=>{_i?.(si),T(Tu.Initializing),b({type:ui.DragStart,initialCoordinates:It,active:Rn}),E({type:"onDragStart",event:si}),K(Ye.current),ne(wt)})},onMove(It){b({type:ui.DragMove,coordinates:It})},onEnd:cn(ui.DragEnd),onCancel:cn(ui.DragCancel)});Ye.current=Ot;function cn(It){return async function(){const{active:Kn,collisions:_i,over:si,scrollAdjustedTranslate:wi}=de.current;let Ii=null;if(Kn&&wi){const{cancelDrop:Ji}=Y.current;Ii={activatorEvent:wt,active:Kn,collisions:_i,delta:wi,over:si},It===ui.DragEnd&&typeof Ji=="function"&&await Promise.resolve(Ji(Ii))&&(It=ui.DragCancel)}R.current=null,ic.unstable_batchedUpdates(()=>{b({type:It}),T(Tu.Uninitialized),st(null),K(null),ne(null),Ye.current=null;const Ji=It===ui.DragEnd?"onDragEnd":"onDragCancel";if(Ii){const Ur=Y.current[Ji];Ur?.(Ii),E({type:Ji,event:Ii})}})}}},[I]),Ze=M.useCallback((Ue,Ce)=>(ye,He)=>{const ht=ye.nativeEvent,wt=I.get(He);if(R.current!==null||!wt||ht.dndKit||ht.defaultPrevented)return;const Ot={active:wt};Ue(ye,Ce.options,Ot)===!0&&(ht.dndKit={capturedBy:Ce.sensor},R.current=He,$e(ye,Ce))},[I,$e]),at=h3e(d,Ze);y3e(d),hl(()=>{ve&&A===Tu.Initializing&&T(Tu.Initialized)},[ve,A]),M.useEffect(()=>{const{onDragMove:Ue}=Y.current,{active:Ce,activatorEvent:ye,collisions:He,over:ht}=de.current;if(!Ce||!ye)return;const wt={active:Ce,activatorEvent:ye,collisions:He,delta:{x:_e.x,y:_e.y},over:ht};ic.unstable_batchedUpdates(()=>{Ue?.(wt),E({type:"onDragMove",event:wt})})},[_e.x,_e.y]),M.useEffect(()=>{const{active:Ue,activatorEvent:Ce,collisions:ye,droppableContainers:He,scrollAdjustedTranslate:ht}=de.current;if(!Ue||R.current==null||!Ce||!ht)return;const{onDragOver:wt}=Y.current,Ot=He.get(Ae),cn=Ot&&Ot.rect.current?{id:Ot.id,rect:Ot.rect.current,data:Ot.data,disabled:Ot.disabled}:null,It={active:Ue,activatorEvent:Ce,collisions:ye,delta:{x:ht.x,y:ht.y},over:cn};ic.unstable_batchedUpdates(()=>{st(cn),wt?.(It),E({type:"onDragOver",event:It})})},[Ae]),hl(()=>{de.current={activatorEvent:W,active:q,activeNode:ue,collisionRect:ge,collisions:me,droppableRects:ee,draggableNodes:I,draggingNode:z,draggingNodeRect:re,droppableContainers:D,over:ze,scrollableAncestors:ke,scrollAdjustedTranslate:_e},L.current={initial:re,translated:ge}},[q,ue,me,ge,I,z,re,ee,D,ze,ke,_e]),l3e({...Me,delta:N,draggingRect:ge,pointerCoordinates:B,scrollableAncestors:ke,scrollableAncestorRects:Ne});const Q=M.useMemo(()=>({active:q,activeNode:ue,activeNodeRect:ve,activatorEvent:W,collisions:me,containerNodeRect:je,dragOverlay:H,draggableNodes:I,droppableContainers:D,droppableRects:ee,over:ze,measureDroppableContainers:ae,scrollableAncestors:ke,scrollableAncestorRects:Ne,measuringConfiguration:$,measuringScheduled:fe,windowRect:le}),[q,ue,ve,W,me,je,H,I,D,ee,ze,ae,ke,Ne,$,fe,le]),Fe=M.useMemo(()=>({activatorEvent:W,activators:at,active:q,activeNodeRect:ve,ariaDescribedById:{draggable:Z},dispatch:b,draggableNodes:I,over:ze,measureDroppableContainers:ae}),[W,at,q,ve,b,Z,I,ze,ae]);return pr.createElement(QK.Provider,{value:S},pr.createElement(QS.Provider,{value:Fe},pr.createElement(pX.Provider,{value:Q},pr.createElement(mX.Provider,{value:ce},u)),pr.createElement(P3e,{disabled:o?.restoreFocus===!1})),pr.createElement(ONe,{...o,hiddenTextDescribedById:Z}));function pe(){const Ue=V?.autoScrollEnabled===!1,Ce=typeof l=="object"?l.enabled===!1:l===!1,ye=P&&!Ue&&!Ce;return typeof l=="object"?{...l,enabled:ye}:{enabled:ye}}}),j3e=M.createContext(null),b8="button",L3e="Draggable";function I3e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=pb(L3e),{activators:a,activatorEvent:o,active:l,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=M.useContext(QS),{role:m=b8,roleDescription:x="draggable",tabIndex:y=0}=i??{},v=l?.id===e,b=M.useContext(v?mX:j3e),[E,S]=dw(),[A,T]=dw(),P=_3e(a,e),C=j0(n);hl(()=>(f.set(e,{id:e,key:s,node:E,activatorNode:A,data:C}),()=>{const N=f.get(e);N&&N.key===s&&f.delete(e)}),[f,e]);const I=M.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&m===b8?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,m,y,v,x,d.draggable]);return{active:l,activatorEvent:o,activeNodeRect:u,attributes:I,isDragging:v,listeners:r?void 0:P,node:E,over:g,setNodeRef:S,setActivatorNodeRef:T,transform:b}}function U3e(){return M.useContext(pX)}const F3e="Droppable",z3e={timeout:25};function B3e(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=pb(F3e),{active:a,dispatch:o,over:l,measureDroppableContainers:u}=M.useContext(QS),d=M.useRef({disabled:n}),f=M.useRef(!1),g=M.useRef(null),m=M.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:v}={...z3e,...i},b=j0(y??r),E=M.useCallback(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(b.current)?b.current:[b.current]),m.current=null},v)},[v]),S=ZS({callback:E,disabled:x||!a}),A=M.useCallback((I,N)=>{S&&(N&&(S.unobserve(N),f.current=!1),I&&S.observe(I))},[S]),[T,P]=dw(A),C=j0(e);return M.useEffect(()=>{!S||!T.current||(S.disconnect(),f.current=!1,S.observe(T.current))},[T,S]),M.useEffect(()=>(o({type:ui.RegisterDroppable,element:{id:r,key:s,disabled:n,node:T,rect:g,data:C}}),()=>o({type:ui.UnregisterDroppable,key:s,id:r})),[r]),M.useEffect(()=>{n!==d.current.disabled&&(o({type:ui.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,o]),{active:a,rect:g,isOver:l?.id===r,node:T,over:l,setNodeRef:P}}function JS(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function H3e(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function d_(t){return t!==null&&t>=0}function $3e(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 V3e(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const VD=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=JS(e,r,n),a=e[i],o=s[i];return!o||!a?null:{x:o.left-a.left,y:o.top-a.top,scaleX:o.width/a.width,scaleY:o.height/a.height}},h_={scaleX:1,scaleY:1},G3e=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:a}=t;const o=(e=s[n])!=null?e:r;if(!o)return null;if(i===n){const u=s[a];return u?{x:0,y:n<a?u.top+u.height-(o.top+o.height):u.top-o.top,...h_}:null}const l=W3e(s,i,n);return i>n&&i<=a?{x:0,y:-o.height-l,...h_}:i<n&&i>=a?{x:0,y:o.height+l,...h_}:{x:0,y:0,...h_}};function W3e(t,e,n){const r=t[e],i=t[e-1],s=t[e+1];return r?n<e?i?r.top-(i.top+i.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const xX="Sortable",bX=pr.createContext({activeIndex:-1,containerId:xX,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:VD,disabled:{draggable:!1,droppable:!1}});function vX(t){let{children:e,id:n,items:r,strategy:i=VD,disabled:s=!1}=t;const{active:a,dragOverlay:o,droppableRects:l,over:u,measureDroppableContainers:d}=U3e(),f=pb(xX,n),g=o.rect!==null,m=M.useMemo(()=>r.map(P=>typeof P=="object"&&"id"in P?P.id:P),[r]),x=a!=null,y=a?m.indexOf(a.id):-1,v=u?m.indexOf(u.id):-1,b=M.useRef(m),E=!$3e(m,b.current),S=v!==-1&&y===-1||E,A=V3e(s);hl(()=>{E&&x&&d(m)},[E,m,x,d]),M.useEffect(()=>{b.current=m},[m]);const T=M.useMemo(()=>({activeIndex:y,containerId:f,disabled:A,disableTransforms:S,items:m,overIndex:v,useDragOverlay:g,sortedRects:H3e(m,l),strategy:i}),[y,f,A.draggable,A.droppable,S,m,v,l,g,i]);return pr.createElement(bX.Provider,{value:T},e)}const q3e=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return JS(n,r,i).indexOf(e)},K3e=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:a,previousItems:o,previousContainerId:l,transition:u}=t;return!u||!r||o!==s&&i===a?!1:n?!0:a!==i&&e===l},X3e={duration:200,easing:"ease"},yX="transform",Y3e=Sm.Transition.toString({property:yX,duration:0,easing:"linear"}),Z3e={roleDescription:"sortable"};function Q3e(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,a]=M.useState(null),o=M.useRef(n);return hl(()=>{if(!e&&n!==o.current&&r.current){const l=i.current;if(l){const u=Wm(r.current,{ignoreTransform:!0}),d={x:l.left-u.left,y:l.top-u.top,scaleX:l.width/u.width,scaleY:l.height/u.height};(d.x||d.y)&&a(d)}}n!==o.current&&(o.current=n)},[e,n,r,i]),M.useEffect(()=>{s&&a(null)},[s]),s}function _X(t){let{animateLayoutChanges:e=K3e,attributes:n,disabled:r,data:i,getNewIndex:s=q3e,id:a,strategy:o,resizeObserverConfig:l,transition:u=X3e}=t;const{items:d,containerId:f,activeIndex:g,disabled:m,disableTransforms:x,sortedRects:y,overIndex:v,useDragOverlay:b,strategy:E}=M.useContext(bX),S=J3e(r,m),A=d.indexOf(a),T=M.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),P=M.useMemo(()=>d.slice(d.indexOf(a)),[d,a]),{rect:C,node:I,isOver:N,setNodeRef:D}=B3e({id:a,data:T,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:P,...l}}),{active:F,activatorEvent:L,activeNodeRect:q,attributes:R,setNodeRef:V,listeners:K,isDragging:W,over:ne,setActivatorNodeRef:Y,transform:Z}=I3e({id:a,data:T,attributes:{...Z3e,...n},disabled:S.draggable}),U=_Ne(D,V),$=!!F,ee=$&&!x&&d_(g)&&d_(v),ae=!b&&W,fe=ae&&ee?Z:null,xe=ee?fe??(o??E)({rects:y,activeNodeRect:q,activeIndex:g,overIndex:v,index:A}):null,Me=d_(g)&&d_(v)?s({id:a,items:d,activeIndex:g,overIndex:v}):A,se=F?.id,ve=M.useRef({activeId:se,items:d,newIndex:Me,containerId:f}),je=d!==ve.current.items,de=e({active:F,containerId:f,isDragging:W,isSorting:$,id:a,index:A,items:d,newIndex:ve.current.newIndex,previousItems:ve.current.items,previousContainerId:ve.current.containerId,transition:u,wasDragging:ve.current.activeId!=null}),ut=Q3e({disabled:!de,index:A,node:I,rect:C});return M.useEffect(()=>{$&&ve.current.newIndex!==Me&&(ve.current.newIndex=Me),f!==ve.current.containerId&&(ve.current.containerId=f),d!==ve.current.items&&(ve.current.items=d)},[$,Me,f,d]),M.useEffect(()=>{if(se===ve.current.activeId)return;if(se!=null&&ve.current.activeId==null){ve.current.activeId=se;return}const z=setTimeout(()=>{ve.current.activeId=se},50);return()=>clearTimeout(z)},[se]),{active:F,activeIndex:g,attributes:R,data:T,rect:C,index:A,newIndex:Me,items:d,isOver:N,isSorting:$,isDragging:W,listeners:K,node:I,overIndex:v,over:ne,setNodeRef:U,setActivatorNodeRef:Y,setDroppableNodeRef:D,setDraggableNodeRef:V,transform:ut??xe,transition:H()};function H(){if(ut||je&&ve.current.newIndex===A)return Y3e;if(!(ae&&!BD(L)||!u)&&($||de))return Sm.Transition.toString({...u,property:yX})}}function J3e(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 mw(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 eke=[_n.Down,_n.Right,_n.Up,_n.Left],wX=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:a,scrollableAncestors:o}}=e;if(eke.includes(t.code)){if(t.preventDefault(),!n||!r)return;const l=[];s.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=i.get(f.id);if(g)switch(t.code){case _n.Down:r.top<g.top&&l.push(f);break;case _n.Up:r.top>g.top&&l.push(f);break;case _n.Left:r.left>g.left&&l.push(f);break;case _n.Right:r.left<g.left&&l.push(f);break}});const u=LNe({collisionRect:r,droppableRects:i,droppableContainers:l});let d=nX(u,"id");if(d===a?.id&&u.length>1&&(d=u[1].id),d!=null){const f=s.get(n.id),g=s.get(d),m=g?i.get(g.id):null,x=g?.node.current;if(x&&m&&f&&g){const v=KS(x).some((P,C)=>o[C]!==P),b=SX(f,g),E=tke(f,g),S=v||!b?{x:0,y:0}:{x:E?r.width-m.width:0,y:E?r.height-m.height:0},A={x:m.left,y:m.top};return S.x&&S.y?A:L0(A,S)}}}};function SX(t,e){return!mw(t)||!mw(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function tke(t,e){return!mw(t)||!mw(e)||!SX(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function nke({item:t,onClose:e}){const n=Sn(),{showToast:r}=ri(),[i,s]=M.useState(t.printer_id),a=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[o,l]=M.useState(t.scheduled_time&&!a?"scheduled":"asap"),[u,d]=M.useState(()=>t.scheduled_time&&!a?new Date(t.scheduled_time).toISOString().slice(0,16):""),[f,g]=M.useState(t.require_previous_success),[m,x]=M.useState(t.auto_off_after),{data:y}=yt({queryKey:["printers"],queryFn:()=>Pe.getPrinters()});M.useEffect(()=>{const S=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e]);const v=_t({mutationFn:S=>Pe.updateQueueItem(t.id,S),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:S=>{r(S.message||"Failed to update queue item","error")}}),b=S=>{S.preventDefault();const A={printer_id:i,require_previous_success:f,auto_off_after:m};o==="scheduled"&&u?A.scheduled_time=new Date(u).toISOString():A.scheduled_time=null,v.mutate(A)},E=()=>{const S=new Date;return S.setMinutes(S.getMinutes()+1),S.toISOString().slice(0,16)};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:c.jsx(Nt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Zu,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),c.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?c.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[c.jsx(Oo,{className:"w-4 h-4"}),"No printers configured"]}):c.jsx("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:S=>s(Number(S.target.value)),required:!0,children:y?.map(S=>c.jsx("option",{value:S.id,children:S.name},S.id))})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("asap"),children:[c.jsx(ti,{className:"w-4 h-4"}),"ASAP (when idle)"]}),c.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("scheduled"),children:[c.jsx(qr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),c.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:S=>d(S.target.value),min:E(),required:!0})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:S=>g(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),c.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:S=>x(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),c.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[c.jsx(fd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{type:"submit",className:"flex-1",disabled:v.isPending||y?.length===0,children:v.isPending?"Saving...":"Save Changes"})]})]})]})})})}function EX(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 rke(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 ike({status:t}){const e={pending:{icon:ti,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:ds,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:hd,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:c1,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Gt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return c.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[c.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function lC({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:a}){const{attributes:o,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:g}=_X({id:t.id,disabled:t.status!=="pending"}),m={transform:Sm.Transform.toString(d),transition:f},x=t.status==="printing",y=t.status==="pending",v=["completed","failed","skipped","cancelled"].includes(t.status);return c.jsx("div",{ref:u,style:m,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${g?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${x?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:c.jsxs("div",{className:"flex items-center gap-4 p-4",children:[y?c.jsx("div",{...o,...l,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:c.jsx(c0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?c.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):c.jsx("div",{className:"w-8"}),c.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?c.jsx("img",{src:Pe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:c.jsx(Oh,{className:"w-6 h-6"})})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),c.jsx(fS,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:c.jsx(ro,{className:"w-3.5 h-3.5"})})]}),c.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(jo,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Ou,{className:"w-3.5 h-3.5"}),EX(t.print_time_seconds)]}),y&&c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(ti,{className:"w-3.5 h-3.5"}),rke(t.scheduled_time)]})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&c.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:"Requires previous success"}),t.auto_off_after&&c.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[c.jsx(fd,{className:"w-3 h-3"}),"Auto power off"]})]}),x&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&c.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[c.jsx(Oo,{className:"w-3 h-3"}),t.error_message]})]}),c.jsx(ike,{status:t.status}),c.jsxs("div",{className:"flex items-center gap-1",children:[x&&c.jsx(Ie,{variant:"ghost",size:"sm",onClick:s,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:c.jsx($ae,{className:"w-4 h-4"})}),y&&c.jsxs(c.Fragment,{children:[c.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:c.jsx(Zu,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:c.jsx(Gt,{className:"w-4 h-4"})})]}),v&&c.jsxs(c.Fragment,{children:[c.jsx(Ie,{variant:"ghost",size:"sm",onClick:a,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:c.jsx(qs,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:c.jsx(kn,{className:"w-4 h-4"})})]})]})]})})}function ske(){const t=Sn(),{showToast:e}=ri(),[n,r]=M.useState(null),[i,s]=M.useState(""),[a,o]=M.useState(!1),[l,u]=M.useState(null),[d,f]=M.useState(null),[g,m]=M.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[x,y]=M.useState(()=>{const Y=localStorage.getItem("queue.historySortAsc");return Y!==null?Y==="true":!1}),[v,b]=M.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[E,S]=M.useState(()=>{const Y=localStorage.getItem("queue.pendingSortAsc");return Y!==null?Y==="true":!0});M.useEffect(()=>{localStorage.setItem("queue.historySortBy",g)},[g]),M.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(x))},[x]),M.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",v)},[v]),M.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(E))},[E]);const A=JK(fw(YS,{activationConstraint:{distance:8}}),fw(XS,{coordinateGetter:wX})),{data:T,isLoading:P}=yt({queryKey:["queue",n,i],queryFn:()=>Pe.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:C}=yt({queryKey:["printers"],queryFn:()=>Pe.getPrinters()}),I=_t({mutationFn:Y=>Pe.cancelQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),N=_t({mutationFn:Y=>Pe.removeFromQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),D=_t({mutationFn:Y=>Pe.stopQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),F=_t({mutationFn:Y=>Pe.reorderQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),L=_t({mutationFn:Y=>{const Z=new Date;return Z.setFullYear(Z.getFullYear()+1),Pe.addToQueue({printer_id:Y.printer_id,archive_id:Y.archive_id,scheduled_time:Z.toISOString(),require_previous_success:!1,auto_off_after:!1})},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e("Added back to queue - please set schedule"),u(Y)},onError:Y=>e(Y.message||"Failed to re-queue item","error")}),q=_t({mutationFn:async()=>{const Y=T?.filter(Z=>["completed","failed","skipped","cancelled"].includes(Z.status))||[];for(const Z of Y)await Pe.removeFromQueue(Z.id);return Y.length},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Y} history item${Y!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),R=M.useMemo(()=>{const Y=T?.filter(U=>U.status==="pending")||[],Z=U=>{if(!U.scheduled_time)return 0;const $=new Date(U.scheduled_time).getTime(),ee=Date.now()+4320*60*60*1e3;return $>ee?0:$};return[...Y].sort((U,$)=>{let ee;return v==="name"?ee=(U.archive_name||"").localeCompare($.archive_name||""):v==="printer"?ee=(U.printer_name||"").localeCompare($.printer_name||""):v==="time"?ee=Z(U)-Z($):ee=U.position-$.position,E?ee:-ee})},[T,v,E]),V=T?.filter(Y=>Y.status==="printing")||[],K=M.useMemo(()=>[...T?.filter(Z=>["completed","failed","skipped","cancelled"].includes(Z.status))||[]].sort((Z,U)=>{let $;return g==="name"?$=(Z.archive_name||"").localeCompare(U.archive_name||""):g==="printer"?$=(Z.printer_name||"").localeCompare(U.printer_name||""):$=new Date(U.completed_at||U.created_at).getTime()-new Date(Z.completed_at||Z.created_at).getTime(),x?-$:$}),[T,g,x]),W=M.useMemo(()=>R.reduce((Y,Z)=>Y+(Z.print_time_seconds||0),0),[R]),ne=Y=>{const{active:Z,over:U}=Y;if(!U||Z.id===U.id)return;const $=R.findIndex(ae=>ae.id===Z.id),ee=R.findIndex(ae=>ae.id===U.id);if($!==-1&&ee!==-1){const fe=JS(R,$,ee).map((ue,xe)=>({id:ue.id,position:xe+1}));F.mutate(fe)}};return c.jsxs("div",{className:"p-4 md:p-8",children:[c.jsx("div",{className:"flex items-center justify-between mb-8",children:c.jsxs("div",{children:[c.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[c.jsx(jG,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),c.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[c.jsx(Nt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:c.jsx(Dt,{className:"p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:c.jsx(bS,{className:"w-5 h-5 text-blue-400"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-2xl font-bold text-white",children:V.length}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),c.jsx(Nt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:c.jsx(Dt,{className:"p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:c.jsx(ti,{className:"w-5 h-5 text-yellow-400"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-2xl font-bold text-white",children:R.length}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),c.jsx(Nt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:c.jsx(Dt,{className:"p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:c.jsx(Ou,{className:"w-5 h-5 text-bambu-green"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-2xl font-bold text-white",children:EX(W)}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),c.jsx(Nt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:c.jsx(Dt,{className:"p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:c.jsx(ds,{className:"w-5 h-5 text-gray-400"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-2xl font-bold text-white",children:K.length}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),c.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[c.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:Y=>r(Y.target.value?Number(Y.target.value):null),children:[c.jsx("option",{value:"",children:"All Printers"}),C?.map(Y=>c.jsx("option",{value:Y.id,children:Y.name},Y.id))]}),c.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:Y=>s(Y.target.value),children:[c.jsx("option",{value:"",children:"All Status"}),c.jsx("option",{value:"pending",children:"Pending"}),c.jsx("option",{value:"printing",children:"Printing"}),c.jsx("option",{value:"completed",children:"Completed"}),c.jsx("option",{value:"failed",children:"Failed"}),c.jsx("option",{value:"skipped",children:"Skipped"}),c.jsx("option",{value:"cancelled",children:"Cancelled"})]}),c.jsx("div",{className:"flex-1"}),K.length>0&&c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[c.jsx(kn,{className:"w-4 h-4"}),"Clear History"]})]}),P?c.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?c.jsxs(Nt,{className:"p-12 text-center border-dashed",children:[c.jsx(qr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),c.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),c.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'})]}):c.jsxs("div",{className:"space-y-8",children:[V.length>0&&c.jsxs("div",{children:[c.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),c.jsx("div",{className:"space-y-3",children:V.map(Y=>c.jsx(lC,{item:Y,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>f({type:"stop",item:Y}),onRequeue:()=>{}},Y.id))})]}),R.length>0&&c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(ti,{className:"w-5 h-5 text-yellow-400"}),"Queued",c.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",R.length," item",R.length!==1?"s":"",")"]}),c.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:"Position only affects ASAP items. Scheduled items run at their set time.",children:"Drag to reorder (ASAP only)"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:v,onChange:Y=>b(Y.target.value),children:[c.jsx("option",{value:"position",children:"Sort by Position"}),c.jsx("option",{value:"name",children:"Sort by Name"}),c.jsx("option",{value:"printer",children:"Sort by Printer"}),c.jsx("option",{value:"time",children:"Sort by Schedule"})]}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>S(!E),title:E?"Ascending":"Descending",className:"px-2",children:E?c.jsx(nm,{className:"w-4 h-4"}):c.jsx(s0,{className:"w-4 h-4"})})]})]}),c.jsx(gX,{sensors:A,collisionDetection:rX,onDragEnd:ne,children:c.jsx(vX,{items:R.map(Y=>Y.id),strategy:G3e,children:c.jsx("div",{className:"space-y-3",children:R.map((Y,Z)=>c.jsx(lC,{item:Y,position:Z+1,onEdit:()=>u(Y),onCancel:()=>f({type:"cancel",item:Y}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Y.id))})})})]}),K.length>0&&c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(ds,{className:"w-5 h-5 text-bambu-gray"}),"History",c.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",K.length," item",K.length!==1?"s":"",")"]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:g,onChange:Y=>m(Y.target.value),children:[c.jsx("option",{value:"date",children:"Sort by Date"}),c.jsx("option",{value:"name",children:"Sort by Name"}),c.jsx("option",{value:"printer",children:"Sort by Printer"})]}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>y(!x),title:x?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:x?c.jsx(nm,{className:"w-4 h-4"}):c.jsx(s0,{className:"w-4 h-4"})})]})]}),c.jsx("div",{className:"space-y-3",children:K.slice(0,20).map((Y,Z)=>c.jsx(lC,{item:Y,position:Z+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>f({type:"remove",item:Y}),onStop:()=>{},onRequeue:()=>L.mutate(Y)},Y.id))})]})]}),l&&c.jsx(nke,{item:l,onClose:()=>u(null)}),d&&c.jsx(Kr,{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):N.mutate(d.item.id),f(null)},onCancel:()=>f(null)}),a&&c.jsx(Kr,{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 ake({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=M.useMemo(()=>{const l={};t.forEach(b=>{const E=b.split("T")[0];l[E]=(l[E]||0)+1});const u=new Date,d=new Date(u);d.setMonth(d.getMonth()-e),d.setDate(d.getDate()-d.getDay());const f=[],g=[];let m=[],x=-1;const y=new Date(d);let v=0;for(;y<=u;)y.getDay()===0&&m.length>0&&(f.push(m),m=[],v++),y.getMonth()!==x&&(g.push({month:y.toLocaleDateString("en-US",{month:"short"}),weekIndex:v}),x=y.getMonth()),m.push(new Date(y)),y.setDate(y.getDate()+1);return m.length>0&&f.push(m),{weeks:f,monthLabels:g,printCounts:l}},[t,e]),s=Math.max(1,...Object.values(i)),a=l=>{if(l===0)return"bg-bambu-dark";const u=l/s;return u<=.25?"bg-bambu-green/30":u<=.5?"bg-bambu-green/50":u<=.75?"bg-bambu-green/75":"bg-bambu-green"},o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return c.jsxs("div",{className:"overflow-x-auto",children:[c.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:l,weekIndex:u},d)=>c.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:d===0?0:`${(u-(r[d-1]?.weekIndex||0))*14-24}px`},children:l},d))}),c.jsxs("div",{className:"flex gap-0.5",children:[c.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((l,u)=>c.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:u%2===1?"visible":"hidden"},children:l},l))}),n.map((l,u)=>c.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(d=>{const f=l.find(y=>y.getDay()===d);if(!f)return c.jsx("div",{className:"w-3 h-3"},d);const g=f.toISOString().split("T")[0],m=i[g]||0,x=g===new Date().toISOString().split("T")[0];return c.jsx("div",{className:`w-3 h-3 rounded-sm ${a(m)} ${x?"ring-1 ring-white":""}`,title:`${f.toLocaleDateString()}: ${m} print${m!==1?"s":""}`},d)})},u))]}),c.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[c.jsx("span",{children:"Less"}),c.jsxs("div",{className:"flex gap-0.5",children:[c.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),c.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),c.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),c.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),c.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),c.jsx("span",{children:"More"})]})]})}function MX(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=MX(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Tn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=MX(t))&&(r&&(r+=" "),r+=e);return r}var oke=["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 GD(t){if(typeof t!="string")return!1;var e=oke;return e.includes(t)}var lke=["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"],cke=new Set(lke);function AX(t){return typeof t!="string"?!1:cke.has(t)}function TX(t){return typeof t=="string"&&t.startsWith("data-")}function Ks(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(AX(n)||TX(n))&&(e[n]=t[n]);return e}function qh(t){if(t==null)return null;if(M.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ks(e)}return typeof t=="object"&&!Array.isArray(t)?Ks(t):null}function Cs(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(AX(n)||TX(n)||GD(n))&&(e[n]=t[n]);return e}function uke(t){return t==null?null:M.isValidElement(t)?Cs(t.props):typeof t=="object"&&!Array.isArray(t)?Cs(t):null}var dke=["children","width","height","viewBox","className","style","title","desc"];function Qk(){return Qk=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},Qk.apply(null,arguments)}function hke(t,e){if(t==null)return{};var n,r,i=fke(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function fke(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 WD=M.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:a,style:o,title:l,desc:u}=t,d=hke(t,dke),f=s||{width:r,height:i,x:0,y:0},g=Tn("recharts-surface",a);return M.createElement("svg",Qk({},Cs(d),{className:g,width:r,height:i,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),M.createElement("title",null,l),M.createElement("desc",null,u),n)}),pke=["children","className"];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 mke(t,e){if(t==null)return{};var n,r,i=gke(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function gke(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Ir=M.forwardRef((t,e)=>{var{children:n,className:r}=t,i=mke(t,pke),s=Tn("recharts-layer",r);return M.createElement("g",Jk({className:s},Cs(i),{ref:e}),n)}),CX=M.createContext(null),xke=()=>M.useContext(CX);function tr(t){return function(){return t}}const NX=Math.cos,gw=Math.sin,zo=Math.sqrt,xw=Math.PI,eE=2*xw,eP=Math.PI,tP=2*eP,Xd=1e-6,bke=tP-Xd;function kX(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function vke(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return kX;const n=10**e;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class yke{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?kX:vke(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,s,a){this._append`C${+e},${+n},${+r},${+i},${this._x1=+s},${this._y1=+a}`}arcTo(e,n,r,i,s){if(e=+e,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let a=this._x1,o=this._y1,l=r-e,u=i-n,d=a-e,f=o-n,g=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>Xd)if(!(Math.abs(f*l-u*d)>Xd)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-a,x=i-o,y=l*l+u*u,v=m*m+x*x,b=Math.sqrt(y),E=Math.sqrt(g),S=s*Math.tan((eP-Math.acos((y+g-v)/(2*b*E)))/2),A=S/E,T=S/b;Math.abs(A-1)>Xd&&this._append`L${e+A*d},${n+A*f}`,this._append`A${s},${s},0,0,${+(f*m>d*x)},${this._x1=e+T*l},${this._y1=n+T*u}`}}arc(e,n,r,i,s,a){if(e=+e,n=+n,r=+r,a=!!a,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),l=r*Math.sin(i),u=e+o,d=n+l,f=1^a,g=a?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Xd||Math.abs(this._y1-d)>Xd)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%tP+tP),g>bke?this._append`A${r},${r},0,1,${f},${e-o},${n-l}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:g>Xd&&this._append`A${r},${r},0,${+(g>=eP)},${f},${this._x1=e+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function qD(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 yke(e)}function KD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function PX(t){this._context=t}PX.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 tE(t){return new PX(t)}function RX(t){return t[0]}function DX(t){return t[1]}function OX(t,e){var n=tr(!0),r=null,i=tE,s=null,a=qD(o);t=typeof t=="function"?t:t===void 0?RX:tr(t),e=typeof e=="function"?e:e===void 0?DX:tr(e);function o(l){var u,d=(l=KD(l)).length,f,g=!1,m;for(r==null&&(s=i(m=a())),u=0;u<=d;++u)!(u<d&&n(f=l[u],u,l))===g&&((g=!g)?s.lineStart():s.lineEnd()),g&&s.point(+t(f,u,l),+e(f,u,l));if(m)return s=null,m+""||null}return o.x=function(l){return arguments.length?(t=typeof l=="function"?l:tr(+l),o):t},o.y=function(l){return arguments.length?(e=typeof l=="function"?l:tr(+l),o):e},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:tr(!!l),o):n},o.curve=function(l){return arguments.length?(i=l,r!=null&&(s=i(r)),o):i},o.context=function(l){return arguments.length?(l==null?r=s=null:s=i(r=l),o):r},o}function f_(t,e,n){var r=null,i=tr(!0),s=null,a=tE,o=null,l=qD(u);t=typeof t=="function"?t:t===void 0?RX:tr(+t),e=typeof e=="function"?e:tr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?DX:tr(+n);function u(f){var g,m,x,y=(f=KD(f)).length,v,b=!1,E,S=new Array(y),A=new Array(y);for(s==null&&(o=a(E=l())),g=0;g<=y;++g){if(!(g<y&&i(v=f[g],g,f))===b)if(b=!b)m=g,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),x=g-1;x>=m;--x)o.point(S[x],A[x]);o.lineEnd(),o.areaEnd()}b&&(S[g]=+t(v,g,f),A[g]=+e(v,g,f),o.point(r?+r(v,g,f):S[g],n?+n(v,g,f):A[g]))}if(E)return o=null,E+""||null}function d(){return OX().defined(i).curve(a).context(s)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:tr(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:tr(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:tr(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:tr(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:tr(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:tr(+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:tr(!!f),u):i},u.curve=function(f){return arguments.length?(a=f,s!=null&&(o=a(s)),u):a},u.context=function(f){return arguments.length?(f==null?s=o=null:o=a(s=f),u):s},u}class jX{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 _ke(t){return new jX(t,!0)}function wke(t){return new jX(t,!1)}const XD={draw(t,e){const n=zo(e/xw);t.moveTo(n,0),t.arc(0,0,n,0,eE)}},Ske={draw(t,e){const n=zo(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},LX=zo(1/3),Eke=LX*2,Mke={draw(t,e){const n=zo(e/Eke),r=n*LX;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Ake={draw(t,e){const n=zo(e),r=-n/2;t.rect(r,r,n,n)}},Tke=.8908130915292852,IX=gw(xw/10)/gw(7*xw/10),Cke=gw(eE/10)*IX,Nke=-NX(eE/10)*IX,kke={draw(t,e){const n=zo(e*Tke),r=Cke*n,i=Nke*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const a=eE*s/5,o=NX(a),l=gw(a);t.lineTo(l*n,-o*n),t.lineTo(o*r-l*i,l*r+o*i)}t.closePath()}},cC=zo(3),Pke={draw(t,e){const n=-zo(e/(cC*3));t.moveTo(0,n*2),t.lineTo(-cC*n,-n),t.lineTo(cC*n,-n),t.closePath()}},Oa=-.5,ja=zo(3)/2,nP=1/zo(12),Rke=(nP/2+1)*3,Dke={draw(t,e){const n=zo(e/Rke),r=n/2,i=n*nP,s=r,a=n*nP+n,o=-s,l=a;t.moveTo(r,i),t.lineTo(s,a),t.lineTo(o,l),t.lineTo(Oa*r-ja*i,ja*r+Oa*i),t.lineTo(Oa*s-ja*a,ja*s+Oa*a),t.lineTo(Oa*o-ja*l,ja*o+Oa*l),t.lineTo(Oa*r+ja*i,Oa*i-ja*r),t.lineTo(Oa*s+ja*a,Oa*a-ja*s),t.lineTo(Oa*o+ja*l,Oa*l-ja*o),t.closePath()}};function Oke(t,e){let n=null,r=qD(i);t=typeof t=="function"?t:tr(t||XD),e=typeof e=="function"?e:tr(e===void 0?64:+e);function i(){let s;if(n||(n=s=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),s)return n=null,s+""||null}return i.type=function(s){return arguments.length?(t=typeof s=="function"?s:tr(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:tr(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function bw(){}function vw(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 UX(t){this._context=t}UX.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:vw(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:vw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function jke(t){return new UX(t)}function FX(t){this._context=t}FX.prototype={areaStart:bw,areaEnd:bw,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:vw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Lke(t){return new FX(t)}function zX(t){this._context=t}zX.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:vw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Ike(t){return new zX(t)}function BX(t){this._context=t}BX.prototype={areaStart:bw,areaEnd:bw,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 Uke(t){return new BX(t)}function v8(t){return t<0?-1:1}function y8(t,e,n){var r=t._x1-t._x0,i=e-t._x1,s=(t._y1-t._y0)/(r||i<0&&-0),a=(n-t._y1)/(i||r<0&&-0),o=(s*i+a*r)/(r+i);return(v8(s)+v8(a))*Math.min(Math.abs(s),Math.abs(a),.5*Math.abs(o))||0}function _8(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function uC(t,e,n){var r=t._x0,i=t._y0,s=t._x1,a=t._y1,o=(s-r)/3;t._context.bezierCurveTo(r+o,i+o*e,s-o,a-o*n,s,a)}function yw(t){this._context=t}yw.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:uC(this,this._t0,_8(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,uC(this,_8(this,n=y8(this,t,e)),n);break;default:uC(this,this._t0,n=y8(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function HX(t){this._context=new $X(t)}(HX.prototype=Object.create(yw.prototype)).point=function(t,e){yw.prototype.point.call(this,e,t)};function $X(t){this._context=t}$X.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,s){this._context.bezierCurveTo(e,t,r,n,s,i)}};function Fke(t){return new yw(t)}function zke(t){return new HX(t)}function VX(t){this._context=t}VX.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=w8(t),i=w8(e),s=0,a=1;a<n;++s,++a)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],t[a],e[a]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function w8(t){var e,n=t.length-1,r,i=new Array(n),s=new Array(n),a=new Array(n);for(i[0]=0,s[0]=2,a[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,s[e]=4,a[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,s[n-1]=7,a[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/s[e-1],s[e]-=r,a[e]-=r*a[e-1];for(i[n-1]=a[n-1]/s[n-1],e=n-2;e>=0;--e)i[e]=(a[e]-i[e+1])/s[e];for(s[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)s[e]=2*t[e+1]-i[e+1];return[i,s]}function Bke(t){return new VX(t)}function nE(t,e){this._context=t,this._t=e}nE.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 Hke(t){return new nE(t,.5)}function $ke(t){return new nE(t,0)}function Vke(t){return new nE(t,1)}function Em(t,e){if((a=t.length)>1)for(var n=1,r,i,s=t[e[0]],a,o=s.length;n<a;++n)for(i=s,s=t[e[n]],r=0;r<o;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function rP(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Gke(t,e){return t[e]}function Wke(t){const e=[];return e.key=t,e}function qke(){var t=tr([]),e=rP,n=Em,r=Gke;function i(s){var a=Array.from(t.apply(this,arguments),Wke),o,l=a.length,u=-1,d;for(const f of s)for(o=0,++u;o<l;++o)(a[o][u]=[0,+r(f,a[o].key,u,s)]).data=f;for(o=0,d=KD(e(a));o<l;++o)a[d[o]].index=o;return n(a,d),a}return i.keys=function(s){return arguments.length?(t=typeof s=="function"?s:tr(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:tr(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?rP:typeof s=="function"?s:tr(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??Em,i):n},i}function Kke(t,e){if((r=t.length)>0){for(var n,r,i=0,s=t[0].length,a;i<s;++i){for(a=n=0;n<r;++n)a+=t[n][i][1]||0;if(a)for(n=0;n<r;++n)t[n][i][1]/=a}Em(t,e)}}function Xke(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,s=r.length;n<s;++n){for(var a=0,o=0;a<i;++a)o+=t[a][n][1]||0;r[n][1]+=r[n][0]=-o/2}Em(t,e)}}function Yke(t,e){if(!(!((a=t.length)>0)||!((s=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,s,a;r<s;++r){for(var o=0,l=0,u=0;o<a;++o){for(var d=t[e[o]],f=d[r][1]||0,g=d[r-1][1]||0,m=(f-g)/2,x=0;x<o;++x){var y=t[e[x]],v=y[r][1]||0,b=y[r-1][1]||0;m+=v-b}l+=f,u+=m*f}i[r-1][1]+=i[r-1][0]=n,l&&(n-=u/l)}i[r-1][1]+=i[r-1][0]=n,Em(t,e)}}var dC={},hC={},S8;function Zke(){return S8||(S8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(hC)),hC}var fC={},E8;function GX(){return E8||(E8=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})(fC)),fC}var pC={},M8;function YD(){return M8||(M8=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})(pC)),pC}var mC={},gC={},A8;function Qke(){return A8||(A8=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})(gC)),gC}var T8;function ZD(){return T8||(T8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Qke(),n=YD();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const s=[],a=i.length;if(a===0)return s;let o=0,l="",u="",d=!1;for(i.charCodeAt(0)===46&&(s.push(""),o++);o<a;){const f=i[o];u?f==="\\"&&o+1<a?(o++,l+=i[o]):f===u?u="":l+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,s.push(l),l=""):l+=f:f==="["?(d=!0,l&&(s.push(l),l="")):f==="."?l&&(s.push(l),l=""):l+=f,o++}return l&&s.push(l),s}t.toPath=r})(mC)),mC}var C8;function QD(){return C8||(C8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Zke(),n=GX(),r=YD(),i=ZD();function s(o,l,u){if(o==null)return u;switch(typeof l){case"string":{if(e.isUnsafeProperty(l))return u;const d=o[l];return d===void 0?n.isDeepKey(l)?s(o,i.toPath(l),u):u:d}case"number":case"symbol":{typeof l=="number"&&(l=r.toKey(l));const d=o[l];return d===void 0?u:d}default:{if(Array.isArray(l))return a(o,l,u);if(Object.is(l?.valueOf(),-0)?l="-0":l=String(l),e.isUnsafeProperty(l))return u;const d=o[l];return d===void 0?u:d}}}function a(o,l,u){if(l.length===0)return u;let d=o;for(let f=0;f<l.length;f++){if(d==null||e.isUnsafeProperty(l[f]))return u;d=d[l[f]]}return d===void 0?u:d}t.get=s})(dC)),dC}var xC,N8;function Jke(){return N8||(N8=1,xC=QD().get),xC}var ePe=Jke();const Kh=oo(ePe);var Di=t=>t===0?0:t>0?1:-1,io=t=>typeof t=="number"&&t!=+t,wc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Ct=t=>(typeof t=="number"||t instanceof Number)&&!io(t),fl=t=>Ct(t)||typeof t=="string",tPe=0,U0=t=>{var e=++tPe;return"".concat(t||"").concat(e)},hs=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(!Ct(e)&&typeof e!="string")return r;var s;if(wc(e)){if(n==null)return r;var a=e.indexOf("%");s=n*parseFloat(e.slice(0,a))/100}else s=+e;return io(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},WX=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 cr(t,e,n){return Ct(t)&&Ct(e)?t+n*(e-t):e}function qX(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Kh(r,e))===n)}var yr=t=>t===null||typeof t>"u",mb=t=>yr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function nPe(t){return t!=null}function gb(){}var rPe=["type","size","sizeType"];function iP(){return iP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},iP.apply(null,arguments)}function 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 P8(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){iPe(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 iPe(t,e,n){return(e=sPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sPe(t){var e=aPe(t,"string");return typeof e=="symbol"?e:e+""}function aPe(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 oPe(t,e){if(t==null)return{};var n,r,i=lPe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lPe(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 KX={symbolCircle:XD,symbolCross:Ske,symbolDiamond:Mke,symbolSquare:Ake,symbolStar:kke,symbolTriangle:Pke,symbolWye:Dke},cPe=Math.PI/180,uPe=t=>{var e="symbol".concat(mb(t));return KX[e]||XD},dPe=(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*cPe;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}},hPe=(t,e)=>{KX["symbol".concat(mb(t))]=e},JD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=oPe(t,rPe),s=P8(P8({},i),{},{type:e,size:n,sizeType:r}),a="circle";typeof e=="string"&&(a=e);var o=()=>{var g=uPe(a),m=Oke().type(g).size(dPe(n,r,a)),x=m();if(x!==null)return x},{className:l,cx:u,cy:d}=s,f=Cs(s);return Ct(u)&&Ct(d)&&Ct(n)?M.createElement("path",iP({},f,{className:Tn("recharts-symbols",l),transform:"translate(".concat(u,", ").concat(d,")"),d:o()})):null};JD.registerSymbol=hPe;var XX=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,eO=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(M.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{GD(i)&&(r[i]=(s=>n[i](n,s)))}),r},fPe=(t,e,n)=>r=>(t(e,n,r),null),xb=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var s=t[i];GD(i)&&typeof s=="function"&&(r||(r={}),r[i]=fPe(s,e,n))}),r};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 pPe(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){mPe(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 mPe(t,e,n){return(e=gPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gPe(t){var e=xPe(t,"string");return typeof e=="symbol"?e:e+""}function xPe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ii(t,e){var n=pPe({},t),r=e,i=Object.keys(e),s=i.reduce((a,o)=>(a[o]===void 0&&r[o]!==void 0&&(a[o]=r[o]),a),n);return s}function _w(){return _w=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},_w.apply(null,arguments)}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 bPe(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){vPe(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 vPe(t,e,n){return(e=yPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yPe(t){var e=_Pe(t,"string");return typeof e=="symbol"?e:e+""}function _Pe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Fa=32,wPe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function SPe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Fa/2,s=Fa/6,a=Fa/3,o=e.inactive?r:e.color,l=n??e.type;if(l==="none")return null;if(l==="plainline"){var u;return M.createElement("line",{strokeWidth:4,fill:"none",stroke:o,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:Fa,y2:i,className:"recharts-legend-icon"})}if(l==="line")return M.createElement("path",{strokeWidth:4,fill:"none",stroke:o,d:"M0,".concat(i,"h").concat(a,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(2*a,",").concat(i,`
- H`).concat(Fa,"M").concat(2*a,",").concat(i,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(a,",").concat(i),className:"recharts-legend-icon"});if(l==="rect")return M.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Fa/8,"h").concat(Fa,"v").concat(Fa*3/4,"h").concat(-Fa,"z"),className:"recharts-legend-icon"});if(M.isValidElement(e.legendIcon)){var d=bPe({},e);return delete d.legendIcon,M.cloneElement(e.legendIcon,d)}return M.createElement(JD,{fill:o,cx:i,cy:i,size:Fa,sizeType:"diameter",type:l})}function EPe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:a}=t,o={x:0,y:0,width:Fa,height:Fa},l={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var g=d.formatter||i,m=Tn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?s:d.color,y=g?g(d.value,d,f):d.value;return M.createElement("li",_w({className:m,style:l,key:"legend-item-".concat(f)},xb(t,d,f)),M.createElement(WD,{width:n,height:n,viewBox:o,style:u,"aria-label":"".concat(y," legend icon")},M.createElement(SPe,{data:d,iconType:a,inactiveColor:s})),M.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var MPe=t=>{var e=ii(t,wPe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var s={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return M.createElement("ul",{className:"recharts-default-legend",style:s},M.createElement(EPe,_w({},e,{payload:n})))},bC={},vC={},O8;function APe(){return O8||(O8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let s=0;s<n.length;s++){const a=n[s],o=r(a);i.has(o)||i.set(o,a)}return Array.from(i.values())}t.uniqBy=e})(vC)),vC}var yC={},j8;function YX(){return j8||(j8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(yC)),yC}var _C={},wC={},SC={},L8;function TPe(){return L8||(L8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(SC)),SC}var I8;function tO(){return I8||(I8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=TPe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(wC)),wC}var EC={},U8;function CPe(){return U8||(U8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(EC)),EC}var F8;function NPe(){return F8||(F8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tO(),n=CPe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(_C)),_C}var MC={},AC={},z8;function kPe(){return z8||(z8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(AC)),AC}var TC={},CC={},NC={},kC={},B8;function ZX(){return B8||(B8=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})(kC)),kC}var PC={},H8;function QX(){return H8||(H8=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})(PC)),PC}var RC={},$8;function JX(){return $8||($8=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})(RC)),RC}var V8;function PPe(){return V8||(V8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ZX(),n=QX(),r=JX();function i(d,f,g){return typeof g!="function"?i(d,f,()=>{}):s(d,f,function m(x,y,v,b,E,S){const A=g(x,y,v,b,E,S);return A!==void 0?!!A:s(x,y,m,S)},new Map)}function s(d,f,g,m){if(f===d)return!0;switch(typeof f){case"object":return a(d,f,g,m);case"function":return Object.keys(f).length>0?s(d,{...f},g,m):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function a(d,f,g,m){if(f==null)return!0;if(Array.isArray(f))return l(d,f,g,m);if(f instanceof Map)return o(d,f,g,m);if(f instanceof Set)return u(d,f,g,m);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(m?.has(f))return m.get(f)===d;m?.set(f,d);try{for(let y=0;y<x.length;y++){const v=x[y];if(!n.isPrimitive(d)&&!(v in d)||f[v]===void 0&&d[v]!==void 0||f[v]===null&&d[v]!==null||!g(d[v],f[v],v,d,f,m))return!1}return!0}finally{m?.delete(f)}}function o(d,f,g,m){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,y]of f.entries()){const v=d.get(x);if(g(v,y,x,d,f,m)===!1)return!1}return!0}function l(d,f,g,m){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let y=0;y<f.length;y++){const v=f[y];let b=!1;for(let E=0;E<d.length;E++){if(x.has(E))continue;const S=d[E];let A=!1;if(g(S,v,y,d,f,m)&&(A=!0),A){x.add(E),b=!0;break}}if(!b)return!1}return!0}function u(d,f,g,m){return f.size===0?!0:d instanceof Set?l([...d],[...f],g,m):!1}t.isMatchWith=i,t.isSetMatch=u})(NC)),NC}var G8;function eY(){return G8||(G8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PPe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(CC)),CC}var DC={},OC={},jC={},W8;function RPe(){return W8||(W8=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})(jC)),jC}var LC={},q8;function tY(){return q8||(q8=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})(LC)),LC}var IC={},K8;function nY(){return K8||(K8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",s="[object Arguments]",a="[object Symbol]",o="[object Date]",l="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",g="[object ArrayBuffer]",m="[object Object]",x="[object Error]",y="[object DataView]",v="[object Uint8Array]",b="[object Uint8ClampedArray]",E="[object Uint16Array]",S="[object Uint32Array]",A="[object BigUint64Array]",T="[object Int8Array]",P="[object Int16Array]",C="[object Int32Array]",I="[object BigInt64Array]",N="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=g,t.arrayTag=d,t.bigInt64ArrayTag=I,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=y,t.dateTag=o,t.errorTag=x,t.float32ArrayTag=N,t.float64ArrayTag=D,t.functionTag=f,t.int16ArrayTag=P,t.int32ArrayTag=C,t.int8ArrayTag=T,t.mapTag=l,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=a,t.uint16ArrayTag=E,t.uint32ArrayTag=S,t.uint8ArrayTag=v,t.uint8ClampedArrayTag=b})(IC)),IC}var UC={},X8;function DPe(){return X8||(X8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(UC)),UC}var Y8;function rY(){return Y8||(Y8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=RPe(),n=tY(),r=nY(),i=QX(),s=DPe();function a(d,f){return o(d,void 0,d,new Map,f)}function o(d,f,g,m=new Map,x=void 0){const y=x?.(d,f,g,m);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const v=new Array(d.length);m.set(d,v);for(let b=0;b<d.length;b++)v[b]=o(d[b],b,g,m,x);return Object.hasOwn(d,"index")&&(v.index=d.index),Object.hasOwn(d,"input")&&(v.input=d.input),v}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const v=new RegExp(d.source,d.flags);return v.lastIndex=d.lastIndex,v}if(d instanceof Map){const v=new Map;m.set(d,v);for(const[b,E]of d)v.set(b,o(E,b,g,m,x));return v}if(d instanceof Set){const v=new Set;m.set(d,v);for(const b of d)v.add(o(b,void 0,g,m,x));return v}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(s.isTypedArray(d)){const v=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,v);for(let b=0;b<d.length;b++)v[b]=o(d[b],b,g,m,x);return v}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const v=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return m.set(d,v),l(v,d,g,m,x),v}if(typeof File<"u"&&d instanceof File){const v=new File([d],d.name,{type:d.type});return m.set(d,v),l(v,d,g,m,x),v}if(typeof Blob<"u"&&d instanceof Blob){const v=new Blob([d],{type:d.type});return m.set(d,v),l(v,d,g,m,x),v}if(d instanceof Error){const v=new d.constructor;return m.set(d,v),v.message=d.message,v.name=d.name,v.stack=d.stack,v.cause=d.cause,l(v,d,g,m,x),v}if(d instanceof Boolean){const v=new Boolean(d.valueOf());return m.set(d,v),l(v,d,g,m,x),v}if(d instanceof Number){const v=new Number(d.valueOf());return m.set(d,v),l(v,d,g,m,x),v}if(d instanceof String){const v=new String(d.valueOf());return m.set(d,v),l(v,d,g,m,x),v}if(typeof d=="object"&&u(d)){const v=Object.create(Object.getPrototypeOf(d));return m.set(d,v),l(v,d,g,m,x),v}return d}function l(d,f,g=d,m,x){const y=[...Object.keys(f),...e.getSymbols(f)];for(let v=0;v<y.length;v++){const b=y[v],E=Object.getOwnPropertyDescriptor(d,b);(E==null||E.writable)&&(d[b]=o(f[b],b,g,m,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=a,t.cloneDeepWithImpl=o,t.copyProperties=l})(OC)),OC}var Z8;function OPe(){return Z8||(Z8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rY();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(DC)),DC}var Q8;function jPe(){return Q8||(Q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eY(),n=OPe();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(TC)),TC}var FC={},zC={},BC={},J8;function LPe(){return J8||(J8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rY(),n=nY();function r(i,s){return e.cloneDeepWith(i,(a,o,l,u)=>{const d=s?.(a,o,l,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(BC)),BC}var eH;function IPe(){return eH||(eH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LPe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(zC)),zC}var HC={},$C={},tH;function iY(){return tH||(tH=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})($C)),$C}var VC={},nH;function UPe(){return nH||(nH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tY();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(VC)),VC}var rH;function FPe(){return rH||(rH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GX(),n=iY(),r=UPe(),i=ZD();function s(a,o){let l;if(Array.isArray(o)?l=o:typeof o=="string"&&e.isDeepKey(o)&&a?.[o]==null?l=i.toPath(o):l=[o],l.length===0)return!1;let u=a;for(let d=0;d<l.length;d++){const f=l[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=s})(HC)),HC}var iH;function zPe(){return iH||(iH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eY(),n=YD(),r=IPe(),i=QD(),s=FPe();function a(o,l){switch(typeof o){case"object":{Object.is(o?.valueOf(),-0)&&(o="-0");break}case"number":{o=n.toKey(o);break}}return l=r.cloneDeep(l),function(u){const d=i.get(u,o);return d===void 0?s.has(u,o):l===void 0?d===void 0:e.isMatch(d,l)}}t.matchesProperty=a})(FC)),FC}var sH;function BPe(){return sH||(sH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YX(),n=kPe(),r=jPe(),i=zPe();function s(a){if(a==null)return e.identity;switch(typeof a){case"function":return a;case"object":return Array.isArray(a)&&a.length===2?i.matchesProperty(a[0],a[1]):r.matches(a);case"string":case"symbol":case"number":return n.property(a)}}t.iteratee=s})(MC)),MC}var aH;function HPe(){return aH||(aH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=APe(),n=YX(),r=NPe(),i=BPe();function s(a,o=n.identity){return r.isArrayLikeObject(a)?e.uniqBy(Array.from(a),i.iteratee(o)):[]}t.uniqBy=s})(bC)),bC}var GC,oH;function $Pe(){return oH||(oH=1,GC=HPe().uniqBy),GC}var VPe=$Pe();const lH=oo(VPe);function sY(t,e,n){return e===!0?lH(t,n):typeof e=="function"?lH(t,e):t}var nO=M.createContext(null),GPe=t=>t,rr=()=>{var t=M.useContext(nO);return t?t.store.dispatch:GPe},Y_=()=>{},WPe=()=>Y_,qPe=(t,e)=>t===e;function kt(t){var e=M.useContext(nO);return vK.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:WPe,e?e.store.getState:Y_,e?e.store.getState:Y_,e?t:Y_,qPe)}function KPe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function XPe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function YPe(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 cH=t=>Array.isArray(t)?t:[t];function ZPe(t){const e=Array.isArray(t[0])?t[0]:t;return YPe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function QPe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var JPe=class{constructor(t){this.value=t}deref(){return this.value}},eRe=typeof WeakRef<"u"?WeakRef:JPe,tRe=0,uH=1;function p_(){return{s:tRe,v:void 0,o:null,p:null}}function aY(t,e={}){let n=p_();const{resultEqualityCheck:r}=e;let i,s=0;function a(){let o=n;const{length:l}=arguments;for(let f=0,g=l;f<g;f++){const m=arguments[f];if(typeof m=="function"||typeof m=="object"&&m!==null){let x=o.o;x===null&&(o.o=x=new WeakMap);const y=x.get(m);y===void 0?(o=p_(),x.set(m,o)):o=y}else{let x=o.p;x===null&&(o.p=x=new Map);const y=x.get(m);y===void 0?(o=p_(),x.set(m,o)):o=y}}const u=o;let d;if(o.s===uH)d=o.v;else if(d=t.apply(null,arguments),s++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,s!==0&&s--),i=typeof d=="object"&&d!==null||typeof d=="function"?new eRe(d):d}return u.s=uH,u.v=d,d}return a.clearCache=()=>{n=p_(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function nRe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let s=0,a=0,o,l={},u=i.pop();typeof u=="object"&&(l=u,u=i.pop()),KPe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...l},{memoize:f,memoizeOptions:g=[],argsMemoize:m=aY,argsMemoizeOptions:x=[]}=d,y=cH(g),v=cH(x),b=ZPe(i),E=f(function(){return s++,u.apply(null,arguments)},...y),S=m(function(){a++;const T=QPe(b,arguments);return o=E.apply(null,T),o},...v);return Object.assign(S,{resultFunc:u,memoizedResultFunc:E,dependencies:b,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>o,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var Ke=nRe(aY),rRe=Object.assign((t,e=Ke)=>{XPe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(s=>t[s]);return e(r,(...s)=>s.reduce((a,o,l)=>(a[n[l]]=o,a),{}))},{withTypes:()=>rRe}),WC={},qC={},KC={},dH;function iRe(){return dH||(dH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,s)=>{if(r!==i){const a=e(r),o=e(i);if(a===o&&a===0){if(r<i)return s==="desc"?1:-1;if(r>i)return s==="desc"?-1:1}return s==="desc"?o-a:a-o}return 0};t.compareValues=n})(KC)),KC}var XC={},YC={},hH;function oY(){return hH||(hH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(YC)),YC}var fH;function sRe(){return fH||(fH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oY(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,a){return Array.isArray(s)?!1:typeof s=="number"||typeof s=="boolean"||s==null||e.isSymbol(s)?!0:typeof s=="string"&&(r.test(s)||!n.test(s))||a!=null&&Object.hasOwn(a,s)}t.isKey=i})(XC)),XC}var pH;function aRe(){return pH||(pH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iRe(),n=sRe(),r=ZD();function i(s,a,o,l){if(s==null)return[];o=l?void 0:o,Array.isArray(s)||(s=Object.values(s)),Array.isArray(a)||(a=a==null?[null]:[a]),a.length===0&&(a=[null]),Array.isArray(o)||(o=o==null?[]:[o]),o=o.map(m=>String(m));const u=(m,x)=>{let y=m;for(let v=0;v<x.length&&y!=null;++v)y=y[x[v]];return y},d=(m,x)=>x==null||m==null?x:typeof m=="object"&&"key"in m?Object.hasOwn(x,m.key)?x[m.key]:u(x,m.path):typeof m=="function"?m(x):Array.isArray(m)?u(x,m):typeof x=="object"?x[m]:x,f=a.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||n.isKey(m)?m:{key:m,path:r.toPath(m)}));return s.map(m=>({original:m,criteria:f.map(x=>d(x,m))})).slice().sort((m,x)=>{for(let y=0;y<f.length;y++){const v=e.compareValues(m.criteria[y],x.criteria[y],o[y]);if(v!==0)return v}return 0}).map(m=>m.original)}t.orderBy=i})(qC)),qC}var ZC={},mH;function oRe(){return mH||(mH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],s=Math.floor(r),a=(o,l)=>{for(let u=0;u<o.length;u++){const d=o[u];Array.isArray(d)&&l<s?a(d,l+1):i.push(d)}};return a(n,0),i}t.flatten=e})(ZC)),ZC}var QC={},gH;function lY(){return gH||(gH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iY(),n=tO(),r=ZX(),i=JX();function s(a,o,l){return r.isObject(l)&&(typeof o=="number"&&n.isArrayLike(l)&&e.isIndex(o)&&o<l.length||typeof o=="string"&&o in l)?i.eq(l[o],a):!1}t.isIterateeCall=s})(QC)),QC}var xH;function lRe(){return xH||(xH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=aRe(),n=oRe(),r=lY();function i(s,...a){const o=a.length;return o>1&&r.isIterateeCall(s,a[0],a[1])?a=[]:o>2&&r.isIterateeCall(a[0],a[1],a[2])&&(a=[a[0]]),e.orderBy(s,n.flatten(a),["asc"])}t.sortBy=i})(WC)),WC}var JC,bH;function cRe(){return bH||(bH=1,JC=lRe().sortBy),JC}var uRe=cRe();const rE=oo(uRe);var cY=t=>t.legend.settings,dRe=t=>t.legend.size,hRe=t=>t.legend.payload,fRe=Ke([hRe,cY],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?rE(r,n):r});function pRe(){return kt(fRe)}var m_=1;function uY(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=M.useState({height:0,left:0,top:0,width:0}),r=M.useCallback(i=>{if(i!=null){var s=i.getBoundingClientRect(),a={height:s.height,left:s.left,top:s.top,width:s.width};(Math.abs(a.height-e.height)>m_||Math.abs(a.left-e.left)>m_||Math.abs(a.top-e.top)>m_||Math.abs(a.width-e.width)>m_)&&n({height:a.height,left:a.left,top:a.top,width:a.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function Wi(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 mRe=typeof Symbol=="function"&&Symbol.observable||"@@observable",vH=mRe,eN=()=>Math.random().toString(36).substring(7).split("").join("."),gRe={INIT:`@@redux/INIT${eN()}`,REPLACE:`@@redux/REPLACE${eN()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${eN()}`},ww=gRe;function rO(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 dY(t,e,n){if(typeof t!="function")throw new Error(Wi(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Wi(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Wi(1));return n(dY)(t,e)}let r=t,i=e,s=new Map,a=s,o=0,l=!1;function u(){a===s&&(a=new Map,s.forEach((v,b)=>{a.set(b,v)}))}function d(){if(l)throw new Error(Wi(3));return i}function f(v){if(typeof v!="function")throw new Error(Wi(4));if(l)throw new Error(Wi(5));let b=!0;u();const E=o++;return a.set(E,v),function(){if(b){if(l)throw new Error(Wi(6));b=!1,u(),a.delete(E),s=null}}}function g(v){if(!rO(v))throw new Error(Wi(7));if(typeof v.type>"u")throw new Error(Wi(8));if(typeof v.type!="string")throw new Error(Wi(17));if(l)throw new Error(Wi(9));try{l=!0,i=r(i,v)}finally{l=!1}return(s=a).forEach(E=>{E()}),v}function m(v){if(typeof v!="function")throw new Error(Wi(10));r=v,g({type:ww.REPLACE})}function x(){const v=f;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(Wi(11));function E(){const A=b;A.next&&A.next(d())}return E(),{unsubscribe:v(E)}},[vH](){return this}}}return g({type:ww.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:m,[vH]:x}}function xRe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:ww.INIT})>"u")throw new Error(Wi(12));if(typeof n(void 0,{type:ww.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Wi(13))})}function hY(t){const e=Object.keys(t),n={};for(let s=0;s<e.length;s++){const a=e[s];typeof t[a]=="function"&&(n[a]=t[a])}const r=Object.keys(n);let i;try{xRe(n)}catch(s){i=s}return function(a={},o){if(i)throw i;let l=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],g=n[f],m=a[f],x=g(m,o);if(typeof x>"u")throw o&&o.type,new Error(Wi(14));u[f]=x,l=l||x!==m}return l=l||r.length!==Object.keys(a).length,l?u:a}}function Sw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function bRe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(Wi(15))};const a={getState:i.getState,dispatch:(l,...u)=>s(l,...u)},o=t.map(l=>l(a));return s=Sw(...o)(i.dispatch),{...i,dispatch:s}}}function fY(t){return rO(t)&&"type"in t&&typeof t.type=="string"}var pY=Symbol.for("immer-nothing"),yH=Symbol.for("immer-draftable"),Ns=Symbol.for("immer-state");function Eo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var pa=Object,Mm=pa.getPrototypeOf,Ew="constructor",iE="prototype",sP="configurable",Mw="enumerable",Z_="writable",F0="value",Sc=t=>!!t&&!!t[Ns];function Io(t){return t?mY(t)||sE(t)||!!t[yH]||!!t[Ew]?.[yH]||aE(t)||oE(t):!1}var vRe=pa[iE][Ew].toString(),_H=new WeakMap;function mY(t){if(!t||!iO(t))return!1;const e=Mm(t);if(e===null||e===pa[iE])return!0;const n=pa.hasOwnProperty.call(e,Ew)&&e[Ew];if(n===Object)return!0;if(!Dp(n))return!1;let r=_H.get(n);return r===void 0&&(r=Function.toString.call(n),_H.set(n,r)),r===vRe}function bb(t,e,n=!0){vb(t)===0?(n?Reflect.ownKeys(t):pa.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function vb(t){const e=t[Ns];return e?e.type_:sE(t)?1:aE(t)?2:oE(t)?3:0}var wH=(t,e,n=vb(t))=>n===2?t.has(e):pa[iE].hasOwnProperty.call(t,e),aP=(t,e,n=vb(t))=>n===2?t.get(e):t[e],Aw=(t,e,n,r=vb(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function yRe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var sE=Array.isArray,aE=t=>t instanceof Map,oE=t=>t instanceof Set,iO=t=>typeof t=="object",Dp=t=>typeof t=="function",tN=t=>typeof t=="boolean",ec=t=>t.copy_||t.base_,sO=t=>t.modified_?t.copy_:t.base_;function oP(t,e){if(aE(t))return new Map(t);if(oE(t))return new Set(t);if(sE(t))return Array[iE].slice.call(t);const n=mY(t);if(e===!0||e==="class_only"&&!n){const r=pa.getOwnPropertyDescriptors(t);delete r[Ns];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const a=i[s],o=r[a];o[Z_]===!1&&(o[Z_]=!0,o[sP]=!0),(o.get||o.set)&&(r[a]={[sP]:!0,[Z_]:!0,[Mw]:o[Mw],[F0]:t[a]})}return pa.create(Mm(t),r)}else{const r=Mm(t);if(r!==null&&n)return{...t};const i=pa.create(r);return pa.assign(i,t)}}function aO(t,e=!1){return lE(t)||Sc(t)||!Io(t)||(vb(t)>1&&pa.defineProperties(t,{set:g_,add:g_,clear:g_,delete:g_}),pa.freeze(t),e&&bb(t,(n,r)=>{aO(r,!0)},!1)),t}function _Re(){Eo(2)}var g_={[F0]:_Re};function lE(t){return t===null||!iO(t)?!0:pa.isFrozen(t)}var Tw="MapSet",lP="Patches",gY={};function Am(t){const e=gY[t];return e||Eo(0,t),e}var wRe=t=>!!gY[t],z0,xY=()=>z0,SRe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:wRe(Tw)?Am(Tw):void 0});function SH(t,e){e&&(t.patchPlugin_=Am(lP),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function cP(t){uP(t),t.drafts_.forEach(ERe),t.drafts_=null}function uP(t){t===z0&&(z0=t.parent_)}var EH=t=>z0=SRe(z0,t);function ERe(t){const e=t[Ns];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function MH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Ns].modified_&&(cP(e),Eo(4)),Io(t)&&(t=AH(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Ns].base_,t,e)}else t=AH(e,n);return MRe(e,t,!0),cP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==pY?t:void 0}function AH(t,e){if(lE(e))return e;const n=e[Ns];if(!n)return oO(e,t.handledSet_,t);if(!cE(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);yY(n,t)}return n.copy_}function MRe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&aO(e,n)}function bY(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var cE=(t,e)=>t.scope_===e,ARe=[];function vY(t,e,n,r){const i=ec(t),s=t.type_;if(r!==void 0&&aP(i,r,s)===e){Aw(i,r,n,s);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;bb(i,(l,u)=>{if(Sc(u)){const d=o.get(u)||[];d.push(l),o.set(u,d)}})}const a=t.draftLocations_.get(e)??ARe;for(const o of a)Aw(i,o,n,s)}function TRe(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!cE(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const a=sO(s);vY(t,s.draft_??s,a,n),yY(s,i)})}function yY(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)}bY(t)}}function CRe(t,e,n){const{scope_:r}=t;if(Sc(n)){const i=n[Ns];cE(i,r)&&i.callbacks_.push(function(){Q_(t);const a=sO(i);vY(t,n,a,e)})}else Io(n)&&t.callbacks_.push(function(){const s=ec(t);aP(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&oO(aP(t.copy_,e,t.type_),r.handledSet_,r)})}function oO(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Sc(t)||e.has(t)||!Io(t)||lE(t)||(e.add(t),bb(t,(r,i)=>{if(Sc(i)){const s=i[Ns];if(cE(s,n)){const a=sO(s);Aw(t,r,a,t.type_),bY(s)}}else Io(i)&&oO(i,e,n)})),t}function NRe(t,e){const n=sE(t),r={type_:n?1:0,scope_:e?e.scope_:xY(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,s=lO;n&&(i=[r],s=B0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,[o,r]}var lO={get(t,e){if(e===Ns)return t;const n=ec(t);if(!wH(n,e,t.type_))return kRe(t,n,e);const r=n[e];if(t.finalized_||!Io(r))return r;if(r===nN(t.base_,e)){Q_(t);const i=t.type_===1?+e:e,s=hP(t.scope_,r,t,i);return t.copy_[i]=s}return r},has(t,e){return e in ec(t)},ownKeys(t){return Reflect.ownKeys(ec(t))},set(t,e,n){const r=_Y(ec(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=nN(ec(t),e),s=i?.[Ns];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(yRe(n,i)&&(n!==void 0||wH(t.base_,e,t.type_)))return!0;Q_(t),dP(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),CRe(t,e,n)),!0},deleteProperty(t,e){return Q_(t),nN(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),dP(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=ec(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[Z_]:!0,[sP]:t.type_!==1||e!=="length",[Mw]:r[Mw],[F0]:n[e]}},defineProperty(){Eo(11)},getPrototypeOf(t){return Mm(t.base_)},setPrototypeOf(){Eo(12)}},B0={};bb(lO,(t,e)=>{B0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});B0.deleteProperty=function(t,e){return B0.set.call(this,t,e,void 0)};B0.set=function(t,e,n){return lO.set.call(this,t[0],e,n,t[0])};function nN(t,e){const n=t[Ns];return(n?ec(n):t)[e]}function kRe(t,e,n){const r=_Y(e,n);return r?F0 in r?r[F0]:r.get?.call(t.draft_):void 0}function _Y(t,e){if(!(e in t))return;let n=Mm(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Mm(n)}}function dP(t){t.modified_||(t.modified_=!0,t.parent_&&dP(t.parent_))}function Q_(t){t.copy_||(t.assigned_=new Map,t.copy_=oP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var PRe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Dp(n)&&!Dp(r)){const a=r;r=n;const o=this;return function(u=a,...d){return o.produce(u,f=>r.call(this,f,...d))}}Dp(r)||Eo(6),i!==void 0&&!Dp(i)&&Eo(7);let s;if(Io(n)){const a=EH(this),o=hP(a,n,void 0);let l=!0;try{s=r(o),l=!1}finally{l?cP(a):uP(a)}return SH(a,i),MH(s,a)}else if(!n||!iO(n)){if(s=r(n),s===void 0&&(s=n),s===pY&&(s=void 0),this.autoFreeze_&&aO(s,!0),i){const a=[],o=[];Am(lP).generateReplacementPatches_(n,s,{patches_:a,inversePatches_:o}),i(a,o)}return s}else Eo(1,n)},this.produceWithPatches=(n,r)=>{if(Dp(n))return(o,...l)=>this.produceWithPatches(o,u=>n(u,...l));let i,s;return[this.produce(n,r,(o,l)=>{i=o,s=l}),i,s]},tN(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),tN(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),tN(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Io(e)||Eo(8),Sc(e)&&(e=Ro(e));const n=EH(this),r=hP(n,e,void 0);return r[Ns].isManual_=!0,uP(n),r}finishDraft(e,n){const r=e&&e[Ns];(!r||!r.isManual_)&&Eo(9);const{scope_:i}=r;return SH(i,n),MH(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const s=n[r];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}r>-1&&(n=n.slice(r+1));const i=Am(lP).applyPatches_;return Sc(e)?i(e,n):this.produce(e,s=>i(s,n))}};function hP(t,e,n,r){const[i,s]=aE(e)?Am(Tw).proxyMap_(e,n):oE(e)?Am(Tw).proxySet_(e,n):NRe(e,n);return(n?.scope_??xY()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?TRe(n,s,r):s.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:u}=l;s.modified_&&u&&u.generatePatches_(s,[],l)}),i}function Ro(t){return Sc(t)||Eo(10,t),wY(t)}function wY(t){if(!Io(t)||lE(t))return t;const e=t[Ns];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=oP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=oP(t,!0);return bb(n,(i,s)=>{Aw(n,i,wY(s))},r),e&&(e.finalized_=!1),n}var RRe=new PRe,SY=RRe.produce;function EY(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var DRe=EY(),ORe=EY,jRe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Sw:Sw.apply(null,arguments)};function so(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(va(0));return{type:t,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:t,payload:r[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=r=>fY(r)&&r.type===t,n}var MY=class Nx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Nx.prototype)}static get[Symbol.species](){return Nx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Nx(...e[0].concat(this)):new Nx(...e.concat(this))}};function TH(t){return Io(t)?SY(t,()=>{}):t}function x_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function LRe(t){return typeof t=="boolean"}var IRe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let a=new MY;return n&&(LRe(n)?a.push(DRe):a.push(ORe(n.extraArgument))),a},AY="RTK_autoBatch",hr=()=>t=>({payload:t,meta:{[AY]:!0}}),CH=t=>e=>{setTimeout(e,t)},TY=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,s=!1,a=!1;const o=new Set,l=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:CH(10):t.type==="callback"?t.queueNotification:CH(t.timeout),u=()=>{a=!1,s&&(s=!1,o.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),g=r.subscribe(f);return o.add(d),()=>{g(),o.delete(d)}},dispatch(d){try{return i=!d?.meta?.[AY],s=!i,s&&(a||(a=!0,l(u))),r.dispatch(d)}finally{i=!0}}})},URe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new MY(t);return r&&i.push(TY(typeof r=="object"?r:void 0)),i};function FRe(t){const e=IRe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:s=void 0,enhancers:a=void 0}=t||{};let o;if(typeof n=="function")o=n;else if(rO(n))o=hY(n);else throw new Error(va(1));let l;typeof r=="function"?l=r(e):l=e();let u=Sw;i&&(u=jRe({trace:!1,...typeof i=="object"&&i}));const d=bRe(...l),f=URe(d);let g=typeof a=="function"?a(f):f();const m=u(...g);return dY(o,s,m)}function CY(t){const e={},n=[];let r;const i={addCase(s,a){const o=typeof s=="string"?s:s.type;if(!o)throw new Error(va(28));if(o in e)throw new Error(va(29));return e[o]=a,i},addAsyncThunk(s,a){return a.pending&&(e[s.pending.type]=a.pending),a.rejected&&(e[s.rejected.type]=a.rejected),a.fulfilled&&(e[s.fulfilled.type]=a.fulfilled),a.settled&&n.push({matcher:s.settled,reducer:a.settled}),i},addMatcher(s,a){return n.push({matcher:s,reducer:a}),i},addDefaultCase(s){return r=s,i}};return t(i),[e,n,r]}function zRe(t){return typeof t=="function"}function BRe(t,e){let[n,r,i]=CY(e),s;if(zRe(t))s=()=>TH(t());else{const o=TH(t);s=()=>o}function a(o=s(),l){let u=[n[l.type],...r.filter(({matcher:d})=>d(l)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Sc(d)){const m=f(d,l);return m===void 0?d:m}else{if(Io(d))return SY(d,g=>f(g,l));{const g=f(d,l);if(g===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return d},o)}return a.getInitialState=s,a}var HRe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",$Re=(t=21)=>{let e="",n=t;for(;n--;)e+=HRe[Math.random()*64|0];return e},VRe=Symbol.for("rtk-slice-createasyncthunk");function GRe(t,e){return`${t}/${e}`}function WRe({creators:t}={}){const e=t?.asyncThunk?.[VRe];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(va(11));const a=(typeof r.reducers=="function"?r.reducers(KRe()):r.reducers)||{},o=Object.keys(a),l={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(S,A){const T=typeof S=="string"?S:S.type;if(!T)throw new Error(va(12));if(T in l.sliceCaseReducersByType)throw new Error(va(13));return l.sliceCaseReducersByType[T]=A,u},addMatcher(S,A){return l.sliceMatchers.push({matcher:S,reducer:A}),u},exposeAction(S,A){return l.actionCreators[S]=A,u},exposeCaseReducer(S,A){return l.sliceCaseReducersByName[S]=A,u}};o.forEach(S=>{const A=a[S],T={reducerName:S,type:GRe(i,S),createNotation:typeof r.reducers=="function"};YRe(A)?QRe(T,A,u,e):XRe(T,A,u)});function d(){const[S={},A=[],T=void 0]=typeof r.extraReducers=="function"?CY(r.extraReducers):[r.extraReducers],P={...S,...l.sliceCaseReducersByType};return BRe(r.initialState,C=>{for(let I in P)C.addCase(I,P[I]);for(let I of l.sliceMatchers)C.addMatcher(I.matcher,I.reducer);for(let I of A)C.addMatcher(I.matcher,I.reducer);T&&C.addDefaultCase(T)})}const f=S=>S,g=new Map,m=new WeakMap;let x;function y(S,A){return x||(x=d()),x(S,A)}function v(){return x||(x=d()),x.getInitialState()}function b(S,A=!1){function T(C){let I=C[S];return typeof I>"u"&&A&&(I=x_(m,T,v)),I}function P(C=f){const I=x_(g,A,()=>new WeakMap);return x_(I,C,()=>{const N={};for(const[D,F]of Object.entries(r.selectors??{}))N[D]=qRe(F,C,()=>x_(m,C,v),A);return N})}return{reducerPath:S,getSelectors:P,get selectors(){return P(T)},selectSlice:T}}const E={name:i,reducer:y,actions:l.actionCreators,caseReducers:l.sliceCaseReducersByName,getInitialState:v,...b(s),injectInto(S,{reducerPath:A,...T}={}){const P=A??s;return S.inject({reducerPath:P,reducer:y},T),{...E,...b(P,!0)}}};return E}}function qRe(t,e,n,r){function i(s,...a){let o=e(s);return typeof o>"u"&&r&&(o=n()),t(o,...a)}return i.unwrapped=t,i}var Zs=WRe();function KRe(){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 XRe({type:t,reducerName:e,createNotation:n},r,i){let s,a;if("reducer"in r){if(n&&!ZRe(r))throw new Error(va(17));s=r.reducer,a=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,a?so(t,a):so(t))}function YRe(t){return t._reducerDefinitionType==="asyncThunk"}function ZRe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function QRe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(va(18));const{payloadCreator:s,fulfilled:a,pending:o,rejected:l,settled:u,options:d}=n,f=i(t,s,d);r.exposeAction(e,f),a&&r.addCase(f.fulfilled,a),o&&r.addCase(f.pending,o),l&&r.addCase(f.rejected,l),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:a||b_,pending:o||b_,rejected:l||b_,settled:u||b_})}function b_(){}var JRe="task",NY="listener",kY="completed",cO="cancelled",eDe=`task-${cO}`,tDe=`task-${kY}`,fP=`${NY}-${cO}`,nDe=`${NY}-${kY}`,uE=class{constructor(t){this.code=t,this.message=`${JRe} ${cO} (reason: ${t})`}name="TaskAbortError";message},uO=(t,e)=>{if(typeof t!="function")throw new TypeError(va(32))},Cw=()=>{},PY=(t,e=Cw)=>(t.catch(e),t),RY=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Sh=(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 uE(e)}};function DY(t,e){let n=Cw;return new Promise((r,i)=>{const s=()=>i(new uE(t.reason));if(t.aborted){s();return}n=RY(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=Cw})}var rDe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof uE?"cancelled":"rejected",error:n}}finally{e?.()}},Nw=t=>e=>PY(DY(t,e).then(n=>(Eh(t),n))),OY=t=>{const e=Nw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Jp}=Object,NH={},dE="listenerMiddleware",iDe=(t,e)=>{const n=r=>RY(t,()=>Sh(r,t.reason));return(r,i)=>{uO(r);const s=new AbortController;n(s);const a=rDe(async()=>{Eh(t),Eh(s.signal);const o=await r({pause:Nw(s.signal),delay:OY(s.signal),signal:s.signal});return Eh(s.signal),o},()=>Sh(s,tDe));return i?.autoJoin&&e.push(a.catch(Cw)),{result:Nw(t)(a),cancel(){Sh(s,eDe)}}}},sDe=(t,e)=>{const n=async(r,i)=>{Eh(e);let s=()=>{};const o=[new Promise((l,u)=>{let d=t({predicate:r,effect:(f,g)=>{g.unsubscribe(),l([f,g.getState(),g.getOriginalState()])}});s=()=>{d(),u()}})];i!=null&&o.push(new Promise(l=>setTimeout(l,i,null)));try{const l=await DY(e,Promise.race(o));return Eh(e),l}finally{s()}};return(r,i)=>PY(n(r,i))},jY=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=so(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(va(21));return uO(s),{predicate:i,type:e,effect:s}},LY=Jp(t=>{const{type:e,predicate:n,effect:r}=jY(t);return{id:$Re(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(va(22))}}},{withTypes:()=>LY}),kH=(t,e)=>{const{type:n,effect:r,predicate:i}=jY(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},pP=t=>{t.pending.forEach(e=>{Sh(e,fP)})},aDe=(t,e)=>()=>{for(const n of e.keys())pP(n);t.clear()},PH=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},IY=Jp(so(`${dE}/add`),{withTypes:()=>IY}),oDe=so(`${dE}/removeAll`),UY=Jp(so(`${dE}/remove`),{withTypes:()=>UY}),lDe=(...t)=>{console.error(`${dE}/error`,...t)},yb=(t={})=>{const e=new Map,n=new Map,r=m=>{const x=n.get(m)??0;n.set(m,x+1)},i=m=>{const x=n.get(m)??1;x===1?n.delete(m):n.set(m,x-1)},{extra:s,onError:a=lDe}=t;uO(a);const o=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),x=>{m.unsubscribe(),x?.cancelActive&&pP(m)}),l=m=>{const x=kH(e,m)??LY(m);return o(x)};Jp(l,{withTypes:()=>l});const u=m=>{const x=kH(e,m);return x&&(x.unsubscribe(),m.cancelActive&&pP(x)),!!x};Jp(u,{withTypes:()=>u});const d=async(m,x,y,v)=>{const b=new AbortController,E=sDe(l,b.signal),S=[];try{m.pending.add(b),r(m),await Promise.resolve(m.effect(x,Jp({},y,{getOriginalState:v,condition:(A,T)=>E(A,T).then(Boolean),take:E,delay:OY(b.signal),pause:Nw(b.signal),extra:s,signal:b.signal,fork:iDe(b.signal,S),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((A,T,P)=>{A!==b&&(Sh(A,fP),P.delete(A))})},cancel:()=>{Sh(b,fP),m.pending.delete(b)},throwIfCancelled:()=>{Eh(b.signal)}})))}catch(A){A instanceof uE||PH(a,A,{raisedBy:"effect"})}finally{await Promise.all(S),Sh(b,nDe),i(m),m.pending.delete(b)}},f=aDe(e,n);return{middleware:m=>x=>y=>{if(!fY(y))return x(y);if(IY.match(y))return l(y.payload);if(oDe.match(y)){f();return}if(UY.match(y))return u(y.payload);let v=m.getState();const b=()=>{if(v===NH)throw new Error(va(23));return v};let E;try{if(E=x(y),e.size>0){const S=m.getState(),A=Array.from(e.values());for(const T of A){let P=!1;try{P=T.predicate(y,S,v)}catch(C){P=!1,PH(a,C,{raisedBy:"predicate"})}P&&d(T,y,m,b)}}}finally{v=NH}return E},startListening:l,stopListening:u,clearListeners:f}};function va(t){return`Minified Redux Toolkit error #${t}; visit https://redux-toolkit.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var cDe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},FY=Zs({name:"chartLayout",initialState:cDe,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,s;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(s=e.payload.left)!==null&&s!==void 0?s:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:uDe,setLayout:dDe,setChartSize:hDe,setScale:fDe}=FY.actions,pDe=FY.reducer;function zY(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function RH(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 Up(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?RH(Object(n),!0).forEach(function(r){mDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mDe(t,e,n){return(e=gDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gDe(t){var e=xDe(t,"string");return typeof e=="symbol"?e:e+""}function xDe(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 Jn(t,e,n){return yr(t)||yr(e)?n:fl(e)?Kh(t,e,n):typeof e=="function"?e(t):n}var bDe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:s,verticalAlign:a,layout:o}=e;if((o==="vertical"||o==="horizontal"&&a==="middle")&&s!=="center"&&Ct(t[s]))return Up(Up({},t),{},{[s]:t[s]+(r||0)});if((o==="horizontal"||o==="vertical"&&s==="center")&&a!=="middle"&&Ct(t[a]))return Up(Up({},t),{},{[a]:t[a]+(i||0)})}return t},kc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",BY=(t,e,n,r)=>{if(r)return t.map(o=>o.coordinate);var i,s,a=t.map(o=>(o.coordinate===e&&(i=!0),o.coordinate===n&&(s=!0),o.coordinate));return i||a.push(e),s||a.push(n),a},HY=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:s,scale:a,realScaleType:o,isCategorical:l,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:g,axisType:m}=t;if(!a)return null;var x=o==="scaleBand"&&a.bandwidth?a.bandwidth()/2:2,y=i==="category"&&a.bandwidth?a.bandwidth()/x:0;if(y=m==="angleAxis"&&s&&s.length>=2?Di(s[0]-s[1])*2*y:y,f||g){var v=(f||g||[]).map((b,E)=>{var S=r?r.indexOf(b):b;return{coordinate:a(S)+y,value:b,offset:y,index:E}});return v.filter(b=>!io(b.coordinate))}return l&&u?u.map((b,E)=>({coordinate:a(b)+y,value:b,index:E,offset:y})):a.ticks&&d!=null?a.ticks(d).map((b,E)=>({coordinate:a(b)+y,value:b,offset:y,index:E})):a.domain().map((b,E)=>({coordinate:a(b)+y,value:r?r[b]:b,index:E,offset:y}))},DH=1e-4,vDe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-DH,s=Math.max(r[0],r[1])+DH,a=t(e[0]),o=t(e[n-1]);(a<i||a>s||o<i||o>s)&&t.domain([e[0],e[n-1]])}},yDe=(t,e)=>{if(!e||e.length!==2||!Ct(e[0])||!Ct(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(!Ct(t[0])||t[0]<n)&&(i[0]=n),(!Ct(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},_De=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0,a=0;a<e;++a){var o=io(t[a][n][1])?t[a][n][0]:t[a][n][1];o>=0?(t[a][n][0]=i,t[a][n][1]=i+o,i=t[a][n][1]):(t[a][n][0]=s,t[a][n][1]=s+o,s=t[a][n][1])}},wDe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0;s<e;++s){var a=io(t[s][n][1])?t[s][n][0]:t[s][n][1];a>=0?(t[s][n][0]=i,t[s][n][1]=i+a,i=t[s][n][1]):(t[s][n][0]=0,t[s][n][1]=0)}},SDe={sign:_De,expand:Kke,none:Em,silhouette:Xke,wiggle:Yke,positive:wDe},EDe=(t,e,n)=>{var r=SDe[n],i=qke().keys(e).value((s,a)=>Number(Jn(s,a,0))).order(rP).offset(r);return i(t)};function $Y(t){return t==null?void 0:String(t)}function OH(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:a}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!yr(i[e.dataKey])){var o=qX(n,"value",i[e.dataKey]);if(o)return o.coordinate+r/2}return n[s]?n[s].coordinate+r/2:null}var l=Jn(i,yr(a)?e.dataKey:a);return yr(l)?null:e.scale(l)}var jH=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:s,index:a}=t;if(e.type==="category")return n[a]?n[a].coordinate+r:null;var o=Jn(s,e.dataKey,e.scale.domain()[a]);return yr(o)?null:e.scale(o)-i/2+r},MDe=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]},ADe=t=>{var e=t.flat(2).filter(Ct);return[Math.min(...e),Math.max(...e)]},TDe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],CDe=(t,e,n)=>{if(t!=null)return TDe(Object.keys(t).reduce((r,i)=>{var s=t[i],{stackedData:a}=s,o=a.reduce((l,u)=>{var d=zY(u,e,n),f=ADe(d);return[Math.min(l[0],f[0]),Math.max(l[1],f[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},LH=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,IH=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Tm=(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=rE(e,d=>d.coordinate),s=1/0,a=1,o=i.length;a<o;a++){var l=i[a],u=i[a-1];s=Math.min((l.coordinate||0)-(u.coordinate||0),s)}return s===1/0?0:s}return n?void 0:0};function UH(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return Up(Up({},e),{},{dataKey:n,payload:r,value:i,name:s})}function qm(t,e){if(t)return String(t);if(typeof e=="string")return e}var NDe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},kDe=(t,e)=>e==="centric"?t.angle:t.radius,Pc=t=>t.layout.width,Rc=t=>t.layout.height,PDe=t=>t.layout.scale,VY=t=>t.layout.margin,hE=Ke(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),fE=Ke(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),GY="data-recharts-item-index",WY="data-recharts-item-data-key",_b=60;function FH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FH(Object(n),!0).forEach(function(r){RDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function RDe(t,e,n){return(e=DDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DDe(t){var e=ODe(t,"string");return typeof e=="symbol"?e:e+""}function ODe(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 jDe=t=>t.brush.height;function LDe(t){var e=fE(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:_b;return n+i}return n},0)}function IDe(t){var e=fE(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:_b;return n+i}return n},0)}function UDe(t){var e=hE(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function FDe(t){var e=hE(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var xi=Ke([Pc,Rc,VY,jDe,LDe,IDe,UDe,FDe,cY,dRe],(t,e,n,r,i,s,a,o,l,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+s},f={top:(n.top||0)+a,bottom:(n.bottom||0)+o},g=v_(v_({},f),d),m=g.bottom;g.bottom+=r,g=bDe(g,l,u);var x=t-g.left-g.right,y=e-g.top-g.bottom;return v_(v_({brushBottom:m},g),{},{width:Math.max(x,0),height:Math.max(y,0)})}),zDe=Ke(xi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),dO=Ke(Pc,Rc,(t,e)=>({x:0,y:0,width:t,height:e})),BDe=M.createContext(null),ms=()=>M.useContext(BDe)!=null,pE=t=>t.brush,mE=Ke([pE,xi,VY],(t,e,n)=>({height:t.height,x:Ct(t.x)?t.x:e.left,y:Ct(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Ct(t.width)?t.width:e.width})),rN={},iN={},sN={},zH;function HDe(){return zH||(zH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:s}={}){let a,o=null;const l=s!=null&&s.includes("leading"),u=s==null||s.includes("trailing"),d=()=>{o!==null&&(n.apply(a,o),a=void 0,o=null)},f=()=>{u&&d(),y()};let g=null;const m=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,f()},r)},x=()=>{g!==null&&(clearTimeout(g),g=null)},y=()=>{x(),a=void 0,o=null},v=()=>{d()},b=function(...E){if(i?.aborted)return;a=this,o=E;const S=g==null;m(),l&&S&&d()};return b.schedule=m,b.cancel=y,b.flush=v,i?.addEventListener("abort",y,{once:!0}),b}t.debounce=e})(sN)),sN}var BH;function $De(){return BH||(BH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=HDe();function n(r,i=0,s={}){typeof s!="object"&&(s={});const{leading:a=!1,trailing:o=!0,maxWait:l}=s,u=Array(2);a&&(u[0]="leading"),o&&(u[1]="trailing");let d,f=null;const g=e.debounce(function(...y){d=r.apply(this,y),f=null},i,{edges:u}),m=function(...y){return l!=null&&(f===null&&(f=Date.now()),Date.now()-f>=l)?(d=r.apply(this,y),f=Date.now(),g.cancel(),g.schedule(),d):(g.apply(this,y),d)},x=()=>(g.flush(),d);return m.cancel=g.cancel,m.flush=x,m}t.debounce=n})(iN)),iN}var HH;function VDe(){return HH||(HH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$De();function n(r,i=0,s={}){const{leading:a=!0,trailing:o=!0}=s;return e.debounce(r,i,{leading:a,maxWait:i,trailing:o})}t.throttle=n})(rN)),rN}var aN,$H;function GDe(){return $H||($H=1,aN=VDe().throttle),aN}var WDe=GDe();const qDe=oo(WDe);var kw=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var a=0;console.warn(n.replace(/%s/g,()=>i[a++]))}},qY=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:s,maxHeight:a}=n,o=wc(r)?t:Number(r),l=wc(i)?e:Number(i);return s&&s>0&&(o?l=o/s:l&&(o=l*s),a&&l!=null&&l>a&&(l=a)),{calculatedWidth:o,calculatedHeight:l}},KDe={width:0,height:0,overflow:"visible"},XDe={width:0,overflowX:"visible"},YDe={height:0,overflowY:"visible"},ZDe={},QDe=t=>{var{width:e,height:n}=t,r=wc(e),i=wc(n);return r&&i?KDe:r?XDe:i?YDe:ZDe};function JDe(t){var{width:e,height:n,aspect:r}=t,i=e,s=n;return i===void 0&&s===void 0?(i="100%",s="100%"):i===void 0?i=r&&r>0?void 0:"100%":s===void 0&&(s=r&&r>0?void 0:"100%"),{width:i,height:s}}function ur(t){return Number.isFinite(t)}function pl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function mP(){return mP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},mP.apply(null,arguments)}function VH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function GH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?VH(Object(n),!0).forEach(function(r){eOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eOe(t,e,n){return(e=tOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tOe(t){var e=nOe(t,"string");return typeof e=="symbol"?e:e+""}function nOe(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 KY=M.createContext({width:-1,height:-1});function rOe(t){return pl(t.width)&&pl(t.height)}function XY(t){var{children:e,width:n,height:r}=t,i=M.useMemo(()=>({width:n,height:r}),[n,r]);return rOe(i)?M.createElement(KY.Provider,{value:i},e):null}var hO=()=>M.useContext(KY),iOe=M.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:s,minWidth:a=0,minHeight:o,maxHeight:l,children:u,debounce:d=0,id:f,className:g,onResize:m,style:x={}}=t,y=M.useRef(null),v=M.useRef();v.current=m,M.useImperativeHandle(e,()=>y.current);var[b,E]=M.useState({containerWidth:r.width,containerHeight:r.height}),S=M.useCallback((I,N)=>{E(D=>{var F=Math.round(I),L=Math.round(N);return D.containerWidth===F&&D.containerHeight===L?D:{containerWidth:F,containerHeight:L}})},[]);M.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return gb;var I=L=>{var q,{width:R,height:V}=L[0].contentRect;S(R,V),(q=v.current)===null||q===void 0||q.call(v,R,V)};d>0&&(I=qDe(I,d,{trailing:!0,leading:!1}));var N=new ResizeObserver(I),{width:D,height:F}=y.current.getBoundingClientRect();return S(D,F),N.observe(y.current),()=>{N.disconnect()}},[S,d]);var{containerWidth:A,containerHeight:T}=b;kw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:P,calculatedHeight:C}=qY(A,T,{width:i,height:s,aspect:n,maxHeight:l});return kw(P!=null&&P>0||C!=null&&C>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,P,C,i,s,a,o,n),M.createElement("div",{id:f?"".concat(f):void 0,className:Tn("recharts-responsive-container",g),style:GH(GH({},x),{},{width:i,height:s,minWidth:a,minHeight:o,maxHeight:l}),ref:y},M.createElement("div",{style:QDe({width:i,height:s})},M.createElement(XY,{width:P,height:C},u)))}),oN=M.forwardRef((t,e)=>{var n=hO();if(pl(n.width)&&pl(n.height))return t.children;var{width:r,height:i}=JDe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:a}=qY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Ct(s)&&Ct(a)?M.createElement(XY,{width:s,height:a},t.children):M.createElement(iOe,mP({},t,{width:r,height:i,ref:e}))});function YY(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 gE=()=>{var t,e=ms(),n=kt(zDe),r=kt(mE),i=(t=kt(pE))===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}},sOe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},ZY=()=>{var t;return(t=kt(xi))!==null&&t!==void 0?t:sOe},fO=()=>kt(Pc),pO=()=>kt(Rc),aOe=()=>kt(t=>t.layout.margin),wn=t=>t.layout.layoutType,Km=()=>kt(wn),oOe=()=>{var t=Km();if(t==="horizontal"||t==="vertical")return t},lOe=()=>{var t=Km();return t!==void 0},xE=t=>{var e=rr(),n=ms(),{width:r,height:i}=t,s=hO(),a=r,o=i;return s&&(a=s.width>0?s.width:r,o=s.height>0?s.height:i),M.useEffect(()=>{!n&&pl(a)&&pl(o)&&e(hDe({width:a,height:o}))},[e,n,a,o]),null},QY=Symbol.for("immer-nothing"),WH=Symbol.for("immer-draftable"),wa=Symbol.for("immer-state");function Mo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var H0=Object.getPrototypeOf;function Cm(t){return!!t&&!!t[wa]}function Xh(t){return t?JY(t)||Array.isArray(t)||!!t[WH]||!!t.constructor?.[WH]||wb(t)||vE(t):!1}var cOe=Object.prototype.constructor.toString(),qH=new WeakMap;function JY(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=qH.get(n);return r===void 0&&(r=Function.toString.call(n),qH.set(n,r)),r===cOe}function Pw(t,e,n=!0){bE(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 bE(t){const e=t[wa];return e?e.type_:Array.isArray(t)?1:wb(t)?2:vE(t)?3:0}function gP(t,e){return bE(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function eZ(t,e,n){const r=bE(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function uOe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function wb(t){return t instanceof Map}function vE(t){return t instanceof Set}function Yd(t){return t.copy_||t.base_}function xP(t,e){if(wb(t))return new Map(t);if(vE(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=JY(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[wa];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const a=i[s],o=r[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[a]})}return Object.create(H0(t),r)}else{const r=H0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function mO(t,e=!1){return yE(t)||Cm(t)||!Xh(t)||(bE(t)>1&&Object.defineProperties(t,{set:y_,add:y_,clear:y_,delete:y_}),Object.freeze(t),e&&Object.values(t).forEach(n=>mO(n,!0))),t}function dOe(){Mo(2)}var y_={value:dOe};function yE(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var hOe={};function Yh(t){const e=hOe[t];return e||Mo(0,t),e}var $0;function tZ(){return $0}function fOe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function KH(t,e){e&&(Yh("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function bP(t){vP(t),t.drafts_.forEach(pOe),t.drafts_=null}function vP(t){t===$0&&($0=t.parent_)}function XH(t){return $0=fOe($0,t)}function pOe(t){const e=t[wa];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function YH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[wa].modified_&&(bP(e),Mo(4)),Xh(t)&&(t=Rw(e,t),e.parent_||Dw(e,t)),e.patches_&&Yh("Patches").generateReplacementPatches_(n[wa].base_,t,e.patches_,e.inversePatches_)):t=Rw(e,n,[]),bP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==QY?t:void 0}function Rw(t,e,n){if(yE(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[wa];if(!i)return Pw(e,(s,a)=>ZH(t,i,e,s,a,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return Dw(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let a=s,o=!1;i.type_===3&&(a=new Set(s),s.clear(),o=!0),Pw(a,(l,u)=>ZH(t,i,s,l,u,n,o),r),Dw(t,s,!1),n&&t.patches_&&Yh("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function ZH(t,e,n,r,i,s,a){if(i==null||typeof i!="object"&&!a)return;const o=yE(i);if(!(o&&!a)){if(Cm(i)){const l=s&&e&&e.type_!==3&&!gP(e.assigned_,r)?s.concat(r):void 0,u=Rw(t,i,l);if(eZ(n,r,u),Cm(u))t.canAutoFreeze_=!1;else return}else a&&n.add(i);if(Xh(i)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&o)return;Rw(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(wb(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Dw(t,i)}}}function Dw(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&mO(e,n)}function mOe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:tZ(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=gO;n&&(i=[r],s=V0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,o}var gO={get(t,e){if(e===wa)return t;const n=Yd(t);if(!gP(n,e))return gOe(t,n,e);const r=n[e];return t.finalized_||!Xh(r)?r:r===lN(t.base_,e)?(cN(t),t.copy_[e]=_P(r,t)):r},has(t,e){return e in Yd(t)},ownKeys(t){return Reflect.ownKeys(Yd(t))},set(t,e,n){const r=nZ(Yd(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=lN(Yd(t),e),s=i?.[wa];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(uOe(n,i)&&(n!==void 0||gP(t.base_,e)))return!0;cN(t),yP(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 lN(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,cN(t),yP(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Yd(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Mo(11)},getPrototypeOf(t){return H0(t.base_)},setPrototypeOf(){Mo(12)}},V0={};Pw(gO,(t,e)=>{V0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});V0.deleteProperty=function(t,e){return V0.set.call(this,t,e,void 0)};V0.set=function(t,e,n){return gO.set.call(this,t[0],e,n,t[0])};function lN(t,e){const n=t[wa];return(n?Yd(n):t)[e]}function gOe(t,e,n){const r=nZ(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function nZ(t,e){if(!(e in t))return;let n=H0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=H0(n)}}function yP(t){t.modified_||(t.modified_=!0,t.parent_&&yP(t.parent_))}function cN(t){t.copy_||(t.copy_=xP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var xOe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const s=n;n=e;const a=this;return function(l=s,...u){return a.produce(l,d=>n.call(this,d,...u))}}typeof n!="function"&&Mo(6),r!==void 0&&typeof r!="function"&&Mo(7);let i;if(Xh(e)){const s=XH(this),a=_P(e,void 0);let o=!0;try{i=n(a),o=!1}finally{o?bP(s):vP(s)}return KH(s,r),YH(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===QY&&(i=void 0),this.autoFreeze_&&mO(i,!0),r){const s=[],a=[];Yh("Patches").generateReplacementPatches_(e,i,s,a),r(s,a)}return i}else Mo(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(a,...o)=>this.produceWithPatches(a,l=>e(l,...o));let r,i;return[this.produce(e,n,(a,o)=>{r=a,i=o}),r,i]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Xh(t)||Mo(8),Cm(t)&&(t=bOe(t));const e=XH(this),n=_P(t,void 0);return n[wa].isManual_=!0,vP(e),n}finishDraft(t,e){const n=t&&t[wa];(!n||!n.isManual_)&&Mo(9);const{scope_:r}=n;return KH(r,e),YH(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=Yh("Patches").applyPatches_;return Cm(t)?r(t,e):this.produce(t,i=>r(i,e))}};function _P(t,e){const n=wb(t)?Yh("MapSet").proxyMap_(t,e):vE(t)?Yh("MapSet").proxySet_(t,e):mOe(t,e);return(e?e.scope_:tZ()).drafts_.push(n),n}function bOe(t){return Cm(t)||Mo(10,t),rZ(t)}function rZ(t){if(!Xh(t)||yE(t))return t;const e=t[wa];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=xP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=xP(t,!0);return Pw(n,(i,s)=>{eZ(n,i,rZ(s))},r),e&&(e.finalized_=!1),n}var vOe=new xOe;vOe.produce;var yOe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},iZ=Zs({name:"legend",initialState:yOe,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:hr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ro(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:hr()},removeLegendPayload:{reducer(t,e){var n=Ro(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:hr()}}}),{setLegendSize:QH,setLegendSettings:_Oe,addLegendPayload:sZ,replaceLegendPayload:aZ,removeLegendPayload:oZ}=iZ.actions,wOe=iZ.reducer,SOe=["contextPayload"];function wP(){return wP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},wP.apply(null,arguments)}function JH(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 Nm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?JH(Object(n),!0).forEach(function(r){EOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):JH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function EOe(t,e,n){return(e=MOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MOe(t){var e=AOe(t,"string");return typeof e=="symbol"?e:e+""}function AOe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function TOe(t,e){if(t==null)return{};var n,r,i=COe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function COe(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 NOe(t){return t.value}function kOe(t){var{contextPayload:e}=t,n=TOe(t,SOe),r=sY(e,t.payloadUniqBy,NOe),i=Nm(Nm({},n),{},{payload:r});return M.isValidElement(t.content)?M.cloneElement(t.content,i):typeof t.content=="function"?M.createElement(t.content,i):M.createElement(MPe,i)}function POe(t,e,n,r,i,s){var{layout:a,align:o,verticalAlign:l}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&a==="vertical"?u={left:((r||0)-s.width)/2}:u=o==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(l==="middle"?d={top:((i||0)-s.height)/2}:d=l==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Nm(Nm({},u),d)}function ROe(t){var e=rr();return M.useEffect(()=>{e(_Oe(t))},[e,t]),null}function DOe(t){var e=rr();return M.useEffect(()=>(e(QH(t)),()=>{e(QH({width:0,height:0}))}),[e,t]),null}function OOe(t,e,n,r){return t==="vertical"&&Ct(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var jOe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function lZ(t){var e=ii(t,jOe),n=pRe(),r=xke(),i=aOe(),{width:s,height:a,wrapperStyle:o,portal:l}=e,[u,d]=uY([n]),f=fO(),g=pO();if(f==null||g==null)return null;var m=f-(i?.left||0)-(i?.right||0),x=OOe(e.layout,a,s,m),y=l?o:Nm(Nm({position:"absolute",width:x?.width||s||"auto",height:x?.height||a||"auto"},POe(o,e,i,f,g,u)),o),v=l??r;if(v==null||n==null)return null;var b=M.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},M.createElement(ROe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!l&&M.createElement(DOe,{width:u.width,height:u.height}),M.createElement(kOe,wP({},e,x,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return ic.createPortal(b,v)}lZ.displayName="Legend";function SP(){return SP=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},SP.apply(null,arguments)}function e$(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 uN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?e$(Object(n),!0).forEach(function(r){LOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LOe(t,e,n){return(e=IOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function IOe(t){var e=UOe(t,"string");return typeof e=="symbol"?e:e+""}function UOe(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 FOe(t){return Array.isArray(t)&&fl(t[0])&&fl(t[1])?t.join(" ~ "):t}var zOe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:s,formatter:a,itemSorter:o,wrapperClassName:l,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:g=!1}=t,m=()=>{if(s&&s.length){var T={padding:0,margin:0},P=(o?rE(s,o):s).map((C,I)=>{if(C.type==="none")return null;var N=C.formatter||a||FOe,{value:D,name:F}=C,L=D,q=F;if(N){var R=N(D,F,C,I,s);if(Array.isArray(R))[L,q]=R;else if(R!=null)L=R;else return null}var V=uN({display:"block",paddingTop:4,paddingBottom:4,color:C.color||"#000"},r);return M.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(I),style:V},fl(q)?M.createElement("span",{className:"recharts-tooltip-item-name"},q):null,fl(q)?M.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,M.createElement("span",{className:"recharts-tooltip-item-value"},L),M.createElement("span",{className:"recharts-tooltip-item-unit"},C.unit||""))});return M.createElement("ul",{className:"recharts-tooltip-item-list",style:T},P)}return null},x=uN({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=uN({margin:0},i),v=!yr(d),b=v?d:"",E=Tn("recharts-default-tooltip",l),S=Tn("recharts-tooltip-label",u);v&&f&&s!==void 0&&s!==null&&(b=f(d,s));var A=g?{role:"status","aria-live":"assertive"}:{};return M.createElement("div",SP({className:E,style:x},A),M.createElement("p",{className:S,style:y},M.isValidElement(b)?b:"".concat(b)),m())},fx="recharts-tooltip-wrapper",BOe={visibility:"hidden"};function HOe(t){var{coordinate:e,translateX:n,translateY:r}=t;return Tn(fx,{["".concat(fx,"-right")]:Ct(n)&&e&&Ct(e.x)&&n>=e.x,["".concat(fx,"-left")]:Ct(n)&&e&&Ct(e.x)&&n<e.x,["".concat(fx,"-bottom")]:Ct(r)&&e&&Ct(e.y)&&r>=e.y,["".concat(fx,"-top")]:Ct(r)&&e&&Ct(e.y)&&r<e.y})}function t$(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:s,reverseDirection:a,tooltipDimension:o,viewBox:l,viewBoxDimension:u}=t;if(s&&Ct(s[r]))return s[r];var d=n[r]-o-(i>0?i:0),f=n[r]+i;if(e[r])return a[r]?d:f;var g=l[r];if(g==null)return 0;if(a[r]){var m=d,x=g;return m<x?Math.max(f,g):Math.max(d,g)}if(u==null)return 0;var y=f+o,v=g+u;return y>v?Math.max(d,g):Math.max(f,g)}function $Oe(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 VOe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:s,tooltipBox:a,useTranslate3d:o,viewBox:l}=t,u,d,f;return a.height>0&&a.width>0&&n?(d=t$({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:a.width,viewBox:l,viewBoxDimension:l.width}),f=t$({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:a.height,viewBox:l,viewBoxDimension:l.height}),u=$Oe({translateX:d,translateY:f,useTranslate3d:o})):u=BOe,{cssProperties:u,cssClasses:HOe({translateX:d,translateY:f,coordinate:n})}}function n$(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 __(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n$(Object(n),!0).forEach(function(r){EP(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function EP(t,e,n){return(e=GOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GOe(t){var e=WOe(t,"string");return typeof e=="symbol"?e:e+""}function WOe(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 qOe extends M.PureComponent{constructor(){super(...arguments),EP(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),EP(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,s;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(s=this.props.coordinate)===null||s===void 0?void 0:s.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:s,coordinate:a,hasPayload:o,isAnimationActive:l,offset:u,position:d,reverseDirection:f,useTranslate3d:g,viewBox:m,wrapperStyle:x,lastBoundingBox:y,innerRef:v,hasPortalFromProps:b}=this.props,{cssClasses:E,cssProperties:S}=VOe({allowEscapeViewBox:n,coordinate:a,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:g,viewBox:m}),A=b?{}:__(__({transition:l&&e?"transform ".concat(r,"ms ").concat(i):void 0},S),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&o?"visible":"hidden",position:"absolute",top:0,left:0}),T=__(__({},A),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},x);return M.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:E,style:T,ref:v},s)}}var cZ=()=>{var t;return(t=kt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function MP(){return MP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},MP.apply(null,arguments)}function r$(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 i$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r$(Object(n),!0).forEach(function(r){KOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KOe(t,e,n){return(e=XOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XOe(t){var e=YOe(t,"string");return typeof e=="symbol"?e:e+""}function YOe(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 s$={curveBasisClosed:Lke,curveBasisOpen:Ike,curveBasis:jke,curveBumpX:_ke,curveBumpY:wke,curveLinearClosed:Uke,curveLinear:tE,curveMonotoneX:Fke,curveMonotoneY:zke,curveNatural:Bke,curveStep:Hke,curveStepAfter:Vke,curveStepBefore:$ke},Ow=t=>ur(t.x)&&ur(t.y),a$=t=>t.base!=null&&Ow(t.base)&&Ow(t),px=t=>t.x,mx=t=>t.y,ZOe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(mb(t));return(n==="curveMonotone"||n==="curveBump")&&e?s$["".concat(n).concat(e==="vertical"?"Y":"X")]:s$[n]||tE},QOe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,a=ZOe(e,i),o=s?n.filter(Ow):n,l;if(Array.isArray(r)){var u=n.map((m,x)=>i$(i$({},m),{},{base:r[x]}));i==="vertical"?l=f_().y(mx).x1(px).x0(m=>m.base.x):l=f_().x(px).y1(mx).y0(m=>m.base.y);var d=l.defined(a$).curve(a),f=s?u.filter(a$):u;return d(f)}i==="vertical"&&Ct(r)?l=f_().y(mx).x1(px).x0(r):Ct(r)?l=f_().x(px).y1(mx).y0(r):l=OX().x(px).y(mx);var g=l.defined(Ow).curve(a);return g(o)},em=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var s=n&&n.length?QOe(t):r;return M.createElement("path",MP({},Ks(t),eO(t),{className:Tn("recharts-curve",e),d:s===null?void 0:s,ref:i}))},JOe=["x","y","top","left","width","height","className"];function AP(){return AP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},AP.apply(null,arguments)}function o$(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 eje(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o$(Object(n),!0).forEach(function(r){tje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tje(t,e,n){return(e=nje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nje(t){var e=rje(t,"string");return typeof e=="symbol"?e:e+""}function rje(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 ije(t,e){if(t==null)return{};var n,r,i=sje(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function sje(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 aje=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),oje=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:a=0,className:o}=t,l=ije(t,JOe),u=eje({x:e,y:n,top:r,left:i,width:s,height:a},l);return!Ct(e)||!Ct(n)||!Ct(s)||!Ct(a)||!Ct(r)||!Ct(i)?null:M.createElement("path",AP({},Cs(u),{className:Tn("recharts-cross",o),d:aje(e,n,s,a,r,i)}))};function lje(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 l$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function c$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l$(Object(n),!0).forEach(function(r){cje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cje(t,e,n){return(e=uje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uje(t){var e=dje(t,"string");return typeof e=="symbol"?e:e+""}function dje(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 hje=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),uZ=(t,e,n)=>t.map(r=>"".concat(hje(r)," ").concat(e,"ms ").concat(n)).join(","),fje=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),G0=(t,e)=>Object.keys(e).reduce((n,r)=>c$(c$({},n),{},{[r]:t(r,e[r])}),{});function u$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ci(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?u$(Object(n),!0).forEach(function(r){pje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pje(t,e,n){return(e=mje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mje(t){var e=gje(t,"string");return typeof e=="symbol"?e:e+""}function gje(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 jw=(t,e,n)=>t+(e-t)*n,TP=t=>{var{from:e,to:n}=t;return e!==n},dZ=(t,e,n)=>{var r=G0((i,s)=>{if(TP(s)){var[a,o]=t(s.from,s.to,s.velocity);return ci(ci({},s),{},{from:a,velocity:o})}return s},e);return n<1?G0((i,s)=>TP(s)?ci(ci({},s),{},{velocity:jw(s.velocity,r[i].velocity,n),from:jw(s.from,r[i].from,n)}):s,e):dZ(t,r,n-1)};function xje(t,e,n,r,i,s){var a,o=r.reduce((g,m)=>ci(ci({},g),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),l=()=>G0((g,m)=>m.from,o),u=()=>!Object.values(o).filter(TP).length,d=null,f=g=>{a||(a=g);var m=g-a,x=m/n.dt;o=dZ(n,o,x),i(ci(ci(ci({},t),e),l())),a=g,u()||(d=s.setTimeout(f))};return()=>(d=s.setTimeout(f),()=>{var g;(g=d)===null||g===void 0||g()})}function bje(t,e,n,r,i,s,a){var o=null,l=i.reduce((f,g)=>ci(ci({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,m=G0((y,v)=>jw(...v,n(g)),l);if(s(ci(ci(ci({},t),e),m)),g<1)o=a.setTimeout(d);else{var x=G0((y,v)=>jw(...v,n(1)),l);s(ci(ci(ci({},t),e),x))}};return()=>(o=a.setTimeout(d),()=>{var f;(f=o)===null||f===void 0||f()})}const vje=(t,e,n,r,i,s)=>{var a=fje(t,e);return n==null?()=>(i(ci(ci({},t),e)),()=>{}):n.isStepper===!0?xje(t,e,n,a,i,s):bje(t,e,n,r,a,i,s)};var Lw=1e-4,hZ=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],fZ=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),d$=(t,e)=>n=>{var r=hZ(t,e);return fZ(r,n)},yje=(t,e)=>n=>{var r=hZ(t,e),i=[...r.map((s,a)=>s*a).slice(1),0];return fZ(i,n)},_je=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,s=n[0].split("(");if(s[0]==="cubic-bezier"&&((i=s[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var a=s[1].split(")")[0].split(",").map(o=>parseFloat(o));return[a[0],a[1],a[2],a[3]]}}}return n.length===4?n:[0,0,1,1]},wje=(t,e,n,r)=>{var i=d$(t,n),s=d$(e,r),a=yje(t,n),o=u=>u>1?1:u<0?0:u,l=u=>{for(var d=u>1?1:u,f=d,g=0;g<8;++g){var m=i(f)-d,x=a(f);if(Math.abs(m-d)<Lw||x<Lw)return s(f);f=o(f-m/x)}return s(f)};return l.isStepper=!1,l},h$=function(){return wje(..._je(...arguments))},Sje=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,s=(a,o,l)=>{var u=-(a-o)*n,d=l*r,f=l+(u-d)*i/1e3,g=l*i/1e3+a;return Math.abs(g-o)<Lw&&Math.abs(f)<Lw?[o,0]:[g,f]};return s.isStepper=!0,s.dt=i,s},Eje=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return h$(t);case"spring":return Sje();default:if(t.split("(")[0]==="cubic-bezier")return h$(t)}return typeof t=="function"?t:null};function Mje(t){var e,n=()=>null,r=!1,i=null,s=a=>{if(!r){if(Array.isArray(a)){if(!a.length)return;var o=a,[l,...u]=o;if(typeof l=="number"){i=t.setTimeout(s.bind(null,u),l);return}s(l),i=t.setTimeout(s.bind(null,u));return}typeof a=="string"&&(e=a,n(e)),typeof a=="object"&&(e=a,n(e)),typeof a=="function"&&a()}};return{stop:()=>{r=!0},start:a=>{r=!1,i&&(i(),i=null),s(a)},subscribe:a=>(n=a,()=>{n=()=>null}),getTimeoutController:()=>t}}class Aje{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,s=a=>{a-r>=n?e(a):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(s))};return i=requestAnimationFrame(s),()=>{i!=null&&cancelAnimationFrame(i)}}}function Tje(){return Mje(new Aje)}var Cje=M.createContext(Tje);function Nje(t,e){var n=M.useContext(Cje);return M.useMemo(()=>e??n(t),[t,e,n])}var kje=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Xm={devToolsEnabled:!1,isSsr:kje()},Pje={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},f$={t:0},dN={t:1};function Sb(t){var e=ii(t,Pje),{isActive:n,canBegin:r,duration:i,easing:s,begin:a,onAnimationEnd:o,onAnimationStart:l,children:u}=e,d=n==="auto"?!Xm.isSsr:n,f=Nje(e.animationId,e.animationManager),[g,m]=M.useState(d?f$:dN),x=M.useRef(null);return M.useEffect(()=>{d||m(dN)},[d]),M.useEffect(()=>{if(!d||!r)return gb;var y=vje(f$,dN,Eje(s),i,m,f.getTimeoutController()),v=()=>{x.current=y()};return f.start([l,a,v,i,o]),()=>{f.stop(),x.current&&x.current(),o()}},[d,r,i,s,a,l,o,f]),u(g.t)}function Eb(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=M.useRef(U0(e)),r=M.useRef(t);return r.current!==t&&(n.current=U0(e),r.current=t),n.current}var Rje=["radius"],Dje=["radius"];function p$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function m$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p$(Object(n),!0).forEach(function(r){Oje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Oje(t,e,n){return(e=jje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jje(t){var e=Lje(t,"string");return typeof e=="symbol"?e:e+""}function Lje(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 Iw(){return Iw=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},Iw.apply(null,arguments)}function g$(t,e){if(t==null)return{};var n,r,i=Ije(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ije(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 x$=(t,e,n,r,i)=>{var s=Math.min(Math.abs(n)/2,Math.abs(r)/2),a=r>=0?1:-1,o=n>=0?1:-1,l=r>=0&&n>=0||r<0&&n<0?1:0,u;if(s>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,g=4;f<g;f++)d[f]=i[f]>s?s:i[f];u="M".concat(t,",").concat(e+a*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(l,",").concat(t+o*d[0],",").concat(e)),u+="L ".concat(t+n-o*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(l,`,
- `).concat(t+n,",").concat(e+a*d[1])),u+="L ".concat(t+n,",").concat(e+r-a*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(l,`,
- `).concat(t+n-o*d[2],",").concat(e+r)),u+="L ".concat(t+o*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(l,`,
- `).concat(t,",").concat(e+r-a*d[3])),u+="Z"}else if(s>0&&i===+i&&i>0){var m=Math.min(s,i);u="M ".concat(t,",").concat(e+a*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+o*m,",").concat(e,`
- L `).concat(t+n-o*m,",").concat(e,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n,",").concat(e+a*m,`
- L `).concat(t+n,",").concat(e+r-a*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n-o*m,",").concat(e+r,`
- L `).concat(t+o*m,",").concat(e+r,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t,",").concat(e+r-a*m," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},b$={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},pZ=t=>{var e=ii(t,b$),n=M.useRef(null),[r,i]=M.useState(-1);M.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var W=n.current.getTotalLength();W&&i(W)}catch{}},[]);var{x:s,y:a,width:o,height:l,radius:u,className:d}=e,{animationEasing:f,animationDuration:g,animationBegin:m,isAnimationActive:x,isUpdateAnimationActive:y}=e,v=M.useRef(o),b=M.useRef(l),E=M.useRef(s),S=M.useRef(a),A=M.useMemo(()=>({x:s,y:a,width:o,height:l,radius:u}),[s,a,o,l,u]),T=Eb(A,"rectangle-");if(s!==+s||a!==+a||o!==+o||l!==+l||o===0||l===0)return null;var P=Tn("recharts-rectangle",d);if(!y){var C=Cs(e),{radius:I}=C,N=g$(C,Rje);return M.createElement("path",Iw({},N,{radius:typeof u=="number"?u:void 0,className:P,d:x$(s,a,o,l,u)}))}var D=v.current,F=b.current,L=E.current,q=S.current,R="0px ".concat(r===-1?1:r,"px"),V="".concat(r,"px 0px"),K=uZ(["strokeDasharray"],g,typeof f=="string"?f:b$.animationEasing);return M.createElement(Sb,{animationId:T,key:T,canBegin:r>0,duration:g,easing:f,isActive:y,begin:m},W=>{var ne=cr(D,o,W),Y=cr(F,l,W),Z=cr(L,s,W),U=cr(q,a,W);n.current&&(v.current=ne,b.current=Y,E.current=Z,S.current=U);var $;x?W>0?$={transition:K,strokeDasharray:V}:$={strokeDasharray:R}:$={strokeDasharray:V};var ee=Cs(e),{radius:ae}=ee,fe=g$(ee,Dje);return M.createElement("path",Iw({},fe,{radius:typeof u=="number"?u:void 0,className:P,d:x$(Z,U,ne,Y,u),ref:n,style:m$(m$({},$),e.style)}))})};function v$(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 y$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v$(Object(n),!0).forEach(function(r){Uje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Uje(t,e,n){return(e=Fje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Fje(t){var e=zje(t,"string");return typeof e=="symbol"?e:e+""}function zje(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 Uw=Math.PI/180,Bje=t=>t*180/Math.PI,Yr=(t,e,n,r)=>({x:t+Math.cos(-Uw*r)*n,y:e+Math.sin(-Uw*r)*n}),mZ=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},Hje=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},$je=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,a=Hje({x:n,y:r},{x:i,y:s});if(a<=0)return{radius:a,angle:0};var o=(n-i)/a,l=Math.acos(o);return r>s&&(l=2*Math.PI-l),{radius:a,angle:Bje(l),angleInRadian:l}},Vje=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),s=Math.min(r,i);return{startAngle:e-s*360,endAngle:n-s*360}},Gje=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),s=Math.floor(r/360),a=Math.min(i,s);return t+a*360},Wje=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=$je({x:n,y:r},e),{innerRadius:a,outerRadius:o}=e;if(i<a||i>o||i===0)return null;var{startAngle:l,endAngle:u}=Vje(e),d=s,f;if(l<=u){for(;d>u;)d-=360;for(;d<l;)d+=360;f=d>=l&&d<=u}else{for(;d>l;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=l}return f?y$(y$({},e),{},{radius:i,angle:Gje(d,e)}):null};function gZ(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,a=Yr(e,n,r,i),o=Yr(e,n,r,s);return{points:[a,o],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}function CP(){return CP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},CP.apply(null,arguments)}var qje=(t,e)=>{var n=Di(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},w_=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:a,cornerRadius:o,cornerIsExternal:l}=t,u=o*(a?1:-1)+r,d=Math.asin(o/u)/Uw,f=l?i:i+s*d,g=Yr(e,n,u,f),m=Yr(e,n,r,f),x=l?i-s*d:i,y=Yr(e,n,u*Math.cos(d*Uw),x);return{center:g,circleTangency:m,lineTangency:y,theta:d}},xZ=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:a}=t,o=qje(s,a),l=s+o,u=Yr(e,n,i,s),d=Yr(e,n,i,l),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(o)>180),",").concat(+(s>l),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var g=Yr(e,n,r,s),m=Yr(e,n,r,l);f+="L ".concat(m.x,",").concat(m.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(o)>180),",").concat(+(s<=l),`,
- `).concat(g.x,",").concat(g.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},Kje=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:a,cornerIsExternal:o,startAngle:l,endAngle:u}=t,d=Di(u-l),{circleTangency:f,lineTangency:g,theta:m}=w_({cx:e,cy:n,radius:i,angle:l,sign:d,cornerRadius:s,cornerIsExternal:o}),{circleTangency:x,lineTangency:y,theta:v}=w_({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:s,cornerIsExternal:o}),b=o?Math.abs(l-u):Math.abs(l-u)-m-v;if(b<0)return a?"M ".concat(g.x,",").concat(g.y,`
- a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0
- a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0
- `):xZ({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:l,endAngle:u});var E="M ".concat(g.x,",").concat(g.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(b>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
- `);if(r>0){var{circleTangency:S,lineTangency:A,theta:T}=w_({cx:e,cy:n,radius:r,angle:l,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),{circleTangency:P,lineTangency:C,theta:I}=w_({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),N=o?Math.abs(l-u):Math.abs(l-u)-T-I;if(N<0&&s===0)return"".concat(E,"L").concat(e,",").concat(n,"Z");E+="L".concat(C.x,",").concat(C.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(P.x,",").concat(P.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(N>180),",").concat(+(d>0),",").concat(S.x,",").concat(S.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else E+="L".concat(e,",").concat(n,"Z");return E},Xje={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},bZ=t=>{var e=ii(t,Xje),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:u,endAngle:d,className:f}=e;if(s<i||u===d)return null;var g=Tn("recharts-sector",f),m=s-i,x=hs(a,m,0,!0),y;return x>0&&Math.abs(u-d)<360?y=Kje({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(x,m/2),forceCornerRadius:o,cornerIsExternal:l,startAngle:u,endAngle:d}):y=xZ({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:u,endAngle:d}),M.createElement("path",CP({},Cs(e),{className:g,d:y}))};function Yje(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(XX(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:a,angle:o}=e,l=Yr(r,i,s,o),u=Yr(r,i,a,o);return[{x:l.x,y:l.y},{x:u.x,y:u.y}]}return gZ(e)}}var hN={},fN={},pN={},_$;function Zje(){return _$||(_$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oY();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(pN)),pN}var w$;function Qje(){return w$||(w$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Zje();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})(fN)),fN}var S$;function Jje(){return S$||(S$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lY(),n=Qje();function r(i,s,a){a&&typeof a!="number"&&e.isIterateeCall(i,s,a)&&(s=a=void 0),i=n.toFinite(i),s===void 0?(s=i,i=0):s=n.toFinite(s),a=a===void 0?i<s?1:-1:n.toFinite(a);const o=Math.max(Math.ceil((s-i)/(a||1)),0),l=new Array(o);for(let u=0;u<o;u++)l[u]=i,i+=a;return l}t.range=r})(hN)),hN}var mN,E$;function eLe(){return E$||(E$=1,mN=Jje().range),mN}var tLe=eLe();const vZ=oo(tLe);function Yu(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function nLe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function xO(t){let e,n,r;t.length!==2?(e=Yu,n=(o,l)=>Yu(t(o),l),r=(o,l)=>t(o)-l):(e=t===Yu||t===nLe?t:rLe,n=t,r=t);function i(o,l,u=0,d=o.length){if(u<d){if(e(l,l)!==0)return d;do{const f=u+d>>>1;n(o[f],l)<0?u=f+1:d=f}while(u<d)}return u}function s(o,l,u=0,d=o.length){if(u<d){if(e(l,l)!==0)return d;do{const f=u+d>>>1;n(o[f],l)<=0?u=f+1:d=f}while(u<d)}return u}function a(o,l,u=0,d=o.length){const f=i(o,l,u,d-1);return f>u&&r(o[f-1],l)>-r(o[f],l)?f-1:f}return{left:i,center:a,right:s}}function rLe(){return 0}function yZ(t){return t===null?NaN:+t}function*iLe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const sLe=xO(Yu),Mb=sLe.right;xO(yZ).center;class M$ extends Map{constructor(e,n=lLe){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(A$(this,e))}has(e){return super.has(A$(this,e))}set(e,n){return super.set(aLe(this,e),n)}delete(e){return super.delete(oLe(this,e))}}function A$({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function aLe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function oLe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function lLe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function cLe(t=Yu){if(t===Yu)return _Z;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 _Z(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const uLe=Math.sqrt(50),dLe=Math.sqrt(10),hLe=Math.sqrt(2);function Fw(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),a=s>=uLe?10:s>=dLe?5:s>=hLe?2:1;let o,l,u;return i<0?(u=Math.pow(10,-i)/a,o=Math.round(t*u),l=Math.round(e*u),o/u<t&&++o,l/u>e&&--l,u=-u):(u=Math.pow(10,i)*a,o=Math.round(t/u),l=Math.round(e/u),o*u<t&&++o,l*u>e&&--l),l<o&&.5<=n&&n<2?Fw(t,e,n*2):[o,l,u]}function NP(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,s,a]=r?Fw(e,t,n):Fw(t,e,n);if(!(s>=i))return[];const o=s-i+1,l=new Array(o);if(r)if(a<0)for(let u=0;u<o;++u)l[u]=(s-u)/-a;else for(let u=0;u<o;++u)l[u]=(s-u)*a;else if(a<0)for(let u=0;u<o;++u)l[u]=(i+u)/-a;else for(let u=0;u<o;++u)l[u]=(i+u)*a;return l}function kP(t,e,n){return e=+e,t=+t,n=+n,Fw(t,e,n)[2]}function PP(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?kP(e,t,n):kP(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function T$(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function C$(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function wZ(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?_Z:cLe(i);r>n;){if(r-n>600){const l=r-n+1,u=e-n+1,d=Math.log(l),f=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*f*(l-f)/l)*(u-l/2<0?-1:1),m=Math.max(n,Math.floor(e-u*f/l+g)),x=Math.min(r,Math.floor(e+(l-u)*f/l+g));wZ(t,e,m,x,i)}const s=t[e];let a=n,o=r;for(gx(t,n,e),i(t[r],s)>0&&gx(t,n,r);a<o;){for(gx(t,a,o),++a,--o;i(t[a],s)<0;)++a;for(;i(t[o],s)>0;)--o}i(t[n],s)===0?gx(t,n,o):(++o,gx(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function gx(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function fLe(t,e,n){if(t=Float64Array.from(iLe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return C$(t);if(e>=1)return T$(t);var r,i=(r-1)*e,s=Math.floor(i),a=T$(wZ(t,s).subarray(0,s+1)),o=C$(t.subarray(s+1));return a+(o-a)*(i-s)}}function pLe(t,e,n=yZ){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,s=Math.floor(i),a=+n(t[s],s,t),o=+n(t[s+1],s+1,t);return a+(o-a)*(i-s)}}function mLe(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,s=new Array(i);++r<i;)s[r]=t+r*n;return s}function lo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Dc(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 RP=Symbol("implicit");function bO(){var t=new M$,e=[],n=[],r=RP;function i(s){let a=t.get(s);if(a===void 0){if(r!==RP)return r;t.set(s,a=e.push(s)-1)}return n[a%n.length]}return i.domain=function(s){if(!arguments.length)return e.slice();e=[],t=new M$;for(const a of s)t.has(a)||t.set(a,e.push(a)-1);return i},i.range=function(s){return arguments.length?(n=Array.from(s),i):n.slice()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return bO(e,n).unknown(r)},lo.apply(i,arguments),i}function vO(){var t=bO().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,s,a,o=!1,l=0,u=0,d=.5;delete t.unknown;function f(){var g=e().length,m=i<r,x=m?i:r,y=m?r:i;s=(y-x)/Math.max(1,g-l+u*2),o&&(s=Math.floor(s)),x+=(y-x-s*(g-l))*d,a=s*(1-l),o&&(x=Math.round(x),a=Math.round(a));var v=mLe(g).map(function(b){return x+s*b});return n(m?v.reverse():v)}return t.domain=function(g){return arguments.length?(e(g),f()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,o=!0,f()},t.bandwidth=function(){return a},t.step=function(){return s},t.round=function(g){return arguments.length?(o=!!g,f()):o},t.padding=function(g){return arguments.length?(l=Math.min(1,u=+g),f()):l},t.paddingInner=function(g){return arguments.length?(l=Math.min(1,g),f()):l},t.paddingOuter=function(g){return arguments.length?(u=+g,f()):u},t.align=function(g){return arguments.length?(d=Math.max(0,Math.min(1,g)),f()):d},t.copy=function(){return vO(e(),[r,i]).round(o).paddingInner(l).paddingOuter(u).align(d)},lo.apply(f(),arguments)}function SZ(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return SZ(e())},t}function gLe(){return SZ(vO.apply(null,arguments).paddingInner(1))}function yO(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function EZ(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Ab(){}var W0=.7,zw=1/W0,tm="\\s*([+-]?\\d+)\\s*",q0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ol="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xLe=/^#([0-9a-f]{3,8})$/,bLe=new RegExp(`^rgb\\(${tm},${tm},${tm}\\)$`),vLe=new RegExp(`^rgb\\(${ol},${ol},${ol}\\)$`),yLe=new RegExp(`^rgba\\(${tm},${tm},${tm},${q0}\\)$`),_Le=new RegExp(`^rgba\\(${ol},${ol},${ol},${q0}\\)$`),wLe=new RegExp(`^hsl\\(${q0},${ol},${ol}\\)$`),SLe=new RegExp(`^hsla\\(${q0},${ol},${ol},${q0}\\)$`),N$={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};yO(Ab,K0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:k$,formatHex:k$,formatHex8:ELe,formatHsl:MLe,formatRgb:P$,toString:P$});function k$(){return this.rgb().formatHex()}function ELe(){return this.rgb().formatHex8()}function MLe(){return MZ(this).formatHsl()}function P$(){return this.rgb().formatRgb()}function K0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=xLe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?R$(e):n===3?new Hs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?S_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?S_(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=bLe.exec(t))?new Hs(e[1],e[2],e[3],1):(e=vLe.exec(t))?new Hs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=yLe.exec(t))?S_(e[1],e[2],e[3],e[4]):(e=_Le.exec(t))?S_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=wLe.exec(t))?j$(e[1],e[2]/100,e[3]/100,1):(e=SLe.exec(t))?j$(e[1],e[2]/100,e[3]/100,e[4]):N$.hasOwnProperty(t)?R$(N$[t]):t==="transparent"?new Hs(NaN,NaN,NaN,0):null}function R$(t){return new Hs(t>>16&255,t>>8&255,t&255,1)}function S_(t,e,n,r){return r<=0&&(t=e=n=NaN),new Hs(t,e,n,r)}function ALe(t){return t instanceof Ab||(t=K0(t)),t?(t=t.rgb(),new Hs(t.r,t.g,t.b,t.opacity)):new Hs}function DP(t,e,n,r){return arguments.length===1?ALe(t):new Hs(t,e,n,r??1)}function Hs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}yO(Hs,DP,EZ(Ab,{brighter(t){return t=t==null?zw:Math.pow(zw,t),new Hs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?W0:Math.pow(W0,t),new Hs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Hs(Mh(this.r),Mh(this.g),Mh(this.b),Bw(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:D$,formatHex:D$,formatHex8:TLe,formatRgb:O$,toString:O$}));function D$(){return`#${uh(this.r)}${uh(this.g)}${uh(this.b)}`}function TLe(){return`#${uh(this.r)}${uh(this.g)}${uh(this.b)}${uh((isNaN(this.opacity)?1:this.opacity)*255)}`}function O$(){const t=Bw(this.opacity);return`${t===1?"rgb(":"rgba("}${Mh(this.r)}, ${Mh(this.g)}, ${Mh(this.b)}${t===1?")":`, ${t})`}`}function Bw(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Mh(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function uh(t){return t=Mh(t),(t<16?"0":"")+t.toString(16)}function j$(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Ao(t,e,n,r)}function MZ(t){if(t instanceof Ao)return new Ao(t.h,t.s,t.l,t.opacity);if(t instanceof Ab||(t=K0(t)),!t)return new Ao;if(t instanceof Ao)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(e===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-e)/o+2:a=(e-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new Ao(a,o,l,t.opacity)}function CLe(t,e,n,r){return arguments.length===1?MZ(t):new Ao(t,e,n,r??1)}function Ao(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}yO(Ao,CLe,EZ(Ab,{brighter(t){return t=t==null?zw:Math.pow(zw,t),new Ao(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?W0:Math.pow(W0,t),new Ao(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 Hs(gN(t>=240?t-240:t+120,i,r),gN(t,i,r),gN(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Ao(L$(this.h),E_(this.s),E_(this.l),Bw(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=Bw(this.opacity);return`${t===1?"hsl(":"hsla("}${L$(this.h)}, ${E_(this.s)*100}%, ${E_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function L$(t){return t=(t||0)%360,t<0?t+360:t}function E_(t){return Math.max(0,Math.min(1,t||0))}function gN(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 _O=t=>()=>t;function NLe(t,e){return function(n){return t+n*e}}function kLe(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 PLe(t){return(t=+t)==1?AZ:function(e,n){return n-e?kLe(e,n,t):_O(isNaN(e)?n:e)}}function AZ(t,e){var n=e-t;return n?NLe(t,n):_O(isNaN(t)?e:t)}const I$=(function t(e){var n=PLe(e);function r(i,s){var a=n((i=DP(i)).r,(s=DP(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),u=AZ(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function RLe(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=t[i]*(1-s)+e[i]*s;return r}}function DLe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function OLe(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),s=new Array(n),a;for(a=0;a<r;++a)i[a]=Ym(t[a],e[a]);for(;a<n;++a)s[a]=e[a];return function(o){for(a=0;a<r;++a)s[a]=i[a](o);return s}}function jLe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Hw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function LLe(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]=Ym(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var OP=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xN=new RegExp(OP.source,"g");function ILe(t){return function(){return t}}function ULe(t){return function(e){return t(e)+""}}function FLe(t,e){var n=OP.lastIndex=xN.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(t=t+"",e=e+"";(r=OP.exec(t))&&(i=xN.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:Hw(r,i)})),n=xN.lastIndex;return n<e.length&&(s=e.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?ULe(l[0].x):ILe(e):(e=l.length,function(u){for(var d=0,f;d<e;++d)o[(f=l[d]).i]=f.x(u);return o.join("")})}function Ym(t,e){var n=typeof e,r;return e==null||n==="boolean"?_O(e):(n==="number"?Hw:n==="string"?(r=K0(e))?(e=r,I$):FLe:e instanceof K0?I$:e instanceof Date?jLe:DLe(e)?RLe:Array.isArray(e)?OLe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?LLe:Hw)(t,e)}function wO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function zLe(t,e){e===void 0&&(e=t,t=Ym);for(var n=0,r=e.length-1,i=e[0],s=new Array(r<0?0:r);n<r;)s[n]=t(i,i=e[++n]);return function(a){var o=Math.max(0,Math.min(r-1,Math.floor(a*=r)));return s[o](a-o)}}function BLe(t){return function(){return t}}function $w(t){return+t}var U$=[0,1];function Ss(t){return t}function jP(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:BLe(isNaN(e)?NaN:.5)}function HLe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function $Le(t,e,n){var r=t[0],i=t[1],s=e[0],a=e[1];return i<r?(r=jP(i,r),s=n(a,s)):(r=jP(r,i),s=n(s,a)),function(o){return s(r(o))}}function VLe(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r),a=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++a<r;)i[a]=jP(t[a],t[a+1]),s[a]=n(e[a],e[a+1]);return function(o){var l=Mb(t,o,1,r)-1;return s[l](i[l](o))}}function Tb(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function _E(){var t=U$,e=U$,n=Ym,r,i,s,a=Ss,o,l,u;function d(){var g=Math.min(t.length,e.length);return a!==Ss&&(a=HLe(t[0],t[g-1])),o=g>2?VLe:$Le,l=u=null,f}function f(g){return g==null||isNaN(g=+g)?s:(l||(l=o(t.map(r),e,n)))(r(a(g)))}return f.invert=function(g){return a(i((u||(u=o(e,t.map(r),Hw)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,$w),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=wO,d()},f.clamp=function(g){return arguments.length?(a=g?!0:Ss,d()):a!==Ss},f.interpolate=function(g){return arguments.length?(n=g,d()):n},f.unknown=function(g){return arguments.length?(s=g,f):s},function(g,m){return r=g,i=m,d()}}function SO(){return _E()(Ss,Ss)}function GLe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Vw(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 km(t){return t=Vw(Math.abs(t)),t?t[1]:NaN}function WLe(t,e){return function(n,r){for(var i=n.length,s=[],a=0,o=t[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),s.push(n.substring(i-=o,i+o)),!((l+=o+1)>r));)o=t[a=(a+1)%t.length];return s.reverse().join(e)}}function qLe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var KLe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function X0(t){if(!(e=KLe.exec(t)))throw new Error("invalid format: "+t);var e;return new EO({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]})}X0.prototype=EO.prototype;function EO(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+""}EO.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 XLe(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 TZ;function YLe(t,e){var n=Vw(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(TZ=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=r.length;return s===a?r:s>a?r+new Array(s-a+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+Vw(t,Math.max(0,e+s-1))[0]}function F$(t,e){var n=Vw(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 z$={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:GLe,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)=>F$(t*100,e),r:F$,s:YLe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function B$(t){return t}var H$=Array.prototype.map,$$=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ZLe(t){var e=t.grouping===void 0||t.thousands===void 0?B$:WLe(H$.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",s=t.numerals===void 0?B$:qLe(H$.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function u(f){f=X0(f);var g=f.fill,m=f.align,x=f.sign,y=f.symbol,v=f.zero,b=f.width,E=f.comma,S=f.precision,A=f.trim,T=f.type;T==="n"?(E=!0,T="g"):z$[T]||(S===void 0&&(S=12),A=!0,T="g"),(v||g==="0"&&m==="=")&&(v=!0,g="0",m="=");var P=y==="$"?n:y==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",C=y==="$"?r:/[%p]/.test(T)?a:"",I=z$[T],N=/[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 L=P,q=C,R,V,K;if(T==="c")q=I(F)+q,F="";else{F=+F;var W=F<0||1/F<0;if(F=isNaN(F)?l:I(Math.abs(F),S),A&&(F=XLe(F)),W&&+F==0&&x!=="+"&&(W=!1),L=(W?x==="("?x:o:x==="-"||x==="("?"":x)+L,q=(T==="s"?$$[8+TZ/3]:"")+q+(W&&x==="("?")":""),N){for(R=-1,V=F.length;++R<V;)if(K=F.charCodeAt(R),48>K||K>57){q=(K===46?i+F.slice(R+1):F.slice(R))+q,F=F.slice(0,R);break}}}E&&!v&&(F=e(F,1/0));var ne=L.length+F.length+q.length,Y=ne<b?new Array(b-ne+1).join(g):"";switch(E&&v&&(F=e(Y+F,Y.length?b-q.length:1/0),Y=""),m){case"<":F=L+F+q+Y;break;case"=":F=L+Y+F+q;break;case"^":F=Y.slice(0,ne=Y.length>>1)+L+F+q+Y.slice(ne);break;default:F=Y+L+F+q;break}return s(F)}return D.toString=function(){return f+""},D}function d(f,g){var m=u((f=X0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(km(g)/3)))*3,y=Math.pow(10,-x),v=$$[8+x/3];return function(b){return m(y*b)+v}}return{format:u,formatPrefix:d}}var M_,MO,CZ;QLe({thousands:",",grouping:[3],currency:["$",""]});function QLe(t){return M_=ZLe(t),MO=M_.format,CZ=M_.formatPrefix,M_}function JLe(t){return Math.max(0,-km(Math.abs(t)))}function eIe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(km(e)/3)))*3-km(Math.abs(t)))}function tIe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,km(e)-km(t))+1}function NZ(t,e,n,r){var i=PP(t,e,n),s;switch(r=X0(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=eIe(i,a))&&(r.precision=s),CZ(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=tIe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=JLe(i))&&(r.precision=s-(r.type==="%")*2);break}}return MO(r)}function xd(t){var e=t.domain;return t.ticks=function(n){var r=e();return NP(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return NZ(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,s=r.length-1,a=r[i],o=r[s],l,u,d=10;for(o<a&&(u=a,a=o,o=u,u=i,i=s,s=u);d-- >0;){if(u=kP(a,o,n),u===l)return r[i]=a,r[s]=o,e(r);if(u>0)a=Math.floor(a/u)*u,o=Math.ceil(o/u)*u;else if(u<0)a=Math.ceil(a*u)/u,o=Math.floor(o*u)/u;else break;l=u}return t},t}function kZ(){var t=SO();return t.copy=function(){return Tb(t,kZ())},lo.apply(t,arguments),xd(t)}function PZ(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,$w),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return PZ(t).unknown(e)},t=arguments.length?Array.from(t,$w):[0,1],xd(n)}function RZ(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],s=t[r],a;return s<i&&(a=n,n=r,r=a,a=i,i=s,s=a),t[n]=e.floor(i),t[r]=e.ceil(s),t}function V$(t){return Math.log(t)}function G$(t){return Math.exp(t)}function nIe(t){return-Math.log(-t)}function rIe(t){return-Math.exp(-t)}function iIe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function sIe(t){return t===10?iIe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function aIe(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 W$(t){return(e,n)=>-t(-e,n)}function AO(t){const e=t(V$,G$),n=e.domain;let r=10,i,s;function a(){return i=aIe(r),s=sIe(r),n()[0]<0?(i=W$(i),s=W$(s),t(nIe,rIe)):t(V$,G$),e}return e.base=function(o){return arguments.length?(r=+o,a()):r},e.domain=function(o){return arguments.length?(n(o),a()):n()},e.ticks=o=>{const l=n();let u=l[0],d=l[l.length-1];const f=d<u;f&&([u,d]=[d,u]);let g=i(u),m=i(d),x,y;const v=o==null?10:+o;let b=[];if(!(r%1)&&m-g<v){if(g=Math.floor(g),m=Math.ceil(m),u>0){for(;g<=m;++g)for(x=1;x<r;++x)if(y=g<0?x/s(-g):x*s(g),!(y<u)){if(y>d)break;b.push(y)}}else for(;g<=m;++g)for(x=r-1;x>=1;--x)if(y=g>0?x/s(-g):x*s(g),!(y<u)){if(y>d)break;b.push(y)}b.length*2<v&&(b=NP(u,d,v))}else b=NP(g,m,Math.min(m-g,v)).map(s);return f?b.reverse():b},e.tickFormat=(o,l)=>{if(o==null&&(o=10),l==null&&(l=r===10?"s":","),typeof l!="function"&&(!(r%1)&&(l=X0(l)).precision==null&&(l.trim=!0),l=MO(l)),o===1/0)return l;const u=Math.max(1,r*o/e.ticks().length);return d=>{let f=d/s(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?l(d):""}},e.nice=()=>n(RZ(n(),{floor:o=>s(Math.floor(i(o))),ceil:o=>s(Math.ceil(i(o)))})),e}function DZ(){const t=AO(_E()).domain([1,10]);return t.copy=()=>Tb(t,DZ()).base(t.base()),lo.apply(t,arguments),t}function q$(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function K$(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function TO(t){var e=1,n=t(q$(e),K$(e));return n.constant=function(r){return arguments.length?t(q$(e=+r),K$(e)):e},xd(n)}function OZ(){var t=TO(_E());return t.copy=function(){return Tb(t,OZ()).constant(t.constant())},lo.apply(t,arguments)}function X$(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function oIe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function lIe(t){return t<0?-t*t:t*t}function CO(t){var e=t(Ss,Ss),n=1;function r(){return n===1?t(Ss,Ss):n===.5?t(oIe,lIe):t(X$(n),X$(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},xd(e)}function NO(){var t=CO(_E());return t.copy=function(){return Tb(t,NO()).exponent(t.exponent())},lo.apply(t,arguments),t}function cIe(){return NO.apply(null,arguments).exponent(.5)}function Y$(t){return Math.sign(t)*t*t}function uIe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function jZ(){var t=SO(),e=[0,1],n=!1,r;function i(s){var a=uIe(t(s));return isNaN(a)?r:n?Math.round(a):a}return i.invert=function(s){return t.invert(Y$(s))},i.domain=function(s){return arguments.length?(t.domain(s),i):t.domain()},i.range=function(s){return arguments.length?(t.range((e=Array.from(s,$w)).map(Y$)),i):e.slice()},i.rangeRound=function(s){return i.range(s).round(!0)},i.round=function(s){return arguments.length?(n=!!s,i):n},i.clamp=function(s){return arguments.length?(t.clamp(s),i):t.clamp()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return jZ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},lo.apply(i,arguments),xd(i)}function LZ(){var t=[],e=[],n=[],r;function i(){var a=0,o=Math.max(1,e.length);for(n=new Array(o-1);++a<o;)n[a-1]=pLe(t,a/o);return s}function s(a){return a==null||isNaN(a=+a)?r:e[Mb(n,a)]}return s.invertExtent=function(a){var o=e.indexOf(a);return o<0?[NaN,NaN]:[o>0?n[o-1]:t[0],o<n.length?n[o]:t[t.length-1]]},s.domain=function(a){if(!arguments.length)return t.slice();t=[];for(let o of a)o!=null&&!isNaN(o=+o)&&t.push(o);return t.sort(Yu),i()},s.range=function(a){return arguments.length?(e=Array.from(a),i()):e.slice()},s.unknown=function(a){return arguments.length?(r=a,s):r},s.quantiles=function(){return n.slice()},s.copy=function(){return LZ().domain(t).range(e).unknown(r)},lo.apply(s,arguments)}function IZ(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function a(l){return l!=null&&l<=l?i[Mb(r,l,0,n)]:s}function o(){var l=-1;for(r=new Array(n);++l<n;)r[l]=((l+1)*e-(l-n)*t)/(n+1);return a}return a.domain=function(l){return arguments.length?([t,e]=l,t=+t,e=+e,o()):[t,e]},a.range=function(l){return arguments.length?(n=(i=Array.from(l)).length-1,o()):i.slice()},a.invertExtent=function(l){var u=i.indexOf(l);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},a.unknown=function(l){return arguments.length&&(s=l),a},a.thresholds=function(){return r.slice()},a.copy=function(){return IZ().domain([t,e]).range(i).unknown(s)},lo.apply(xd(a),arguments)}function UZ(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[Mb(t,s,0,r)]:n}return i.domain=function(s){return arguments.length?(t=Array.from(s),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(s){return arguments.length?(e=Array.from(s),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(s){var a=e.indexOf(s);return[t[a-1],t[a]]},i.unknown=function(s){return arguments.length?(n=s,i):n},i.copy=function(){return UZ().domain(t).range(e).unknown(n)},lo.apply(i,arguments)}const bN=new Date,vN=new Date;function bi(t,e,n,r){function i(s){return t(s=arguments.length===0?new Date:new Date(+s)),s}return i.floor=s=>(t(s=new Date(+s)),s),i.ceil=s=>(t(s=new Date(s-1)),e(s,1),t(s),s),i.round=s=>{const a=i(s),o=i.ceil(s);return s-a<o-s?a:o},i.offset=(s,a)=>(e(s=new Date(+s),a==null?1:Math.floor(a)),s),i.range=(s,a,o)=>{const l=[];if(s=i.ceil(s),o=o==null?1:Math.floor(o),!(s<a)||!(o>0))return l;let u;do l.push(u=new Date(+s)),e(s,o),t(s);while(u<s&&s<a);return l},i.filter=s=>bi(a=>{if(a>=a)for(;t(a),!s(a);)a.setTime(a-1)},(a,o)=>{if(a>=a)if(o<0)for(;++o<=0;)for(;e(a,-1),!s(a););else for(;--o>=0;)for(;e(a,1),!s(a););}),n&&(i.count=(s,a)=>(bN.setTime(+s),vN.setTime(+a),t(bN),t(vN),Math.floor(n(bN,vN))),i.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?i.filter(r?a=>r(a)%s===0:a=>i.count(0,a)%s===0):i)),i}const Gw=bi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Gw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?bi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Gw);Gw.range;const cc=1e3,Qa=cc*60,uc=Qa*60,Ec=uc*24,kO=Ec*7,Z$=Ec*30,yN=Ec*365,dh=bi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*cc)},(t,e)=>(e-t)/cc,t=>t.getUTCSeconds());dh.range;const PO=bi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*cc)},(t,e)=>{t.setTime(+t+e*Qa)},(t,e)=>(e-t)/Qa,t=>t.getMinutes());PO.range;const RO=bi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Qa)},(t,e)=>(e-t)/Qa,t=>t.getUTCMinutes());RO.range;const DO=bi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*cc-t.getMinutes()*Qa)},(t,e)=>{t.setTime(+t+e*uc)},(t,e)=>(e-t)/uc,t=>t.getHours());DO.range;const OO=bi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*uc)},(t,e)=>(e-t)/uc,t=>t.getUTCHours());OO.range;const Cb=bi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Qa)/Ec,t=>t.getDate()-1);Cb.range;const wE=bi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Ec,t=>t.getUTCDate()-1);wE.range;const FZ=bi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Ec,t=>Math.floor(t/Ec));FZ.range;function af(t){return bi(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*Qa)/kO)}const SE=af(0),Ww=af(1),dIe=af(2),hIe=af(3),Pm=af(4),fIe=af(5),pIe=af(6);SE.range;Ww.range;dIe.range;hIe.range;Pm.range;fIe.range;pIe.range;function of(t){return bi(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/kO)}const EE=of(0),qw=of(1),mIe=of(2),gIe=of(3),Rm=of(4),xIe=of(5),bIe=of(6);EE.range;qw.range;mIe.range;gIe.range;Rm.range;xIe.range;bIe.range;const jO=bi(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());jO.range;const LO=bi(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());LO.range;const Mc=bi(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Mc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:bi(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});Mc.range;const Ac=bi(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());Ac.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:bi(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});Ac.range;function zZ(t,e,n,r,i,s){const a=[[dh,1,cc],[dh,5,5*cc],[dh,15,15*cc],[dh,30,30*cc],[s,1,Qa],[s,5,5*Qa],[s,15,15*Qa],[s,30,30*Qa],[i,1,uc],[i,3,3*uc],[i,6,6*uc],[i,12,12*uc],[r,1,Ec],[r,2,2*Ec],[n,1,kO],[e,1,Z$],[e,3,3*Z$],[t,1,yN]];function o(u,d,f){const g=d<u;g&&([u,d]=[d,u]);const m=f&&typeof f.range=="function"?f:l(u,d,f),x=m?m.range(u,+d+1):[];return g?x.reverse():x}function l(u,d,f){const g=Math.abs(d-u)/f,m=xO(([,,v])=>v).right(a,g);if(m===a.length)return t.every(PP(u/yN,d/yN,f));if(m===0)return Gw.every(Math.max(PP(u,d,f),1));const[x,y]=a[g/a[m-1][2]<a[m][2]/g?m-1:m];return x.every(y)}return[o,l]}const[vIe,yIe]=zZ(Ac,LO,EE,FZ,OO,RO),[_Ie,wIe]=zZ(Mc,jO,SE,Cb,DO,PO);function _N(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 wN(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 xx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function SIe(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,a=t.shortDays,o=t.months,l=t.shortMonths,u=bx(i),d=vx(i),f=bx(s),g=vx(s),m=bx(a),x=vx(a),y=bx(o),v=vx(o),b=bx(l),E=vx(l),S={a:W,A:ne,b:Y,B:Z,c:null,d:rV,e:rV,f:WIe,g:n4e,G:i4e,H:$Ie,I:VIe,j:GIe,L:BZ,m:qIe,M:KIe,p:U,q:$,Q:aV,s:oV,S:XIe,u:YIe,U:ZIe,V:QIe,w:JIe,W:e4e,x:null,X:null,y:t4e,Y:r4e,Z:s4e,"%":sV},A={a:ee,A:ae,b:fe,B:ue,c:null,d:iV,e:iV,f:c4e,g:v4e,G:_4e,H:a4e,I:o4e,j:l4e,L:$Z,m:u4e,M:d4e,p:xe,q:Me,Q:aV,s:oV,S:h4e,u:f4e,U:p4e,V:m4e,w:g4e,W:x4e,x:null,X:null,y:b4e,Y:y4e,Z:w4e,"%":sV},T={a:D,A:F,b:L,B:q,c:R,d:tV,e:tV,f:FIe,g:eV,G:J$,H:nV,I:nV,j:jIe,L:UIe,m:OIe,M:LIe,p:N,q:DIe,Q:BIe,s:HIe,S:IIe,u:CIe,U:NIe,V:kIe,w:TIe,W:PIe,x:V,X:K,y:eV,Y:J$,Z:RIe,"%":zIe};S.x=P(n,S),S.X=P(r,S),S.c=P(e,S),A.x=P(n,A),A.X=P(r,A),A.c=P(e,A);function P(se,ve){return function(je){var de=[],ut=-1,H=0,z=se.length,re,G,J;for(je instanceof Date||(je=new Date(+je));++ut<z;)se.charCodeAt(ut)===37&&(de.push(se.slice(H,ut)),(G=Q$[re=se.charAt(++ut)])!=null?re=se.charAt(++ut):G=re==="e"?" ":"0",(J=ve[re])&&(re=J(je,G)),de.push(re),H=ut+1);return de.push(se.slice(H,ut)),de.join("")}}function C(se,ve){return function(je){var de=xx(1900,void 0,1),ut=I(de,se,je+="",0),H,z;if(ut!=je.length)return null;if("Q"in de)return new Date(de.Q);if("s"in de)return new Date(de.s*1e3+("L"in de?de.L:0));if(ve&&!("Z"in de)&&(de.Z=0),"p"in de&&(de.H=de.H%12+de.p*12),de.m===void 0&&(de.m="q"in de?de.q:0),"V"in de){if(de.V<1||de.V>53)return null;"w"in de||(de.w=1),"Z"in de?(H=wN(xx(de.y,0,1)),z=H.getUTCDay(),H=z>4||z===0?qw.ceil(H):qw(H),H=wE.offset(H,(de.V-1)*7),de.y=H.getUTCFullYear(),de.m=H.getUTCMonth(),de.d=H.getUTCDate()+(de.w+6)%7):(H=_N(xx(de.y,0,1)),z=H.getDay(),H=z>4||z===0?Ww.ceil(H):Ww(H),H=Cb.offset(H,(de.V-1)*7),de.y=H.getFullYear(),de.m=H.getMonth(),de.d=H.getDate()+(de.w+6)%7)}else("W"in de||"U"in de)&&("w"in de||(de.w="u"in de?de.u%7:"W"in de?1:0),z="Z"in de?wN(xx(de.y,0,1)).getUTCDay():_N(xx(de.y,0,1)).getDay(),de.m=0,de.d="W"in de?(de.w+6)%7+de.W*7-(z+5)%7:de.w+de.U*7-(z+6)%7);return"Z"in de?(de.H+=de.Z/100|0,de.M+=de.Z%100,wN(de)):_N(de)}}function I(se,ve,je,de){for(var ut=0,H=ve.length,z=je.length,re,G;ut<H;){if(de>=z)return-1;if(re=ve.charCodeAt(ut++),re===37){if(re=ve.charAt(ut++),G=T[re in Q$?ve.charAt(ut++):re],!G||(de=G(se,je,de))<0)return-1}else if(re!=je.charCodeAt(de++))return-1}return de}function N(se,ve,je){var de=u.exec(ve.slice(je));return de?(se.p=d.get(de[0].toLowerCase()),je+de[0].length):-1}function D(se,ve,je){var de=m.exec(ve.slice(je));return de?(se.w=x.get(de[0].toLowerCase()),je+de[0].length):-1}function F(se,ve,je){var de=f.exec(ve.slice(je));return de?(se.w=g.get(de[0].toLowerCase()),je+de[0].length):-1}function L(se,ve,je){var de=b.exec(ve.slice(je));return de?(se.m=E.get(de[0].toLowerCase()),je+de[0].length):-1}function q(se,ve,je){var de=y.exec(ve.slice(je));return de?(se.m=v.get(de[0].toLowerCase()),je+de[0].length):-1}function R(se,ve,je){return I(se,e,ve,je)}function V(se,ve,je){return I(se,n,ve,je)}function K(se,ve,je){return I(se,r,ve,je)}function W(se){return a[se.getDay()]}function ne(se){return s[se.getDay()]}function Y(se){return l[se.getMonth()]}function Z(se){return o[se.getMonth()]}function U(se){return i[+(se.getHours()>=12)]}function $(se){return 1+~~(se.getMonth()/3)}function ee(se){return a[se.getUTCDay()]}function ae(se){return s[se.getUTCDay()]}function fe(se){return l[se.getUTCMonth()]}function ue(se){return o[se.getUTCMonth()]}function xe(se){return i[+(se.getUTCHours()>=12)]}function Me(se){return 1+~~(se.getUTCMonth()/3)}return{format:function(se){var ve=P(se+="",S);return ve.toString=function(){return se},ve},parse:function(se){var ve=C(se+="",!1);return ve.toString=function(){return se},ve},utcFormat:function(se){var ve=P(se+="",A);return ve.toString=function(){return se},ve},utcParse:function(se){var ve=C(se+="",!0);return ve.toString=function(){return se},ve}}}var Q$={"-":"",_:" ",0:"0"},Li=/^\s*\d+/,EIe=/^%/,MIe=/[\\^$*+?|[\]().{}]/g;function Cn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s<n?new Array(n-s+1).join(e)+i:i)}function AIe(t){return t.replace(MIe,"\\$&")}function bx(t){return new RegExp("^(?:"+t.map(AIe).join("|")+")","i")}function vx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function TIe(t,e,n){var r=Li.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function CIe(t,e,n){var r=Li.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function NIe(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function kIe(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function PIe(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function J$(t,e,n){var r=Li.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function eV(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function RIe(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 DIe(t,e,n){var r=Li.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function OIe(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function tV(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function jIe(t,e,n){var r=Li.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function nV(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function LIe(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function IIe(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function UIe(t,e,n){var r=Li.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function FIe(t,e,n){var r=Li.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function zIe(t,e,n){var r=EIe.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function BIe(t,e,n){var r=Li.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function HIe(t,e,n){var r=Li.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function rV(t,e){return Cn(t.getDate(),e,2)}function $Ie(t,e){return Cn(t.getHours(),e,2)}function VIe(t,e){return Cn(t.getHours()%12||12,e,2)}function GIe(t,e){return Cn(1+Cb.count(Mc(t),t),e,3)}function BZ(t,e){return Cn(t.getMilliseconds(),e,3)}function WIe(t,e){return BZ(t,e)+"000"}function qIe(t,e){return Cn(t.getMonth()+1,e,2)}function KIe(t,e){return Cn(t.getMinutes(),e,2)}function XIe(t,e){return Cn(t.getSeconds(),e,2)}function YIe(t){var e=t.getDay();return e===0?7:e}function ZIe(t,e){return Cn(SE.count(Mc(t)-1,t),e,2)}function HZ(t){var e=t.getDay();return e>=4||e===0?Pm(t):Pm.ceil(t)}function QIe(t,e){return t=HZ(t),Cn(Pm.count(Mc(t),t)+(Mc(t).getDay()===4),e,2)}function JIe(t){return t.getDay()}function e4e(t,e){return Cn(Ww.count(Mc(t)-1,t),e,2)}function t4e(t,e){return Cn(t.getFullYear()%100,e,2)}function n4e(t,e){return t=HZ(t),Cn(t.getFullYear()%100,e,2)}function r4e(t,e){return Cn(t.getFullYear()%1e4,e,4)}function i4e(t,e){var n=t.getDay();return t=n>=4||n===0?Pm(t):Pm.ceil(t),Cn(t.getFullYear()%1e4,e,4)}function s4e(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Cn(e/60|0,"0",2)+Cn(e%60,"0",2)}function iV(t,e){return Cn(t.getUTCDate(),e,2)}function a4e(t,e){return Cn(t.getUTCHours(),e,2)}function o4e(t,e){return Cn(t.getUTCHours()%12||12,e,2)}function l4e(t,e){return Cn(1+wE.count(Ac(t),t),e,3)}function $Z(t,e){return Cn(t.getUTCMilliseconds(),e,3)}function c4e(t,e){return $Z(t,e)+"000"}function u4e(t,e){return Cn(t.getUTCMonth()+1,e,2)}function d4e(t,e){return Cn(t.getUTCMinutes(),e,2)}function h4e(t,e){return Cn(t.getUTCSeconds(),e,2)}function f4e(t){var e=t.getUTCDay();return e===0?7:e}function p4e(t,e){return Cn(EE.count(Ac(t)-1,t),e,2)}function VZ(t){var e=t.getUTCDay();return e>=4||e===0?Rm(t):Rm.ceil(t)}function m4e(t,e){return t=VZ(t),Cn(Rm.count(Ac(t),t)+(Ac(t).getUTCDay()===4),e,2)}function g4e(t){return t.getUTCDay()}function x4e(t,e){return Cn(qw.count(Ac(t)-1,t),e,2)}function b4e(t,e){return Cn(t.getUTCFullYear()%100,e,2)}function v4e(t,e){return t=VZ(t),Cn(t.getUTCFullYear()%100,e,2)}function y4e(t,e){return Cn(t.getUTCFullYear()%1e4,e,4)}function _4e(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Rm(t):Rm.ceil(t),Cn(t.getUTCFullYear()%1e4,e,4)}function w4e(){return"+0000"}function sV(){return"%"}function aV(t){return+t}function oV(t){return Math.floor(+t/1e3)}var Sp,GZ,WZ;S4e({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 S4e(t){return Sp=SIe(t),GZ=Sp.format,Sp.parse,WZ=Sp.utcFormat,Sp.utcParse,Sp}function E4e(t){return new Date(t)}function M4e(t){return t instanceof Date?+t:+new Date(+t)}function IO(t,e,n,r,i,s,a,o,l,u){var d=SO(),f=d.invert,g=d.domain,m=u(".%L"),x=u(":%S"),y=u("%I:%M"),v=u("%I %p"),b=u("%a %d"),E=u("%b %d"),S=u("%B"),A=u("%Y");function T(P){return(l(P)<P?m:o(P)<P?x:a(P)<P?y:s(P)<P?v:r(P)<P?i(P)<P?b:E:n(P)<P?S:A)(P)}return d.invert=function(P){return new Date(f(P))},d.domain=function(P){return arguments.length?g(Array.from(P,M4e)):g().map(E4e)},d.ticks=function(P){var C=g();return t(C[0],C[C.length-1],P??10)},d.tickFormat=function(P,C){return C==null?T:u(C)},d.nice=function(P){var C=g();return(!P||typeof P.range!="function")&&(P=e(C[0],C[C.length-1],P??10)),P?g(RZ(C,P)):d},d.copy=function(){return Tb(d,IO(t,e,n,r,i,s,a,o,l,u))},d}function A4e(){return lo.apply(IO(_Ie,wIe,Mc,jO,SE,Cb,DO,PO,dh,GZ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function T4e(){return lo.apply(IO(vIe,yIe,Ac,LO,EE,wE,OO,RO,dh,WZ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function ME(){var t=0,e=1,n,r,i,s,a=Ss,o=!1,l;function u(f){return f==null||isNaN(f=+f)?l:a(i===0?.5:(f=(s(f)-n)*i,o?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=s(t=+t),r=s(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(o=!!f,u):o},u.interpolator=function(f){return arguments.length?(a=f,u):a};function d(f){return function(g){var m,x;return arguments.length?([m,x]=g,a=f(m,x),u):[a(0),a(1)]}}return u.range=d(Ym),u.rangeRound=d(wO),u.unknown=function(f){return arguments.length?(l=f,u):l},function(f){return s=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function bd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function qZ(){var t=xd(ME()(Ss));return t.copy=function(){return bd(t,qZ())},Dc.apply(t,arguments)}function KZ(){var t=AO(ME()).domain([1,10]);return t.copy=function(){return bd(t,KZ()).base(t.base())},Dc.apply(t,arguments)}function XZ(){var t=TO(ME());return t.copy=function(){return bd(t,XZ()).constant(t.constant())},Dc.apply(t,arguments)}function UO(){var t=CO(ME());return t.copy=function(){return bd(t,UO()).exponent(t.exponent())},Dc.apply(t,arguments)}function C4e(){return UO.apply(null,arguments).exponent(.5)}function YZ(){var t=[],e=Ss;function n(r){if(r!=null&&!isNaN(r=+r))return e((Mb(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(Yu),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,s)=>fLe(t,s/r))},n.copy=function(){return YZ(e).domain(t)},Dc.apply(n,arguments)}function AE(){var t=0,e=.5,n=1,r=1,i,s,a,o,l,u=Ss,d,f=!1,g;function m(y){return isNaN(y=+y)?g:(y=.5+((y=+d(y))-s)*(r*y<r*s?o:l),u(f?Math.max(0,Math.min(1,y)):y))}m.domain=function(y){return arguments.length?([t,e,n]=y,i=d(t=+t),s=d(e=+e),a=d(n=+n),o=i===s?0:.5/(s-i),l=s===a?0:.5/(a-s),r=s<i?-1:1,m):[t,e,n]},m.clamp=function(y){return arguments.length?(f=!!y,m):f},m.interpolator=function(y){return arguments.length?(u=y,m):u};function x(y){return function(v){var b,E,S;return arguments.length?([b,E,S]=v,u=zLe(y,[b,E,S]),m):[u(0),u(.5),u(1)]}}return m.range=x(Ym),m.rangeRound=x(wO),m.unknown=function(y){return arguments.length?(g=y,m):g},function(y){return d=y,i=y(t),s=y(e),a=y(n),o=i===s?0:.5/(s-i),l=s===a?0:.5/(a-s),r=s<i?-1:1,m}}function ZZ(){var t=xd(AE()(Ss));return t.copy=function(){return bd(t,ZZ())},Dc.apply(t,arguments)}function QZ(){var t=AO(AE()).domain([.1,1,10]);return t.copy=function(){return bd(t,QZ()).base(t.base())},Dc.apply(t,arguments)}function JZ(){var t=TO(AE());return t.copy=function(){return bd(t,JZ()).constant(t.constant())},Dc.apply(t,arguments)}function FO(){var t=CO(AE());return t.copy=function(){return bd(t,FO()).exponent(t.exponent())},Dc.apply(t,arguments)}function N4e(){return FO.apply(null,arguments).exponent(.5)}const kx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:vO,scaleDiverging:ZZ,scaleDivergingLog:QZ,scaleDivergingPow:FO,scaleDivergingSqrt:N4e,scaleDivergingSymlog:JZ,scaleIdentity:PZ,scaleImplicit:RP,scaleLinear:kZ,scaleLog:DZ,scaleOrdinal:bO,scalePoint:gLe,scalePow:NO,scaleQuantile:LZ,scaleQuantize:IZ,scaleRadial:jZ,scaleSequential:qZ,scaleSequentialLog:KZ,scaleSequentialPow:UO,scaleSequentialQuantile:YZ,scaleSequentialSqrt:C4e,scaleSequentialSymlog:XZ,scaleSqrt:cIe,scaleSymlog:OZ,scaleThreshold:UZ,scaleTime:A4e,scaleUtc:T4e,tickFormat:NZ},Symbol.toStringTag,{value:"Module"}));var vd=t=>t.chartData,zO=Ke([vd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),TE=(t,e,n,r)=>r?zO(t):vd(t);function ad(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(ur(e)&&ur(n))return!0}return!1}function lV(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function eQ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(ur(n))i=n;else if(typeof n=="function")return;if(ur(r))s=r;else if(typeof r=="function")return;var a=[i,s];if(ad(a))return a}}function k4e(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(ad(r))return lV(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,s]=t,a,o;if(i==="auto")e!=null&&(a=Math.min(...e));else if(Ct(i))a=i;else if(typeof i=="function")try{e!=null&&(a=i(e?.[0]))}catch{}else if(typeof i=="string"&&LH.test(i)){var l=LH.exec(i);if(l==null||e==null)a=void 0;else{var u=+l[1];a=e[0]-u}}else a=e?.[0];if(s==="auto")e!=null&&(o=Math.max(...e));else if(Ct(s))o=s;else if(typeof s=="function")try{e!=null&&(o=s(e?.[1]))}catch{}else if(typeof s=="string"&&IH.test(s)){var d=IH.exec(s);if(d==null||e==null)o=void 0;else{var f=+d[1];o=e[1]+f}}else o=e?.[1];var g=[a,o];if(ad(g))return e==null?g:lV(g,e,n)}}}var Zm=1e9,P4e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},HO,mr=!0,ao="[DecimalError] ",Ah=ao+"Invalid argument: ",BO=ao+"Exponent out of range: ",Qm=Math.floor,Zd=Math.pow,R4e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,fa,ki=1e7,lr=7,tQ=9007199254740991,Kw=Qm(tQ/lr),Pt={};Pt.absoluteValue=Pt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Pt.comparedTo=Pt.cmp=function(t){var e,n,r,i,s=this;if(t=new s.constructor(t),s.s!==t.s)return s.s||-t.s;if(s.e!==t.e)return s.e>t.e^s.s<0?1:-1;for(r=s.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(s.d[e]!==t.d[e])return s.d[e]>t.d[e]^s.s<0?1:-1;return r===i?0:r>i^s.s<0?1:-1};Pt.decimalPlaces=Pt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*lr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Pt.dividedBy=Pt.div=function(t){return xc(this,new this.constructor(t))};Pt.dividedToIntegerBy=Pt.idiv=function(t){var e=this,n=e.constructor;return er(xc(e,new n(t),0,1),n.precision)};Pt.equals=Pt.eq=function(t){return!this.cmp(t)};Pt.exponent=function(){return ei(this)};Pt.greaterThan=Pt.gt=function(t){return this.cmp(t)>0};Pt.greaterThanOrEqualTo=Pt.gte=function(t){return this.cmp(t)>=0};Pt.isInteger=Pt.isint=function(){return this.e>this.d.length-2};Pt.isNegative=Pt.isneg=function(){return this.s<0};Pt.isPositive=Pt.ispos=function(){return this.s>0};Pt.isZero=function(){return this.s===0};Pt.lessThan=Pt.lt=function(t){return this.cmp(t)<0};Pt.lessThanOrEqualTo=Pt.lte=function(t){return this.cmp(t)<1};Pt.logarithm=Pt.log=function(t){var e,n=this,r=n.constructor,i=r.precision,s=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(fa))throw Error(ao+"NaN");if(n.s<1)throw Error(ao+(n.s?"NaN":"-Infinity"));return n.eq(fa)?new r(0):(mr=!1,e=xc(Y0(n,s),Y0(t,s),s),mr=!0,er(e,i))};Pt.minus=Pt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?iQ(e,t):nQ(e,(t.s=-t.s,t))};Pt.modulo=Pt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(ao+"NaN");return n.s?(mr=!1,e=xc(n,t,0,1).times(t),mr=!0,n.minus(e)):er(new r(n),i)};Pt.naturalExponential=Pt.exp=function(){return rQ(this)};Pt.naturalLogarithm=Pt.ln=function(){return Y0(this)};Pt.negated=Pt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Pt.plus=Pt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?nQ(e,t):iQ(e,(t.s=-t.s,t))};Pt.precision=Pt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Ah+t);if(e=ei(i)+1,r=i.d.length-1,n=r*lr+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};Pt.squareRoot=Pt.sqrt=function(){var t,e,n,r,i,s,a,o=this,l=o.constructor;if(o.s<1){if(!o.s)return new l(0);throw Error(ao+"NaN")}for(t=ei(o),mr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=il(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Qm((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new l(e)):r=new l(i.toString()),n=l.precision,i=a=n+3;;)if(s=r,r=s.plus(xc(o,s,a+2)).times(.5),il(s.d).slice(0,a)===(e=il(r.d)).slice(0,a)){if(e=e.slice(a-3,a+1),i==a&&e=="4999"){if(er(s,n+1,0),s.times(s).eq(o)){r=s;break}}else if(e!="9999")break;a+=4}return mr=!0,er(r,n)};Pt.times=Pt.mul=function(t){var e,n,r,i,s,a,o,l,u,d=this,f=d.constructor,g=d.d,m=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,l=g.length,u=m.length,l<u&&(s=g,g=m,m=s,a=l,l=u,u=a),s=[],a=l+u,r=a;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=l+r;i>r;)o=s[i]+m[r]*g[i-r-1]+e,s[i--]=o%ki|0,e=o/ki|0;s[i]=(s[i]+e)%ki|0}for(;!s[--a];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,mr?er(t,f.precision):t};Pt.toDecimalPlaces=Pt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(ml(t,0,Zm),e===void 0?e=r.rounding:ml(e,0,8),er(n,t+ei(n)+1,e))};Pt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Zh(r,!0):(ml(t,0,Zm),e===void 0?e=i.rounding:ml(e,0,8),r=er(new i(r),t+1,e),n=Zh(r,!0,t+1)),n};Pt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Zh(i):(ml(t,0,Zm),e===void 0?e=s.rounding:ml(e,0,8),r=er(new s(i),t+ei(i)+1,e),n=Zh(r.abs(),!1,t+ei(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Pt.toInteger=Pt.toint=function(){var t=this,e=t.constructor;return er(new e(t),ei(t)+1,e.rounding)};Pt.toNumber=function(){return+this};Pt.toPower=Pt.pow=function(t){var e,n,r,i,s,a,o=this,l=o.constructor,u=12,d=+(t=new l(t));if(!t.s)return new l(fa);if(o=new l(o),!o.s){if(t.s<1)throw Error(ao+"Infinity");return o}if(o.eq(fa))return o;if(r=l.precision,t.eq(fa))return er(o,r);if(e=t.e,n=t.d.length-1,a=e>=n,s=o.s,a){if((n=d<0?-d:d)<=tQ){for(i=new l(fa),e=Math.ceil(r/lr+4),mr=!1;n%2&&(i=i.times(o),uV(i.d,e)),n=Qm(n/2),n!==0;)o=o.times(o),uV(o.d,e);return mr=!0,t.s<0?new l(fa).div(i):er(i,r)}}else if(s<0)throw Error(ao+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,mr=!1,i=t.times(Y0(o,r+u)),mr=!0,i=rQ(i),i.s=s,i};Pt.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=ei(i),r=Zh(i,n<=s.toExpNeg||n>=s.toExpPos)):(ml(t,1,Zm),e===void 0?e=s.rounding:ml(e,0,8),i=er(new s(i),t,e),n=ei(i),r=Zh(i,t<=n||n<=s.toExpNeg,t)),r};Pt.toSignificantDigits=Pt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(ml(t,1,Zm),e===void 0?e=r.rounding:ml(e,0,8)),er(new r(n),t,e)};Pt.toString=Pt.valueOf=Pt.val=Pt.toJSON=Pt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=ei(t),n=t.constructor;return Zh(t,e<=n.toExpNeg||e>=n.toExpPos)};function nQ(t,e){var n,r,i,s,a,o,l,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),mr?er(e,f):e;if(l=t.d,u=e.d,a=t.e,i=e.e,l=l.slice(),s=a-i,s){for(s<0?(r=l,s=-s,o=u.length):(r=u,i=a,o=l.length),a=Math.ceil(f/lr),o=a>o?a+1:o+1,s>o&&(s=o,r.length=1),r.reverse();s--;)r.push(0);r.reverse()}for(o=l.length,s=u.length,o-s<0&&(s=o,r=u,u=l,l=r),n=0;s;)n=(l[--s]=l[s]+u[s]+n)/ki|0,l[s]%=ki;for(n&&(l.unshift(n),++i),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=i,mr?er(e,f):e}function ml(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Ah+t)}function il(t){var e,n,r,i=t.length-1,s="",a=t[0];if(i>0){for(s+=a,e=1;e<i;e++)r=t[e]+"",n=lr-r.length,n&&(s+=Cu(n)),s+=r;a=t[e],r=a+"",n=lr-r.length,n&&(s+=Cu(n))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}var xc=(function(){function t(r,i){var s,a=0,o=r.length;for(r=r.slice();o--;)s=r[o]*i+a,r[o]=s%ki|0,a=s/ki|0;return a&&r.unshift(a),r}function e(r,i,s,a){var o,l;if(s!=a)l=s>a?1:-1;else for(o=l=0;o<s;o++)if(r[o]!=i[o]){l=r[o]>i[o]?1:-1;break}return l}function n(r,i,s){for(var a=0;s--;)r[s]-=a,a=r[s]<i[s]?1:0,r[s]=a*ki+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,a){var o,l,u,d,f,g,m,x,y,v,b,E,S,A,T,P,C,I,N=r.constructor,D=r.s==i.s?1:-1,F=r.d,L=i.d;if(!r.s)return new N(r);if(!i.s)throw Error(ao+"Division by zero");for(l=r.e-i.e,C=L.length,T=F.length,m=new N(D),x=m.d=[],u=0;L[u]==(F[u]||0);)++u;if(L[u]>(F[u]||0)&&--l,s==null?E=s=N.precision:a?E=s+(ei(r)-ei(i))+1:E=s,E<0)return new N(0);if(E=E/lr+2|0,u=0,C==1)for(d=0,L=L[0],E++;(u<T||d)&&E--;u++)S=d*ki+(F[u]||0),x[u]=S/L|0,d=S%L|0;else{for(d=ki/(L[0]+1)|0,d>1&&(L=t(L,d),F=t(F,d),C=L.length,T=F.length),A=C,y=F.slice(0,C),v=y.length;v<C;)y[v++]=0;I=L.slice(),I.unshift(0),P=L[0],L[1]>=ki/2&&++P;do d=0,o=e(L,y,C,v),o<0?(b=y[0],C!=v&&(b=b*ki+(y[1]||0)),d=b/P|0,d>1?(d>=ki&&(d=ki-1),f=t(L,d),g=f.length,v=y.length,o=e(f,y,g,v),o==1&&(d--,n(f,C<g?I:L,g))):(d==0&&(o=d=1),f=L.slice()),g=f.length,g<v&&f.unshift(0),n(y,f,v),o==-1&&(v=y.length,o=e(L,y,C,v),o<1&&(d++,n(y,C<v?I:L,v))),v=y.length):o===0&&(d++,y=[0]),x[u++]=d,o&&y[0]?y[v++]=F[A]||0:(y=[F[A]],v=1);while((A++<T||y[0]!==void 0)&&E--)}return x[0]||x.shift(),m.e=l,er(m,a?s+ei(m)+1:s)}})();function rQ(t,e){var n,r,i,s,a,o,l=0,u=0,d=t.constructor,f=d.precision;if(ei(t)>16)throw Error(BO+ei(t));if(!t.s)return new d(fa);for(mr=!1,o=f,a=new d(.03125);t.abs().gte(.1);)t=t.times(a),u+=5;for(r=Math.log(Zd(2,u))/Math.LN10*2+5|0,o+=r,n=i=s=new d(fa),d.precision=o;;){if(i=er(i.times(t),o),n=n.times(++l),a=s.plus(xc(i,n,o)),il(a.d).slice(0,o)===il(s.d).slice(0,o)){for(;u--;)s=er(s.times(s),o);return d.precision=f,e==null?(mr=!0,er(s,f)):s}s=a}}function ei(t){for(var e=t.e*lr,n=t.d[0];n>=10;n/=10)e++;return e}function SN(t,e,n){if(e>t.LN10.sd())throw mr=!0,n&&(t.precision=n),Error(ao+"LN10 precision limit exceeded");return er(new t(t.LN10),e)}function Cu(t){for(var e="";t--;)e+="0";return e}function Y0(t,e){var n,r,i,s,a,o,l,u,d,f=1,g=10,m=t,x=m.d,y=m.constructor,v=y.precision;if(m.s<1)throw Error(ao+(m.s?"NaN":"-Infinity"));if(m.eq(fa))return new y(0);if(e==null?(mr=!1,u=v):u=e,m.eq(10))return e==null&&(mr=!0),SN(y,u);if(u+=g,y.precision=u,n=il(x),r=n.charAt(0),s=ei(m),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=il(m.d),r=n.charAt(0),f++;s=ei(m),r>1?(m=new y("0."+n),s++):m=new y(r+"."+n.slice(1))}else return l=SN(y,u+2,v).times(s+""),m=Y0(new y(r+"."+n.slice(1)),u-g).plus(l),y.precision=v,e==null?(mr=!0,er(m,v)):m;for(o=a=m=xc(m.minus(fa),m.plus(fa),u),d=er(m.times(m),u),i=3;;){if(a=er(a.times(d),u),l=o.plus(xc(a,new y(i),u)),il(l.d).slice(0,u)===il(o.d).slice(0,u))return o=o.times(2),s!==0&&(o=o.plus(SN(y,u+2,v).times(s+""))),o=xc(o,new y(f),u),y.precision=v,e==null?(mr=!0,er(o,v)):o;o=l,i+=2}}function cV(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;)++r;for(i=e.length;e.charCodeAt(i-1)===48;)--i;if(e=e.slice(r,i),e){if(i-=r,n=n-r-1,t.e=Qm(n/lr),t.d=[],r=(n+1)%lr,n<0&&(r+=lr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=lr;r<i;)t.d.push(+e.slice(r,r+=lr));e=e.slice(r),r=lr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),mr&&(t.e>Kw||t.e<-Kw))throw Error(BO+n)}else t.s=0,t.e=0,t.d=[0];return t}function er(t,e,n){var r,i,s,a,o,l,u,d,f=t.d;for(a=1,s=f[0];s>=10;s/=10)a++;if(r=e-a,r<0)r+=lr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/lr),s=f.length,d>=s)return t;for(u=s=f[d],a=1;s>=10;s/=10)a++;r%=lr,i=r-lr+a}if(n!==void 0&&(s=Zd(10,a-i-1),o=u/s%10|0,l=e<0||f[d+1]!==void 0||u%s,l=n<4?(o||l)&&(n==0||n==(t.s<0?3:2)):o>5||o==5&&(n==4||l||n==6&&(r>0?i>0?u/Zd(10,a-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return l?(s=ei(t),f.length=1,e=e-s-1,f[0]=Zd(10,(lr-e%lr)%lr),t.e=Qm(-e/lr)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,s=1,d--):(f.length=d+1,s=Zd(10,lr-r),f[d]=i>0?(u/Zd(10,a-i)%Zd(10,i)|0)*s:0),l)for(;;)if(d==0){(f[0]+=s)==ki&&(f[0]=1,++t.e);break}else{if(f[d]+=s,f[d]!=ki)break;f[d--]=0,s=1}for(r=f.length;f[--r]===0;)f.pop();if(mr&&(t.e>Kw||t.e<-Kw))throw Error(BO+ei(t));return t}function iQ(t,e){var n,r,i,s,a,o,l,u,d,f,g=t.constructor,m=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),mr?er(e,m):e;if(l=t.d,f=e.d,r=e.e,u=t.e,l=l.slice(),a=u-r,a){for(d=a<0,d?(n=l,a=-a,o=f.length):(n=f,r=u,o=l.length),i=Math.max(Math.ceil(m/lr),o)+2,a>i&&(a=i,n.length=1),n.reverse(),i=a;i--;)n.push(0);n.reverse()}else{for(i=l.length,o=f.length,d=i<o,d&&(o=i),i=0;i<o;i++)if(l[i]!=f[i]){d=l[i]<f[i];break}a=0}for(d&&(n=l,l=f,f=n,e.s=-e.s),o=l.length,i=f.length-o;i>0;--i)l[o++]=0;for(i=f.length;i>a;){if(l[--i]<f[i]){for(s=i;s&&l[--s]===0;)l[s]=ki-1;--l[s],l[i]+=ki}l[i]-=f[i]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(e.d=l,e.e=r,mr?er(e,m):e):new g(0)}function Zh(t,e,n){var r,i=ei(t),s=il(t.d),a=s.length;return e?(n&&(r=n-a)>0?s=s.charAt(0)+"."+s.slice(1)+Cu(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+Cu(-i-1)+s,n&&(r=n-a)>0&&(s+=Cu(r))):i>=a?(s+=Cu(i+1-a),n&&(r=n-i-1)>0&&(s=s+"."+Cu(r))):((r=i+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-a)>0&&(i+1===a&&(s+="."),s+=Cu(r))),t.s<0?"-"+s:s}function uV(t,e){if(t.length>e)return t.length=e,!0}function sQ(t){var e,n,r;function i(s){var a=this;if(!(a instanceof i))return new i(s);if(a.constructor=i,s instanceof i){a.s=s.s,a.e=s.e,a.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(Ah+s);if(s>0)a.s=1;else if(s<0)s=-s,a.s=-1;else{a.s=0,a.e=0,a.d=[0];return}if(s===~~s&&s<1e7){a.e=0,a.d=[s];return}return cV(a,s.toString())}else if(typeof s!="string")throw Error(Ah+s);if(s.charCodeAt(0)===45?(s=s.slice(1),a.s=-1):a.s=1,R4e.test(s))cV(a,s);else throw Error(Ah+s)}if(i.prototype=Pt,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=sQ,i.config=i.set=D4e,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 D4e(t){if(!t||typeof t!="object")throw Error(ao+"Object expected");var e,n,r,i=["precision",1,Zm,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e<i.length;e+=3)if((r=t[n=i[e]])!==void 0)if(Qm(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Ah+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Ah+n+": "+r);return this}var HO=sQ(P4e);fa=new HO(1);const In=HO;var O4e=t=>t,aQ={},oQ=t=>t===aQ,dV=t=>function e(){return arguments.length===0||arguments.length===1&&oQ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},lQ=(t,e)=>t===1?e:dV(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var s=r.filter(a=>a!==aQ).length;return s>=t?e(...r):lQ(t-s,dV(function(){for(var a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];var u=r.map(d=>oQ(d)?o.shift():d);return e(...u,...o)}))}),j4e=t=>lQ(t.length,t),LP=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},L4e=j4e((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),I4e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return O4e;var i=n.reverse(),s=i[0],a=i.slice(1);return function(){return a.reduce((o,l)=>l(o),s(...arguments))}},IP=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function cQ(t){var e;return t===0?e=1:e=Math.floor(new In(t).abs().log(10).toNumber())+1,e}function uQ(t,e,n){for(var r=new In(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var dQ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},hQ=(t,e,n)=>{if(t.lte(0))return new In(0);var r=cQ(t.toNumber()),i=new In(10).pow(r),s=t.div(i),a=r!==1?.05:.1,o=new In(Math.ceil(s.div(a).toNumber())).add(n).mul(a),l=o.mul(i);return e?new In(l.toNumber()):new In(Math.ceil(l.toNumber()))},U4e=(t,e,n)=>{var r=new In(1),i=new In(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new In(10).pow(cQ(t)-1),i=new In(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new In(Math.floor(t)))}else t===0?i=new In(Math.floor((e-1)/2)):n||(i=new In(Math.floor(t)));var a=Math.floor((e-1)/2),o=I4e(L4e(l=>i.add(new In(l-a).mul(r)).toNumber()),LP);return o(0,e)},fQ=function(e,n,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new In(0),tickMin:new In(0),tickMax:new In(0)};var a=hQ(new In(n).sub(e).div(r-1),i,s),o;e<=0&&n>=0?o=new In(0):(o=new In(e).add(n).div(2),o=o.sub(new In(o).mod(a)));var l=Math.ceil(o.sub(e).div(a).toNumber()),u=Math.ceil(new In(n).sub(o).div(a).toNumber()),d=l+u+1;return d>r?fQ(e,n,r,i,s+1):(d<r&&(u=n>0?u+(r-d):u,l=n>0?l:l+(r-d)),{step:a,tickMin:o.sub(new In(l).mul(a)),tickMax:o.add(new In(u).mul(a))})},F4e=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=Math.max(i,2),[o,l]=dQ([n,r]);if(o===-1/0||l===1/0){var u=l===1/0?[o,...LP(0,i-1).map(()=>1/0)]:[...LP(0,i-1).map(()=>-1/0),l];return n>r?IP(u):u}if(o===l)return U4e(o,i,s);var{step:d,tickMin:f,tickMax:g}=fQ(o,l,a,s,0),m=uQ(f,g.add(new In(.1).mul(d)),d);return n>r?IP(m):m},z4e=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[a,o]=dQ([r,i]);if(a===-1/0||o===1/0)return[r,i];if(a===o)return[a];var l=Math.max(n,2),u=hQ(new In(o).sub(a).div(l-1),s,0),d=[...uQ(new In(a),new In(o),u),o];return s===!1&&(d=d.map(f=>Math.round(f))),r>i?IP(d):d},pQ=t=>t.rootProps.maxBarSize,B4e=t=>t.rootProps.barGap,mQ=t=>t.rootProps.barCategoryGap,H4e=t=>t.rootProps.barSize,Nb=t=>t.rootProps.stackOffset,gQ=t=>t.rootProps.reverseStackOrder,$O=t=>t.options.chartName,VO=t=>t.rootProps.syncId,xQ=t=>t.rootProps.syncMethod,GO=t=>t.options.eventEmitter,$4e=t=>t.rootProps.baseValue,Zr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},nc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},ua={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},CE=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},V4e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:nc.angleAxisId,includeHidden:!1,name:void 0,reversed:nc.reversed,scale:nc.scale,tick:nc.tick,tickCount:void 0,ticks:void 0,type:nc.type,unit:void 0},G4e={allowDataOverflow:ua.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ua.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ua.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ua.scale,tick:ua.tick,tickCount:ua.tickCount,ticks:void 0,type:ua.type,unit:void 0},W4e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:nc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:nc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:nc.scale,tick:nc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},q4e={allowDataOverflow:ua.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ua.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ua.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ua.scale,tick:ua.tick,tickCount:ua.tickCount,ticks:void 0,type:"category",unit:void 0},WO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?W4e:V4e,qO=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?q4e:G4e,NE=t=>t.polarOptions,KO=Ke([Pc,Rc,xi],mZ),bQ=Ke([NE,KO],(t,e)=>{if(t!=null)return hs(t.innerRadius,e,0)}),vQ=Ke([NE,KO],(t,e)=>{if(t!=null)return hs(t.outerRadius,e,e*.8)}),K4e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},yQ=Ke([NE],K4e);Ke([WO,yQ],CE);var _Q=Ke([KO,bQ,vQ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ke([qO,_Q],CE);var wQ=Ke([wn,NE,bQ,vQ,Pc,Rc],(t,e,n,r,i,s)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:a,cy:o,startAngle:l,endAngle:u}=e;return{cx:hs(a,i,i/2),cy:hs(o,s,s/2),innerRadius:n,outerRadius:r,startAngle:l,endAngle:u,clockWise:!1}}}),gr=(t,e)=>e,kb=(t,e,n)=>n;function kE(t){return t?.id}function SQ(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=n,a=new Map;return t.forEach(o=>{var l,u=(l=o.data)!==null&&l!==void 0?l:r;if(!(u==null||u.length===0)){var d=kE(o);u.forEach((f,g)=>{var m=s==null||i?g:String(Jn(f,s,null)),x=Jn(f,o.dataKey,0),y;a.has(m)?y=a.get(m):y={},Object.assign(y,{[d]:x}),a.set(m,y)})}}),Array.from(a.values())}function PE(t){return t.stackId!=null&&t.dataKey!=null}var RE=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function DE(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function X4e(t,e){if(t.length===e.length){for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return!1}var vi=t=>{var e=wn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Jm=t=>t.tooltip.settings.axisId;function hV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hV(Object(n),!0).forEach(function(r){Y4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Y4e(t,e,n){return(e=Z4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z4e(t){var e=Q4e(t,"string");return typeof e=="symbol"?e:e+""}function Q4e(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 UP=[0,"auto"],Ci={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},EQ=(t,e)=>t.cartesianAxis.xAxis[e],Oc=(t,e)=>{var n=EQ(t,e);return n??Ci},Ni={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:UP,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:_b},MQ=(t,e)=>t.cartesianAxis.yAxis[e],jc=(t,e)=>{var n=MQ(t,e);return n??Ni},J4e={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:""},XO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??J4e},wr=(t,e,n)=>{switch(e){case"xAxis":return Oc(t,n);case"yAxis":return jc(t,n);case"zAxis":return XO(t,n);case"angleAxis":return WO(t,n);case"radiusAxis":return qO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},eUe=(t,e,n)=>{switch(e){case"xAxis":return Oc(t,n);case"yAxis":return jc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Pb=(t,e,n)=>{switch(e){case"xAxis":return Oc(t,n);case"yAxis":return jc(t,n);case"angleAxis":return WO(t,n);case"radiusAxis":return qO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},AQ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function YO(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 OE=t=>t.graphicalItems.cartesianItems,tUe=Ke([gr,kb],YO),ZO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Rb=Ke([OE,wr,tUe],ZO,{memoizeOptions:{resultEqualityCheck:DE}}),TQ=Ke([Rb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(PE)),CQ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),nUe=Ke([Rb],CQ),QO=t=>t.map(e=>e.data).filter(Boolean).flat(1),rUe=Ke([Rb],QO,{memoizeOptions:{resultEqualityCheck:DE}}),JO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},ej=Ke([rUe,TE],JO),tj=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Jn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Jn(i,r)}))):t.map(r=>({value:r})),jE=Ke([ej,wr,Rb],tj);function NQ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function J_(t){if(fl(t)||t instanceof Date){var e=Number(t);if(ur(e))return e}}function fV(t){if(Array.isArray(t)){var e=[J_(t[0]),J_(t[1])];return ad(e)?e:void 0}var n=J_(t);if(n!=null)return[n,n]}function Tc(t){return t.map(J_).filter(nPe)}function iUe(t,e,n){return!n||typeof e!="number"||io(e)?[]:n.length?Tc(n.flatMap(r=>{var i=Jn(t,r.dataKey),s,a;if(Array.isArray(i)?[s,a]=i:s=a=i,!(!ur(s)||!ur(a)))return[e-s,e+a]})):[]}var yi=t=>{var e=vi(t),n=Jm(t);return Pb(t,e,n)},Db=Ke([yi],t=>t?.dataKey),sUe=Ke([TQ,TE,yi],SQ),kQ=(t,e,n,r)=>{var i={},s=e.reduce((a,o)=>(o.stackId==null||(a[o.stackId]==null&&(a[o.stackId]=[]),a[o.stackId].push(o)),a),i);return Object.fromEntries(Object.entries(s).map(a=>{var[o,l]=a,u=r?[...l].reverse():l,d=u.map(kE);return[o,{stackedData:EDe(t,d,n),graphicalItems:u}]}))},Z0=Ke([sUe,TQ,Nb,gQ],kQ),PQ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var a=CDe(t,i,s);if(!(a!=null&&a[0]===0&&a[1]===0))return a}},aUe=Ke([wr],t=>t.allowDataOverflow),nj=t=>{var e;if(t==null||!("domain"in t))return UP;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Tc(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:UP},rj=Ke([wr],nj),ij=Ke([rj,aUe],eQ),oUe=Ke([Z0,vd,gr,ij],PQ,{memoizeOptions:{resultEqualityCheck:RE}}),LE=t=>t.errorBars,lUe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>NQ(n,r)),Yw=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var s=i.flat(),a=Math.min(...s),o=Math.max(...s);return[a,o]}},sj=(t,e,n,r,i)=>{var s,a;if(n.length>0&&t.forEach(o=>{n.forEach(l=>{var u,d,f=(u=r[l.id])===null||u===void 0?void 0:u.filter(b=>NQ(i,b)),g=Jn(o,(d=e.dataKey)!==null&&d!==void 0?d:l.dataKey),m=iUe(o,g,f);if(m.length>=2){var x=Math.min(...m),y=Math.max(...m);(s==null||x<s)&&(s=x),(a==null||y>a)&&(a=y)}var v=fV(g);v!=null&&(s=s==null?v[0]:Math.min(s,v[0]),a=a==null?v[1]:Math.max(a,v[1]))})}),e?.dataKey!=null&&t.forEach(o=>{var l=fV(Jn(o,e.dataKey));l!=null&&(s=s==null?l[0]:Math.min(s,l[0]),a=a==null?l[1]:Math.max(a,l[1]))}),ur(s)&&ur(a))return[s,a]},cUe=Ke([ej,wr,nUe,LE,gr],sj,{memoizeOptions:{resultEqualityCheck:RE}});function uUe(t){var{value:e}=t;if(fl(e)||e instanceof Date)return e}var dUe=(t,e,n)=>{var r=t.map(uUe).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&WX(r))?vZ(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},RQ=t=>t.referenceElements.dots,eg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),hUe=Ke([RQ,gr,kb],eg),DQ=t=>t.referenceElements.areas,fUe=Ke([DQ,gr,kb],eg),OQ=t=>t.referenceElements.lines,pUe=Ke([OQ,gr,kb],eg),jQ=(t,e)=>{var n=Tc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},mUe=Ke(hUe,gr,jQ),LQ=(t,e)=>{var n=Tc(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)]},gUe=Ke([fUe,gr],LQ);function xUe(t){var e;if(t.x!=null)return Tc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Tc(n)}function bUe(t){var e;if(t.y!=null)return Tc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Tc(n)}var IQ=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?xUe(r):bUe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},vUe=Ke([pUe,gr],IQ),yUe=Ke(mUe,vUe,gUe,(t,e,n)=>Yw(t,n,e)),aj=(t,e,n,r,i,s,a,o)=>{if(n!=null)return n;var l=a==="vertical"&&o==="xAxis"||a==="horizontal"&&o==="yAxis",u=l?Yw(r,s,i):Yw(s,i);return k4e(e,u,t.allowDataOverflow)},_Ue=Ke([wr,rj,ij,oUe,cUe,yUe,wn,gr],aj,{memoizeOptions:{resultEqualityCheck:RE}}),wUe=[0,1],oj=(t,e,n,r,i,s,a)=>{if(!((t==null||n==null||n.length===0)&&a===void 0)){var{dataKey:o,type:l}=t,u=kc(e,s);if(u&&o==null){var d;return vZ(0,(d=n?.length)!==null&&d!==void 0?d:0)}return l==="category"?dUe(r,t,u):i==="expand"?wUe:a}},lj=Ke([wr,wn,ej,jE,Nb,gr,_Ue],oj),UQ=(t,e,n,r,i)=>{if(t!=null){var{scale:s,type:a}=t;if(s==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":a==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":a==="category"?"band":"linear";if(typeof s=="string"){var o="scale".concat(mb(s));return o in kx?o:"point"}}},tg=Ke([wr,wn,AQ,$O,gr],UQ);function SUe(t){if(t!=null){if(t in kx)return kx[t]();var e="scale".concat(mb(t));if(e in kx)return kx[e]()}}function cj(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=SUe(e);if(i!=null){var s=i.domain(n).range(r);return vDe(s),s}}}var uj=(t,e,n)=>{var r=nj(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&ad(t))return F4e(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&ad(t))return z4e(t,e.tickCount,e.allowDecimals)}},dj=Ke([lj,Pb,tg],uj),hj=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&ad(e)&&Array.isArray(n)&&n.length>0){var i=e[0],s=n[0],a=e[1],o=n[n.length-1];return[Math.min(i,s),Math.max(a,o)]}return e},EUe=Ke([wr,lj,dj,gr],hj),MUe=Ke(jE,wr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Tc(t.map(o=>o.value))).sort((o,l)=>o-l);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var s=0;s<r.length-1;s++){var a=r[s+1]-r[s];n=Math.min(n,a)}return n/i}}),FQ=Ke(MUe,wn,mQ,xi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!ur(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var a=hs(n,t*s),o=t*s/2;return o-a-(o-a)/s*a}return 0}),AUe=(t,e)=>{var n=Oc(t,e);return n==null||typeof n.padding!="string"?0:FQ(t,"xAxis",e,n.padding)},TUe=(t,e)=>{var n=jc(t,e);return n==null||typeof n.padding!="string"?0:FQ(t,"yAxis",e,n.padding)},CUe=Ke(Oc,AUe,(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}}),NUe=Ke(jc,TUe,(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}}),kUe=Ke([xi,CUe,mE,pE,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:s}=r;return i?[s.left,n.width-s.right]:[t.left+e.left,t.left+t.width-e.right]}),PUe=Ke([xi,wn,NUe,mE,pE,(t,e,n)=>n],(t,e,n,r,i,s)=>{var{padding:a}=i;return s?[r.height-a.bottom,a.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),Ob=(t,e,n,r)=>{var i;switch(e){case"xAxis":return kUe(t,n,r);case"yAxis":return PUe(t,n,r);case"zAxis":return(i=XO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return yQ(t);case"radiusAxis":return _Q(t,n);default:return}},zQ=Ke([wr,Ob],CE),ng=Ke([wr,tg,EUe,zQ],cj);Ke([Rb,LE,gr],lUe);function BQ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var IE=(t,e)=>e,UE=(t,e,n)=>n,RUe=Ke(hE,IE,UE,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BQ)),DUe=Ke(fE,IE,UE,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BQ)),HQ=(t,e)=>({width:t.width,height:e.height}),OUe=(t,e)=>{var n=typeof e.width=="number"?e.width:_b;return{width:n,height:t.height}},$Q=Ke(xi,Oc,HQ),jUe=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},LUe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},IUe=Ke(Rc,xi,RUe,IE,UE,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var l=HQ(e,o);a==null&&(a=jUe(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;s[o.id]=a-Number(u)*l.height,a+=(u?-1:1)*l.height}),s}),UUe=Ke(Pc,xi,DUe,IE,UE,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var l=OUe(e,o);a==null&&(a=LUe(e,r,t));var u=r==="left"&&!i||r==="right"&&i;s[o.id]=a-Number(u)*l.width,a+=(u?-1:1)*l.width}),s}),FUe=(t,e)=>{var n=Oc(t,e);if(n!=null)return IUe(t,n.orientation,n.mirror)},zUe=Ke([xi,Oc,FUe,(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}}}),BUe=(t,e)=>{var n=jc(t,e);if(n!=null)return UUe(t,n.orientation,n.mirror)},HUe=Ke([xi,jc,BUe,(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}}}),VQ=Ke(xi,jc,(t,e)=>{var n=typeof e.width=="number"?e.width:_b;return{width:n,height:t.height}}),pV=(t,e,n)=>{switch(e){case"xAxis":return $Q(t,n).width;case"yAxis":return VQ(t,n).height;default:return}},GQ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:a}=n,o=kc(t,r),l=e.map(u=>u.value);if(a&&o&&s==="category"&&i&&WX(l))return l}},fj=Ke([wn,jE,wr,gr],GQ),WQ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,a=kc(t,r);if(a&&(i==="number"||s!=="auto"))return e.map(o=>o.value)}},pj=Ke([wn,jE,Pb,gr],WQ),mV=Ke([wn,eUe,tg,ng,fj,pj,Ob,dj,gr],(t,e,n,r,i,s,a,o,l)=>{if(e!=null){var u=kc(t,l);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:l,categoricalDomain:s,duplicateDomain:i,isCategorical:u,niceTicks:o,range:a,realScaleType:n,scale:r}}}),$Ue=(t,e,n,r,i,s,a,o,l)=>{if(!(e==null||r==null)){var u=kc(t,l),{type:d,ticks:f,tickCount:g}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/m:0;x=l==="angleAxis"&&s!=null&&s.length>=2?Di(s[0]-s[1])*2*x:x;var y=f||i;if(y){var v=y.map((b,E)=>{var S=a?a.indexOf(b):b;return{index:E,coordinate:r(S)+x,value:b,offset:x}});return v.filter(b=>ur(b.coordinate))}return u&&o?o.map((b,E)=>({coordinate:r(b)+x,value:b,index:E,offset:x})).filter(b=>ur(b.coordinate)):r.ticks?r.ticks(g).map(b=>({coordinate:r(b)+x,value:b,offset:x})):r.domain().map((b,E)=>({coordinate:r(b)+x,value:a?a[b]:b,index:E,offset:x}))}},qQ=Ke([wn,Pb,tg,ng,dj,Ob,fj,pj,gr],$Ue),VUe=(t,e,n,r,i,s,a)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=kc(t,a),{tickCount:l}=e,u=0;return u=a==="angleAxis"&&r?.length>=2?Di(r[0]-r[1])*2*u:u,o&&s?s.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(l).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},od=Ke([wn,Pb,ng,Ob,fj,pj,gr],VUe),ld=Ke(wr,ng,(t,e)=>{if(!(t==null||e==null))return Xw(Xw({},t),{},{scale:e})}),GUe=Ke([wr,tg,lj,zQ],cj);Ke((t,e,n)=>XO(t,n),GUe,(t,e)=>{if(!(t==null||e==null))return Xw(Xw({},t),{},{scale:e})});var WUe=Ke([wn,hE,fE],(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}}),KQ=t=>t.options.defaultTooltipEventType,XQ=t=>t.options.validateTooltipEventTypes;function YQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function mj(t,e){var n=KQ(t),r=XQ(t);return YQ(e,n,r)}function qUe(t){return kt(e=>mj(e,t))}var ZQ=(t,e)=>{var n,r=Number(e);if(!(io(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},KUe=t=>t.tooltip.settings,Du={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},XUe={itemInteraction:{click:Du,hover:Du},axisInteraction:{click:Du,hover:Du},keyboardInteraction:Du,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},QQ=Zs({name:"tooltip",initialState:XUe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:hr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ro(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:hr()},removeTooltipEntrySettings:{reducer(t,e){var n=Ro(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:hr()},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:YUe,replaceTooltipEntrySettings:ZUe,removeTooltipEntrySettings:QUe,setTooltipSettingsState:JUe,setActiveMouseOverItemIndex:JQ,mouseLeaveItem:e5e,mouseLeaveChart:eJ,setActiveClickItemIndex:t5e,setMouseOverAxisIndex:tJ,setMouseClickAxisIndex:n5e,setSyncInteraction:FP,setKeyboardInteraction:zP}=QQ.actions,r5e=QQ.reducer;function gV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function A_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gV(Object(n),!0).forEach(function(r){i5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function i5e(t,e,n){return(e=s5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s5e(t){var e=a5e(t,"string");return typeof e=="symbol"?e:e+""}function a5e(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 o5e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function l5e(t){return t.index!=null}var nJ=(t,e,n,r)=>{if(e==null)return Du;var i=o5e(t,e,n);if(i==null)return Du;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var s=t.settings.active===!0;if(l5e(i)){if(s)return A_(A_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return A_(A_({},Du),{},{coordinate:i.coordinate})};function c5e(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 u5e(t,e){var n=c5e(t),r=e[0],i=e[1];if(n===void 0)return!1;var s=Math.min(r,i),a=Math.max(r,i);return n>=s&&n<=a}function d5e(t,e,n){if(n==null||e==null)return!0;var r=Jn(t,e);return r==null||!ad(n)?!0:u5e(r,n)}var gj=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!ur(s))return i;var a=0,o=1/0;e.length>0&&(o=e.length-1);var l=Math.max(a,Math.min(s,o)),u=e[l];return u==null||d5e(u,n,r)?String(l):null},rJ=(t,e,n,r,i,s,a,o)=>{if(!(s==null||o==null)){var l=a[0],u=l==null?void 0:o(l.positions,s);if(u!=null)return u;var d=i?.[Number(s)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},iJ=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(s=>{var a;return((a=s.settings)===null||a===void 0?void 0:a.dataKey)===i})},jb=t=>t.options.tooltipPayloadSearcher,rg=t=>t.tooltip;function xV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function bV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xV(Object(n),!0).forEach(function(r){h5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function h5e(t,e,n){return(e=f5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f5e(t){var e=p5e(t,"string");return typeof e=="symbol"?e:e+""}function p5e(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 m5e(t,e){return t??e}var sJ=(t,e,n,r,i,s,a)=>{if(!(e==null||s==null)){var{chartData:o,computedData:l,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((g,m)=>{var x,{dataDefinedOnItem:y,settings:v}=m,b=m5e(y,o),E=Array.isArray(b)?zY(b,u,d):b,S=(x=v?.dataKey)!==null&&x!==void 0?x:r,A=v?.nameKey,T;if(r&&Array.isArray(E)&&!Array.isArray(E[0])&&a==="axis"?T=qX(E,r,i):T=s(E,e,l,A),Array.isArray(T))T.forEach(C=>{var I=bV(bV({},v),{},{name:C.name,unit:C.unit,color:void 0,fill:void 0});g.push(UH({tooltipEntrySettings:I,dataKey:C.dataKey,payload:C.payload,value:Jn(C.payload,C.dataKey),name:C.name}))});else{var P;g.push(UH({tooltipEntrySettings:v,dataKey:S,payload:T,value:Jn(T,S),name:(P=Jn(T,A))!==null&&P!==void 0?P:v?.name}))}return g},f)}},xj=Ke([yi,wn,AQ,$O,vi],UQ),g5e=Ke([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),x5e=Ke([vi,Jm],YO),Lb=Ke([g5e,yi,x5e],ZO,{memoizeOptions:{resultEqualityCheck:DE}}),b5e=Ke([Lb],t=>t.filter(PE)),v5e=Ke([Lb],QO,{memoizeOptions:{resultEqualityCheck:DE}}),ig=Ke([v5e,vd],JO),y5e=Ke([b5e,vd,yi],SQ),bj=Ke([ig,yi,Lb],tj),aJ=Ke([yi],nj),_5e=Ke([yi],t=>t.allowDataOverflow),oJ=Ke([aJ,_5e],eQ),w5e=Ke([Lb],t=>t.filter(PE)),S5e=Ke([y5e,w5e,Nb,gQ],kQ),E5e=Ke([S5e,vd,vi,oJ],PQ),M5e=Ke([Lb],CQ),A5e=Ke([ig,yi,M5e,LE,vi],sj,{memoizeOptions:{resultEqualityCheck:RE}}),T5e=Ke([RQ,vi,Jm],eg),C5e=Ke([T5e,vi],jQ),N5e=Ke([DQ,vi,Jm],eg),k5e=Ke([N5e,vi],LQ),P5e=Ke([OQ,vi,Jm],eg),R5e=Ke([P5e,vi],IQ),D5e=Ke([C5e,R5e,k5e],Yw),O5e=Ke([yi,aJ,oJ,E5e,A5e,D5e,wn,vi],aj),Ib=Ke([yi,wn,ig,bj,Nb,vi,O5e],oj),j5e=Ke([Ib,yi,xj],uj),L5e=Ke([yi,Ib,j5e,vi],hj),lJ=t=>{var e=vi(t),n=Jm(t),r=!1;return Ob(t,e,n,r)},cJ=Ke([yi,lJ],CE),uJ=Ke([yi,xj,L5e,cJ],cj),I5e=Ke([wn,bj,yi,vi],GQ),U5e=Ke([wn,bj,yi,vi],WQ),F5e=(t,e,n,r,i,s,a,o)=>{if(e){var{type:l}=e,u=kc(t,o);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=l==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=o==="angleAxis"&&i!=null&&i?.length>=2?Di(i[0]-i[1])*2*f:f,u&&a?a.map((g,m)=>({coordinate:r(g)+f,value:g,index:m,offset:f})):r.domain().map((g,m)=>({coordinate:r(g)+f,value:s?s[g]:g,index:m,offset:f}))}}},Lc=Ke([wn,yi,xj,uJ,lJ,I5e,U5e,vi],F5e),vj=Ke([KQ,XQ,KUe],(t,e,n)=>YQ(n.shared,t,e)),dJ=t=>t.tooltip.settings.trigger,yj=t=>t.tooltip.settings.defaultIndex,Ub=Ke([rg,vj,dJ,yj],nJ),cd=Ke([Ub,ig,Db,Ib],gj),hJ=Ke([Lc,cd],ZQ),_j=Ke([Ub],t=>{if(t)return t.dataKey}),z5e=Ke([Ub],t=>{if(t)return t.graphicalItemId}),fJ=Ke([rg,vj,dJ,yj],iJ),B5e=Ke([Pc,Rc,wn,xi,Lc,yj,fJ,jb],rJ),H5e=Ke([Ub,B5e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),$5e=Ke([Ub],t=>t.active),V5e=Ke([fJ,cd,vd,Db,hJ,jb,vj],sJ),G5e=Ke([V5e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function vV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vV(Object(n),!0).forEach(function(r){W5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function W5e(t,e,n){return(e=q5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q5e(t){var e=K5e(t,"string");return typeof e=="symbol"?e:e+""}function K5e(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 X5e=()=>kt(yi),Y5e=()=>{var t=X5e(),e=kt(Lc),n=kt(uJ);return Tm(!t||!n?void 0:yV(yV({},t),{},{scale:n}),e)};function _V(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?_V(Object(n),!0).forEach(function(r){Z5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_V(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Z5e(t,e,n){return(e=Q5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Q5e(t){var e=J5e(t,"string");return typeof e=="symbol"?e:e+""}function J5e(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 eFe=(t,e,n,r)=>{var i=e.find(s=>s&&s.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},tFe=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var s=i.coordinate,{radius:a}=r;return Ep(Ep(Ep({},r),Yr(r.cx,r.cy,a,s)),{},{angle:s,radius:a})}var o=i.coordinate,{angle:l}=r;return Ep(Ep(Ep({},r),Yr(r.cx,r.cy,o,l)),{},{angle:l,radius:o})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function nFe(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 pJ=(t,e,n,r,i)=>{var s,a=-1,o=(s=e?.length)!==null&&s!==void 0?s:0;if(o<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var l=0;l<o;l++){var u=l>0?n[l-1].coordinate:n[o-1].coordinate,d=n[l].coordinate,f=l>=o-1?n[0].coordinate:n[l+1].coordinate,g=void 0;if(Di(d-u)!==Di(f-d)){var m=[];if(Di(f-d)===Di(i[1]-i[0])){g=f;var x=d+i[1]-i[0];m[0]=Math.min(x,(x+u)/2),m[1]=Math.max(x,(x+u)/2)}else{g=u;var y=f+i[1]-i[0];m[0]=Math.min(d,(y+d)/2),m[1]=Math.max(d,(y+d)/2)}var v=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>v[0]&&t<=v[1]||t>=m[0]&&t<=m[1]){({index:a}=n[l]);break}}else{var b=Math.min(u,f),E=Math.max(u,f);if(t>(b+d)/2&&t<=(E+d)/2){({index:a}=n[l]);break}}}else if(e){for(var S=0;S<o;S++)if(S===0&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S>0&&S<o-1&&t>(e[S].coordinate+e[S-1].coordinate)/2&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S===o-1&&t>(e[S].coordinate+e[S-1].coordinate)/2){({index:a}=e[S]);break}}return a},mJ=()=>kt($O),wj=(t,e)=>e,gJ=(t,e,n)=>n,Sj=(t,e,n,r)=>r,rFe=Ke(Lc,t=>rE(t,e=>e.coordinate)),Ej=Ke([rg,wj,gJ,Sj],nJ),Mj=Ke([Ej,ig,Db,Ib],gj),iFe=(t,e,n)=>{if(e!=null){var r=rg(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},xJ=Ke([rg,wj,gJ,Sj],iJ),Zw=Ke([Pc,Rc,wn,xi,Lc,Sj,xJ,jb],rJ),sFe=Ke([Ej,Zw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),bJ=Ke([Lc,Mj],ZQ),aFe=Ke([xJ,Mj,vd,Db,bJ,jb,wj],sJ),oFe=Ke([Ej,Mj],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),lFe=(t,e,n,r,i,s,a)=>{if(!(!t||!n||!r||!i)&&nFe(t,a)){var o=NDe(t,e),l=pJ(o,s,i,n,r),u=eFe(e,i,l,t);return{activeIndex:String(l),activeCoordinate:u}}},cFe=(t,e,n,r,i,s,a)=>{if(!(!t||!r||!i||!s||!n)){var o=Wje(t,n);if(o){var l=kDe(o,e),u=pJ(l,a,s,r,i),d=tFe(e,s,u,o);return{activeIndex:String(u),activeCoordinate:d}}}},uFe=(t,e,n,r,i,s,a,o)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?lFe(t,e,r,i,s,a,o):cFe(t,e,n,r,i,s,a)},dFe=Ke(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}}),hFe=Ke(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Zr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:X4e}});function wV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function SV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wV(Object(n),!0).forEach(function(r){fFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fFe(t,e,n){return(e=pFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pFe(t){var e=mFe(t,"string");return typeof e=="symbol"?e:e+""}function mFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var gFe={},xFe={zIndexMap:Object.values(Zr).reduce((t,e)=>SV(SV({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),gFe)},bFe=new Set(Object.values(Zr));function vFe(t){return bFe.has(t)}var vJ=Zs({name:"zIndex",initialState:xFe,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:hr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!vFe(n)&&delete t.zIndexMap[n])},prepare:hr()},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:hr()},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:hr()}}}),{registerZIndexPortal:yFe,unregisterZIndexPortal:_Fe,registerZIndexPortalId:wFe,unregisterZIndexPortalId:SFe}=vJ.actions,EFe=vJ.reducer;function Qs(t){var{zIndex:e,children:n}=t,r=lOe(),i=r&&e!==void 0&&e!==0,s=ms(),a=rr();M.useLayoutEffect(()=>i?(a(yFe({zIndex:e})),()=>{a(_Fe({zIndex:e}))}):gb,[a,e,i]);var o=kt(u=>dFe(u,e,s));if(!i)return n;if(!o)return null;var l=document.getElementById(o);return l?ic.createPortal(n,l):null}function BP(){return BP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},BP.apply(null,arguments)}function EV(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 T_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?EV(Object(n),!0).forEach(function(r){MFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):EV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MFe(t,e,n){return(e=AFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function AFe(t){var e=TFe(t,"string");return typeof e=="symbol"?e:e+""}function TFe(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 CFe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return M.isValidElement(e)?M.cloneElement(e,r):M.createElement(n,r)}function NFe(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:a,layout:o,cursor:l,tooltipEventType:u,chartName:d}=t,f=n,g=r,m=i;if(!l||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,y,v;if(d==="ScatterChart")x=f,y=oje,v=Zr.cursorLine;else if(d==="BarChart")x=lje(o,f,s,a),y=pZ,v=Zr.cursorRectangle;else if(o==="radial"&&XX(f)){var{cx:b,cy:E,radius:S,startAngle:A,endAngle:T}=gZ(f);x={cx:b,cy:E,startAngle:A,endAngle:T,innerRadius:S,outerRadius:S},y=bZ,v=Zr.cursorLine}else x={points:Yje(o,f,s)},y=em,v=Zr.cursorLine;var P=typeof l=="object"&&"className"in l?l.className:void 0,C=T_(T_(T_(T_({stroke:"#ccc",pointerEvents:"none"},s),x),qh(l)),{},{payload:g,payloadIndex:m,className:Tn("recharts-tooltip-cursor",P)});return M.createElement(Qs,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},M.createElement(CFe,{cursor:l,cursorComp:y,cursorProps:C}))}function kFe(t){var e=Y5e(),n=ZY(),r=Km(),i=mJ();return e==null||n==null||r==null||i==null?null:M.createElement(NFe,BP({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var yJ=M.createContext(null),PFe=()=>M.useContext(yJ),EN={exports:{}},MV;function RFe(){return MV||(MV=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(l,u,d){this.fn=l,this.context=u,this.once=d||!1}function s(l,u,d,f,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,f||l,g),x=n?n+u:u;return l._events[x]?l._events[x].fn?l._events[x]=[l._events[x],m]:l._events[x].push(m):(l._events[x]=m,l._eventsCount++),l}function a(l,u){--l._eventsCount===0?l._events=new r:delete l._events[u]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},o.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,m=f.length,x=new Array(m);g<m;g++)x[g]=f[g].fn;return x},o.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},o.prototype.emit=function(u,d,f,g,m,x){var y=n?n+u:u;if(!this._events[y])return!1;var v=this._events[y],b=arguments.length,E,S;if(v.fn){switch(v.once&&this.removeListener(u,v.fn,void 0,!0),b){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,d),!0;case 3:return v.fn.call(v.context,d,f),!0;case 4:return v.fn.call(v.context,d,f,g),!0;case 5:return v.fn.call(v.context,d,f,g,m),!0;case 6:return v.fn.call(v.context,d,f,g,m,x),!0}for(S=1,E=new Array(b-1);S<b;S++)E[S-1]=arguments[S];v.fn.apply(v.context,E)}else{var A=v.length,T;for(S=0;S<A;S++)switch(v[S].once&&this.removeListener(u,v[S].fn,void 0,!0),b){case 1:v[S].fn.call(v[S].context);break;case 2:v[S].fn.call(v[S].context,d);break;case 3:v[S].fn.call(v[S].context,d,f);break;case 4:v[S].fn.call(v[S].context,d,f,g);break;default:if(!E)for(T=1,E=new Array(b-1);T<b;T++)E[T-1]=arguments[T];v[S].fn.apply(v[S].context,E)}}return!0},o.prototype.on=function(u,d,f){return s(this,u,d,f,!1)},o.prototype.once=function(u,d,f){return s(this,u,d,f,!0)},o.prototype.removeListener=function(u,d,f,g){var m=n?n+u:u;if(!this._events[m])return this;if(!d)return a(this,m),this;var x=this._events[m];if(x.fn)x.fn===d&&(!g||x.once)&&(!f||x.context===f)&&a(this,m);else{for(var y=0,v=[],b=x.length;y<b;y++)(x[y].fn!==d||g&&!x[y].once||f&&x[y].context!==f)&&v.push(x[y]);v.length?this._events[m]=v.length===1?v[0]:v:a(this,m)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&a(this,d)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o})(EN)),EN.exports}var DFe=RFe();const OFe=oo(DFe);var Q0=new OFe,HP="recharts.syncEvent.tooltip",AV="recharts.syncEvent.brush";function Aj(t,e){if(e){var n=Number.parseInt(e,10);if(!io(n))return t?.[n]}}var jFe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},_J=Zs({name:"options",initialState:jFe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),LFe=_J.reducer,{createEventEmitter:IFe}=_J.actions;function UFe(t){return t.tooltip.syncInteraction}var FFe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},wJ=Zs({name:"chartData",initialState:FFe,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:TV,setDataStartEndIndexes:zFe,setComputedData:b7e}=wJ.actions,BFe=wJ.reducer,HFe=["x","y"];function CV(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 Mp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CV(Object(n),!0).forEach(function(r){$Fe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Fe(t,e,n){return(e=VFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VFe(t){var e=GFe(t,"string");return typeof e=="symbol"?e:e+""}function GFe(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 WFe(t,e){if(t==null)return{};var n,r,i=qFe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function qFe(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 KFe(){var t=kt(VO),e=kt(GO),n=rr(),r=kt(xQ),i=kt(Lc),s=Km(),a=gE(),o=kt(l=>l.rootProps.className);M.useEffect(()=>{if(t==null)return gb;var l=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var g;if(a&&d!==null&&d!==void 0&&(g=d.payload)!==null&&g!==void 0&&g.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x,y}=m,v=WFe(m,HFe),{x:b,y:E,width:S,height:A}=d.payload.sourceViewBox,T=Mp(Mp({},v),{},{x:a.x+(S?(x-b)/S:0)*a.width,y:a.y+(A?(y-E)/A:0)*a.height});n(Mp(Mp({},d),{},{payload:Mp(Mp({},d.payload),{},{coordinate:T})}))}else n(d);return}if(i!=null){var P;if(typeof r=="function"){var C={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,C);P=i[I]}else r==="value"&&(P=i.find(K=>String(K.value)===d.payload.label));var{coordinate:N}=d.payload;if(P==null||d.payload.active===!1||N==null||a==null){n(FP({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}=N,L=Math.min(D,a.x+a.width),q=Math.min(F,a.y+a.height),R={x:s==="horizontal"?P.coordinate:L,y:s==="horizontal"?q:P.coordinate},V=FP({active:d.payload.active,coordinate:R,dataKey:d.payload.dataKey,index:String(P.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(V)}}};return Q0.on(HP,l),()=>{Q0.off(HP,l)}},[o,n,e,t,r,i,s,a])}function XFe(){var t=kt(VO),e=kt(GO),n=rr();M.useEffect(()=>{if(t==null)return gb;var r=(i,s,a)=>{e!==a&&t===i&&n(zFe(s))};return Q0.on(AV,r),()=>{Q0.off(AV,r)}},[n,e,t])}function YFe(){var t=rr();M.useEffect(()=>{t(IFe())},[t]),KFe(),XFe()}function ZFe(t,e,n,r,i,s){var a=kt(m=>iFe(m,t,e)),o=kt(GO),l=kt(VO),u=kt(xQ),d=kt(UFe),f=d?.active,g=gE();M.useEffect(()=>{if(!f&&l!=null&&o!=null){var m=FP({active:s,coordinate:n,dataKey:a,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});Q0.emit(HP,l,m,o)}},[f,n,a,i,r,o,l,u,s,g])}function NV(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?NV(Object(n),!0).forEach(function(r){QFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):NV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QFe(t,e,n){return(e=JFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JFe(t){var e=eze(t,"string");return typeof e=="symbol"?e:e+""}function eze(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 tze(t){return t.dataKey}function nze(t,e){return M.isValidElement(t)?M.cloneElement(t,e):typeof t=="function"?M.createElement(t,e):M.createElement(zOe,e)}var PV=[],rze={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 MN(t){var e,n,r=ii(t,rze),{active:i,allowEscapeViewBox:s,animationDuration:a,animationEasing:o,content:l,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:g,position:m,reverseDirection:x,useTranslate3d:y,wrapperStyle:v,cursor:b,shared:E,trigger:S,defaultIndex:A,portal:T,axisId:P}=r,C=rr(),I=typeof A=="number"?String(A):A;M.useEffect(()=>{C(JUe({shared:E,trigger:S,axisId:P,active:i,defaultIndex:I}))},[C,E,S,P,i,I]);var N=gE(),D=cZ(),F=qUe(E),{activeIndex:L,isActive:q}=(e=kt(xe=>oFe(xe,F,S,I)))!==null&&e!==void 0?e:{},R=kt(xe=>aFe(xe,F,S,I)),V=kt(xe=>bJ(xe,F,S,I)),K=kt(xe=>sFe(xe,F,S,I)),W=R,ne=PFe(),Y=(n=i??q)!==null&&n!==void 0?n:!1,[Z,U]=uY([W,Y]),$=F==="axis"?V:void 0;ZFe(F,S,K,$,L,Y);var ee=T??ne;if(ee==null||N==null||F==null)return null;var ae=W??PV;Y||(ae=PV),u&&ae.length&&(ae=sY(ae.filter(xe=>xe.value!=null&&(xe.hide!==!0||r.includeHidden)),g,tze));var fe=ae.length>0,ue=M.createElement(qOe,{allowEscapeViewBox:s,animationDuration:a,animationEasing:o,isAnimationActive:d,active:Y,coordinate:K,hasPayload:fe,offset:f,position:m,reverseDirection:x,useTranslate3d:y,viewBox:N,wrapperStyle:v,lastBoundingBox:Z,innerRef:U,hasPortalFromProps:!!T},nze(l,kV(kV({},r),{},{payload:ae,label:$,active:Y,activeIndex:L,coordinate:K,accessibilityLayer:D})));return M.createElement(M.Fragment,null,ic.createPortal(ue,ee),Y&&M.createElement(kFe,{cursor:b,tooltipEventType:F,coordinate:K,payload:ae,index:L}))}var Fb=t=>null;Fb.displayName="Cell";function ize(t,e,n){return(e=sze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sze(t){var e=aze(t,"string");return typeof e=="symbol"?e:e+""}function aze(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 oze{constructor(e){ize(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 RV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function lze(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?RV(Object(n),!0).forEach(function(r){cze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cze(t,e,n){return(e=uze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uze(t){var e=dze(t,"string");return typeof e=="symbol"?e:e+""}function dze(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 hze={cacheSize:2e3,enableCache:!0},SJ=lze({},hze),DV=new oze(SJ.cacheSize),fze={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},OV="recharts_measurement_span";function pze(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",s=e.fontStyle||"",a=e.letterSpacing||"",o=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(s,"|").concat(a,"|").concat(o)}var jV=(t,e)=>{try{var n=document.getElementById(OV);n||(n=document.createElement("span"),n.setAttribute("id",OV),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,fze,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},e0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Xm.isSsr)return{width:0,height:0};if(!SJ.enableCache)return jV(e,n);var r=pze(e,n),i=DV.get(r);if(i)return i;var s=jV(e,n);return DV.set(r,s),s},LV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,IV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,mze=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,gze=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,EJ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},xze=Object.keys(EJ),Fp="NaN";function bze(t,e){return t*EJ[e]}class Fs{static parse(e){var n,[,r,i]=(n=gze.exec(e))!==null&&n!==void 0?n:[];return new Fs(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,io(e)&&(this.unit=""),n!==""&&!mze.test(n)&&(this.num=NaN,this.unit=""),xze.includes(n)&&(this.num=bze(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Fs(NaN,""):new Fs(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return io(this.num)}}function MJ(t){if(t.includes(Fp))return Fp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=LV.exec(e))!==null&&n!==void 0?n:[],a=Fs.parse(r??""),o=Fs.parse(s??""),l=i==="*"?a.multiply(o):a.divide(o);if(l.isNaN())return Fp;e=e.replace(LV,l.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=IV.exec(e))!==null&&u!==void 0?u:[],m=Fs.parse(d??""),x=Fs.parse(g??""),y=f==="+"?m.add(x):m.subtract(x);if(y.isNaN())return Fp;e=e.replace(IV,y.toString())}return e}var UV=/\(([^()]*)\)/;function vze(t){for(var e=t,n;(n=UV.exec(e))!=null;){var[,r]=n;e=e.replace(UV,MJ(r))}return e}function yze(t){var e=t.replace(/\s+/g,"");return e=vze(e),e=MJ(e),e}function _ze(t){try{return yze(t)}catch{return Fp}}function AN(t){var e=_ze(t.slice(5,-1));return e===Fp?"":e}var wze=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],Sze=["dx","dy","angle","className","breakAll"];function $P(){return $P=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},$P.apply(null,arguments)}function FV(t,e){if(t==null)return{};var n,r,i=Eze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Eze(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var AJ=/[ \f\n\r\t\v\u2028\u2029]+/,TJ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];yr(e)||(n?i=e.toString().split(""):i=e.toString().split(AJ));var s=i.map(o=>({word:o,width:e0(o,r).width})),a=n?0:e0(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:a}}catch{return null}};function Mze(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var CJ=(t,e,n,r)=>t.reduce((i,s)=>{var{word:a,width:o}=s,l=i[i.length-1];if(l&&o!=null&&(e==null||r||l.width+o+n<Number(e)))l.words.push(a),l.width+=o+n;else{var u={words:[a],width:o};i.push(u)}return i},[]),NJ=t=>t.reduce((e,n)=>e.width>n.width?e:n),Aze="…",zV=(t,e,n,r,i,s,a,o)=>{var l=t.slice(0,e),u=TJ({breakAll:n,style:r,children:l+Aze});if(!u)return[!1,[]];var d=CJ(u.wordsWithComputedWidth,s,a,o),f=d.length>i||NJ(d).width>Number(s);return[f,d]},Tze=(t,e,n,r,i)=>{var{maxLines:s,children:a,style:o,breakAll:l}=t,u=Ct(s),d=String(a),f=CJ(e,r,n,i);if(!u||i)return f;var g=f.length>s||NJ(f).width>Number(r);if(!g)return f;for(var m=0,x=d.length-1,y=0,v;m<=x&&y<=d.length-1;){var b=Math.floor((m+x)/2),E=b-1,[S,A]=zV(d,E,l,o,s,r,n,i),[T]=zV(d,b,l,o,s,r,n,i);if(!S&&!T&&(m=b+1),S&&T&&(x=b-1),!S&&T){v=A;break}y++}return v||f},BV=t=>{var e=yr(t)?[]:t.toString().split(AJ);return[{words:e,width:void 0}]},Cze=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:a}=t;if((e||n)&&!Xm.isSsr){var o,l,u=TJ({breakAll:s,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;o=d,l=f}else return BV(r);return Tze({breakAll:s,children:r,maxLines:a,style:i},o,l,e,!!n)}return BV(r)},kJ="#808080",Nze={angle:0,breakAll:!1,capHeight:"0.71em",fill:kJ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},FE=M.forwardRef((t,e)=>{var n=ii(t,Nze),{x:r,y:i,lineHeight:s,capHeight:a,fill:o,scaleToFit:l,textAnchor:u,verticalAnchor:d}=n,f=FV(n,wze),g=M.useMemo(()=>Cze({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:l,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,l,f.style,f.width]),{dx:m,dy:x,angle:y,className:v,breakAll:b}=f,E=FV(f,Sze);if(!fl(r)||!fl(i)||g.length===0)return null;var S=Number(r)+(Ct(m)?m:0),A=Number(i)+(Ct(x)?x:0);if(!ur(S)||!ur(A))return null;var T;switch(d){case"start":T=AN("calc(".concat(a,")"));break;case"middle":T=AN("calc(".concat((g.length-1)/2," * -").concat(s," + (").concat(a," / 2))"));break;default:T=AN("calc(".concat(g.length-1," * -").concat(s,")"));break}var P=[];if(l){var C=g[0].width,{width:I}=f;P.push("scale(".concat(Ct(I)&&Ct(C)?I/C:1,")"))}return y&&P.push("rotate(".concat(y,", ").concat(S,", ").concat(A,")")),P.length&&(E.transform=P.join(" ")),M.createElement("text",$P({},Cs(E),{ref:e,x:S,y:A,className:Tn("recharts-text",v),textAnchor:u,fill:o.includes("url")?kJ:o}),g.map((N,D)=>{var F=N.words.join(b?"":" ");return M.createElement("tspan",{x:S,dy:D===0?T:s,key:"".concat(F,"-").concat(D)},F)}))});FE.displayName="Text";var kze=["labelRef"];function Pze(t,e){if(t==null)return{};var n,r,i=Rze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Rze(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function HV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Or(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HV(Object(n),!0).forEach(function(r){Dze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Dze(t,e,n){return(e=Oze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Oze(t){var e=jze(t,"string");return typeof e=="symbol"?e:e+""}function jze(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 rc(){return rc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},rc.apply(null,arguments)}var PJ=M.createContext(null),Lze=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a,children:o}=t,l=M.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a}),[e,n,r,i,s,a]);return M.createElement(PJ.Provider,{value:l},o)},RJ=()=>{var t=M.useContext(PJ),e=gE();return t||YY(e)},Ize=M.createContext(null),Uze=()=>{var t=M.useContext(Ize),e=kt(wQ);return t||e},Fze=t=>{var{value:e,formatter:n}=t,r=yr(t.children)?e:t.children;return typeof n=="function"?n(r):r},Tj=t=>t!=null&&typeof t=="function",zze=(t,e)=>{var n=Di(e-t),r=Math.min(Math.abs(e-t),360);return n*r},Bze=(t,e,n,r,i)=>{var{offset:s,className:a}=t,{cx:o,cy:l,innerRadius:u,outerRadius:d,startAngle:f,endAngle:g,clockWise:m}=i,x=(u+d)/2,y=zze(f,g),v=y>=0?1:-1,b,E;switch(e){case"insideStart":b=f+v*s,E=m;break;case"insideEnd":b=g-v*s,E=!m;break;case"end":b=g+v*s,E=m;break;default:throw new Error("Unsupported position ".concat(e))}E=y<=0?E:!E;var S=Yr(o,l,x,b),A=Yr(o,l,x,b+(E?1:-1)*359),T="M".concat(S.x,",").concat(S.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(E?0:1,`,
- `).concat(A.x,",").concat(A.y),P=yr(t.id)?U0("recharts-radial-line-"):t.id;return M.createElement("text",rc({},r,{dominantBaseline:"central",className:Tn("recharts-radial-bar-label",a)}),M.createElement("defs",null,M.createElement("path",{id:P,d:T})),M.createElement("textPath",{xlinkHref:"#".concat(P)},n))},Hze=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:a,startAngle:o,endAngle:l}=t,u=(o+l)/2;if(n==="outside"){var{x:d,y:f}=Yr(r,i,a+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(s+a)/2,{x:m,y:x}=Yr(r,i,g,u);return{x:m,y:x,textAnchor:"middle",verticalAnchor:"middle"}},VP=t=>"cx"in t&&Ct(t.cx),$ze=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!VP(n)&&(s=n);var{x:a,y:o,upperWidth:l,lowerWidth:u,height:d}=e,f=a,g=a+(l-u)/2,m=(f+g)/2,x=(l+u)/2,y=f+l/2,v=d>=0?1:-1,b=v*r,E=v>0?"end":"start",S=v>0?"start":"end",A=l>=0?1:-1,T=A*r,P=A>0?"end":"start",C=A>0?"start":"end";if(i==="top"){var I={x:f+l/2,y:o-b,textAnchor:"middle",verticalAnchor:E};return Or(Or({},I),s?{height:Math.max(o-s.y,0),width:l}:{})}if(i==="bottom"){var N={x:g+u/2,y:o+d+b,textAnchor:"middle",verticalAnchor:S};return Or(Or({},N),s?{height:Math.max(s.y+s.height-(o+d),0),width:u}:{})}if(i==="left"){var D={x:m-T,y:o+d/2,textAnchor:P,verticalAnchor:"middle"};return Or(Or({},D),s?{width:Math.max(D.x-s.x,0),height:d}:{})}if(i==="right"){var F={x:m+x+T,y:o+d/2,textAnchor:C,verticalAnchor:"middle"};return Or(Or({},F),s?{width:Math.max(s.x+s.width-F.x,0),height:d}:{})}var L=s?{width:x,height:d}:{};return i==="insideLeft"?Or({x:m+T,y:o+d/2,textAnchor:C,verticalAnchor:"middle"},L):i==="insideRight"?Or({x:m+x-T,y:o+d/2,textAnchor:P,verticalAnchor:"middle"},L):i==="insideTop"?Or({x:f+l/2,y:o+b,textAnchor:"middle",verticalAnchor:S},L):i==="insideBottom"?Or({x:g+u/2,y:o+d-b,textAnchor:"middle",verticalAnchor:E},L):i==="insideTopLeft"?Or({x:f+T,y:o+b,textAnchor:C,verticalAnchor:S},L):i==="insideTopRight"?Or({x:f+l-T,y:o+b,textAnchor:P,verticalAnchor:S},L):i==="insideBottomLeft"?Or({x:g+T,y:o+d-b,textAnchor:C,verticalAnchor:E},L):i==="insideBottomRight"?Or({x:g+u-T,y:o+d-b,textAnchor:P,verticalAnchor:E},L):i&&typeof i=="object"&&(Ct(i.x)||wc(i.x))&&(Ct(i.y)||wc(i.y))?Or({x:a+hs(i.x,x),y:o+hs(i.y,d),textAnchor:"end",verticalAnchor:"end"},L):Or({x:y,y:o+d/2,textAnchor:"middle",verticalAnchor:"middle"},L)},Vze={angle:0,offset:5,zIndex:Zr.label,position:"middle",textBreakAll:!1};function Nu(t){var e=ii(t,Vze),{viewBox:n,position:r,value:i,children:s,content:a,className:o="",textBreakAll:l,labelRef:u}=e,d=Uze(),f=RJ(),g=r==="center"?f:d??f,m,x,y;if(n==null?m=g:VP(n)?m=n:m=YY(n),!m||yr(i)&&yr(s)&&!M.isValidElement(a)&&typeof a!="function")return null;var v=Or(Or({},e),{},{viewBox:m});if(M.isValidElement(a)){var{labelRef:b}=v,E=Pze(v,kze);return M.cloneElement(a,E)}if(typeof a=="function"){if(x=M.createElement(a,v),M.isValidElement(x))return x}else x=Fze(e);var S=Cs(e);if(VP(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return Bze(e,r,x,S,m);y=Hze(m,e.offset,e.position)}else y=$ze(e,m);return M.createElement(Qs,{zIndex:e.zIndex},M.createElement(FE,rc({ref:u,className:Tn("recharts-label",o)},S,y,{textAnchor:Mze(S.textAnchor)?S.textAnchor:y.textAnchor,breakAll:l}),x))}Nu.displayName="Label";var Gze=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?M.createElement(Nu,rc({key:"label-implicit"},r)):fl(t)?M.createElement(Nu,rc({key:"label-implicit",value:t},r)):M.isValidElement(t)?t.type===Nu?M.cloneElement(t,Or({key:"label-implicit"},r)):M.createElement(Nu,rc({key:"label-implicit",content:t},r)):Tj(t)?M.createElement(Nu,rc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?M.createElement(Nu,rc({},t,{key:"label-implicit"},r)):null};function Wze(t){var{label:e,labelRef:n}=t,r=RJ();return Gze(e,r,n)||null}var TN={},CN={},$V;function qze(){return $V||($V=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(CN)),CN}var NN={},VV;function Kze(){return VV||(VV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(NN)),NN}var GV;function Xze(){return GV||(GV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qze(),n=Kze(),r=tO();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(TN)),TN}var kN,WV;function Yze(){return WV||(WV=1,kN=Xze().last),kN}var Zze=Yze();const Qze=oo(Zze);var Jze=["valueAccessor"],eBe=["dataKey","clockWise","id","textBreakAll","zIndex"];function Qw(){return Qw=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},Qw.apply(null,arguments)}function qV(t,e){if(t==null)return{};var n,r,i=tBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function tBe(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 nBe=t=>Array.isArray(t.value)?Qze(t.value):t.value,DJ=M.createContext(void 0),OJ=DJ.Provider,jJ=M.createContext(void 0),rBe=jJ.Provider;function iBe(){return M.useContext(DJ)}function sBe(){return M.useContext(jJ)}function e1(t){var{valueAccessor:e=nBe}=t,n=qV(t,Jze),{dataKey:r,clockWise:i,id:s,textBreakAll:a,zIndex:o}=n,l=qV(n,eBe),u=iBe(),d=sBe(),f=u||d;return!f||!f.length?null:M.createElement(Qs,{zIndex:o??Zr.label},M.createElement(Ir,{className:"recharts-label-list"},f.map((g,m)=>{var x,y=yr(r)?e(g,m):Jn(g&&g.payload,r),v=yr(s)?{}:{id:"".concat(s,"-").concat(m)};return M.createElement(Nu,Qw({key:"label-".concat(m)},Cs(g),l,v,{fill:(x=n.fill)!==null&&x!==void 0?x:g.fill,parentViewBox:g.parentViewBox,value:y,textBreakAll:a,viewBox:g.viewBox,index:m,zIndex:0}))})))}e1.displayName="LabelList";function Cj(t){var{label:e}=t;return e?e===!0?M.createElement(e1,{key:"labelList-implicit"}):M.isValidElement(e)||Tj(e)?M.createElement(e1,{key:"labelList-implicit",content:e}):typeof e=="object"?M.createElement(e1,Qw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function GP(){return GP=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},GP.apply(null,arguments)}var LJ=t=>{var{cx:e,cy:n,r,className:i}=t,s=Tn("recharts-dot",i);return Ct(e)&&Ct(n)&&Ct(r)?M.createElement("circle",GP({},Ks(t),eO(t),{className:s,cx:e,cy:n,r})):null},IJ=t=>t.graphicalItems.polarItems,aBe=Ke([gr,kb],YO),zE=Ke([IJ,wr,aBe],ZO),oBe=Ke([zE],QO),BE=Ke([oBe,zO],JO),lBe=Ke([BE,wr,zE],tj);Ke([BE,wr,zE],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,a=Jn(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:a,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Jn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var KV=()=>{},cBe=Ke([BE,wr,zE,LE,gr],sj),uBe=Ke([wr,rj,ij,KV,cBe,KV,wn,gr],aj),UJ=Ke([wr,wn,BE,lBe,Nb,gr,uBe],oj),dBe=Ke([UJ,wr,tg],uj);Ke([wr,UJ,dBe,gr],hj);var hBe={radiusAxis:{},angleAxis:{}},FJ=Zs({name:"polarAxis",initialState:hBe,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:v7e,removeRadiusAxis:y7e,addAngleAxis:_7e,removeAngleAxis:w7e}=FJ.actions,fBe=FJ.reducer;function XV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function YV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XV(Object(n),!0).forEach(function(r){pBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pBe(t,e,n){return(e=mBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mBe(t){var e=gBe(t,"string");return typeof e=="symbol"?e:e+""}function gBe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var xBe=(t,e)=>e,Nj=Ke([IJ,xBe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),bBe=[],kj=(t,e,n)=>n?.length===0?bBe:n,zJ=Ke([zO,Nj,kj],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(s=>YV(YV({},e.presentationProps),s.props))),i!=null)return i}}),vBe=Ke([zJ,Nj,kj],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,a=Jn(r,e.nameKey,e.name),o;return n!=null&&(s=n[i])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:qm(a,e.dataKey),color:o,payload:r,type:e.legendType}})}),yBe=Ke([zJ,Nj,kj,xi],(t,e,n,r)=>{if(!(e==null||t==null))return _6e({offset:r,pieSettings:e,displayedData:t,cells:n})}),PN={exports:{}},Bn={};var ZV;function _Be(){if(ZV)return Bn;ZV=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function x(y){if(typeof y=="object"&&y!==null){var v=y.$$typeof;switch(v){case t:switch(y=y.type,y){case n:case i:case r:case l:case u:case g:return y;default:switch(y=y&&y.$$typeof,y){case a:case o:case f:case d:return y;case s:return y;default:return v}}case e:return v}}}return Bn.ContextConsumer=s,Bn.ContextProvider=a,Bn.Element=t,Bn.ForwardRef=o,Bn.Fragment=n,Bn.Lazy=f,Bn.Memo=d,Bn.Portal=e,Bn.Profiler=i,Bn.StrictMode=r,Bn.Suspense=l,Bn.SuspenseList=u,Bn.isContextConsumer=function(y){return x(y)===s},Bn.isContextProvider=function(y){return x(y)===a},Bn.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},Bn.isForwardRef=function(y){return x(y)===o},Bn.isFragment=function(y){return x(y)===n},Bn.isLazy=function(y){return x(y)===f},Bn.isMemo=function(y){return x(y)===d},Bn.isPortal=function(y){return x(y)===e},Bn.isProfiler=function(y){return x(y)===i},Bn.isStrictMode=function(y){return x(y)===r},Bn.isSuspense=function(y){return x(y)===l},Bn.isSuspenseList=function(y){return x(y)===u},Bn.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===l||y===u||typeof y=="object"&&y!==null&&(y.$$typeof===f||y.$$typeof===d||y.$$typeof===a||y.$$typeof===s||y.$$typeof===o||y.$$typeof===m||y.getModuleId!==void 0)},Bn.typeOf=x,Bn}var QV;function wBe(){return QV||(QV=1,PN.exports=_Be()),PN.exports}var SBe=wBe(),JV=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",e9=null,RN=null,BJ=t=>{if(t===e9&&Array.isArray(RN))return RN;var e=[];return M.Children.forEach(t,n=>{yr(n)||(SBe.isFragment(n)?e=e.concat(BJ(n.props.children)):e.push(n))}),RN=e,e9=t,e};function Pj(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>JV(i)):r=[JV(e)],BJ(t).forEach(i=>{var s=Kh(i,"type.displayName")||Kh(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var HJ=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,DN={},t9;function EBe(){return t9||(t9=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})(DN)),DN}var ON,n9;function MBe(){return n9||(n9=1,ON=EBe().isPlainObject),ON}var ABe=MBe();const TBe=oo(ABe);function r9(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 i9(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r9(Object(n),!0).forEach(function(r){CBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function CBe(t,e,n){return(e=NBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function NBe(t){var e=kBe(t,"string");return typeof e=="symbol"?e:e+""}function kBe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Jw(){return Jw=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},Jw.apply(null,arguments)}var s9=(t,e,n,r,i)=>{var s=n-r,a;return a="M ".concat(t,",").concat(e),a+="L ".concat(t+n,",").concat(e),a+="L ".concat(t+n-s/2,",").concat(e+i),a+="L ".concat(t+n-s/2-r,",").concat(e+i),a+="L ".concat(t,",").concat(e," Z"),a},PBe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},RBe=t=>{var e=ii(t,PBe),{x:n,y:r,upperWidth:i,lowerWidth:s,height:a,className:o}=e,{animationEasing:l,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,g=M.useRef(null),[m,x]=M.useState(-1),y=M.useRef(i),v=M.useRef(s),b=M.useRef(a),E=M.useRef(n),S=M.useRef(r),A=Eb(t,"trapezoid-");if(M.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var R=g.current.getTotalLength();R&&x(R)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||a!==+a||i===0&&s===0||a===0)return null;var T=Tn("recharts-trapezoid",o);if(!f)return M.createElement("g",null,M.createElement("path",Jw({},Cs(e),{className:T,d:s9(n,r,i,s,a)})));var P=y.current,C=v.current,I=b.current,N=E.current,D=S.current,F="0px ".concat(m===-1?1:m,"px"),L="".concat(m,"px 0px"),q=uZ(["strokeDasharray"],u,l);return M.createElement(Sb,{animationId:A,key:A,canBegin:m>0,duration:u,easing:l,isActive:f,begin:d},R=>{var V=cr(P,i,R),K=cr(C,s,R),W=cr(I,a,R),ne=cr(N,n,R),Y=cr(D,r,R);g.current&&(y.current=V,v.current=K,b.current=W,E.current=ne,S.current=Y);var Z=R>0?{transition:q,strokeDasharray:L}:{strokeDasharray:F};return M.createElement("path",Jw({},Cs(e),{className:T,d:s9(ne,Y,V,K,W),ref:g,style:i9(i9({},Z),e.style)}))})},DBe=["option","shapeType","propTransformer","activeClassName"];function OBe(t,e){if(t==null)return{};var n,r,i=jBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function jBe(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 a9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function eS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?a9(Object(n),!0).forEach(function(r){LBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LBe(t,e,n){return(e=IBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function IBe(t){var e=UBe(t,"string");return typeof e=="symbol"?e:e+""}function UBe(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 FBe(t,e){return eS(eS({},e),t)}function zBe(t,e){return t==="symbols"}function o9(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return M.createElement(pZ,n);case"trapezoid":return M.createElement(RBe,n);case"sector":return M.createElement(bZ,n);case"symbols":if(zBe(e))return M.createElement(JD,n);break;case"curve":return M.createElement(em,n);default:return null}}function BBe(t){return M.isValidElement(t)?t.props:t}function $J(t){var{option:e,shapeType:n,propTransformer:r=FBe,activeClassName:i="recharts-active-shape"}=t,s=OBe(t,DBe),a;if(M.isValidElement(e))a=M.cloneElement(e,eS(eS({},s),BBe(e)));else if(typeof e=="function")a=e(s,s.index);else if(TBe(e)&&typeof e!="boolean"){var o=r(e,s);a=M.createElement(o9,{shapeType:n,elementProps:o})}else{var l=s;a=M.createElement(o9,{shapeType:n,elementProps:l})}return s.isActive?M.createElement(Ir,{className:i},a):a}var Rj=(t,e,n)=>{var r=rr();return(i,s)=>a=>{t?.(i,s,a),r(JQ({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},Dj=t=>{var e=rr();return(n,r)=>i=>{t?.(n,r,i),e(e5e())}},Oj=(t,e,n)=>{var r=rr();return(i,s)=>a=>{t?.(i,s,a),r(t5e({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function jj(t){var{tooltipEntrySettings:e}=t,n=rr(),r=ms(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n(YUe(e)):i.current!==e&&n(ZUe({prev:i.current,next:e})),i.current=e)},[e,n,r]),M.useLayoutEffect(()=>()=>{i.current&&(n(QUe(i.current)),i.current=null)},[n]),null}function VJ(t){var{legendPayload:e}=t,n=rr(),r=ms(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n(sZ(e)):i.current!==e&&n(aZ({prev:i.current,next:e})),i.current=e)},[n,r,e]),M.useLayoutEffect(()=>()=>{i.current&&(n(oZ(i.current)),i.current=null)},[n]),null}function HBe(t){var{legendPayload:e}=t,n=rr(),r=kt(wn),i=M.useRef(null);return M.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(sZ(e)):i.current!==e&&n(aZ({prev:i.current,next:e})),i.current=e)},[n,r,e]),M.useLayoutEffect(()=>()=>{i.current&&(n(oZ(i.current)),i.current=null)},[n]),null}var jN,$Be=()=>{var[t]=M.useState(()=>U0("uid-"));return t},VBe=(jN=$ne.useId)!==null&&jN!==void 0?jN:$Be;function GJ(t,e){var n=VBe();return e||(t?"".concat(t,"-").concat(n):n)}var GBe=M.createContext(void 0),Lj=t=>{var{id:e,type:n,children:r}=t,i=GJ("recharts-".concat(n),e);return M.createElement(GBe.Provider,{value:i},r(i))},WBe={cartesianItems:[],polarItems:[]},WJ=Zs({name:"graphicalItems",initialState:WBe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:hr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ro(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:hr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Ro(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:hr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:hr()},removePolarGraphicalItem:{reducer(t,e){var n=Ro(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:hr()}}}),{addCartesianGraphicalItem:qBe,replaceCartesianGraphicalItem:KBe,removeCartesianGraphicalItem:XBe,addPolarGraphicalItem:YBe,removePolarGraphicalItem:ZBe}=WJ.actions,QBe=WJ.reducer,JBe=t=>{var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(qBe(t)):n.current!==t&&e(KBe({prev:n.current,next:t})),n.current=t},[e,t]),M.useLayoutEffect(()=>()=>{n.current&&(e(XBe(n.current)),n.current=null)},[e]),null},qJ=M.memo(JBe);function e6e(t){var e=rr();return M.useLayoutEffect(()=>(e(YBe(t)),()=>{e(ZBe(t))}),[e,t]),null}var t6e=["key"],n6e=["onMouseEnter","onClick","onMouseLeave"],r6e=["id"],i6e=["id"];function l9(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 Tr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l9(Object(n),!0).forEach(function(r){s6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function s6e(t,e,n){return(e=a6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a6e(t){var e=o6e(t,"string");return typeof e=="symbol"?e:e+""}function o6e(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 HE(t,e){if(t==null)return{};var n,r,i=l6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function l6e(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 c6e(t){var e=M.useMemo(()=>Pj(t.children,Fb),[t.children]),n=kt(r=>vBe(r,t.id,e));return n==null?null:M.createElement(HBe,{legendPayload:n})}var u6e=M.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:a,name:o,hide:l,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:a,dataKey:e,nameKey:n,name:qm(o,e),hide:l,type:u,color:a,unit:""}};return M.createElement(jj,{tooltipEntrySettings:d})}),d6e=(t,e)=>t>e?"start":t<e?"end":"middle",h6e=(t,e,n)=>hs(typeof e=="function"?e(t):e,n,n*.8),f6e=(t,e,n)=>{var{top:r,left:i,width:s,height:a}=e,o=mZ(s,a),l=i+hs(t.cx,s,s/2),u=r+hs(t.cy,a,a/2),d=hs(t.innerRadius,o,0),f=h6e(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(s*s+a*a)/2;return{cx:l,cy:u,innerRadius:d,outerRadius:f,maxRadius:g}},p6e=(t,e)=>{var n=Di(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function m6e(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var g6e=(t,e)=>{if(M.isValidElement(t))return M.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Tn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=HE(e,t6e);return M.createElement(em,ud({},i,{type:"linear",className:n}))},x6e=(t,e,n)=>{if(M.isValidElement(t))return M.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),M.isValidElement(r)))return r;var i=Tn("recharts-pie-label-text",m6e(t));return M.createElement(FE,ud({},e,{alignmentBaseline:"middle",className:i}),r)};function b6e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:a}=n;if(!r||!i||!e)return null;var o=Ks(n),l=qh(i),u=qh(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((g,m)=>{var x=(g.startAngle+g.endAngle)/2,y=Yr(g.cx,g.cy,g.outerRadius+d,x),v=Tr(Tr(Tr(Tr({},o),g),{},{stroke:"none"},l),{},{index:m,textAnchor:d6e(y.x,g.cx)},y),b=Tr(Tr(Tr(Tr({},o),g),{},{fill:"none",stroke:g.fill},u),{},{index:m,points:[Yr(g.cx,g.cy,g.outerRadius,x),y],key:"line"});return M.createElement(Qs,{zIndex:Zr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},M.createElement(Ir,null,s&&g6e(s,b),x6e(i,v,Jn(g,a))))});return M.createElement(Ir,{className:"recharts-pie-labels"},f)}function v6e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?M.createElement(Cj,{label:i}):M.createElement(b6e,{sectors:e,props:n,showLabels:r})}function y6e(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:a}=t,o=kt(cd),l=kt(_j),u=kt(z5e),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,m=HE(i,n6e),x=Rj(d,i.dataKey,a),y=Dj(g),v=Oj(f,i.dataKey,a);return e==null||e.length===0?null:M.createElement(M.Fragment,null,e.map((b,E)=>{if(b?.startAngle===0&&b?.endAngle===0&&e.length!==1)return null;var S=u==null||u===a,A=String(E)===o&&(l==null||i.dataKey===l)&&S,T=o?r:null,P=n&&A?n:T,C=Tr(Tr({},b),{},{stroke:b.stroke,tabIndex:-1,[GY]:E,[WY]:i.dataKey});return M.createElement(Ir,ud({key:"sector-".concat(b?.startAngle,"-").concat(b?.endAngle,"-").concat(b.midAngle,"-").concat(E),tabIndex:-1,className:"recharts-pie-sector"},xb(m,b,E),{onMouseEnter:x(b,E),onMouseLeave:y(b,E),onClick:v(b,E)}),M.createElement($J,ud({option:s??P,index:E,shapeType:"sector",isActive:A},C)))}))}function _6e(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:a,startAngle:o,endAngle:l,dataKey:u,nameKey:d,tooltipType:f}=n,g=Math.abs(n.minAngle),m=p6e(o,l),x=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=r.filter(P=>Jn(P,u,0)!==0).length,b=(x>=360?v:v-1)*y,E=x-v*g-b,S=r.reduce((P,C)=>{var I=Jn(C,u,0);return P+(Ct(I)?I:0)},0),A;if(S>0){var T;A=r.map((P,C)=>{var I=Jn(P,u,0),N=Jn(P,d,C),D=f6e(n,s,P),F=(Ct(I)?I:0)/S,L,q=Tr(Tr({},P),i&&i[C]&&i[C].props);C?L=T.endAngle+Di(m)*y*(I!==0?1:0):L=o;var R=L+Di(m)*((I!==0?g:0)+F*E),V=(L+R)/2,K=(D.innerRadius+D.outerRadius)/2,W=[{name:N,value:I,payload:q,dataKey:u,type:f}],ne=Yr(D.cx,D.cy,K,V);return T=Tr(Tr(Tr(Tr({},n.presentationProps),{},{percent:F,cornerRadius:typeof a=="string"?parseFloat(a):a,name:N,tooltipPayload:W,midAngle:V,middleRadius:K,tooltipPosition:ne},q),D),{},{value:I,dataKey:u,startAngle:L,endAngle:R,payload:q,paddingAngle:Di(m)*y}),T})}return A}function w6e(t){var{showLabels:e,sectors:n,children:r}=t,i=M.useMemo(()=>!e||!n?[]:n.map(s=>({value:s.value,payload:s.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:s.cx,cy:s.cy,innerRadius:s.innerRadius,outerRadius:s.outerRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockWise:!1},fill:s.fill})),[n,e]);return M.createElement(rBe,{value:e?i:void 0},r)}function S6e(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:g}=e,m=Eb(e,"recharts-pie-"),x=n.current,[y,v]=M.useState(!1),b=M.useCallback(()=>{typeof g=="function"&&g(),v(!1)},[g]),E=M.useCallback(()=>{typeof f=="function"&&f(),v(!0)},[f]);return M.createElement(w6e,{showLabels:!y,sectors:i},M.createElement(Sb,{animationId:m,begin:a,duration:o,isActive:s,easing:l,onAnimationStart:E,onAnimationEnd:b,key:m},S=>{var A=[],T=i&&i[0],P=T?.startAngle;return i?.forEach((C,I)=>{var N=x&&x[I],D=I>0?Kh(C,"paddingAngle",0):0;if(N){var F=cr(N.endAngle-N.startAngle,C.endAngle-C.startAngle,S),L=Tr(Tr({},C),{},{startAngle:P+D,endAngle:P+F+D});A.push(L),P=L.endAngle}else{var{endAngle:q,startAngle:R}=C,V=cr(0,q-R,S),K=Tr(Tr({},C),{},{startAngle:P+D,endAngle:P+V+D});A.push(K),P=K.endAngle}}),n.current=A,M.createElement(Ir,null,M.createElement(y6e,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),M.createElement(v6e,{showLabels:!y,sectors:i,props:e}),e.children)}var E6e={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:Zr.area};function M6e(t){var{id:e}=t,n=HE(t,r6e),{hide:r,className:i,rootTabIndex:s}=t,a=M.useMemo(()=>Pj(t.children,Fb),[t.children]),o=kt(d=>yBe(d,e,a)),l=M.useRef(null),u=Tn("recharts-pie",i);return r||o==null?(l.current=null,M.createElement(Ir,{tabIndex:s,className:u})):M.createElement(Qs,{zIndex:t.zIndex},M.createElement(u6e,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:o,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),M.createElement(Ir,{tabIndex:s,className:u},M.createElement(S6e,{props:Tr(Tr({},n),{},{sectors:o}),previousSectorsRef:l,id:e})))}function KJ(t){var e=ii(t,E6e),{id:n}=e,r=HE(e,i6e),i=Ks(r);return M.createElement(Lj,{id:n,type:"pie"},s=>M.createElement(M.Fragment,null,M.createElement(e6e,{type:"pie",id:s,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),M.createElement(c6e,ud({},r,{id:s})),M.createElement(M6e,ud({},r,{id:s}))))}KJ.displayName="Pie";var A6e=["points"];function c9(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 LN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c9(Object(n),!0).forEach(function(r){T6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function T6e(t,e,n){return(e=C6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function C6e(t){var e=N6e(t,"string");return typeof e=="symbol"?e:e+""}function N6e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function tS(){return tS=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},tS.apply(null,arguments)}function k6e(t,e){if(t==null)return{};var n,r,i=P6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function P6e(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 R6e(t){var{option:e,dotProps:n,className:r}=t;if(M.isValidElement(e))return M.cloneElement(e,n);if(typeof e=="function")return e(n);var i=Tn(r,typeof e!="boolean"?e.className:""),s=n??{},{points:a}=s,o=k6e(s,A6e);return M.createElement(LJ,tS({},o,{className:i}))}function D6e(t,e){return t==null?!1:e?!0:t.length===1}function O6e(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:a,needClip:o,clipPathId:l,zIndex:u=Zr.scatter}=t;if(!D6e(e,n))return null;var d=HJ(n),f=uke(n),g=e.map((x,y)=>{var v,b,E=LN(LN(LN({r:3},a),f),{},{index:y,cx:(v=x.x)!==null&&v!==void 0?v:void 0,cy:(b=x.y)!==null&&b!==void 0?b:void 0,dataKey:s,value:x.value,payload:x.payload,points:e});return M.createElement(R6e,{key:"dot-".concat(y),option:n,dotProps:E,className:i})}),m={};return o&&l!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(l,")")),M.createElement(Qs,{zIndex:u},M.createElement(Ir,tS({className:r},m),g))}function u9(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 d9(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?u9(Object(n),!0).forEach(function(r){j6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function j6e(t,e,n){return(e=L6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function L6e(t){var e=I6e(t,"string");return typeof e=="symbol"?e:e+""}function I6e(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 U6e={xAxis:{},yAxis:{},zAxis:{}},XJ=Zs({name:"cartesianAxis",initialState:U6e,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:hr()},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:hr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:hr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:hr()},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:hr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:hr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:hr()},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:hr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:hr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var s=i.widthHistory||[];if(s.length===3&&s[0]===s[2]&&r===s[1]&&r!==i.width&&Math.abs(r-s[0])<=1)return;var a=[...s,r].slice(-3);t.yAxis[n]=d9(d9({},t.yAxis[n]),{},{width:r,widthHistory:a})}}}}),{addXAxis:F6e,replaceXAxis:z6e,removeXAxis:B6e,addYAxis:H6e,replaceYAxis:$6e,removeYAxis:V6e,addZAxis:S7e,replaceZAxis:E7e,removeZAxis:M7e,updateYAxisWidth:G6e}=XJ.actions,W6e=XJ.reducer,q6e=Ke([xi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),K6e=Ke([q6e,Pc,Rc],(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)}}),Ij=()=>kt(K6e),X6e=()=>kt(G5e);function h9(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 IN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?h9(Object(n),!0).forEach(function(r){Y6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Y6e(t,e,n){return(e=Z6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z6e(t){var e=Q6e(t,"string");return typeof e=="symbol"?e:e+""}function Q6e(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 J6e=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:s,clipPath:a}=t;if(i===!1||e.x==null||e.y==null)return null;var o={index:n,dataKey:s,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},l=IN(IN(IN({},o),qh(i)),eO(i)),u;return M.isValidElement(i)?u=M.cloneElement(i,l):typeof i=="function"?u=i(l):u=M.createElement(LJ,l),M.createElement(Ir,{className:"recharts-active-dot",clipPath:a},u)};function f9(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:a=Zr.activeDot}=t,o=kt(cd),l=X6e();if(e==null||l==null)return null;var u=e.find(d=>l.includes(d.payload));return yr(u)?null:M.createElement(Qs,{zIndex:a},M.createElement(J6e,{point:u,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var e8e="Invariant failed";function t8e(t,e){throw new Error(e8e)}var n8e=["x","y"];function WP(){return WP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},WP.apply(null,arguments)}function p9(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 yx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p9(Object(n),!0).forEach(function(r){r8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r8e(t,e,n){return(e=i8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i8e(t){var e=s8e(t,"string");return typeof e=="symbol"?e:e+""}function s8e(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 a8e(t,e){if(t==null)return{};var n,r,i=o8e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function o8e(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 l8e(t,e){var{x:n,y:r}=t,i=a8e(t,n8e),s="".concat(n),a=parseInt(s,10),o="".concat(r),l=parseInt(o,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),g=parseInt(f,10);return yx(yx(yx(yx(yx({},e),i),a?{x:a}:{}),l?{y:l}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function nS(t){return M.createElement($J,WP({shapeType:"rectangle",propTransformer:l8e,activeClassName:"recharts-active-bar"},t))}var c8e=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Ct(e))return e;var s=Ct(r)||yr(r);return s?e(r,i):(s||t8e(),n)}},u8e={},YJ=Zs({name:"errorBars",initialState:u8e,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(s=>s.dataKey===r.dataKey&&s.direction===r.direction?i:s))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:A7e,replaceErrorBar:T7e,removeErrorBar:C7e}=YJ.actions,d8e=YJ.reducer,h8e=["children"];function f8e(t,e){if(t==null)return{};var n,r,i=p8e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function p8e(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 m8e={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},g8e=M.createContext(m8e);function x8e(t){var{children:e}=t,n=f8e(t,h8e);return M.createElement(g8e.Provider,{value:n},e)}function Uj(t,e){var n,r,i=kt(u=>Oc(u,t)),s=kt(u=>jc(u,e)),a=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Ci.allowDataOverflow,o=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:Ni.allowDataOverflow,l=a||o;return{needClip:l,needClipX:a,needClipY:o}}function ZJ(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=Ij(),{needClipX:s,needClipY:a,needClip:o}=Uj(e,n);if(!o||!i)return null;var{x:l,y:u,width:d,height:f}=i;return M.createElement("clipPath",{id:"clipPath-".concat(r)},M.createElement("rect",{x:s?l:l-d/2,y:a?u:u-f/2,width:s?d:d*2,height:a?f:f*2}))}function b8e(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&ur(t.zIndex)?t.zIndex:e}var UN={exports:{}},FN={};var m9;function v8e(){if(m9)return FN;m9=1;var t=Dm();function e(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,o=t.useDebugValue;return FN.useSyncExternalStoreWithSelector=function(l,u,d,f,g){var m=i(null);if(m.current===null){var x={hasValue:!1,value:null};m.current=x}else x=m.current;m=a(function(){function v(T){if(!b){if(b=!0,E=T,T=f(T),g!==void 0&&x.hasValue){var P=x.value;if(g(P,T))return S=P}return S=T}if(P=S,n(E,T))return P;var C=f(T);return g!==void 0&&g(P,C)?(E=T,P):(E=T,S=C)}var b=!1,E,S,A=d===void 0?null:d;return[function(){return v(u())},A===null?void 0:function(){return v(A())}]},[u,d,f,g]);var y=r(l,m[0],m[1]);return s(function(){x.hasValue=!0,x.value=y},[y]),o(y),y},FN}var g9;function y8e(){return g9||(g9=1,UN.exports=v8e()),UN.exports}y8e();function _8e(t){t()}function w8e(){let t=null,e=null;return{clear(){t=null,e=null},notify(){_8e(()=>{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 x9={notify(){},get:()=>[]};function S8e(t,e){let n,r=x9,i=0,s=!1;function a(y){d();const v=r.subscribe(y);let b=!1;return()=>{b||(b=!0,v(),f())}}function o(){r.notify()}function l(){x.onStateChange&&x.onStateChange()}function u(){return s}function d(){i++,n||(n=t.subscribe(l),r=w8e())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=x9)}function g(){s||(s=!0,d())}function m(){s&&(s=!1,f())}const x={addNestedSub:a,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:u,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return x}var E8e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",M8e=E8e(),A8e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",T8e=A8e(),C8e=()=>M8e||T8e?M.useLayoutEffect:M.useEffect,N8e=C8e();function b9(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function k8e(t,e){if(b9(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])||!b9(t[n[i]],e[n[i]]))return!1;return!0}var P8e=Symbol.for("react-redux-context"),R8e=typeof globalThis<"u"?globalThis:{};function D8e(){if(!M.createContext)return{};const t=R8e[P8e]??=new Map;let e=t.get(M.createContext);return e||(e=M.createContext(null),t.set(M.createContext,e)),e}var O8e=D8e();function j8e(t){const{children:e,context:n,serverState:r,store:i}=t,s=M.useMemo(()=>{const l=S8e(i);return{store:i,subscription:l,getServerState:r?()=>r:void 0}},[i,r]),a=M.useMemo(()=>i.getState(),[i]);N8e(()=>{const{subscription:l}=s;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),a!==i.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[s,a]);const o=n||O8e;return M.createElement(o.Provider,{value:s},e)}var L8e=j8e,I8e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function U8e(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function $E(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(I8e.has(r)){if(t[r]==null&&e[r]==null)continue;if(!k8e(t[r],e[r]))return!1}else if(!U8e(t[r],e[r]))return!1;return!0}var F8e=["onMouseEnter","onMouseLeave","onClick"],z8e=["value","background","tooltipPosition"],B8e=["id"],H8e=["onMouseEnter","onClick","onMouseLeave"];function Cc(){return Cc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Cc.apply(null,arguments)}function v9(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 _s(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v9(Object(n),!0).forEach(function(r){$8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $8e(t,e,n){return(e=V8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function V8e(t){var e=G8e(t,"string");return typeof e=="symbol"?e:e+""}function G8e(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 rS(t,e){if(t==null)return{};var n,r,i=W8e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function W8e(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 q8e=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:qm(n,e),payload:t}]},K8e=M.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:a,unit:o,tooltipType:l}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:qm(s,e),hide:a,type:l,color:i,unit:o}};return M.createElement(jj,{tooltipEntrySettings:u})});function X8e(t){var e=kt(cd),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:a,onMouseLeave:o,onClick:l}=s,u=rS(s,F8e),d=Rj(a,r),f=Dj(o),g=Oj(l,r);if(!i||n==null)return null;var m=qh(i);return M.createElement(Qs,{zIndex:b8e(i,Zr.barBackground)},n.map((x,y)=>{var{value:v,background:b,tooltipPosition:E}=x,S=rS(x,z8e);if(!b)return null;var A=d(x,y),T=f(x,y),P=g(x,y),C=_s(_s(_s(_s(_s({option:i,isActive:String(y)===e},S),{},{fill:"#eee"},b),m),xb(u,x,y)),{},{onMouseEnter:A,onMouseLeave:T,onClick:P,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return M.createElement(nS,Cc({key:"background-bar-".concat(y)},C))}))}function Y8e(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(s=>{var a={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return _s(_s({},a),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:a,fill:s.fill})});return M.createElement(OJ,{value:e?i:void 0},n)}function Z8e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:a}=t,o=kt(cd),l=kt(_j),u=n&&String(s)===o&&(l==null||a===l),d=u?n:e;return u?M.createElement(Qs,{zIndex:Zr.activeBar},M.createElement(nS,Cc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:a}))):M.createElement(nS,Cc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:a}))}function Q8e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return M.createElement(nS,Cc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function J8e(t){var e,{data:n,props:r}=t,i=(e=Ks(r))!==null&&e!==void 0?e:{},{id:s}=i,a=rS(i,B8e),{shape:o,dataKey:l,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,m=rS(r,H8e),x=Rj(d,l),y=Dj(g),v=Oj(f,l);return n?M.createElement(M.Fragment,null,n.map((b,E)=>M.createElement(Ir,Cc({key:"rectangle-".concat(b?.x,"-").concat(b?.y,"-").concat(b?.value,"-").concat(E),className:"recharts-bar-rectangle"},xb(m,b,E),{onMouseEnter:x(b,E),onMouseLeave:y(b,E),onClick:v(b,E)}),u?M.createElement(Z8e,{shape:o,activeBar:u,baseProps:a,entry:b,index:E,dataKey:l}):M.createElement(Q8e,{shape:o,baseProps:a,entry:b,index:E,dataKey:l})))):null}function eHe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,g=Eb(e,"recharts-bar-"),[m,x]=M.useState(!1),y=!m,v=M.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),b=M.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return M.createElement(Y8e,{showLabels:y,rects:r},M.createElement(Sb,{animationId:g,begin:a,duration:o,isActive:s,easing:l,onAnimationEnd:v,onAnimationStart:b,key:g},E=>{var S=E===1?r:r?.map((A,T)=>{var P=f&&f[T];if(P)return _s(_s({},A),{},{x:cr(P.x,A.x,E),y:cr(P.y,A.y,E),width:cr(P.width,A.width,E),height:cr(P.height,A.height,E)});if(i==="horizontal"){var C=cr(0,A.height,E),I=cr(A.stackedBarStart,A.y,E);return _s(_s({},A),{},{y:I,height:C})}var N=cr(0,A.width,E),D=cr(A.stackedBarStart,A.x,E);return _s(_s({},A),{},{width:N,x:D})});return E>0&&(n.current=S??null),S==null?null:M.createElement(Ir,null,M.createElement(J8e,{props:e,data:S}))}),M.createElement(Cj,{label:e.label}),e.children)}function tHe(t){var e=M.useRef(null);return M.createElement(eHe,{previousRectanglesRef:e,props:t})}var QJ=0,nHe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Jn(t,e)}};class rHe extends M.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:a,needClip:o,background:l,id:u}=this.props;if(e||n==null)return null;var d=Tn("recharts-bar",i),f=u;return M.createElement(Ir,{className:d,id:u},o&&M.createElement("defs",null,M.createElement(ZJ,{clipPathId:f,xAxisId:s,yAxisId:a})),M.createElement(Ir,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(f,")"):void 0},M.createElement(X8e,{data:n,dataKey:r,background:l,allOtherBarProps:this.props}),M.createElement(tHe,this.props)))}}var iHe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:QJ,xAxisId:0,yAxisId:0,zIndex:Zr.bar};function sHe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=Uj(e,n),g=Km(),m=ms(),x=Pj(t.children,Fb),y=kt(E=>DHe(E,e,n,m,t.id,x));if(g!=="vertical"&&g!=="horizontal")return null;var v,b=y?.[0];return b==null||b.height==null||b.width==null?v=0:v=g==="vertical"?b.height/2:b.width/2,M.createElement(x8e,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:nHe,errorBarOffset:v},M.createElement(rHe,Cc({},t,{layout:g,needClip:f,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:u,isAnimationActive:d})))}function aHe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:a,yAxis:o,xAxisTicks:l,yAxisTicks:u,stackedData:d,displayedData:f,offset:g,cells:m,parentViewBox:x,dataStartIndex:y}=t,v=e==="horizontal"?o:a,b=d?v.scale.domain():null,E=MDe({numericAxis:v}),S=v.scale(E);return f.map((A,T)=>{var P,C,I,N,D,F;d?P=yDe(d[T+y],b):(P=Jn(A,n),Array.isArray(P)||(P=[E,P]));var L=c8e(r,QJ)(P[1],T);if(e==="horizontal"){var q,[R,V]=[o.scale(P[0]),o.scale(P[1])];C=jH({axis:a,ticks:l,bandSize:s,offset:i.offset,entry:A,index:T}),I=(q=V??R)!==null&&q!==void 0?q:void 0,N=i.size;var K=R-V;if(D=io(K)?0:K,F={x:C,y:g.top,width:N,height:g.height},Math.abs(L)>0&&Math.abs(D)<Math.abs(L)){var W=Di(D||L)*(Math.abs(L)-Math.abs(D));I-=W,D+=W}}else{var[ne,Y]=[a.scale(P[0]),a.scale(P[1])];if(C=ne,I=jH({axis:o,ticks:u,bandSize:s,offset:i.offset,entry:A,index:T}),N=Y-ne,D=i.size,F={x:g.left,y:I,width:g.width,height:D},Math.abs(L)>0&&Math.abs(N)<Math.abs(L)){var Z=Di(N||L)*(Math.abs(L)-Math.abs(N));N+=Z}}if(C==null||I==null||N==null||D==null)return null;var U=_s(_s({},A),{},{stackedBarStart:S,x:C,y:I,width:N,height:D,value:d?P:P[1],payload:A,background:F,tooltipPosition:{x:C+N/2,y:I+D/2},parentViewBox:x},m&&m[T]&&m[T].props);return U}).filter(Boolean)}function oHe(t){var e=ii(t,iHe),n=ms();return M.createElement(Lj,{id:e.id,type:"bar"},r=>M.createElement(M.Fragment,null,M.createElement(VJ,{legendPayload:q8e(e)}),M.createElement(K8e,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),M.createElement(qJ,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:$Y(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),M.createElement(Qs,{zIndex:e.zIndex},M.createElement(sHe,Cc({},e,{id:r})))))}var JJ=M.memo(oHe,$E);JJ.displayName="Bar";function y9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function C_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y9(Object(n),!0).forEach(function(r){lHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lHe(t,e,n){return(e=cHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cHe(t){var e=uHe(t,"string");return typeof e=="symbol"?e:e+""}function uHe(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 dHe=(t,e)=>e,hHe=(t,e,n)=>n,fHe=(t,e,n,r)=>r,pHe=(t,e,n,r,i)=>i,zb=Ke([OE,pHe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),mHe=Ke([zb],t=>t?.maxBarSize),gHe=(t,e,n,r,i,s)=>s,_9=(t,e,n)=>{var r=n??t;if(!yr(r))return hs(r,e,0)},xHe=Ke([wn,OE,dHe,hHe,fHe],(t,e,n,r,i)=>e.filter(s=>t==="horizontal"?s.xAxisId===n:s.yAxisId===r).filter(s=>s.isPanorama===i).filter(s=>s.hide===!1).filter(s=>s.type==="bar")),bHe=(t,e,n,r)=>{var i=wn(t);return i==="horizontal"?Z0(t,"yAxis",n,r):Z0(t,"xAxis",e,r)},vHe=(t,e,n)=>{var r=wn(t);return r==="horizontal"?pV(t,"xAxis",e):pV(t,"yAxis",n)},yHe=(t,e,n)=>{var r={},i=t.filter(PE),s=t.filter(u=>u.stackId==null),a=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),o=Object.entries(a).map(u=>{var[d,f]=u,g=f.map(x=>x.dataKey),m=_9(e,n,f[0].barSize);return{stackId:d,dataKeys:g,barSize:m}}),l=s.map(u=>{var d=[u.dataKey].filter(g=>g!=null),f=_9(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...o,...l]},_He=Ke([xHe,H4e,vHe],yHe),wHe=(t,e,n,r,i)=>{var s,a,o=zb(t,e,n,r,i);if(o!=null){var l=wn(t),u=pQ(t),{maxBarSize:d}=o,f=yr(d)?u:d,g,m;return l==="horizontal"?(g=ld(t,"xAxis",e,r),m=od(t,"xAxis",e,r)):(g=ld(t,"yAxis",n,r),m=od(t,"yAxis",n,r)),(s=(a=Tm(g,m,!0))!==null&&a!==void 0?a:f)!==null&&s!==void 0?s:0}},eee=(t,e,n,r)=>{var i=wn(t),s,a;return i==="horizontal"?(s=ld(t,"xAxis",e,r),a=od(t,"xAxis",e,r)):(s=ld(t,"yAxis",n,r),a=od(t,"yAxis",n,r)),Tm(s,a)};function SHe(t,e,n,r,i){var s=r.length;if(!(s<1)){var a=hs(t,n,0,!0),o,l=[];if(ur(r[0].barSize)){var u=!1,d=n/s,f=r.reduce((b,E)=>b+(E.barSize||0),0);f+=(s-1)*a,f>=n&&(f-=(s-1)*a,a=0),f>=n&&d>0&&(u=!0,d*=.9,f=s*d);var g=(n-f)/2>>0,m={offset:g-a,size:0};o=r.reduce((b,E)=>{var S,A={stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:m.offset+m.size+a,size:u?d:(S=E.barSize)!==null&&S!==void 0?S:0}},T=[...b,A];return m=T[T.length-1].position,T},l)}else{var x=hs(e,n,0,!0);n-2*x-(s-1)*a<=0&&(a=0);var y=(n-2*x-(s-1)*a)/s;y>1&&(y>>=0);var v=ur(i)?Math.min(y,i):y;o=r.reduce((b,E,S)=>[...b,{stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:x+(y+a)*S+(y-v)/2,size:v}}],l)}return o}}var EHe=(t,e,n,r,i,s,a)=>{var o=yr(a)?e:a,l=SHe(n,r,i!==s?i:s,t,o);return i!==s&&l!=null&&(l=l.map(u=>C_(C_({},u),{},{position:C_(C_({},u.position),{},{offset:u.position.offset-i/2})}))),l},MHe=Ke([_He,pQ,B4e,mQ,wHe,eee,mHe],EHe),AHe=(t,e,n,r)=>ld(t,"xAxis",e,r),THe=(t,e,n,r)=>ld(t,"yAxis",n,r),CHe=(t,e,n,r)=>od(t,"xAxis",e,r),NHe=(t,e,n,r)=>od(t,"yAxis",n,r),kHe=Ke([MHe,zb],(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}}),PHe=(t,e)=>{var n=kE(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:s}=i;if(s)return s.find(a=>a.key===n)}}}},RHe=Ke([bHe,zb],PHe),DHe=Ke([xi,dO,AHe,THe,CHe,NHe,kHe,wn,TE,eee,RHe,zb,gHe],(t,e,n,r,i,s,a,o,l,u,d,f,g)=>{var{chartData:m,dataStartIndex:x,dataEndIndex:y}=l;if(!(f==null||a==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||s==null||u==null)){var{data:v}=f,b;if(v!=null&&v.length>0?b=v:b=m?.slice(x,y+1),b!=null)return aHe({layout:o,barSettings:f,pos:a,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:b,offset:t,cells:g,dataStartIndex:x})}}),tee=t=>{var{chartData:e}=t,n=rr(),r=ms();return M.useEffect(()=>r?()=>{}:(n(TV(e)),()=>{n(TV(void 0))}),[e,n,r]),null},w9={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},nee=Zs({name:"brush",initialState:w9,reducers:{setBrushSettings(t,e){return e.payload==null?w9:e.payload}}}),{setBrushSettings:N7e}=nee.actions,OHe=nee.reducer;function jHe(t,e,n){return(e=LHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LHe(t){var e=IHe(t,"string");return typeof e=="symbol"?e:e+""}function IHe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class Fj{static create(e){return new Fj(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var s=this.bandwidth?this.bandwidth():0;return this.scale(e)+s}default:return this.scale(e)}if(n){var a=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+a}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}jHe(Fj,"EPS",1e-4);function UHe(t){return(t%180+180)%180}var FHe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=UHe(i),a=s*Math.PI/180,o=Math.atan(r/n),l=a>o&&a<Math.PI-o?r/Math.sin(a):n/Math.cos(a);return Math.abs(l)},zHe={dots:[],areas:[],lines:[]},ree=Zs({name:"referenceElements",initialState:zHe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Ro(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=Ro(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=Ro(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:k7e,removeDot:P7e,addArea:R7e,removeArea:D7e,addLine:O7e,removeLine:j7e}=ree.actions,BHe=ree.reducer,HHe=M.createContext(void 0),$He=t=>{var{children:e}=t,[n]=M.useState("".concat(U0("recharts"),"-clip")),r=Ij();if(r==null)return null;var{x:i,y:s,width:a,height:o}=r;return M.createElement(HHe.Provider,{value:n},M.createElement("defs",null,M.createElement("clipPath",{id:n},M.createElement("rect",{x:i,y:s,height:o,width:a}))),e)};function iee(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 VHe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return FHe(r,n)}function GHe(t,e,n){var r=n==="width",{x:i,y:s,width:a,height:o}=t;return e===1?{start:r?i:s,end:r?i+a:s+o}:{start:r?i+a:s+o,end:r?i:s}}function iS(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var s=n();return t*(e-t*s/2-r)>=0&&t*(e+t*s/2-i)<=0}function WHe(t,e){return iee(t,e+1)}function qHe(t,e,n,r,i){for(var s=(r||[]).slice(),{start:a,end:o}=e,l=0,u=1,d=a,f=function(){var x=r?.[l];if(x===void 0)return{v:iee(r,u)};var y=l,v,b=()=>(v===void 0&&(v=n(x,y)),v),E=x.coordinate,S=l===0||iS(t,E,b,d,o);S||(l=0,d=a,u+=1),S&&(d=E+t*(b()/2+i),l+=u)},g;u<=s.length;)if(g=f(),g)return g.v;return[]}function S9(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 ls(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S9(Object(n),!0).forEach(function(r){KHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KHe(t,e,n){return(e=XHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XHe(t){var e=YHe(t,"string");return typeof e=="symbol"?e:e+""}function YHe(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 ZHe(t,e,n,r,i){for(var s=(r||[]).slice(),a=s.length,{start:o}=e,{end:l}=e,u=function(g){var m=s[g],x,y=()=>(x===void 0&&(x=n(m,g)),x);if(g===a-1){var v=t*(m.coordinate+t*y()/2-l);s[g]=m=ls(ls({},m),{},{tickCoord:v>0?m.coordinate-v*t:m.coordinate})}else s[g]=m=ls(ls({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var b=iS(t,m.tickCoord,y,o,l);b&&(l=m.tickCoord-t*(y()/2+i),s[g]=ls(ls({},m),{},{isShow:!0}))}},d=a-1;d>=0;d--)u(d);return s}function QHe(t,e,n,r,i,s){var a=(r||[]).slice(),o=a.length,{start:l,end:u}=e;if(s){var d=r[o-1],f=n(d,o-1),g=t*(d.coordinate+t*f/2-u);if(a[o-1]=d=ls(ls({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var m=iS(t,d.tickCoord,()=>f,l,u);m&&(u=d.tickCoord-t*(f/2+i),a[o-1]=ls(ls({},d),{},{isShow:!0}))}}for(var x=s?o-1:o,y=function(E){var S=a[E],A,T=()=>(A===void 0&&(A=n(S,E)),A);if(E===0){var P=t*(S.coordinate-t*T()/2-l);a[E]=S=ls(ls({},S),{},{tickCoord:P<0?S.coordinate-P*t:S.coordinate})}else a[E]=S=ls(ls({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var C=iS(t,S.tickCoord,T,l,u);C&&(l=S.tickCoord+t*(T()/2+i),a[E]=ls(ls({},S),{},{isShow:!0}))}},v=0;v<x;v++)y(v);return a}function zj(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:a,orientation:o,interval:l,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Ct(l)||Xm.isSsr){var g;return(g=WHe(i,Ct(l)?l:0))!==null&&g!==void 0?g:[]}var m=[],x=o==="top"||o==="bottom"?"width":"height",y=d&&x==="width"?e0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},v=(S,A)=>{var T=typeof u=="function"?u(S.value,A):S.value;return x==="width"?VHe(e0(T,{fontSize:e,letterSpacing:n}),y,f):e0(T,{fontSize:e,letterSpacing:n})[x]},b=i.length>=2?Di(i[1].coordinate-i[0].coordinate):1,E=GHe(s,b,x);return l==="equidistantPreserveStart"?qHe(b,E,v,i,a):(l==="preserveStart"||l==="preserveStartEnd"?m=QHe(b,E,v,i,a,l==="preserveStartEnd"):m=ZHe(b,E,v,i,a),m.filter(S=>S.isShow))}var JHe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,a=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>a&&(a=f.width)}});var o=n?n.getBoundingClientRect().width:0,l=i+s,u=a+l+o+(n?r:0);return Math.round(u)}return 0},e$e=["axisLine","width","height","className","hide","ticks","axisType"];function t$e(t,e){if(t==null)return{};var n,r,i=n$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function n$e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Qh(){return Qh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Qh.apply(null,arguments)}function E9(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 Gr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E9(Object(n),!0).forEach(function(r){r$e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r$e(t,e,n){return(e=i$e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i$e(t){var e=s$e(t,"string");return typeof e=="symbol"?e:e+""}function s$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 bc={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:Zr.axis};function a$e(t){var{x:e,y:n,width:r,height:i,orientation:s,mirror:a,axisLine:o,otherSvgProps:l}=t;if(!o)return null;var u=Gr(Gr(Gr({},l),Ks(o)),{},{fill:"none"});if(s==="top"||s==="bottom"){var d=+(s==="top"&&!a||s==="bottom"&&a);u=Gr(Gr({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(s==="left"&&!a||s==="right"&&a);u=Gr(Gr({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return M.createElement("line",Qh({},u,{className:Tn("recharts-cartesian-axis-line",Kh(o,"className"))}))}function o$e(t,e,n,r,i,s,a,o,l){var u,d,f,g,m,x,y=o?-1:1,v=t.tickSize||a,b=Ct(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":u=d=t.coordinate,g=n+ +!o*i,f=g-y*v,x=f-y*l,m=b;break;case"left":f=g=t.coordinate,d=e+ +!o*r,u=d-y*v,m=u-y*l,x=b;break;case"right":f=g=t.coordinate,d=e+ +o*r,u=d+y*v,m=u+y*l,x=b;break;default:u=d=t.coordinate,g=n+ +o*i,f=g+y*v,x=f+y*l,m=b;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:m,y:x}}}function l$e(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function c$e(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function u$e(t){var{option:e,tickProps:n,value:r}=t,i,s=Tn(n.className,"recharts-cartesian-axis-tick-value");if(M.isValidElement(e))i=M.cloneElement(e,Gr(Gr({},n),{},{className:s}));else if(typeof e=="function")i=e(Gr(Gr({},n),{},{className:s}));else{var a="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(a=Tn(a,e?.className)),i=M.createElement(FE,Qh({},n,{className:a}),r)}return i}var d$e=M.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:a,unit:o,padding:l,tickTextProps:u,orientation:d,mirror:f,x:g,y:m,width:x,height:y,tickSize:v,tickMargin:b,fontSize:E,letterSpacing:S,getTicksConfig:A,events:T,axisType:P}=t,C=zj(Gr(Gr({},A),{},{ticks:n}),E,S),I=l$e(d,f),N=c$e(d,f),D=Ks(A),F=qh(r),L={};typeof i=="object"&&(L=i);var q=Gr(Gr({},D),{},{fill:"none"},L),R=C.map(W=>Gr({entry:W},o$e(W,g,m,x,y,d,v,f,b))),V=R.map(W=>{var{entry:ne,line:Y}=W;return M.createElement(Ir,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(ne.value,"-").concat(ne.coordinate,"-").concat(ne.tickCoord)},i&&M.createElement("line",Qh({},q,Y,{className:Tn("recharts-cartesian-axis-tick-line",Kh(i,"className"))})))}),K=R.map((W,ne)=>{var{entry:Y,tick:Z}=W,U=Gr(Gr(Gr(Gr({textAnchor:I,verticalAnchor:N},D),{},{stroke:"none",fill:s},F),Z),{},{index:ne,payload:Y,visibleTicksCount:C.length,tickFormatter:a,padding:l},u);return M.createElement(Ir,Qh({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Y.value,"-").concat(Y.coordinate,"-").concat(Y.tickCoord)},xb(T,Y,ne)),r&&M.createElement(u$e,{option:r,tickProps:U,value:"".concat(typeof a=="function"?a(Y.value,ne):Y.value).concat(o||"")}))});return M.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(P,"-ticks")},K.length>0&&M.createElement(Qs,{zIndex:Zr.label},M.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(P,"-tick-labels"),ref:e},K)),V.length>0&&M.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(P,"-tick-lines")},V))}),h$e=M.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:a,ticks:o,axisType:l}=t,u=t$e(t,e$e),[d,f]=M.useState(""),[g,m]=M.useState(""),x=M.useRef(null);M.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return JHe({ticks:x.current,label:(v=t.labelRef)===null||v===void 0?void 0:v.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=M.useCallback(v=>{if(v){var b=v.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=b;var E=b[0];if(E){var S=window.getComputedStyle(E),A=S.fontSize,T=S.letterSpacing;(A!==d||T!==g)&&(f(A),m(T))}}},[d,g]);return a||r!=null&&r<=0||i!=null&&i<=0?null:M.createElement(Qs,{zIndex:t.zIndex},M.createElement(Ir,{className:Tn("recharts-cartesian-axis",s)},M.createElement(a$e,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ks(t)}),M.createElement(d$e,{ref:y,axisType:l,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),M.createElement(Lze,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},M.createElement(Wze,{label:t.label,labelRef:t.labelRef}),t.children)))}),Bj=M.forwardRef((t,e)=>{var n=ii(t,bc);return M.createElement(h$e,Qh({},n,{ref:e}))});Bj.displayName="CartesianAxis";var f$e=["x1","y1","x2","y2","key"],p$e=["offset"],m$e=["xAxisId","yAxisId"],g$e=["xAxisId","yAxisId"];function M9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function cs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M9(Object(n),!0).forEach(function(r){x$e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function x$e(t,e,n){return(e=b$e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function b$e(t){var e=v$e(t,"string");return typeof e=="symbol"?e:e+""}function v$e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function hh(){return hh=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},hh.apply(null,arguments)}function sS(t,e){if(t==null)return{};var n,r,i=y$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function y$e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var _$e=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:s,height:a,ry:o}=t;return M.createElement("rect",{x:r,y:i,ry:o,width:s,height:a,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function see(t){var{option:e,lineItemProps:n}=t,r;if(M.isValidElement(e))r=M.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:s,y1:a,x2:o,y2:l,key:u}=n,d=sS(n,f$e),f=(i=Ks(d))!==null&&i!==void 0?i:{},{offset:g}=f,m=sS(f,p$e);r=M.createElement("line",hh({},m,{x1:s,y1:a,x2:o,y2:l,fill:"none",key:u}))}return r}function w$e(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:a}=t,o=sS(t,m$e),l=i.map((u,d)=>{var f=cs(cs({},o),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return M.createElement(see,{key:"line-".concat(d),option:r,lineItemProps:f})});return M.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function S$e(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:a}=t,o=sS(t,g$e),l=i.map((u,d)=>{var f=cs(cs({},o),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return M.createElement(see,{option:r,lineItemProps:f,key:"line-".concat(d)})});return M.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function E$e(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:s,height:a,horizontalPoints:o,horizontal:l=!0}=t;if(!l||!e||!e.length||o==null)return null;var u=o.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var m=!u[g+1],x=m?i+a-f:u[g+1]-f;if(x<=0)return null;var y=g%e.length;return M.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:x,width:s,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function M$e(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:s,width:a,height:o,verticalPoints:l}=t;if(!e||!n||!n.length)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var m=!u[g+1],x=m?i+a-f:u[g+1]-f;if(x<=0)return null;var y=g%n.length;return M.createElement("rect",{key:"react-".concat(g),x:f,y:s,width:x,height:o,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var A$e=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return BY(zj(cs(cs(cs({},bc),n),{},{ticks:HY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},T$e=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return BY(zj(cs(cs(cs({},bc),n),{},{ticks:HY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},C$e={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Zr.grid};function qP(t){var e=fO(),n=pO(),r=ZY(),i=cs(cs({},ii(t,C$e)),{},{x:Ct(t.x)?t.x:r.left,y:Ct(t.y)?t.y:r.top,width:Ct(t.width)?t.width:r.width,height:Ct(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:a,x:o,y:l,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:m}=i,x=ms(),y=kt(N=>mV(N,"xAxis",s,x)),v=kt(N=>mV(N,"yAxis",a,x));if(!pl(u)||!pl(d)||!Ct(o)||!Ct(l))return null;var b=i.verticalCoordinatesGenerator||A$e,E=i.horizontalCoordinatesGenerator||T$e,{horizontalPoints:S,verticalPoints:A}=i;if((!S||!S.length)&&typeof E=="function"){var T=g&&g.length,P=E({yAxis:v?cs(cs({},v),{},{ticks:T?g:v.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);kw(Array.isArray(P),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof P,"]")),Array.isArray(P)&&(S=P)}if((!A||!A.length)&&typeof b=="function"){var C=m&&m.length,I=b({xAxis:y?cs(cs({},y),{},{ticks:C?m:y.ticks}):void 0,width:e??u,height:n??d,offset:r},C?!0:f);kw(Array.isArray(I),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof I,"]")),Array.isArray(I)&&(A=I)}return M.createElement(Qs,{zIndex:i.zIndex},M.createElement("g",{className:"recharts-cartesian-grid"},M.createElement(_$e,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),M.createElement(E$e,hh({},i,{horizontalPoints:S})),M.createElement(M$e,hh({},i,{verticalPoints:A})),M.createElement(w$e,hh({},i,{offset:r,horizontalPoints:S,xAxis:y,yAxis:v})),M.createElement(S$e,hh({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:v}))))}qP.displayName="CartesianGrid";function N$e(t){var e=qh(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:s}=e,a=Number(i),o=Number(s);return(Number.isNaN(a)||a<0)&&(a=n),(Number.isNaN(o)||o<0)&&(o=r),{r:a,strokeWidth:o}}return{r:n,strokeWidth:r}}var aee=(t,e,n,r)=>ld(t,"xAxis",e,r),oee=(t,e,n,r)=>od(t,"xAxis",e,r),lee=(t,e,n,r)=>ld(t,"yAxis",n,r),cee=(t,e,n,r)=>od(t,"yAxis",n,r),k$e=Ke([wn,aee,lee,oee,cee],(t,e,n,r,i)=>kc(t,"xAxis")?Tm(e,r,!1):Tm(n,i,!1)),P$e=(t,e,n,r,i)=>i,uee=Ke([OE,P$e],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),R$e=(t,e,n,r,i)=>{var s,a=uee(t,e,n,r,i);if(a!=null){var o=wn(t),l=kc(o,"xAxis"),u;if(l?u=Z0(t,"yAxis",n,r):u=Z0(t,"xAxis",e,r),u!=null){var{stackId:d}=a,f=kE(a);if(!(d==null||f==null)){var g=(s=u[d])===null||s===void 0?void 0:s.stackedData;return g?.find(m=>m.key===f)}}}},D$e=Ke([wn,aee,lee,oee,cee,R$e,TE,k$e,uee,$4e],(t,e,n,r,i,s,a,o,l,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:g}=a;if(!(l==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null)){var{data:m}=l,x;if(m&&m.length>0?x=m:x=d?.slice(f,g+1),x!=null)return Q$e({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:l,stackedData:s,displayedData:x,chartBaseValue:u,bandSize:o})}}),O$e=["id"],j$e=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Th(){return Th=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},Th.apply(null,arguments)}function dee(t,e){if(t==null)return{};var n,r,i=L$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function L$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 A9(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 zp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A9(Object(n),!0).forEach(function(r){I$e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function I$e(t,e,n){return(e=U$e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U$e(t){var e=F$e(t,"string");return typeof e=="symbol"?e:e+""}function F$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 aS(t,e){return t&&t!=="none"?t:e}var z$e=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:a}=t;return[{inactive:a,dataKey:e,type:s,color:aS(r,i),value:qm(n,e),payload:t}]},B$e=M.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:a,hide:o,unit:l,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:qm(a,e),hide:o,type:u,color:aS(r,s),unit:l}};return M.createElement(jj,{tooltipEntrySettings:d})});function H$e(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:a}=r,o=Ks(r);return M.createElement(O6e,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:a,baseProps:o,needClip:i,clipPathId:e})}function $$e(t){var{showLabels:e,children:n,points:r}=t,i=r.map(s=>{var a,o,l={x:(a=s.x)!==null&&a!==void 0?a:0,y:(o=s.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return zp(zp({},l),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:l,fill:void 0})});return M.createElement(OJ,{value:e?i:void 0},n)}function T9(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:a,type:o,stroke:l,connectNulls:u,isRange:d}=s,{id:f}=s,g=dee(s,O$e),m=Ks(g),x=Cs(g);return M.createElement(M.Fragment,null,e?.length>1&&M.createElement(Ir,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},M.createElement(em,Th({},x,{id:f,points:e,connectNulls:u,type:o,baseLine:n,layout:a,stroke:"none",className:"recharts-area-area"})),l!=="none"&&M.createElement(em,Th({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:u,fill:"none",points:e})),l!=="none"&&d&&M.createElement(em,Th({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:u,fill:"none",points:n}))),M.createElement(H$e,{points:e,props:g,clipPathId:i}))}function V$e(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,a=r[r.length-1].y;if(!ur(s)||!ur(a))return null;var o=e*Math.abs(s-a),l=Math.max(...r.map(u=>u.x||0));return Ct(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(u=>u.x||0),l)),Ct(l)?M.createElement("rect",{x:0,y:s<a?s:s-o,width:l+(i?parseInt("".concat(i),10):1),height:Math.floor(o)}):null}function G$e(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,a=r[r.length-1].x;if(!ur(s)||!ur(a))return null;var o=e*Math.abs(s-a),l=Math.max(...r.map(u=>u.y||0));return Ct(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(u=>u.y||0),l)),Ct(l)?M.createElement("rect",{x:s<a?s:s-o,y:0,width:o,height:Math.floor(l+(i?parseInt("".concat(i),10):1))}):null}function W$e(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?M.createElement(V$e,{alpha:e,points:r,baseLine:i,strokeWidth:s}):M.createElement(G$e,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function q$e(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:a,baseLine:o,isAnimationActive:l,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:g,onAnimationEnd:m}=r,x=M.useMemo(()=>({points:a,baseLine:o}),[a,o]),y=Eb(x,"recharts-area-"),v=oOe(),[b,E]=M.useState(!1),S=!b,A=M.useCallback(()=>{typeof m=="function"&&m(),E(!1)},[m]),T=M.useCallback(()=>{typeof g=="function"&&g(),E(!0)},[g]);if(v==null)return null;var P=i.current,C=s.current;return M.createElement($$e,{showLabels:S,points:a},r.children,M.createElement(Sb,{animationId:y,begin:u,duration:d,isActive:l,easing:f,onAnimationEnd:A,onAnimationStart:T,key:y},I=>{if(P){var N=P.length/a.length,D=I===1?a:a.map((L,q)=>{var R=Math.floor(q*N);if(P[R]){var V=P[R];return zp(zp({},L),{},{x:cr(V.x,L.x,I),y:cr(V.y,L.y,I)})}return L}),F;return Ct(o)?F=cr(C,o,I):yr(o)||io(o)?F=cr(C,0,I):F=o.map((L,q)=>{var R=Math.floor(q*N);if(Array.isArray(C)&&C[R]){var V=C[R];return zp(zp({},L),{},{x:cr(V.x,L.x,I),y:cr(V.y,L.y,I)})}return L}),I>0&&(i.current=D,s.current=F),M.createElement(T9,{points:D,baseLine:F,needClip:e,clipPathId:n,props:r})}return I>0&&(i.current=a,s.current=o),M.createElement(Ir,null,l&&M.createElement("defs",null,M.createElement("clipPath",{id:"animationClipPath-".concat(n)},M.createElement(W$e,{alpha:I,points:a,baseLine:o,layout:v,strokeWidth:r.strokeWidth}))),M.createElement(Ir,{clipPath:"url(#animationClipPath-".concat(n,")")},M.createElement(T9,{points:a,baseLine:o,needClip:e,clipPathId:n,props:r})))}),M.createElement(Cj,{label:r.label}))}function K$e(t){var{needClip:e,clipPathId:n,props:r}=t,i=M.useRef(null),s=M.useRef();return M.createElement(q$e,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class X$e extends M.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:a,needClip:o,xAxisId:l,yAxisId:u,width:d,height:f,id:g,baseLine:m,zIndex:x}=this.props;if(e)return null;var y=Tn("recharts-area",i),v=g,{r:b,strokeWidth:E}=N$e(n),S=HJ(n),A=b*2+E,T=o?"url(#clipPath-".concat(S?"":"dots-").concat(v,")"):void 0;return M.createElement(Qs,{zIndex:x},M.createElement(Ir,{className:y},o&&M.createElement("defs",null,M.createElement(ZJ,{clipPathId:v,xAxisId:l,yAxisId:u}),!S&&M.createElement("clipPath",{id:"clipPath-dots-".concat(v)},M.createElement("rect",{x:a-A/2,y:s-A/2,width:d+A,height:f+A}))),M.createElement(K$e,{needClip:o,clipPathId:v,props:this.props})),M.createElement(f9,{points:r,mainColor:aS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(m)&&M.createElement(f9,{points:m,mainColor:aS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var hee={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:Zr.area};function Y$e(t){var e,n=ii(t,hee),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,connectNulls:o,dot:l,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:m,stroke:x,xAxisId:y,yAxisId:v}=n,b=dee(n,j$e),E=Km(),S=mJ(),{needClip:A}=Uj(y,v),T=ms(),{points:P,isRange:C,baseLine:I}=(e=kt(R=>D$e(R,y,v,T,t.id)))!==null&&e!==void 0?e:{},N=Ij();if(E!=="horizontal"&&E!=="vertical"||N==null||S!=="AreaChart"&&S!=="ComposedChart")return null;var{height:D,width:F,x:L,y:q}=N;return!P||!P.length?null:M.createElement(X$e,Th({},b,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,baseLine:I,connectNulls:o,dot:l,fill:u,fillOpacity:d,height:D,hide:f,layout:E,isAnimationActive:g==="auto"?!Xm.isSsr:g,isRange:C,legendType:m,needClip:A,points:P,stroke:x,width:F,left:L,top:q,xAxisId:y,yAxisId:v}))}var Z$e=(t,e,n,r,i)=>{var s=n??e;if(Ct(s))return s;var a=t==="horizontal"?i:r,o=a.scale.domain();if(a.type==="number"){var l=Math.max(o[0],o[1]),u=Math.min(o[0],o[1]);return s==="dataMin"?u:s==="dataMax"||l<0?l:Math.max(Math.min(o[0],o[1]),0)}return s==="dataMin"?o[0]:s==="dataMax"?o[1]:o[0]};function Q$e(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:a,xAxis:o,yAxis:l,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:g,bandSize:m}=t,x=i&&i.length,y=Z$e(s,a,n,o,l),v=s==="horizontal",b=!1,E=u.map((A,T)=>{var P;x?P=i[d+T]:(P=Jn(A,r),Array.isArray(P)?b=!0:P=[y,P]);var C=P[1]==null||x&&!e&&Jn(A,r)==null;return v?{x:OH({axis:o,ticks:f,bandSize:m,entry:A,index:T}),y:C?null:l.scale(P[1]),value:P,payload:A}:{x:C?null:o.scale(P[1]),y:OH({axis:l,ticks:g,bandSize:m,entry:A,index:T}),value:P,payload:A}}),S;return x||b?S=E.map(A=>{var T=Array.isArray(A.value)?A.value[0]:null;return v?{x:A.x,y:T!=null&&A.y!=null?l.scale(T):null,payload:A.payload}:{x:T!=null?o.scale(T):null,y:A.y,payload:A.payload}}):S=v?l.scale(y):o.scale(y),{points:E,baseLine:S,isRange:b}}function J$e(t){var e=ii(t,hee),n=ms();return M.createElement(Lj,{id:e.id,type:"area"},r=>M.createElement(M.Fragment,null,M.createElement(VJ,{legendPayload:z$e(e)}),M.createElement(B$e,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),M.createElement(qJ,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:$Y(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),M.createElement(Y$e,Th({},e,{id:r}))))}var fee=M.memo(J$e,$E);fee.displayName="Area";var eVe=["domain","range"],tVe=["domain","range"];function C9(t,e){if(t==null)return{};var n,r,i=nVe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function nVe(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 N9(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 pee(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=C9(t,eVe),{domain:s,range:a}=e,o=C9(e,tVe);return!N9(n,s)||!N9(r,a)?!1:$E(i,o)}var rVe=["dangerouslySetInnerHTML","ticks"],iVe=["id"];function KP(){return KP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},KP.apply(null,arguments)}function k9(t,e){if(t==null)return{};var n,r,i=sVe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function sVe(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 aVe(t){var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(F6e(t)):n.current!==t&&e(z6e({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(B6e(n.current)),n.current=null)},[e]),null}var oVe=t=>{var{xAxisId:e,className:n}=t,r=kt(dO),i=ms(),s="xAxis",a=kt(v=>ng(v,s,e,i)),o=kt(v=>qQ(v,s,e,i)),l=kt(v=>$Q(v,e)),u=kt(v=>zUe(v,e)),d=kt(v=>EQ(v,e));if(l==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,m=k9(t,rVe),{id:x}=d,y=k9(d,iVe);return M.createElement(Bj,KP({},m,y,{scale:a,x:u.x,y:u.y,width:l.width,height:l.height,className:Tn("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:o,axisType:s}))},lVe={allowDataOverflow:Ci.allowDataOverflow,allowDecimals:Ci.allowDecimals,allowDuplicatedCategory:Ci.allowDuplicatedCategory,angle:Ci.angle,axisLine:bc.axisLine,height:Ci.height,hide:!1,includeHidden:Ci.includeHidden,interval:Ci.interval,minTickGap:Ci.minTickGap,mirror:Ci.mirror,orientation:Ci.orientation,padding:Ci.padding,reversed:Ci.reversed,scale:Ci.scale,tick:Ci.tick,tickCount:Ci.tickCount,tickLine:bc.tickLine,tickSize:bc.tickSize,type:Ci.type,xAxisId:0},cVe=t=>{var e=ii(t,lVe);return M.createElement(M.Fragment,null,M.createElement(aVe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),M.createElement(oVe,e))},XP=M.memo(cVe,pee);XP.displayName="XAxis";var uVe=["dangerouslySetInnerHTML","ticks"],dVe=["id"];function YP(){return YP=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},YP.apply(null,arguments)}function P9(t,e){if(t==null)return{};var n,r,i=hVe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function hVe(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 fVe(t){var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(H6e(t)):n.current!==t&&e($6e({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(V6e(n.current)),n.current=null)},[e]),null}var pVe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=M.useRef(null),a=M.useRef(null),o=kt(dO),l=ms(),u=rr(),d="yAxis",f=kt(T=>ng(T,d,e,l)),g=kt(T=>VQ(T,e)),m=kt(T=>HUe(T,e)),x=kt(T=>qQ(T,d,e,l)),y=kt(T=>MQ(T,e));if(M.useLayoutEffect(()=>{if(!(r!=="auto"||!g||Tj(i)||M.isValidElement(i)||y==null)){var T=s.current;if(T){var P=T.getCalculatedWidth();Math.round(g.width)!==Math.round(P)&&u(G6e({id:e,width:P}))}}},[x,g,u,i,e,r,y]),g==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:v,ticks:b}=t,E=P9(t,uVe),{id:S}=y,A=P9(y,dVe);return M.createElement(Bj,YP({},E,A,{ref:s,labelRef:a,scale:f,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:Tn("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:x,axisType:d}))},mVe={allowDataOverflow:Ni.allowDataOverflow,allowDecimals:Ni.allowDecimals,allowDuplicatedCategory:Ni.allowDuplicatedCategory,angle:Ni.angle,axisLine:bc.axisLine,hide:!1,includeHidden:Ni.includeHidden,interval:Ni.interval,minTickGap:Ni.minTickGap,mirror:Ni.mirror,orientation:Ni.orientation,padding:Ni.padding,reversed:Ni.reversed,scale:Ni.scale,tick:Ni.tick,tickCount:Ni.tickCount,tickLine:bc.tickLine,tickSize:bc.tickSize,type:Ni.type,width:Ni.width,yAxisId:0},gVe=t=>{var e=ii(t,mVe);return M.createElement(M.Fragment,null,M.createElement(fVe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),M.createElement(pVe,e))},ZP=M.memo(gVe,pee);ZP.displayName="YAxis";var xVe=(t,e)=>e,Hj=Ke([xVe,wn,wQ,vi,cJ,Lc,rFe,xi],uFe),$j=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)}},mee=so("mouseClick"),gee=yb();gee.startListening({actionCreator:mee,effect:(t,e)=>{var n=t.payload,r=Hj(e.getState(),$j(n));r?.activeIndex!=null&&e.dispatch(n5e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var QP=so("mouseMove"),xee=yb(),N_=null;xee.startListening({actionCreator:QP,effect:(t,e)=>{var n=t.payload;N_!==null&&cancelAnimationFrame(N_);var r=$j(n);N_=requestAnimationFrame(()=>{var i=e.getState(),s=mj(i,i.tooltip.settings.shared);if(s==="axis"){var a=Hj(i,r);a?.activeIndex!=null?e.dispatch(tJ({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate})):e.dispatch(eJ())}N_=null})}});var R9={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},bee=Zs({name:"rootProps",initialState:R9,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:R9.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}}}),bVe=bee.reducer,{updateOptions:vVe}=bee.actions,vee=Zs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:yVe}=vee.actions,_Ve=vee.reducer,yee=so("keyDown"),_ee=so("focus"),Vj=yb();Vj.startListening({actionCreator:yee,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,s=t.payload;if(!(s!=="ArrowRight"&&s!=="ArrowLeft"&&s!=="Enter")){var a=gj(i,ig(n),Db(n),Ib(n)),o=a==null?-1:Number(a);if(!(!Number.isFinite(o)||o<0)){var l=Lc(n);if(s==="Enter"){var u=Zw(n,"axis","hover",String(i.index));e.dispatch(zP({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=WUe(n),f=d==="left-to-right"?1:-1,g=s==="ArrowRight"?1:-1,m=o+g*f;if(!(l==null||m>=l.length||m<0)){var x=Zw(n,"axis","hover",String(m));e.dispatch(zP({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});Vj.startListening({actionCreator:_ee,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var s="0",a=Zw(n,"axis","hover",String(s));e.dispatch(zP({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:a}))}}}});var Ia=so("externalEvent"),wee=yb(),zN=new Map;wee.startListening({actionCreator:Ia,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=zN.get(i);s!==void 0&&cancelAnimationFrame(s);var a=requestAnimationFrame(()=>{try{var o=e.getState(),l={activeCoordinate:H5e(o),activeDataKey:_j(o),activeIndex:cd(o),activeLabel:hJ(o),activeTooltipIndex:cd(o),isTooltipActive:$5e(o)};n(l,r)}finally{zN.delete(i)}});zN.set(i,a)}}});var wVe=Ke([rg],t=>t.tooltipItemPayloads),SVe=Ke([wVe,jb,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(o=>o.settings.dataKey===r);if(i!=null){var{positions:s}=i;if(s!=null){var a=e(s,n);return a}}}),See=so("touchMove"),Eee=yb();Eee.startListening({actionCreator:See,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=mj(r,r.tooltip.settings.shared);if(i==="axis"){var s=Hj(r,$j({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(tJ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate}))}else if(i==="item"){var a,o=n.touches[0];if(document.elementFromPoint==null)return;var l=document.elementFromPoint(o.clientX,o.clientY);if(!l||!l.getAttribute)return;var u=l.getAttribute(GY),d=(a=l.getAttribute(WY))!==null&&a!==void 0?a:void 0,f=SVe(e.getState(),u,d);e.dispatch(JQ({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var EVe=hY({brush:OHe,cartesianAxis:W6e,chartData:BFe,errorBars:d8e,graphicalItems:QBe,layout:pDe,legend:wOe,options:LFe,polarAxis:fBe,polarOptions:_Ve,referenceElements:BHe,rootProps:bVe,tooltip:r5e,zIndex:EFe}),MVe=function(e){return FRe({reducer:EVe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([gee.middleware,xee.middleware,Vj.middleware,wee.middleware,Eee.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(TY({type:"raf"}))},devTools:Xm.devToolsEnabled})};function Mee(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=ms(),s=M.useRef(null);if(i)return n;s.current==null&&(s.current=MVe(e));var a=nO;return M.createElement(L8e,{context:a,store:s.current},n)}function AVe(t){var{layout:e,margin:n}=t,r=rr(),i=ms();return M.useEffect(()=>{i||(r(dDe(e)),r(uDe(n)))},[r,i,e,n]),null}var Aee=M.memo(AVe,$E);function Tee(t){var e=rr();return M.useEffect(()=>{e(vVe(t))},[e,t]),null}function D9(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=GJ("".concat(r).concat(e)),s=rr();return M.useLayoutEffect(()=>(s(wFe({zIndex:e,elementId:i,isPanorama:n})),()=>{s(SFe({zIndex:e,isPanorama:n}))}),[s,e,i,n]),M.createElement("g",{tabIndex:-1,id:i})}function O9(t){var{children:e,isPanorama:n}=t,r=kt(hFe);if(!r||r.length===0)return e;var i=r.filter(a=>a<0),s=r.filter(a=>a>0);return M.createElement(M.Fragment,null,i.map(a=>M.createElement(D9,{key:a,zIndex:a,isPanorama:n})),e,s.map(a=>M.createElement(D9,{key:a,zIndex:a,isPanorama:n})))}var TVe=["children"];function CVe(t,e){if(t==null)return{};var n,r,i=NVe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function NVe(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 oS(){return oS=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},oS.apply(null,arguments)}var kVe={width:"100%",height:"100%",display:"block"},PVe=M.forwardRef((t,e)=>{var n=fO(),r=pO(),i=cZ();if(!pl(n)||!pl(r))return null;var{children:s,otherAttributes:a,title:o,desc:l}=t,u,d;return a!=null&&(typeof a.tabIndex=="number"?u=a.tabIndex:u=i?0:void 0,typeof a.role=="string"?d=a.role:d=i?"application":void 0),M.createElement(WD,oS({},a,{title:o,desc:l,role:d,tabIndex:u,width:n,height:r,style:kVe,ref:e}),s)}),RVe=t=>{var{children:e}=t,n=kt(mE);if(!n)return null;var{width:r,height:i,y:s,x:a}=n;return M.createElement(WD,{width:r,height:i,x:a,y:s},e)},j9=M.forwardRef((t,e)=>{var{children:n}=t,r=CVe(t,TVe),i=ms();return i?M.createElement(RVe,null,M.createElement(O9,{isPanorama:!0},n)):M.createElement(PVe,oS({ref:e},r),M.createElement(O9,{isPanorama:!1},n))});function DVe(){var t=rr(),[e,n]=M.useState(null),r=kt(PDe);return M.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;ur(s)&&s!==r&&t(fDe(s))}},[e,t,r]),n}function L9(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 OVe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L9(Object(n),!0).forEach(function(r){jVe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jVe(t,e,n){return(e=LVe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LVe(t){var e=IVe(t,"string");return typeof e=="symbol"?e:e+""}function IVe(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 Jh(){return Jh=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},Jh.apply(null,arguments)}var UVe=()=>(YFe(),null);function lS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var FVe=M.forwardRef((t,e)=>{var n,r,i=M.useRef(null),[s,a]=M.useState({containerWidth:lS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:lS((r=t.style)===null||r===void 0?void 0:r.height)}),o=M.useCallback((u,d)=>{a(f=>{var g=Math.round(u),m=Math.round(d);return f.containerWidth===g&&f.containerHeight===m?f:{containerWidth:g,containerHeight:m}})},[]),l=M.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();o(d,f);var g=x=>{var{width:y,height:v}=x[0].contentRect;o(y,v)},m=new ResizeObserver(g);m.observe(u),i.current=m}},[e,o]);return M.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[o]),M.createElement(M.Fragment,null,M.createElement(xE,{width:s.containerWidth,height:s.containerHeight}),M.createElement("div",Jh({ref:l},t)))}),zVe=M.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=M.useState({containerWidth:lS(n),containerHeight:lS(r)}),a=M.useCallback((l,u)=>{s(d=>{var f=Math.round(l),g=Math.round(u);return d.containerWidth===f&&d.containerHeight===g?d:{containerWidth:f,containerHeight:g}})},[]),o=M.useCallback(l=>{if(typeof e=="function"&&e(l),l!=null){var{width:u,height:d}=l.getBoundingClientRect();a(u,d)}},[e,a]);return M.createElement(M.Fragment,null,M.createElement(xE,{width:i.containerWidth,height:i.containerHeight}),M.createElement("div",Jh({ref:o},t)))}),BVe=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return M.createElement(M.Fragment,null,M.createElement(xE,{width:n,height:r}),M.createElement("div",Jh({ref:e},t)))}),HVe=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return wc(n)||wc(r)?M.createElement(zVe,Jh({},t,{ref:e})):M.createElement(BVe,Jh({},t,{ref:e}))});function $Ve(t){return t===!0?FVe:HVe}var VVe=M.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:a,onDoubleClick:o,onMouseDown:l,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:g,onTouchEnd:m,onTouchMove:x,onTouchStart:y,style:v,width:b,responsive:E,dispatchTouchEvents:S=!0}=t,A=M.useRef(null),T=rr(),[P,C]=M.useState(null),[I,N]=M.useState(null),D=DVe(),F=hO(),L=F?.width>0?F.width:b,q=F?.height>0?F.height:i,R=M.useCallback(se=>{D(se),typeof e=="function"&&e(se),C(se),N(se),se!=null&&(A.current=se)},[D,e,C,N]),V=M.useCallback(se=>{T(mee(se)),T(Ia({handler:s,reactEvent:se}))},[T,s]),K=M.useCallback(se=>{T(QP(se)),T(Ia({handler:u,reactEvent:se}))},[T,u]),W=M.useCallback(se=>{T(eJ()),T(Ia({handler:d,reactEvent:se}))},[T,d]),ne=M.useCallback(se=>{T(QP(se)),T(Ia({handler:f,reactEvent:se}))},[T,f]),Y=M.useCallback(()=>{T(_ee())},[T]),Z=M.useCallback(se=>{T(yee(se.key))},[T]),U=M.useCallback(se=>{T(Ia({handler:a,reactEvent:se}))},[T,a]),$=M.useCallback(se=>{T(Ia({handler:o,reactEvent:se}))},[T,o]),ee=M.useCallback(se=>{T(Ia({handler:l,reactEvent:se}))},[T,l]),ae=M.useCallback(se=>{T(Ia({handler:g,reactEvent:se}))},[T,g]),fe=M.useCallback(se=>{T(Ia({handler:y,reactEvent:se}))},[T,y]),ue=M.useCallback(se=>{S&&T(See(se)),T(Ia({handler:x,reactEvent:se}))},[T,S,x]),xe=M.useCallback(se=>{T(Ia({handler:m,reactEvent:se}))},[T,m]),Me=$Ve(E);return M.createElement(yJ.Provider,{value:P},M.createElement(CX.Provider,{value:I},M.createElement(Me,{width:L??v?.width,height:q??v?.height,className:Tn("recharts-wrapper",r),style:OVe({position:"relative",cursor:"default",width:L,height:q},v),onClick:V,onContextMenu:U,onDoubleClick:$,onFocus:Y,onKeyDown:Z,onMouseDown:ee,onMouseEnter:K,onMouseLeave:W,onMouseMove:ne,onMouseUp:ae,onTouchEnd:xe,onTouchMove:ue,onTouchStart:fe,ref:R},M.createElement(UVe,null),n)))}),GVe=["width","height","responsive","children","className","style","compact","title","desc"];function WVe(t,e){if(t==null)return{};var n,r,i=qVe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function qVe(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 Cee=M.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:a,style:o,compact:l,title:u,desc:d}=t,f=WVe(t,GVe),g=Ks(f);return l?M.createElement(M.Fragment,null,M.createElement(xE,{width:n,height:r}),M.createElement(j9,{otherAttributes:g,title:u,desc:d},s)):M.createElement(VVe,{className:a,style:o,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},M.createElement(j9,{otherAttributes:g,title:u,desc:d,ref:e},M.createElement($He,null,s)))});function JP(){return JP=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},JP.apply(null,arguments)}var KVe={top:5,right:5,bottom:5,left:5},XVe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:KVe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},Nee=M.forwardRef(function(e,n){var r,i=ii(e.categoricalChartProps,XVe),{chartName:s,defaultTooltipEventType:a,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:u}=e,d={chartName:s,defaultTooltipEventType:a,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0};return M.createElement(Mee,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:s},M.createElement(tee,{chartData:u.data}),M.createElement(Aee,{layout:i.layout,margin:i.margin}),M.createElement(Tee,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),M.createElement(Cee,JP({},i,{ref:n})))}),YVe=["axis","item"],ZVe=M.forwardRef((t,e)=>M.createElement(Nee,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:YVe,tooltipPayloadSearcher:Aj,categoricalChartProps:t,ref:e}));function QVe(t){var e=rr();return M.useEffect(()=>{e(yVe(t))},[e,t]),null}var JVe=["layout"];function eR(){return eR=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},eR.apply(null,arguments)}function e9e(t,e){if(t==null)return{};var n,r,i=t9e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function t9e(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 n9e={top:5,right:5,bottom:5,left:5},kee={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:n9e,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},r9e=M.forwardRef(function(e,n){var r,i=ii(e.categoricalChartProps,kee),{layout:s}=i,a=e9e(i,JVe),{chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return M.createElement(Mee,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:o},M.createElement(tee,{chartData:i.data}),M.createElement(Aee,{layout:s,margin:i.margin}),M.createElement(Tee,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),M.createElement(QVe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),M.createElement(Cee,eR({},a,{ref:n})))});function I9(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 U9(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I9(Object(n),!0).forEach(function(r){i9e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function i9e(t,e,n){return(e=s9e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s9e(t){var e=a9e(t,"string");return typeof e=="symbol"?e:e+""}function a9e(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 o9e=["item"],l9e=U9(U9({},kee),{},{layout:"centric",startAngle:0,endAngle:360}),c9e=M.forwardRef((t,e)=>{var n=ii(t,l9e);return M.createElement(r9e,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:o9e,tooltipPayloadSearcher:Aj,categoricalChartProps:n,ref:e})}),u9e=["axis"],d9e=M.forwardRef((t,e)=>M.createElement(Nee,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:u9e,tooltipPayloadSearcher:Aj,categoricalChartProps:t,ref:e}));const k_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function h9e(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 f9e({archives:t,currency:e="$"}){const[n,r]=M.useState("30d"),i=M.useMemo(()=>{const g=h9e(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=g)},[t,n]),s=M.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=new Date(m.completed_at||m.created_at).toISOString().split("T")[0],v=g.get(y)||{date:y,filament:0,cost:0,prints:0};v.filament+=m.filament_used_grams||0,v.cost+=m.cost||0,v.prints+=1,g.set(y,v)}),Array.from(g.values()).sort((m,x)=>m.date.localeCompare(x.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),a=M.useMemo(()=>{if(n==="7d"||n==="30d")return s;const g=new Map;return i.forEach(m=>{const x=new Date(m.completed_at||m.created_at),y=new Date(x);y.setDate(x.getDate()-x.getDay());const v=y.toISOString().split("T")[0],b=g.get(v)||{week:v,filament:0,cost:0,prints:0};b.filament+=m.filament_used_grams||0,b.cost+=m.cost||0,b.prints+=1,g.set(v,b)}),Array.from(g.values()).sort((m,x)=>m.week.localeCompare(x.week)).map(m=>({date:m.week,dateLabel:`Week of ${new Date(m.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...m}))},[i,s,n]),o=M.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=(m.filament_type||"Unknown").split(", ");y.forEach(v=>{const b=(m.filament_used_grams||0)/y.length;g.set(v,(g.get(v)||0)+b)})}),Array.from(g.entries()).map(([m,x])=>({name:m,value:Math.round(x)})).sort((m,x)=>x.value-m.value)},[i]),l=M.useMemo(()=>{const g=new Date,m=[];for(let x=5;x>=0;x--){const y=new Date(g.getFullYear(),g.getMonth()-x,1),v=new Date(g.getFullYear(),g.getMonth()-x+1,0),b=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),E=t.filter(S=>{const A=new Date(S.completed_at||S.created_at);return A>=y&&A<=v});m.push({month:b,filament:Math.round(E.reduce((S,A)=>S+(A.filament_used_grams||0),0)),cost:E.reduce((S,A)=>S+(A.cost||0),0),prints:E.length})}return m},[t]),u=n==="7d"||n==="30d"?s:a,d=i.reduce((g,m)=>g+(m.filament_used_grams||0),0),f=i.reduce((g,m)=>g+(m.cost||0),0);return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),c.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>c.jsx("button",{onClick:()=>r(g),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===g?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:g==="all"?"All":g.replace("d","D")},g))})]}),c.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),c.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),c.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),c.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),c.jsx(oN,{width:"100%",height:250,children:c.jsxs(d9e,{data:u,children:[c.jsx("defs",{children:c.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[c.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),c.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),c.jsx(qP,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),c.jsx(XP,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),c.jsx(ZP,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),c.jsx(MN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),c.jsx(fee,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):c.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),c.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx(oN,{width:160,height:160,children:c.jsxs(c9e,{children:[c.jsx(KJ,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>c.jsx(Fb,{fill:k_[m%k_.length]},`cell-${m}`))}),c.jsx(MN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),c.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const x=o.reduce((v,b)=>v+b.value,0),y=x>0?(g.value/x*100).toFixed(0):0;return c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:k_[m%k_.length]}}),c.jsx("span",{className:"text-white truncate flex-1",children:g.name}),c.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):c.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),c.jsx(oN,{width:"100%",height:200,children:c.jsxs(ZVe,{data:l,children:[c.jsx(qP,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),c.jsx(XP,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),c.jsx(ZP,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),c.jsx(MN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,m)=>[m==="filament"?`${g}g`:m==="cost"?`${e}${g.toFixed(2)}`:g,m==="filament"?"Filament":m==="cost"?"Cost":"Prints"]}),c.jsx(lZ,{}),c.jsx(JJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function p9e({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:a}){const{attributes:o,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:g}=_X({id:t}),m={transform:Sm.Transform.toString(d),transition:f,opacity:g?.5:1};return r?null:c.jsxs("div",{ref:u,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{...o,...l,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:c.jsx(c0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),c.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?c.jsx(Ele,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):c.jsx(ble,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),c.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:c.jsx(mR,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),c.jsx("div",{className:"p-4",children:n})]})}function m9e({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i}){const s=()=>{const E={};return t.forEach(S=>{E[S.id]=S.defaultSize||4}),E},[a,o]=M.useState(()=>{const E=localStorage.getItem(e);if(E)try{const S=JSON.parse(E);return S.sizes||(S.sizes=s()),S}catch{}return{order:t.map(S=>S.id),hidden:t.filter(S=>S.defaultVisible===!1).map(S=>S.id),sizes:s()}}),[l,u]=M.useState(!1);M.useEffect(()=>{localStorage.setItem(e,JSON.stringify(a))},[a,e]),M.useEffect(()=>{const S=t.map(A=>A.id).filter(A=>!a.order.includes(A));S.length>0&&o(A=>({...A,order:[...A.order,...S]}))},[t,a.order]);const d=JK(fw(YS,{activationConstraint:{distance:8}}),fw(XS,{coordinateGetter:wX})),f=E=>{const{active:S,over:A}=E;A&&S.id!==A.id&&o(T=>{const P=T.order.indexOf(S.id),C=T.order.indexOf(A.id);return{...T,order:JS(T.order,P,C)}})},g=E=>{o(S=>({...S,hidden:S.hidden.includes(E)?S.hidden.filter(A=>A!==E):[...S.hidden,E]}))},m=E=>{o(S=>{const A=S.sizes[E]||4,T=A===1?2:A===2?4:1;return{...S,sizes:{...S.sizes,[E]:T}}})},x=()=>{const E={order:t.map(S=>S.id),hidden:t.filter(S=>S.defaultVisible===!1).map(S=>S.id),sizes:s()};o(E),i?.()},y=a.order.map(E=>t.find(S=>S.id===E)).filter(Boolean),v=y.filter(E=>!a.hidden.includes(E.id)),b=y.filter(E=>a.hidden.includes(E.id));return c.jsxs("div",{className:"space-y-4",children:[!r&&c.jsxs("div",{className:"flex items-center justify-end gap-2",children:[b.length>0&&c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>u(!l),children:[c.jsx(o0,{className:"w-4 h-4"}),b.length," Hidden"]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:x,children:[c.jsx(Im,{className:"w-4 h-4"}),"Reset Layout"]})]}),l&&b.length>0&&c.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[c.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(E=>c.jsxs("button",{onClick:()=>g(E.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[c.jsx(o0,{className:"w-3 h-3"}),E.title]},E.id))})]}),c.jsx(gX,{sensors:d,collisionDetection:rX,onDragEnd:f,children:c.jsx(vX,{items:v.map(E=>E.id),strategy:VD,children:c.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(E=>c.jsx(p9e,{id:E.id,title:E.title,isHidden:a.hidden.includes(E.id),size:a.sizes[E.id]||2,onToggleVisibility:()=>g(E.id),onToggleSize:()=>m(E.id),children:E.component},E.id))})})}),v.length===0&&c.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[c.jsx("p",{children:"All widgets are hidden."}),c.jsx(Ie,{className:"mt-4",onClick:x,children:"Reset Layout"})]})]})}function g9e({stats:t,currency:e}){return c.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:c.jsx(u0,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),c.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:c.jsx(ti,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),c.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:c.jsx(u0,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),c.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:c.jsx(a3,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),c.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:c.jsx(am,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),c.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:c.jsx(a3,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),c.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function x9e({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return c.jsxs("div",{className:"flex items-center gap-6",children:[c.jsxs("div",{className:"relative w-28 h-28",children:[c.jsxs("svg",{className:"w-full h-full -rotate-90",children:[c.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),c.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),c.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:c.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ds,{className:"w-4 h-4 text-bambu-green"}),c.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),c.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(hd,{className:"w-4 h-4 text-red-400"}),c.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),c.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function b9e({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const i=(Math.min(150,Math.max(50,n))-50)/100*100,a=(l=>l>=95&&l<=105?"#00ae42":l>105?"#3b82f6":"#f97316")(n),o=n-100;return c.jsxs("div",{className:"flex items-center gap-6",children:[c.jsxs("div",{className:"relative w-28 h-28",children:[c.jsxs("svg",{className:"w-full h-full -rotate-90",children:[c.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),c.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:a,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),c.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[c.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),c.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),c.jsxs("div",{className:"space-y-2 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[c.jsx(IG,{className:"w-3 h-3"}),c.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&c.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,u])=>c.jsxs("div",{className:"flex items-center justify-between text-xs",children:[c.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),c.jsxs("span",{className:`font-medium ${u>=95&&u<=105?"text-bambu-green":u>105?"text-blue-400":"text-orange-400"}`,children:[u.toFixed(0),"%"]})]},l))})]})]})}function v9e({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return c.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const e=Object.entries(t.prints_by_filament_type).sort(([,n],[,r])=>r-n);return c.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return c.jsxs("div",{children:[c.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[c.jsx("span",{className:"text-white",children:n}),c.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),c.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:c.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function y9e({printDates:t}){return c.jsx(ake,{printDates:t,months:4})}function _9e({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?c.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):c.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>c.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[c.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:c.jsx(jo,{className:"w-4 h-4 text-bambu-green"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function w9e({archives:t,currency:e}){return!t||t.length===0?c.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):c.jsx(f9e,{archives:t,currency:e})}function S9e(){const{data:t,isLoading:e}=yt({queryKey:["failureAnalysis"],queryFn:()=>Pe.getFailureAnalysis({days:30})});if(e)return c.jsx("div",{className:"flex justify-center py-4",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!t||t.total_prints===0)return c.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const n=Object.entries(t.failures_by_reason).sort(([,r],[,i])=>i-r).slice(0,5);return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Qr,{className:`w-5 h-5 ${t.failure_rate>20?"text-red-400":t.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),c.jsxs("span",{className:"text-2xl font-bold text-white",children:[t.failure_rate.toFixed(1),"%"]}),c.jsx("span",{className:"text-sm text-bambu-gray",children:"failure rate"})]}),c.jsxs("div",{className:"text-sm text-bambu-gray",children:[t.failed_prints," / ",t.total_prints," prints failed"]})]}),n.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray font-medium",children:"Top Failure Reasons"}),n.map(([r,i])=>c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsx("span",{className:"text-white truncate max-w-[200px]",children:r||"Unknown"}),c.jsx("span",{className:"text-bambu-gray",children:i})]},r))]}),t.trend&&t.trend.length>=2&&c.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx(jce,{className:`w-4 h-4 ${t.trend[t.trend.length-1].failure_rate<t.trend[t.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),c.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",t.trend[t.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]})}function E9e(){const{showToast:t}=ri(),[e,n]=M.useState(!1),[r,i]=M.useState(!1),[s,a]=M.useState(0),{data:o,isLoading:l}=yt({queryKey:["archiveStats"],queryFn:Pe.getArchiveStats}),{data:u}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:d}=yt({queryKey:["archives"],queryFn:()=>Pe.getArchives(void 0,1e3,0)}),{data:f}=yt({queryKey:["settings"],queryFn:Pe.getSettings}),g=async E=>{i(!1),n(!0);try{const{blob:S,filename:A}=await Pe.exportStats({format:E,days:90}),T=URL.createObjectURL(S),P=document.createElement("a");P.href=T,P.download=A,P.click(),URL.revokeObjectURL(T),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},m=f?.currency||"$",x=new Map(u?.map(E=>[String(E.id),E.name])||[]),y=d?.map(E=>E.created_at)||[];if(l)return c.jsx("div",{className:"p-4 md:p-8",children:c.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const v=[{id:"quick-stats",title:"Quick Stats",component:c.jsx(g9e,{stats:o,currency:m}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:c.jsx(x9e,{stats:o}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:c.jsx(b9e,{stats:o,printerMap:x}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:c.jsx(v9e,{stats:o}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:c.jsx(S9e,{}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:c.jsx(y9e,{printDates:y}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:c.jsx(_9e,{stats:o,printerMap:x}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:c.jsx(w9e,{archives:d||[],currency:m}),defaultSize:4}],b=()=>{localStorage.removeItem("bambusy-dashboard-layout"),a(E=>E+1),t("Layout reset")};return c.jsxs("div",{className:"p-4 md:p-8",children:[c.jsxs("div",{className:"flex items-center justify-between mb-6",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),c.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ie,{variant:"secondary",onClick:b,children:[c.jsx(Im,{className:"w-4 h-4"}),"Reset Layout"]}),c.jsxs("div",{className:"relative",children:[c.jsxs(Ie,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(o1,{className:"w-4 h-4"}),"Export Stats"]}),r&&c.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[c.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>g("csv"),children:[c.jsx(Ya,{className:"w-4 h-4"}),"Export as CSV"]}),c.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>g("xlsx"),children:[c.jsx(o1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),c.jsx(m9e,{widgets:v,storageKey:"bambusy-dashboard-layout",hideControls:!0},s)]})}function M9e({plug:t,onEdit:e}){const n=Sn(),[r,i]=M.useState(!1),[s,a]=M.useState(!1),[o,l]=M.useState(!1),[u,d]=M.useState(!1),{data:f,isLoading:g,refetch:m}=yt({queryKey:["smart-plug-status",t.id],queryFn:()=>Pe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),y=x?.find(P=>P.id===t.printer_id),v=_t({mutationFn:P=>Pe.controlSmartPlug(t.id,P),onSuccess:()=>{m()}}),b=_t({mutationFn:P=>Pe.updateSmartPlug(t.id,P),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=_t({mutationFn:()=>Pe.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),S=f?.state==="ON",A=f?.reachable??!1,T=v.isPending;return c.jsxs(c.Fragment,{children:[c.jsx(Nt,{className:"relative",children:c.jsxs(Dt,{className:"p-4",children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:`p-2 rounded-lg ${A?S?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:c.jsx(Ox,{className:`w-5 h-5 ${A?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-white",children:t.name}),c.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),c.jsx("div",{className:"flex items-center gap-2",children:g?c.jsx(At,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?c.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[c.jsx(BG,{className:"w-4 h-4 text-bambu-green"}),c.jsx("span",{className:S?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):c.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[c.jsx(SR,{className:"w-4 h-4"}),c.jsx("span",{children:"Offline"})]})})]}),y&&c.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),c.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&c.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&c.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[c.jsx(fh,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&c.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[c.jsx(qr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),c.jsxs("div",{className:"flex gap-2 mb-3",children:[c.jsxs(Ie,{size:"sm",variant:S?"primary":"secondary",disabled:!A||T,onClick:()=>a(!0),className:"flex-1",children:[T?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(fd,{className:"w-4 h-4"}),"On"]}),c.jsxs(Ie,{size:"sm",variant:S?"secondary":"primary",disabled:!A||T,onClick:()=>l(!0),className:"flex-1",children:[T?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(yR,{className:"w-4 h-4"}),"Off"]})]}),c.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(vS,{className:"w-4 h-4"}),"Automation Settings"]}),c.jsx("span",{children:u?"-":"+"})]}),u&&c.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Enabled"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:t.enabled,onChange:P=>b.mutate({enabled:P.target.checked}),className:"sr-only peer"}),c.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Auto On"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:P=>b.mutate({auto_on:P.target.checked}),className:"sr-only peer"}),c.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:P=>b.mutate({auto_off:P.target.checked}),className:"sr-only peer"}),c.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&c.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[c.jsx(ti,{className:"w-4 h-4"}),"Time"]}),c.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[c.jsx($p,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),c.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:P=>b.mutate({off_delay_minutes:parseInt(P.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),c.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:P=>b.mutate({off_temp_threshold:parseInt(P.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),c.jsxs("div",{className:"flex gap-2 pt-2",children:[c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[c.jsx(vR,{className:"w-4 h-4"}),"Edit"]}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:c.jsx(kn,{className:"w-4 h-4"})})]})]})]})}),r&&c.jsx(Kr,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{E.mutate(),i(!1)},onCancel:()=>i(!1)}),s&&c.jsx(Kr,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{v.mutate("on"),a(!1)},onCancel:()=>a(!1)}),o&&c.jsx(Kr,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{v.mutate("off"),l(!1)},onCancel:()=>l(!1)})]})}function A9e({plug:t,onClose:e}){const n=Sn(),r=!!t,[i,s]=M.useState(t?.name||""),[a,o]=M.useState(t?.ip_address||""),[l,u]=M.useState(t?.username||""),[d,f]=M.useState(t?.password||""),[g,m]=M.useState(t?.printer_id||null),[x,y]=M.useState(null),[v,b]=M.useState(null),[E,S]=M.useState(t?.power_alert_enabled||!1),[A,T]=M.useState(t?.power_alert_high?.toString()||""),[P,C]=M.useState(t?.power_alert_low?.toString()||""),[I,N]=M.useState(t?.schedule_enabled||!1),[D,F]=M.useState(t?.schedule_on_time||""),[L,q]=M.useState(t?.schedule_off_time||""),{data:R}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:V}=yt({queryKey:["smart-plugs"],queryFn:Pe.getSmartPlugs});M.useEffect(()=>{const $=ee=>{ee.key==="Escape"&&e()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e]);const K=_t({mutationFn:()=>Pe.testSmartPlugConnection(a,l||null,d||null),onSuccess:$=>{y($),b(null),!i&&$.device_name&&s($.device_name)},onError:$=>{y(null),b($.message)}}),W=_t({mutationFn:$=>Pe.createSmartPlug($),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:$=>{b($.message)}}),ne=_t({mutationFn:$=>Pe.updateSmartPlug(t.id,$),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:$=>{b($.message)}}),Y=R?.filter($=>!V?.some(ae=>ae.printer_id===$.id&&ae.id!==t?.id)),Z=$=>{if($.preventDefault(),b(null),!i.trim()){b("Name is required");return}if(!a.trim()){b("IP address is required");return}const ee={name:i.trim(),ip_address:a.trim(),username:l.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:E,power_alert_high:A?parseFloat(A):null,power_alert_low:P?parseFloat(P):null,schedule_enabled:I,schedule_on_time:D||null,schedule_off_time:L||null};r?ne.mutate(ee):W.mutate(ee)},U=W.isPending||ne.isPending;return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:$=>$.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:Z,className:"p-6 space-y-4",children:[v&&c.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:v}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("input",{type:"text",value:a,onChange:$=>{o($.target.value),y(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),c.jsxs(Ie,{type:"button",variant:"secondary",onClick:()=>K.mutate(),disabled:!a.trim()||K.isPending,children:[K.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(BG,{className:"w-4 h-4"}),"Test"]})]})]}),x&&c.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${x.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:x.success?c.jsxs(c.Fragment,{children:[c.jsx(ds,{className:"w-5 h-5"}),c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"Connected!"}),c.jsxs("p",{className:"text-sm opacity-80",children:[x.device_name&&`Device: ${x.device_name} - `,"State: ",x.state]})]})]}):c.jsxs(c.Fragment,{children:[c.jsx(SR,{className:"w-5 h-5"}),c.jsx("span",{children:"Connection failed"})]})}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),c.jsx("input",{type:"text",value:i,onChange:$=>s($.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),c.jsx("input",{type:"text",value:l,onChange:$=>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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),c.jsx("input",{type:"password",value:d,onChange:$=>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"})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),c.jsxs("select",{value:g??"",onChange:$=>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:[c.jsx("option",{value:"",children:"No printer (manual control only)"}),Y?.map($=>c.jsx("option",{value:$.id,children:$.name},$.id))]}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),c.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(fh,{className:"w-4 h-4 text-bambu-green"}),c.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:E,onChange:$=>S($.target.checked),className:"sr-only peer"}),c.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E&&c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),c.jsx("input",{type:"number",value:A,onChange:$=>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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),c.jsx("input",{type:"number",value:P,onChange:$=>C($.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),c.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ti,{className:"w-4 h-4 text-bambu-green"}),c.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:I,onChange:$=>N($.target.checked),className:"sr-only peer"}),c.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),I&&c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),c.jsx("input",{type:"time",value:D,onChange:$=>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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),c.jsx("input",{type:"time",value:L,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"})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{type:"submit",disabled:U,className:"flex-1",children:[U?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(To,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Zn({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return c.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:c.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const T9e={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function C9e({provider:t,onEdit:e}){const n=Sn(),[r,i]=M.useState(!1),[s,a]=M.useState(!1),[o,l]=M.useState(null),{data:u}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=_t({mutationFn:y=>Pe.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=_t({mutationFn:()=>Pe.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=_t({mutationFn:()=>Pe.testNotificationProvider(t.id),onSuccess:y=>{l(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{l({success:!1,message:y.message})}}),x=y=>y||"";return c.jsxs(c.Fragment,{children:[c.jsx(Nt,{className:"relative",children:c.jsxs(Dt,{className:"p-4",children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:c.jsx(fh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-white",children:t.name}),c.jsx("p",{className:"text-sm text-bambu-gray",children:T9e[t.provider_type]||t.provider_type})]})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&c.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&t.last_error_at&&(!t.last_success||new Date(t.last_error_at)>new Date(t.last_success))&&c.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),c.jsx(Zn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]})]}),d&&c.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),c.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&c.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:c.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),c.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&c.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&c.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&c.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&c.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&c.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&c.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&c.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&c.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&c.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&c.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[c.jsx(l1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&c.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[c.jsx(qr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),c.jsx("div",{className:"mb-3",children:c.jsxs(Ie,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:"w-full",children:[m.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(_R,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&c.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?c.jsx(ds,{className:"w-4 h-4"}):c.jsx(hd,{className:"w-4 h-4"}),c.jsx("span",{children:o.message})]}),c.jsxs("button",{onClick:()=>a(!s),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(vS,{className:"w-4 h-4"}),"Event Settings"]}),s?c.jsx(mS,{className:"w-4 h-4"}):c.jsx(ef,{className:"w-4 h-4"})]}),s&&c.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Enabled"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),c.jsx(Zn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Print Started"}),c.jsx(Zn,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),c.jsx(Zn,{checked:t.on_print_complete,onChange:y=>f.mutate({on_print_complete:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),c.jsx(Zn,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),c.jsx(Zn,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),c.jsx(Zn,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),c.jsx(Zn,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),c.jsx(Zn,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),c.jsx(Zn,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),c.jsx(Zn,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(l1,{className:"w-4 h-4 text-purple-400"}),c.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),c.jsx(Zn,{checked:t.quiet_hours_enabled,onChange:y=>f.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&c.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ti,{className:"w-4 h-4 text-bambu-gray"}),c.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(qr,{className:"w-4 h-4 text-emerald-400"}),c.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),c.jsx(Zn,{checked:t.daily_digest_enabled,onChange:y=>f.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&c.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ti,{className:"w-4 h-4 text-bambu-gray"}),c.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),c.jsxs("div",{className:"flex gap-2 pt-2",children:[c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[c.jsx(vR,{className:"w-4 h-4"}),"Edit"]}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:c.jsx(kn,{className:"w-4 h-4"})})]})]})]})}),r&&c.jsx(Kr,{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 F9=[{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"email",label:"Email",description:"SMTP email notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function N9e({provider:t,onClose:e}){const n=Sn(),r=!!t,[i,s]=M.useState(t?.name||""),[a,o]=M.useState(t?.provider_type||"discord"),[l,u]=M.useState(t?.printer_id||null),[d,f]=M.useState(t?.quiet_hours_enabled||!1),[g,m]=M.useState(t?.quiet_hours_start||"22:00"),[x,y]=M.useState(t?.quiet_hours_end||"07:00"),[v,b]=M.useState(t?.daily_digest_enabled||!1),[E,S]=M.useState(t?.daily_digest_time||"08:00"),[A,T]=M.useState(t?.on_print_start??!1),[P,C]=M.useState(t?.on_print_complete??!0),[I,N]=M.useState(t?.on_print_failed??!0),[D,F]=M.useState(t?.on_print_stopped??!0),[L,q]=M.useState(t?.on_print_progress??!1),[R,V]=M.useState(t?.on_printer_offline??!1),[K,W]=M.useState(t?.on_printer_error??!1),[ne,Y]=M.useState(t?.on_filament_low??!1),[Z,U]=M.useState(t?.on_maintenance_due??!1),[$,ee]=M.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([G,J])=>[G,String(J)])):{}),[ae,fe]=M.useState(null),[ue,xe]=M.useState(null),{data:Me}=yt({queryKey:["printers"],queryFn:Pe.getPrinters});M.useEffect(()=>{const G=J=>{J.key==="Escape"&&e()};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[e]);const se=_t({mutationFn:()=>Pe.testNotificationConfig({provider_type:a,config:$}),onSuccess:G=>{fe(G),xe(null)},onError:G=>{fe({success:!1,message:G.message})}}),ve=_t({mutationFn:G=>Pe.createNotificationProvider(G),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:G=>{xe(G.message)}}),je=_t({mutationFn:G=>Pe.updateNotificationProvider(t.id,G),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:G=>{xe(G.message)}}),de=G=>{if(G.preventDefault(),xe(null),!i.trim()){xe("Name is required");return}const J=z(a);for(const ke of J)if(!$[ke.key]?.trim()){xe(`${ke.label} is required`);return}const le={name:i.trim(),provider_type:a,config:$,printer_id:l,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?x:null,daily_digest_enabled:v,daily_digest_time:v?E:null,on_print_start:A,on_print_complete:P,on_print_failed:I,on_print_stopped:D,on_print_progress:L,on_printer_offline:R,on_printer_error:K,on_filament_low:ne,on_maintenance_due:Z};r?je.mutate(le):ve.mutate(le)},ut=ve.isPending||je.isPending,H=G=>{switch(G){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},z=G=>H(G).filter(J=>J.required),re=H(a);return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8",onClick:G=>G.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:de,className:"p-6 space-y-4",children:[ue&&c.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:ue}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),c.jsx("input",{type:"text",value:i,onChange:G=>s(G.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),c.jsx("select",{value:a,onChange:G=>{o(G.target.value),ee({}),fe(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:F9.map(G=>c.jsx("option",{value:G.value,children:G.label},G.value))}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:F9.find(G=>G.value===a)?.description})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),re.map(G=>c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[G.label," ",G.required&&"*"]}),G.type==="select"&&G.options?c.jsx("select",{value:$[G.key]||G.options[0]?.value||"",onChange:J=>{ee({...$,[G.key]:J.target.value}),fe(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:G.options.map(J=>c.jsx("option",{value:J.value,children:J.label},J.value))}):c.jsx("input",{type:G.type,value:$[G.key]||"",onChange:J=>{ee({...$,[G.key]:J.target.value}),fe(null)},placeholder:G.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},G.key))]}),c.jsx("div",{className:"flex gap-2",children:c.jsxs(Ie,{type:"button",variant:"secondary",onClick:()=>{fe(null),se.mutate()},disabled:se.isPending||!$[z(a)[0]?.key],className:"flex-1",children:[se.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(_R,{className:"w-4 h-4"}),"Test Configuration"]})}),ae&&c.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ae.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:ae.success?c.jsxs(c.Fragment,{children:[c.jsx(ds,{className:"w-5 h-5"}),c.jsx("span",{children:ae.message})]}):c.jsxs(c.Fragment,{children:[c.jsx(hd,{className:"w-5 h-5"}),c.jsx("span",{children:ae.message})]})}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),c.jsxs("select",{value:l??"",onChange:G=>u(G.target.value?Number(G.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"",children:"All printers"}),Me?.map(G=>c.jsx("option",{value:G.id,children:G.name},G.id))]}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),c.jsx(Zn,{checked:d,onChange:f})]}),d&&c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),c.jsx("input",{type:"time",value:g,onChange:G=>m(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),c.jsx("input",{type:"time",value:x,onChange:G=>y(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),c.jsx(Zn,{checked:v,onChange:b})]}),v&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),c.jsx("input",{type:"time",value:E,onChange:G=>S(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),c.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[c.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),c.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Start"}),c.jsx(Zn,{checked:A,onChange:T})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Complete"}),c.jsx(Zn,{checked:P,onChange:C})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Failed"}),c.jsx(Zn,{checked:I,onChange:N})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Stopped"}),c.jsx(Zn,{checked:D,onChange:F})]}),c.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[c.jsxs("div",{children:[c.jsx("span",{className:"text-sm text-white",children:"Progress"}),c.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),c.jsx(Zn,{checked:L,onChange:q})]})]})]}),c.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[c.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),c.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Offline"}),c.jsx(Zn,{checked:R,onChange:V})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Error"}),c.jsx(Zn,{checked:K,onChange:W})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),c.jsx(Zn,{checked:ne,onChange:Y})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),c.jsx(Zn,{checked:Z,onChange:U})]})]})]})]}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{type:"submit",disabled:ut,className:"flex-1",children:[ut?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(To,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function k9e({template:t,onClose:e}){const n=Sn(),r=M.useRef(null),[i,s]=M.useState(t.title_template),[a,o]=M.useState(t.body_template),[l,u]=M.useState(null),[d,f]=M.useState(!0),{data:g}=yt({queryKey:["template-variables"],queryFn:Pe.getTemplateVariables}),m=g?.find(T=>T.event_type===t.event_type),{data:x,isLoading:y}=yt({queryKey:["template-preview",t.event_type,i,a],queryFn:()=>Pe.previewTemplate({event_type:t.event_type,title_template:i,body_template:a}),enabled:d&&i.length>0&&a.length>0});M.useEffect(()=>{const T=P=>{P.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const v=_t({mutationFn:T=>Pe.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),b=_t({mutationFn:()=>Pe.resetNotificationTemplate(t.id),onSuccess:T=>{s(T.title_template),o(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{u(T.message)}}),E=T=>{if(T.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!a.trim()){u("Body is required");return}v.mutate({title_template:i,body_template:a})},S=T=>{const P=r.current;if(!P)return;const C=P.selectionStart,I=P.selectionEnd,N=a,D=N.substring(0,C),F=N.substring(I),L=D+`{${T}}`+F;o(L),setTimeout(()=>{P.focus();const q=C+T.length+2;P.setSelectionRange(q,q)},0)},A=i!==t.title_template||a!==t.body_template;return c.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),c.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:c.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]}),c.jsxs("form",{onSubmit:E,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[l&&c.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:l}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),c.jsx("input",{type:"text",value:i,onChange:T=>s(T.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),c.jsx("textarea",{ref:r,value:a,onChange:T=>o(T.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),m&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(T=>c.jsxs("button",{type:"button",onClick:()=>S(T),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[c.jsx(fr,{className:"w-3 h-3"}),T]},T))}),c.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[c.jsx(o0,{className:"w-4 h-4"}),"Live Preview"]}),c.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&c.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[c.jsx(At,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),c.jsx("div",{className:"text-white font-medium",children:x.title})]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),c.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):c.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),c.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[c.jsxs(Ie,{type:"button",variant:"ghost",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-orange-400 hover:text-orange-300",children:[b.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin mr-2"}):c.jsx(Im,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),c.jsxs(Ie,{onClick:E,disabled:v.isPending||!A,children:[v.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin mr-2"}):c.jsx(To,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const P9e={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"},R9e={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 D9e({onClose:t}){const e=Sn(),{showToast:n}=ri(),[r,i]=M.useState(7),[s,a]=M.useState(null),[o,l]=M.useState(!1),{data:u,isLoading:d,refetch:f,isRefetching:g}=yt({queryKey:["notification-logs",r,o],queryFn:()=>Pe.getNotificationLogs({days:r,limit:100,success:o?!1:void 0})}),{data:m}=yt({queryKey:["notification-log-stats",r],queryFn:()=>Pe.getNotificationLogStats(r)}),x=_t({mutationFn:()=>Pe.clearNotificationLogs(30),onSuccess:v=>{n(v.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:v=>{n(`Failed to clear logs: ${v.message}`,"error")}}),y=v=>{const b=new Date(v),S=new Date().getTime()-b.getTime();return S<6e4?"Just now":S<36e5?`${Math.floor(S/6e4)}m ago`:S<864e5?`${Math.floor(S/36e5)}h ago`:b.toLocaleDateString()+" "+b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[c.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(o3,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),c.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),m&&c.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:c.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[c.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",c.jsx("span",{className:"text-white font-medium",children:m.total})," notifications"]}),c.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[c.jsx(ds,{className:"w-4 h-4"}),m.success_count," sent"]}),m.failure_count>0&&c.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[c.jsx(hd,{className:"w-4 h-4"}),m.failure_count," failed"]})]})}),c.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[c.jsxs("select",{value:r,onChange:v=>i(Number(v.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[c.jsx("option",{value:1,children:"Last 24 hours"}),c.jsx("option",{value:7,children:"Last 7 days"}),c.jsx("option",{value:30,children:"Last 30 days"}),c.jsx("option",{value:90,children:"Last 90 days"})]}),c.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:o,onChange:v=>l(v.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),c.jsx("div",{className:"flex-1"}),c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:g,children:[g?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(qs,{className:"w-4 h-4"}),"Refresh"]}),c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"}),"Clear Old"]})]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?c.jsx("div",{className:"space-y-2",children:u.map(v=>c.jsx(O9e,{log:v,isExpanded:s===v.id,onToggle:()=>a(s===v.id?null:v.id),formatDate:y},v.id))}):c.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[c.jsx(o3,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),c.jsx("p",{className:"text-sm",children:o?"No failed notifications":"No notifications logged"})]})})]})})}function O9e({log:t,isExpanded:e,onToggle:n,formatDate:r}){return c.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[c.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?c.jsx(ds,{className:"w-4 h-4 text-bambu-green shrink-0"}):c.jsx(hd,{className:"w-4 h-4 text-red-400 shrink-0"}),c.jsx("span",{className:`text-xs font-medium ${R9e[t.event_type]||"text-bambu-gray"}`,children:P9e[t.event_type]||t.event_type}),c.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&c.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),c.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?c.jsx(mS,{className:"w-4 h-4 text-bambu-gray shrink-0"}):c.jsx(ef,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&c.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),c.jsx("p",{className:"text-sm text-white",children:t.title})]}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),c.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),c.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),c.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[c.jsxs("span",{children:["Provider: ",t.provider_type]}),c.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const P_=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:c.jsx(wR,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:c.jsx(fh,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:c.jsx(Ya,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:c.jsx(Ox,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:c.jsx(jo,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:c.jsx(Dle,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:c.jsx(Ju,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:c.jsx(pS,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"}];function j9e({onClose:t,onExport:e}){const{t:n}=uS(),[r,i]=M.useState(()=>{const x={};return P_.forEach(y=>{x[y.id]=y.default}),x}),[s,a]=M.useState(!1),[o,l]=M.useState(!1);M.useEffect(()=>{const x=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(y=>({...y,[x]:!y[x]}))},d=()=>{const x={};P_.forEach(y=>{x[y.id]=!0}),i(x)},f=()=>{const x={};P_.forEach(y=>{x[y.id]=!1}),i(x)},g=Object.values(r).filter(Boolean).length,m=async()=>{l(!0);try{await e({...r,access_codes:s&&r.printers})}finally{l(!1)}};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o?void 0:t,children:c.jsx(Nt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:c.jsx(ya,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),c.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),c.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[c.jsx("button",{onClick:d,disabled:o,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),c.jsx("span",{className:"text-bambu-gray",children:"|"}),c.jsx("button",{onClick:f,disabled:o,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),c.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${o?"opacity-50 pointer-events-none":""}`,children:P_.map(x=>c.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[c.jsx("input",{type:"checkbox",checked:r[x.id],onChange:()=>u(x.id),disabled:o,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),c.jsx("div",{className:`${r[x.id]?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),c.jsxs("div",{className:"flex-1",children:[c.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),c.jsx("div",{className:"text-xs text-bambu-gray",children:x.description})]})]},x.id))}),r.archives&&c.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:c.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[c.jsx(pS,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),c.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[c.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),c.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&c.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx(Op,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),c.jsx(Zn,{checked:s,onChange:a})]}),s&&c.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:c.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[c.jsx(Qr,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),c.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),c.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx(Ie,{variant:"secondary",onClick:t,disabled:o,children:n("common.cancel",{defaultValue:"Cancel"})}),c.jsx(Ie,{onClick:m,disabled:g===0||o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:o?c.jsxs(c.Fragment,{children:[c.jsx(At,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):c.jsxs(c.Fragment,{children:[c.jsx(ya,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const z9={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 L9e({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=M.useState("options"),[s,a]=M.useState(!1),[o,l]=M.useState(null),[u,d]=M.useState(null),[f,g]=M.useState(new Set),m=M.useRef(null);M.useEffect(()=>{const S=A=>{A.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[t,r]);const x=S=>{const A=S.target.files?.[0];A&&l(A)},y=async()=>{if(o){i("restoring");try{const S=await e(o,s);d(S),i("result"),S.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},v=S=>{g(A=>{const T=new Set(A);return T.has(S)?T.delete(S):T.add(S),T})},b=u?.restored?Object.values(u.restored).reduce((S,A)=>S+A,0)+(u.files_restored||0):0,E=u?.total_skipped||0;return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:S=>{S.target===S.currentTarget&&r!=="restoring"&&t()},children:c.jsx(Nt,{className:"w-full max-w-lg",children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:`p-2 rounded-full ${r==="result"&&u?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!u?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&u?.success?c.jsx(ds,{className:"w-5 h-5"}):r==="result"&&!u?.success?c.jsx(Qr,{className:"w-5 h-5"}):c.jsx(ma,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),c.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&c.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),r==="options"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"p-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx("input",{ref:m,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),c.jsx("button",{type:"button",onClick:()=>m.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:o?c.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[c.jsx(ds,{className:"w-5 h-5"}),c.jsx("span",{className:"font-medium",children:o.name})]}):c.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[c.jsx(ma,{className:"w-8 h-8"}),c.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),c.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:c.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[c.jsx(Qr,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),c.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[c.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),c.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[c.jsxs("li",{children:[c.jsx("strong",{children:"Printers"})," - matched by serial number"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),c.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[s?c.jsx(qs,{className:"w-4 h-4 text-orange-400"}):c.jsx(c1,{className:"w-4 h-4 text-bambu-gray"}),s?"Replace existing data":"Keep existing data"]}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),c.jsx(Zn,{checked:s,onChange:a})]})}),s&&c.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:c.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[c.jsx(Qr,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),c.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[c.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),c.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),c.jsxs(Ie,{type:"button",onClick:y,disabled:!o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[c.jsx(ma,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&c.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[c.jsx(At,{className:"w-12 h-12 text-bambu-green animate-spin"}),c.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[c.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:b}),c.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),c.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[c.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:E}),c.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,S])=>S>0)&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[c.jsx(ds,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),c.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,S])=>S>0).map(([S,A])=>c.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[c.jsx("span",{className:"text-white",children:z9[S]||S}),c.jsx("span",{className:"text-bambu-green font-medium",children:A})]},S)),(u.files_restored||0)>0&&c.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[c.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),c.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,S])=>S>0)&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[c.jsx(c1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),c.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,S])=>S>0).map(([S,A])=>{const T=u.skipped_details?.[S]||[],P=f.has(S);return c.jsxs("div",{children:[c.jsxs("button",{onClick:()=>T.length>0&&v(S),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${T.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[c.jsxs("span",{className:"text-white flex items-center gap-2",children:[z9[S]||S,T.length>0&&(P?c.jsx(mS,{className:"w-3 h-3"}):c.jsx(ef,{className:"w-3 h-3"}))]}),c.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),P&&T.length>0&&c.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[T.slice(0,10).map((C,I)=>c.jsx("div",{children:C},I)),T.length>10&&c.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",T.length-10," more"]})]})]},S)})})]}),b===0&&E===0&&c.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),c.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:c.jsx(Ie,{onClick:t,children:"Close"})})]})]})})})}async function I9e(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function U9e(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 F9e(){const t=Sn(),[e,n]=M.useState(!1),[r,i]=M.useState(""),[s,a]=M.useState("auto"),[o,l]=M.useState(!1),[u,d]=M.useState("all"),[f,g]=M.useState(!1),{data:m,isLoading:x}=yt({queryKey:["spoolman-settings"],queryFn:I9e}),{data:y,isLoading:v,refetch:b}=yt({queryKey:["spoolman-status"],queryFn:Pe.getSpoolmanStatus,refetchInterval:3e4}),{data:E}=yt({queryKey:["printers"],queryFn:Pe.getPrinters});M.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),i(m.spoolman_url||""),a(m.spoolman_sync_mode||"auto"),g(!0))},[m]),M.useEffect(()=>{if(!f||!m)return;if(m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==r||(m.spoolman_sync_mode||"auto")!==s){const q=setTimeout(()=>{S.mutate()},500);return()=>clearTimeout(q)}},[e,r,s,f]);const S=_t({mutationFn:()=>U9e({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:s}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!0),setTimeout(()=>l(!1),2e3)}}),A=_t({mutationFn:Pe.connectSpoolman,onSuccess:()=>{b()}}),T=_t({mutationFn:Pe.disconnectSpoolman,onSuccess:()=>{b()}}),P=_t({mutationFn:Pe.syncAllPrintersAms,onSuccess:L=>{L.success}}),C=_t({mutationFn:L=>Pe.syncPrinterAms(L),onSuccess:L=>{L.success}}),I=()=>{u==="all"?P.mutate():C.mutate(u)},N=P.isPending||C.isPending,D=u==="all"?P.data:C.data,F=u==="all"?P.isSuccess:C.isSuccess;return x?c.jsxs(Nt,{children:[c.jsx(za,{children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(s3,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),c.jsx(Dt,{children:c.jsx("div",{className:"flex justify-center py-8",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):c.jsxs(Nt,{children:[c.jsx(za,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(s3,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),S.isPending&&c.jsx(At,{className:"w-4 h-4 text-bambu-green animate-spin"}),o&&c.jsx(Ph,{className:"w-4 h-4 text-bambu-green"})]})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Enable Spoolman"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:e,onChange:L=>n(L.target.checked),className:"sr-only peer"}),c.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),c.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:L=>i(L.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),c.jsxs("select",{value:s,onChange:L=>a(L.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[c.jsx("option",{value:"auto",children:"Automatic"}),c.jsx("option",{value:"manual",children:"Manual Only"})]}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&c.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),v?c.jsx(At,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?c.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[c.jsx(Ph,{className:"w-4 h-4"}),"Connected"]}):c.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[c.jsx(Gt,{className:"w-4 h-4"}),"Disconnected"]})]}),c.jsx("div",{className:"flex gap-2",children:y?.connected?c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(nle,{className:"w-4 h-4"}),"Disconnect"]}):c.jsxs(Ie,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!r,children:[A.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(c3,{className:"w-4 h-4"}),"Connect"]})})]}),A.isError&&c.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:A.error.message}),y?.connected&&c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsxs("select",{value:u,onChange:L=>d(L.target.value==="all"?"all":Number(L.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[c.jsx("option",{value:"all",children:"All Printers"}),E?.map(L=>c.jsx("option",{value:L.id,children:L.name},L.id))]}),c.jsx(ef,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:I,disabled:N,children:[N?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(qs,{className:"w-4 h-4"}),"Sync"]})]})]}),F&&D&&c.jsx("div",{className:`mt-2 p-2 rounded text-sm ${D.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:D.success?`Synced ${D.synced_count} trays successfully`:`Synced ${D.synced_count} trays with ${D.errors.length} errors`})]})]})]})}function z9e({link:t,onClose:e}){const n=Sn(),{theme:r}=yS(),i=!!t,s=M.useRef(null),[a,o]=M.useState(t?.name||""),[l,u]=M.useState(t?.url||""),[d,f]=M.useState(t?.icon||"link"),[g,m]=M.useState(!!t?.custom_icon),[x,y]=M.useState(t?.custom_icon?Pe.getExternalLinkIconUrl(t.id):null),[v,b]=M.useState(null),[E,S]=M.useState(null);M.useEffect(()=>{const F=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const A=_t({mutationFn:async F=>{const L=await Pe.createExternalLink(F);return v?await Pe.uploadExternalLinkIcon(L.id,v):L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),T=_t({mutationFn:async F=>{let L=await Pe.updateExternalLink(t.id,F);return v?L=await Pe.uploadExternalLinkIcon(t.id,v):!g&&t?.custom_icon&&(L=await Pe.deleteExternalLinkIcon(t.id)),L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),P=F=>{const L=F.target.files?.[0];if(L){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(L.type)){S("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(L.size>1024*1024){S("Image file must be less than 1MB");return}b(L),m(!0);const R=new FileReader;R.onload=V=>{y(V.target?.result)},R.readAsDataURL(L)}},C=()=>{b(null),y(null),m(!1),s.current&&(s.current.value="")},I=F=>{if(F.preventDefault(),S(null),!a.trim()){S("Name is required");return}if(!l.trim()){S("URL is required");return}if(!l.startsWith("http://")&&!l.startsWith("https://")){S("URL must start with http:// or https://");return}const L={name:a.trim(),url:l.trim(),icon:d};i?T.mutate(L):A.mutate(L)},N=A.isPending||T.isPending,D=_S(d);return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:F=>F.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:g&&x?c.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):c.jsx(D,{className:"w-5 h-5"})}),c.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:I,className:"p-6 space-y-4",children:[E&&c.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),c.jsx("input",{type:"text",value:a,onChange:F=>o(F.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),c.jsx("input",{type:"text",value:l,onChange:F=>u(F.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),c.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),c.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:P}),g&&x?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),c.jsx("button",{type:"button",onClick:C,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:c.jsx(kn,{className:"w-4 h-4"})})]}):c.jsxs(Ie,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[c.jsx(ma,{className:"w-4 h-4"}),"Upload"]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!g&&c.jsxs("div",{children:[c.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),c.jsx(oue,{value:d,onChange:f})]})]}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{type:"submit",disabled:N,className:"flex-1",children:[N?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(To,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function B9e(){const t=Sn(),[e,n]=M.useState(!1),[r,i]=M.useState(null),[s,a]=M.useState(null),[o,l]=M.useState(null),{data:u,isLoading:d}=yt({queryKey:["external-links"],queryFn:Pe.getExternalLinks}),f=_t({mutationFn:E=>Pe.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=_t({mutationFn:E=>Pe.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=(E,S)=>{l(S),E.dataTransfer.effectAllowed="move"},x=E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},y=(E,S)=>{if(E.preventDefault(),o===null||o===S||!u)return;const A=u.map(I=>I.id),T=A.indexOf(o),P=A.indexOf(S);if(T===-1||P===-1)return;const C=[...A];C.splice(T,1),C.splice(P,0,o),g.mutate(C),l(null)},v=E=>{a(E)},b=()=>{s&&(f.mutate(s.id),a(null))};return c.jsxs(c.Fragment,{children:[c.jsxs(Nt,{children:[c.jsx(za,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(c3,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),c.jsxs(Ie,{size:"sm",onClick:()=>n(!0),children:[c.jsx(fr,{className:"w-4 h-4"}),"Add Link"]})]})}),c.jsxs(Dt,{children:[c.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?c.jsx("div",{className:"flex justify-center py-8",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?c.jsx("div",{className:"space-y-2",children:u.map(E=>{const S=_S(E.icon);return c.jsxs("div",{draggable:!0,onDragStart:A=>m(A,E.id),onDragOver:x,onDrop:A=>y(A,E.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${o===E.id?"opacity-50":""}`,children:[c.jsx(c0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:c.jsx(S,{className:"w-4 h-4"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-white font-medium truncate",children:E.name}),c.jsx(ro,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),c.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:E.url})]}),c.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[c.jsx("button",{onClick:()=>i(E),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:c.jsx(Zu,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>v(E),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:c.jsx(kn,{className:"w-4 h-4"})})]})]},E.id)})}):c.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[c.jsx(c3,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),c.jsx("p",{children:"No external links configured"}),c.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&c.jsx(z9e,{link:r,onClose:()=>{n(!1),i(null)}}),s&&c.jsx(Kr,{title:"Delete Link",message:`Are you sure you want to delete "${s.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:b,onCancel:()=>a(null)})]})}function H9e(){const t=Sn(),{t:e,i18n:n}=uS(),{showToast:r}=ri(),[i,s]=M.useState(null),[a,o]=M.useState(!1),[l,u]=M.useState(null),[d,f]=M.useState(!1),[g,m]=M.useState(null),[x,y]=M.useState(null),[v,b]=M.useState(!1),[E,S]=M.useState(GG()),[A,T]=M.useState("general"),[P,C]=M.useState(!1),[I,N]=M.useState(""),[D,F]=M.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[L,q]=M.useState(null),[R,V]=M.useState(null),[K,W]=M.useState(!1),[ne,Y]=M.useState(!1),[Z,U]=M.useState(null),[$,ee]=M.useState(!1),[ae,fe]=M.useState(!1),ue=Q=>{S(Q),uue(Q)},xe=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Me,isLoading:se}=yt({queryKey:["settings"],queryFn:Pe.getSettings}),{data:ve,isLoading:je}=yt({queryKey:["smart-plugs"],queryFn:Pe.getSmartPlugs}),{data:de,isLoading:ut}=yt({queryKey:["smart-plugs-energy",ve?.map(Q=>Q.id)],queryFn:async()=>{if(!ve||ve.length===0)return null;const Q=await Promise.all(ve.filter(He=>He.enabled).map(async He=>{try{const ht=await Pe.getSmartPlugStatus(He.id);return{plug:He,status:ht}}catch{return{plug:He,status:null}}}));let Fe=0,pe=0,Ue=0,Ce=0,ye=0;for(const{status:He}of Q)He?.reachable&&He.energy&&(ye++,He.energy.power!=null&&(Fe+=He.energy.power),He.energy.today!=null&&(pe+=He.energy.today),He.energy.yesterday!=null&&(Ue+=He.energy.yesterday),He.energy.total!=null&&(Ce+=He.energy.total));return{totalPower:Fe,totalToday:pe,totalYesterday:Ue,totalLifetime:Ce,reachableCount:ye,totalPlugs:ve.filter(He=>He.enabled).length}},enabled:A==="plugs"&&!!ve&&ve.length>0,refetchInterval:A==="plugs"?1e4:!1}),{data:H,isLoading:z}=yt({queryKey:["notification-providers"],queryFn:Pe.getNotificationProviders}),{data:re,isLoading:G}=yt({queryKey:["api-keys"],queryFn:Pe.getAPIKeys,enabled:A==="apikeys"}),J=_t({mutationFn:Q=>Pe.createAPIKey(Q),onSuccess:Q=>{q(Q.key||null),C(!1),N(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:Q=>{r(`Failed to create API key: ${Q.message}`,"error")}}),le=_t({mutationFn:Q=>Pe.deleteAPIKey(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:Q=>{r(`Failed to delete API key: ${Q.message}`,"error")}}),{data:ke}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:Ne,isLoading:we}=yt({queryKey:["notification-templates"],queryFn:Pe.getNotificationTemplates}),{data:B}=yt({queryKey:["ffmpeg-status"],queryFn:Pe.checkFfmpeg}),{data:j}=yt({queryKey:["version"],queryFn:Pe.getVersion}),{data:te,refetch:be,isRefetching:_e}=yt({queryKey:["updateCheck"],queryFn:Pe.checkForUpdates,staleTime:300*1e3}),{data:ge,refetch:me}=yt({queryKey:["updateStatus"],queryFn:Pe.getUpdateStatus,refetchInterval:Q=>{const Fe=Q.state.data;return Fe?.status==="downloading"||Fe?.status==="installing"?1e3:!1}}),Ae=_t({mutationFn:Pe.applyUpdate,onSuccess:()=>{me()}}),[ze,st]=M.useState(null),Ve=_t({mutationFn:Pe.testAllNotificationProviders,onSuccess:Q=>{st(Q),t.invalidateQueries({queryKey:["notification-providers"]}),Q.failed===0?r(`All ${Q.tested} providers tested successfully!`,"success"):r(`${Q.success}/${Q.tested} providers succeeded`,Q.failed>0?"error":"success")},onError:Q=>{r(`Failed to test providers: ${Q.message}`,"error")}}),ce=_t({mutationFn:async Q=>{if(!ve)return{success:0,failed:0};const Fe=ve.filter(Ue=>Ue.enabled),pe=await Promise.all(Fe.map(async Ue=>{try{return await Pe.controlSmartPlug(Ue.id,Q),{success:!0}}catch{return{success:!1}}}));return{success:pe.filter(Ue=>Ue.success).length,failed:pe.filter(Ue=>!Ue.success).length}},onSuccess:(Q,Fe)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),Q.failed===0?r(`All ${Q.success} plugs turned ${Fe}`,"success"):r(`${Q.success} plugs turned ${Fe}, ${Q.failed} failed`,"error")},onError:Q=>{r(`Failed: ${Q.message}`,"error")}}),Ye=M.useRef(null),$e=M.useRef(!0);M.useEffect(()=>{Me&&!i&&(s(Me),setTimeout(()=>{$e.current=!1},100))},[Me,i]);const Ze=_t({mutationFn:Pe.updateSettings,onSuccess:Q=>{t.setQueryData(["settings"],Q),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:Q=>{r(`Failed to save: ${Q.message}`,"error")}});M.useEffect(()=>{if(!($e.current||!i||!Me||!(Me.auto_archive!==i.auto_archive||Me.save_thumbnails!==i.save_thumbnails||Me.capture_finish_photo!==i.capture_finish_photo||Me.default_filament_cost!==i.default_filament_cost||Me.currency!==i.currency||Me.energy_cost_per_kwh!==i.energy_cost_per_kwh||Me.energy_tracking_mode!==i.energy_tracking_mode||Me.check_updates!==i.check_updates||Me.notification_language!==i.notification_language||Me.ams_humidity_good!==i.ams_humidity_good||Me.ams_humidity_fair!==i.ams_humidity_fair||Me.ams_temp_good!==i.ams_temp_good||Me.ams_temp_fair!==i.ams_temp_fair||Me.date_format!==i.date_format||Me.time_format!==i.time_format||Me.default_printer_id!==i.default_printer_id)))return Ye.current&&clearTimeout(Ye.current),Ye.current=setTimeout(()=>{Ze.mutate(i)},500),()=>{Ye.current&&clearTimeout(Ye.current)}},[i,Me,Ze]);const at=M.useCallback((Q,Fe)=>{s(pe=>pe?{...pe,[Q]:Fe}:null)},[]);return se||!i?c.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c.jsxs("div",{className:"p-4 md:p-8",children:[c.jsxs("div",{className:"mb-8",children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),c.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),c.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[c.jsx("button",{onClick:()=>T("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${A==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),c.jsxs("button",{onClick:()=>T("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(Ox,{className:"w-4 h-4"}),"Smart Plugs",ve&&ve.length>0&&c.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ve.length})]}),c.jsxs("button",{onClick:()=>T("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(fh,{className:"w-4 h-4"}),"Notifications",H&&H.length>0&&c.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:H.length})]}),c.jsxs("button",{onClick:()=>T("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(Op,{className:"w-4 h-4"}),"API Keys",re&&re.length>0&&c.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:re.length})]})]}),A==="general"&&c.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[c.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[c.jsxs(Nt,{children:[c.jsx(za,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[c.jsx(l0,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),c.jsx("select",{value:n.language,onChange:Q=>n.changeLanguage(Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:r5.map(Q=>c.jsxs("option",{value:Q.code,children:[Q.nativeName," (",Q.name,")"]},Q.code))}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),c.jsx("select",{value:E,onChange:Q=>ue(Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:p0.map(Q=>c.jsx("option",{value:Q.to,children:e(Q.labelKey)},Q.id))}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),c.jsxs("select",{value:i.date_format||"system",onChange:Q=>at("date_format",Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"system",children:"System Default"}),c.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),c.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),c.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),c.jsxs("select",{value:i.time_format||"system",onChange:Q=>at("time_format",Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"system",children:"System Default"}),c.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),c.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),c.jsxs("select",{value:i.default_printer_id??"",onChange:Q=>at("default_printer_id",Q.target.value?Number(Q.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"",children:"No default (ask each time)"}),ke?.map(Q=>c.jsx("option",{value:Q.id,children:Q.name},Q.id))]}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Sidebar order"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:xe,children:[c.jsx(Im,{className:"w-4 h-4"}),"Reset"]})]})]})]}),c.jsxs(Nt,{children:[c.jsx(za,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Auto-archive prints"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:i.auto_archive,onChange:Q=>at("auto_archive",Q.target.checked),className:"sr-only peer"}),c.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Save thumbnails"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:i.save_thumbnails,onChange:Q=>at("save_thumbnails",Q.target.checked),className:"sr-only peer"}),c.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Capture finish photo"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:i.capture_finish_photo,onChange:Q=>at("capture_finish_photo",Q.target.checked),className:"sr-only peer"}),c.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.capture_finish_photo&&B&&!B.installed&&c.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[c.jsx(Qr,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),c.jsxs("div",{className:"text-sm",children:[c.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),c.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",c.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",c.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),c.jsxs(Nt,{children:[c.jsx(za,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),c.jsx("input",{type:"number",step:"0.01",min:"0",value:i.default_filament_cost,onChange:Q=>at("default_filament_cost",parseFloat(Q.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),c.jsxs("select",{value:i.currency,onChange:Q=>at("currency",Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"USD",children:"USD ($)"}),c.jsx("option",{value:"EUR",children:"EUR (€)"}),c.jsx("option",{value:"GBP",children:"GBP (£)"}),c.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),c.jsx("option",{value:"JPY",children:"JPY (¥)"}),c.jsx("option",{value:"CNY",children:"CNY (¥)"}),c.jsx("option",{value:"CAD",children:"CAD ($)"}),c.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),c.jsx("input",{type:"number",step:"0.01",min:"0",value:i.energy_cost_per_kwh,onChange:Q=>at("energy_cost_per_kwh",parseFloat(Q.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),c.jsxs("select",{value:i.energy_tracking_mode||"total",onChange:Q=>at("energy_tracking_mode",Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"print",children:"Prints Only"}),c.jsx("option",{value:"total",children:"Total Consumption"})]}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]})]}),c.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[c.jsxs(Nt,{children:[c.jsx(za,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-white",children:[c.jsx(loe,{className:"w-4 h-4 text-blue-400"}),c.jsx("span",{className:"font-medium",children:"Humidity"})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_good??40,onChange:Q=>at("ams_humidity_good",parseInt(Q.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),c.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_fair??60,onChange:Q=>at("ams_humidity_fair",parseInt(Q.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),c.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),c.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2 text-white",children:[c.jsx($p,{className:"w-4 h-4 text-orange-400"}),c.jsx("span",{className:"font-medium",children:"Temperature"})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_good??28,onChange:Q=>at("ams_temp_good",parseFloat(Q.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),c.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_fair??35,onChange:Q=>at("ams_temp_fair",parseFloat(Q.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),c.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]})]})]}),c.jsx(F9e,{}),c.jsx(B9e,{})]}),c.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[c.jsxs(Nt,{children:[c.jsx(za,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Check for updates"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:i.check_updates,onChange:Q=>at("check_updates",Q.target.checked),className:"sr-only peer"}),c.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),c.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Current version"}),c.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",j?.version||"..."]})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>be(),disabled:_e,children:[_e?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(qs,{className:"w-4 h-4"}),"Check now"]})]}),te?.update_available?c.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[c.jsxs("div",{className:"flex items-start justify-between",children:[c.jsxs("div",{children:[c.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",te.latest_version]}),te.release_name&&te.release_name!==te.latest_version&&c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:te.release_name}),te.release_notes&&c.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:te.release_notes})]}),te.release_url&&c.jsx("a",{href:te.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:c.jsx(ro,{className:"w-4 h-4"})})]}),ge?.status==="downloading"||ge?.status==="installing"?c.jsxs("div",{className:"mt-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[c.jsx(At,{className:"w-4 h-4 animate-spin"}),c.jsx("span",{children:ge.message})]}),c.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:c.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${ge.progress}%`}})})]}):ge?.status==="complete"?c.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:ge.message}):ge?.status==="error"?c.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:ge.error||ge.message}):c.jsxs(Ie,{className:"mt-3",onClick:()=>Ae.mutate(),disabled:Ae.isPending,children:[Ae.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(ya,{className:"w-4 h-4"}),"Install Update"]})]}):te?.error?c.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",te.error]}):te&&!te.update_available?c.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),c.jsxs(Nt,{children:[c.jsx(za,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Backup Data"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>ee(!0),children:[c.jsx(ya,{className:"w-4 h-4"}),"Export"]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Restore Backup"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>fe(!0),children:[c.jsx(ma,{className:"w-4 h-4"}),"Restore"]})]}),c.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>W(!0),children:[c.jsx(kn,{className:"w-4 h-4"}),"Clear"]})]})}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[c.jsx(kn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),A==="plugs"&&c.jsxs("div",{className:"max-w-4xl",children:[c.jsxs("div",{className:"flex items-start justify-between mb-6",children:[c.jsxs("div",{children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(Ox,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect Tasmota-based smart plugs to automate power control and track energy usage for your printers."})]}),c.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[ve&&ve.filter(Q=>Q.enabled).length>1&&c.jsxs(c.Fragment,{children:[c.jsxs(Ie,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>U("on"),disabled:ce.isPending,title:"Turn all plugs on",children:[ce.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(fd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),c.jsxs(Ie,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>U("off"),disabled:ce.isPending,title:"Turn all plugs off",children:[ce.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(yR,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),c.jsxs(Ie,{className:"whitespace-nowrap",onClick:()=>{u(null),o(!0)},children:[c.jsx(fr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ve&&ve.length>0&&c.jsxs(Nt,{className:"mb-6",children:[c.jsx(za,{children:c.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[c.jsx(am,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",ut&&c.jsx(At,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),c.jsx(Dt,{children:de?c.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[c.jsx(am,{className:"w-3 h-3"}),"Current Power"]}),c.jsxs("div",{className:"text-xl font-bold text-white",children:[de.totalPower.toFixed(1),c.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),c.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[de.reachableCount,"/",de.totalPlugs," plugs online"]})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[c.jsx(qr,{className:"w-3 h-3"}),"Today"]}),c.jsxs("div",{className:"text-xl font-bold text-white",children:[de.totalToday.toFixed(2),c.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&c.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(de.totalToday*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[c.jsx(Ice,{className:"w-3 h-3"}),"Yesterday"]}),c.jsxs("div",{className:"text-xl font-bold text-white",children:[de.totalYesterday.toFixed(2),c.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&c.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(de.totalYesterday*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[c.jsx(a3,{className:"w-3 h-3"}),"Total"]}),c.jsxs("div",{className:"text-xl font-bold text-white",children:[de.totalLifetime.toFixed(1),c.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&c.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(de.totalLifetime*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]})]}):ut?null:c.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),je?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ve&&ve.length>0?c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ve.map(Q=>c.jsx(M9e,{plug:Q,onEdit:Fe=>{u(Fe),o(!0)}},Q.id))}):c.jsx(Nt,{children:c.jsx(Dt,{className:"py-12",children:c.jsxs("div",{className:"text-center text-bambu-gray",children:[c.jsx(Ox,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),c.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),c.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),c.jsxs(Ie,{onClick:()=>{u(null),o(!0)},children:[c.jsx(fr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),A==="notifications"&&c.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(fh,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>b(!0),children:[c.jsx(o3,{className:"w-4 h-4"}),"Log"]}),H&&H.length>0&&c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>{st(null),Ve.mutate()},disabled:Ve.isPending,children:[Ve.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(_R,{className:"w-4 h-4"}),"Test All"]}),c.jsxs(Ie,{size:"sm",onClick:()=>{m(null),f(!0)},children:[c.jsx(fr,{className:"w-4 h-4"}),"Add"]})]})]}),c.jsx(Nt,{className:"mb-4",children:c.jsx(Dt,{className:"py-3",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),c.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),c.jsx("select",{value:i.notification_language||"en",onChange:Q=>at("notification_language",Q.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:r5.map(Q=>c.jsx("option",{value:Q.code,children:Q.nativeName},Q.code))})]})})}),ze&&c.jsx(Nt,{className:"mb-4",children:c.jsxs(Dt,{className:"py-3",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),c.jsx("button",{onClick:()=>st(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),c.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[c.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[c.jsx(ds,{className:"w-4 h-4"}),ze.success," passed"]}),ze.failed>0&&c.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[c.jsx(hd,{className:"w-4 h-4"}),ze.failed," failed"]})]}),ze.results.filter(Q=>!Q.success).length>0&&c.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:ze.results.filter(Q=>!Q.success).map(Q=>c.jsxs("div",{className:"text-xs text-red-400",children:[c.jsxs("span",{className:"font-medium",children:[Q.provider_name,":"]})," ",Q.message]},Q.provider_id))})]})}),z?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):H&&H.length>0?c.jsx("div",{className:"space-y-3",children:H.map(Q=>c.jsx(C9e,{provider:Q,onEdit:Fe=>{m(Fe),f(!0)}},Q.id))}):c.jsx(Nt,{children:c.jsx(Dt,{className:"py-8",children:c.jsxs("div",{className:"text-center text-bambu-gray",children:[c.jsx(fh,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),c.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),c.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),c.jsxs(Ie,{size:"sm",onClick:()=>{m(null),f(!0)},children:[c.jsx(fr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),c.jsxs("div",{children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[c.jsx(Ya,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),c.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),we?c.jsx("div",{className:"flex justify-center py-8",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Ne&&Ne.length>0?c.jsx("div",{className:"space-y-2",children:Ne.map(Q=>c.jsx(Nt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>y(Q),children:c.jsx(Dt,{className:"py-2.5 px-3",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"text-white font-medium text-sm truncate",children:Q.name}),c.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:Q.title_template})]}),c.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:Fe=>{Fe.stopPropagation(),y(Q)},children:c.jsx(vR,{className:"w-4 h-4 text-bambu-gray"})})]})})},Q.id))}):c.jsx(Nt,{children:c.jsx(Dt,{className:"py-8",children:c.jsxs("div",{className:"text-center text-bambu-gray",children:[c.jsx(Ya,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),c.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),A==="apikeys"&&c.jsxs("div",{className:"max-w-3xl",children:[c.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[c.jsxs("div",{className:"flex-1",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(Op,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks. Use these keys to control your printers from automation tools like Home Assistant."})]}),c.jsxs(Ie,{size:"sm",onClick:()=>C(!0),className:"flex-shrink-0",children:[c.jsx(fr,{className:"w-4 h-4"}),"Create Key"]})]}),L&&c.jsx(Nt,{className:"mb-6 border-bambu-green",children:c.jsx(Dt,{className:"py-4",children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx(ds,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),c.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),c.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[c.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:L}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(L);else{const Q=document.createElement("textarea");Q.value=L,Q.style.position="fixed",Q.style.left="-999999px",document.body.appendChild(Q),Q.select(),document.execCommand("copy"),document.body.removeChild(Q)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:c.jsx(Dh,{className:"w-4 h-4"})})]}),c.jsx(Ie,{variant:"secondary",size:"sm",className:"mt-3",onClick:()=>q(null),children:"Dismiss"})]})]})})}),P&&c.jsxs(Nt,{className:"mb-6",children:[c.jsx(za,{children:c.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),c.jsx("input",{type:"text",value:I,onChange:Q=>N(Q.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:D.can_read_status,onChange:Q=>F(Fe=>({...Fe,can_read_status:Q.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),c.jsxs("div",{children:[c.jsx("span",{className:"text-white",children:"Read Status"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:D.can_queue,onChange:Q=>F(Fe=>({...Fe,can_queue:Q.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),c.jsxs("div",{children:[c.jsx("span",{className:"text-white",children:"Manage Queue"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:D.can_control_printer,onChange:Q=>F(Fe=>({...Fe,can_control_printer:Q.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),c.jsxs("div",{children:[c.jsx("span",{className:"text-white",children:"Control Printer"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),c.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[c.jsxs(Ie,{onClick:()=>J.mutate({name:I||"Unnamed Key",...D}),disabled:J.isPending,children:[J.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(fr,{className:"w-4 h-4"}),"Create Key"]}),c.jsx(Ie,{variant:"secondary",onClick:()=>C(!1),children:"Cancel"})]})]})]}),G?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):re&&re.length>0?c.jsx("div",{className:"space-y-3",children:re.map(Q=>c.jsx(Nt,{children:c.jsx(Dt,{className:"py-3",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Op,{className:`w-5 h-5 ${Q.enabled?"text-bambu-green":"text-bambu-gray"}`}),c.jsxs("div",{children:[c.jsx("p",{className:"text-white font-medium",children:Q.name}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[Q.key_prefix,"••••••••",Q.last_used&&` · Last used: ${new Date(Q.last_used).toLocaleDateString()}`]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"flex gap-1 text-xs",children:[Q.can_read_status&&c.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),Q.can_queue&&c.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),Q.can_control_printer&&c.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>V(Q.id),children:c.jsx(kn,{className:"w-4 h-4 text-red-400"})})]})]})})},Q.id))}):c.jsx(Nt,{children:c.jsx(Dt,{className:"py-12",children:c.jsxs("div",{className:"text-center text-bambu-gray",children:[c.jsx(Op,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),c.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),c.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),c.jsxs(Ie,{onClick:()=>C(!0),children:[c.jsx(fr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),c.jsxs(Nt,{className:"mt-6",children:[c.jsx(za,{children:c.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),c.jsxs(Dt,{className:"space-y-3 text-sm",children:[c.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",c.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),c.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-blue-400",children:"GET"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),c.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-blue-400",children:"GET"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),c.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-green-400",children:"POST"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),c.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-orange-400",children:"POST"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),c.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-orange-400",children:"POST"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),c.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-red-400",children:"POST"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),c.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),R!==null&&c.jsx(Kr,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{le.mutate(R),V(null)},onCancel:()=>V(null)}),a&&c.jsx(A9e,{plug:l,onClose:()=>{o(!1),u(null)}}),d&&c.jsx(N9e,{provider:g,onClose:()=>{f(!1),m(null)}}),x&&c.jsx(k9e,{template:x,onClose:()=>y(null)}),v&&c.jsx(D9e,{onClose:()=>b(!1)}),K&&c.jsx(Kr,{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()=>{W(!1);try{const Q=await Pe.clearNotificationLogs(30);r(Q.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>W(!1)}),ne&&c.jsx(Kr,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{Y(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>Y(!1)}),Z&&c.jsx(Kr,{title:`Turn All Plugs ${Z==="on"?"On":"Off"}`,message:`This will turn ${Z==="on"?"ON":"OFF"} all ${ve?.filter(Q=>Q.enabled).length||0} enabled smart plugs. ${Z==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${Z==="on"?"On":"Off"}`,variant:Z==="off"?"danger":"warning",onConfirm:()=>{const Q=Z;U(null),ce.mutate(Q)},onCancel:()=>U(null)}),$&&c.jsx(j9e,{onClose:()=>ee(!1),onExport:async Q=>{ee(!1);try{const{blob:Fe,filename:pe}=await Pe.exportBackup(Q),Ue=URL.createObjectURL(Fe),Ce=document.createElement("a");Ce.href=Ue,Ce.download=pe,Ce.click(),URL.revokeObjectURL(Ue),r("Backup downloaded","success")}catch{r("Failed to create backup","error")}}}),ae&&c.jsx(L9e,{onClose:()=>fe(!1),onRestore:async(Q,Fe)=>await Pe.importBackup(Q,Fe),onSuccess:()=>{t.invalidateQueries()}})]})}const Pee=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},$9e=t=>t.startsWith("HH")?"HF":"S",V9e=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},tR=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 BN({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:a}){const o=$9e(t.nozzle_id),l=t.nozzle_diameter,u=()=>{r&&s?s():e()};return c.jsxs("div",{className:"flex items-center gap-2",children:[r&&c.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?c.jsx(jh,{className:"w-4 h-4 text-bambu-green"}):c.jsx(im,{className:"w-4 h-4"})}),c.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:Pee(t.k_value)}),c.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),a&&c.jsx("span",{title:"Has note",children:c.jsx(LG,{className:"w-3 h-3 text-yellow-500"})}),c.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",l]})]}),a&&c.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:a,children:["Note: ",a.length>50?a.substring(0,50)+"...":a]})]}),!r&&n&&c.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:c.jsx(Dh,{className:"w-4 h-4"})})]})}function HN({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:a=null,onClose:o,onSave:l,onSaveNote:u}){const{showToast:d}=ri(),[f,g]=M.useState(t?.name||""),[m,x]=M.useState(t?.k_value?Pee(t.k_value):"0.020"),[y,v]=M.useState(t?.filament_id||""),[b,E]=M.useState(t?.nozzle_id?V9e(t.nozzle_id):"HH00"),[S,A]=M.useState(t?.nozzle_diameter||n),[T,P]=M.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,I]=M.useState(!1),[N,D]=M.useState({current:0,total:0}),[F,L]=M.useState(s),q=pr.useMemo(()=>{const Z=new Map;for(const U of r)if(U.filament_id&&!Z.has(U.filament_id)){const $=tR(U.name||"");Z.set(U.filament_id,{id:U.filament_id,name:$||U.filament_id})}return Array.from(Z.values()).sort((U,$)=>U.name.localeCompare($.name))},[r]),R=_t({mutationFn:Z=>(console.log("[KProfile] Calling API..."),Pe.setKProfile(e,Z)),onSuccess:Z=>{if(console.log("[KProfile] Save success:",Z),d("K-profile saved"),u&&F!==s){let U;F===""&&a?U=a:t&&t.slot_id>0?U=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:U=`name_${f}_${y}`,u(U,F)}I(!0),setTimeout(()=>{I(!1),l()},2500)},onError:Z=>{console.error("[KProfile] Save error:",Z),d(Z.message,"error"),I(!1)}}),V=_t({mutationFn:Z=>(console.log("[KProfile] Deleting profile..."),Pe.deleteKProfile(e,Z)),onSuccess:Z=>{console.log("[KProfile] Delete success:",Z),d("K-profile deleted"),I(!0),setTimeout(()=>{I(!1),o()},4e3)},onError:Z=>{console.error("[KProfile] Delete error:",Z),d(Z.message,"error"),I(!1)}}),[K,W]=M.useState(!1),ne=()=>{t&&V.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},Y=async Z=>{if(Z.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const U=parseFloat(m).toFixed(6),$=`${b}-${S}`;if(t||T.length===1){const ae={name:f,k_value:U,filament_id:y,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:",ae),R.mutate(ae);return}I(!0),D({current:1,total:T.length});const ee=T.map(ae=>({name:f,k_value:U,filament_id:y,nozzle_id:$,nozzle_diameter:S,extruder_id:ae,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ee.length} profiles in batch:`,ee);try{if(await Pe.setKProfilesBatch(e,ee),d(`K-profile saved to ${T.length} extruders`),u&&F){const ae=`name_${f}_${y}`;u(ae,F)}}catch(ae){console.error("[KProfile] Failed to save batch:",ae),d("Failed to save K-profiles","error"),I(!1),D({current:0,total:0});return}D({current:T.length,total:T.length}),setTimeout(()=>{I(!1),D({current:0,total:0}),l()},3e3)};return c.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[c.jsxs(Nt,{className:"w-full max-w-md relative",children:[C&&c.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),c.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),c.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),c.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:C,children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:Y,className:"p-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),c.jsx("input",{type:"text",value:f,onChange:Z=>g(Z.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),c.jsx("input",{type:"text",inputMode:"decimal",value:m,onChange:Z=>{const U=Z.target.value;(U===""||/^\d*\.?\d*$/.test(U))&&x(U)},onBlur:Z=>{const U=parseFloat(Z.target.value);isNaN(U)||x((Math.trunc(U*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),c.jsxs("select",{value:y,onChange:Z=>{const U=Z.target.value;if(v(U),!t&&U&&!f){const $=q.find(ee=>ee.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:[c.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&c.jsx("option",{value:t.filament_id,children:q.find(Z=>Z.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(Z=>c.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),!t&&q.length===0&&c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),c.jsxs("select",{value:b,onChange:Z=>{const U=Z.target.value;if(E(U),!t&&y&&!f){const $=q.find(ee=>ee.id===y);$&&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:[c.jsx("option",{value:"HH00",children:"High Flow"}),c.jsx("option",{value:"HS00",children:"Standard"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),c.jsxs("select",{value:S,onChange:Z=>A(Z.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[c.jsx("option",{value:"0.2",children:"0.2mm"}),c.jsx("option",{value:"0.4",children:"0.4mm"}),c.jsx("option",{value:"0.6",children:"0.6mm"}),c.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?c.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):c.jsxs("div",{className:"flex gap-4",children:[c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:Z=>{Z.target.checked?P([...T,1]):P(T.filter(U=>U!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),c.jsx("span",{className:"text-white",children:"Left"})]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:Z=>{Z.target.checked?P([...T,0]):P(T.filter(U=>U!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),c.jsx("span",{className:"text-white",children:"Right"})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),c.jsx("textarea",{value:F,onChange:Z=>L(Z.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),c.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&c.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>W(!0),disabled:V.isPending||C,className:"text-red-500 hover:bg-red-500/10",children:V.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"})}),c.jsx(Ie,{type:"button",variant:"secondary",onClick:o,disabled:C,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{type:"submit",disabled:R.isPending||C,className:"flex-1",children:[R.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(xR,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:c.jsx(Nt,{className:"w-full max-w-sm",children:c.jsxs(Dt,{className:"p-6",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:c.jsx(kn,{className:"w-5 h-5 text-red-500"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),c.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",c.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx(Ie,{variant:"secondary",onClick:()=>W(!1),className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{onClick:()=>{W(!1),ne()},disabled:V.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[V.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const R_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function G9e(){const{showToast:t}=ri(),[e,n]=M.useState(null),[r,i]=M.useState(()=>localStorage.getItem(R_.NOZZLE_DIAMETER)||"0.4"),[s,a]=M.useState(null),[o,l]=M.useState(!1),[u,d]=M.useState(null),[f,g]=M.useState(""),[m,x]=M.useState("all"),[y,v]=M.useState("all"),[b,E]=M.useState(()=>localStorage.getItem(R_.SORT_OPTION)||"name"),[S,A]=M.useState(!1),[T,P]=M.useState(new Set),[C,I]=M.useState(!1),[N,D]=M.useState(!1),F=G=>`${G.slot_id}_${G.extruder_id}`;M.useEffect(()=>{localStorage.setItem(R_.NOZZLE_DIAMETER,r)},[r]),M.useEffect(()=>{localStorage.setItem(R_.SORT_OPTION,b)},[b]);const{data:L,isLoading:q}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:R,isLoading:V,isFetching:K,error:W,refetch:ne}=yt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const G=await Pe.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",G?.profiles?.length||0,"profiles"),G},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Y}=yt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>Pe.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:Z,refetch:U}=yt({queryKey:["kprofile-notes",e],queryFn:()=>Pe.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),$=W?.message?.includes("not connected");M.useEffect(()=>{if(!e&&L&&L.length>0){const G=L.find(J=>J.is_active);G&&n(G.id)}},[e,L]),M.useEffect(()=>{if(e){const G=setTimeout(()=>{ne()},150);return()=>clearTimeout(G)}},[e,r]);const ee=L?.filter(G=>G.is_active)||[],ae=pr.useMemo(()=>R?.profiles?R.profiles.filter(J=>{const le=f.toLowerCase(),ke=!le||J.name.toLowerCase().includes(le)||J.filament_id.toLowerCase().includes(le),Ne=m==="all"||m==="left"&&J.extruder_id===1||m==="right"&&J.extruder_id===0,we=y==="all"||y==="hf"&&J.nozzle_id.startsWith("HH")||y==="s"&&J.nozzle_id.startsWith("HS");return ke&&Ne&&we}).sort((J,le)=>{switch(b){case"k_value":return parseFloat(J.k_value)-parseFloat(le.k_value);case"filament":return tR(J.name).localeCompare(tR(le.name));case"name":default:return J.name.localeCompare(le.name)}}):[],[R?.profiles,f,m,y,b]),fe=L?.find(G=>G.id===e),ue=fe?.nozzle_count===2;M.useEffect(()=>{const G=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||s||o||u||(J.key==="r"||J.key==="R"?(J.preventDefault(),ne()):J.key==="n"||J.key==="N"?(J.preventDefault(),l(!0)):J.key==="Escape"&&S&&(J.preventDefault(),A(!1),P(new Set)))};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[s,o,u,S,ne]);const xe=M.useCallback(()=>{if(!R?.profiles||R.profiles.length===0){t("No profiles to export","error");return}const G={version:1,exported_at:new Date().toISOString(),printer:fe?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(Ne=>({name:Ne.name,k_value:Ne.k_value,filament_id:Ne.filament_id,nozzle_id:Ne.nozzle_id,nozzle_diameter:Ne.nozzle_diameter,extruder_id:Ne.extruder_id}))},J=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),le=URL.createObjectURL(J),ke=document.createElement("a");ke.href=le,ke.download=`kprofiles_${fe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(ke),ke.click(),document.body.removeChild(ke),URL.revokeObjectURL(le),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,fe,r,t]),Me=M.useCallback(()=>{const G=document.createElement("input");G.type="file",G.accept=".json",G.onchange=async J=>{const le=J.target.files?.[0];if(le)try{const ke=await le.text(),Ne=JSON.parse(ke);if(!Ne.profiles||!Array.isArray(Ne.profiles)){t("Invalid file format","error");return}let we=0;for(const B of Ne.profiles)if(!(!B.name||!B.k_value||!B.filament_id))try{await Pe.setKProfile(e,{name:B.name,k_value:parseFloat(B.k_value).toFixed(6),filament_id:B.filament_id,nozzle_id:B.nozzle_id||`HH00-${r}`,nozzle_diameter:B.nozzle_diameter||r,extruder_id:B.extruder_id??0,slot_id:0}),we++,await new Promise(j=>setTimeout(j,500))}catch(j){console.error("Failed to import profile:",B.name,j)}t(`Imported ${we} of ${Ne.profiles.length} profiles`),ne()}catch(ke){console.error("Import error:",ke),t("Failed to parse import file","error")}},G.click()},[e,r,t,ne]),se=M.useCallback(G=>{P(J=>{const le=new Set(J);return le.has(G)?le.delete(G):le.add(G),le})},[]),ve=M.useCallback(()=>{P(new Set(ae.map(G=>F(G))))},[ae,F]),je=M.useCallback(()=>{T.size!==0&&I(!0)},[T.size]),de=M.useCallback(async()=>{const G=ae.filter(le=>T.has(F(le)));D(!0);let J=0;for(const le of G)try{await Pe.deleteKProfile(e,{slot_id:le.slot_id,extruder_id:le.extruder_id,nozzle_id:le.nozzle_id,nozzle_diameter:le.nozzle_diameter,filament_id:le.filament_id,setting_id:le.setting_id}),J++,await new Promise(ke=>setTimeout(ke,300))}catch(ke){console.error("Failed to delete profile:",le.name,ke)}t(`Deleted ${J} profiles`),D(!1),I(!1),A(!1),P(new Set),ne()},[e,T,ae,t,ne,F]),ut=M.useCallback(G=>{const J=[];return G.setting_id&&J.push(G.setting_id),J.push(`slot_${G.slot_id}_${G.filament_id}_${G.extruder_id}`),J.push(`name_${G.name}_${G.filament_id}`),J},[]),H=M.useCallback(async(G,J)=>{if(e)try{await Pe.setKProfileNote(e,G,J),U()}catch(le){console.error("Failed to save note:",le),t("Failed to save note","error")}},[e,U,t]),z=M.useCallback(G=>{if(!Z?.notes)return{note:"",key:null};const J=ut(G);for(const le of J)if(Z.notes[le])return{note:Z.notes[le],key:le};return{note:"",key:null}},[Z,ut]),re=M.useCallback(G=>z(G).note,[z]);return q?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!L||L.length===0?c.jsx(Nt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(Oo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),c.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ee.length===0?c.jsx(Nt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(jo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),c.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):c.jsxs(c.Fragment,{children:[K&&!V&&c.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[c.jsx(At,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),c.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),c.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[c.jsxs("div",{className:"flex-1 min-w-48",children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),c.jsx("select",{value:e||"",onChange:G=>n(parseInt(G.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:ee.map(G=>c.jsx("option",{value:G.id,children:G.name},G.id))})]}),c.jsxs("div",{className:"w-32",children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),c.jsxs("select",{value:r,onChange:G=>i(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"0.2",children:"0.2mm"}),c.jsx("option",{value:"0.4",children:"0.4mm"}),c.jsx("option",{value:"0.6",children:"0.6mm"}),c.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsxs(Ie,{variant:"secondary",onClick:()=>ne(),disabled:K,children:[c.jsx(qs,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),c.jsxs(Ie,{onClick:()=>l(!0),children:[c.jsx(fr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),c.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[c.jsxs("div",{className:"flex-1 min-w-48 relative",children:[c.jsx(Qu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:f,onChange:G=>g(G.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),ue&&c.jsx("div",{className:"w-36",children:c.jsxs("select",{value:m,onChange:G=>x(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"all",children:"All Extruders"}),c.jsx("option",{value:"left",children:"Left Only"}),c.jsx("option",{value:"right",children:"Right Only"})]})}),c.jsx("div",{className:"w-32",children:c.jsxs("select",{value:y,onChange:G=>v(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"all",children:"All Flow"}),c.jsx("option",{value:"hf",children:"HF Only"}),c.jsx("option",{value:"s",children:"S Only"})]})}),c.jsx("div",{className:"w-32",children:c.jsxs("select",{value:b,onChange:G=>E(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"name",children:"Sort: Name"}),c.jsx("option",{value:"k_value",children:"Sort: K-Value"}),c.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),c.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[c.jsxs(Ie,{variant:"secondary",onClick:xe,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[c.jsx(ya,{className:"w-4 h-4"}),"Export"]}),c.jsxs(Ie,{variant:"secondary",onClick:Me,title:"Import profiles from JSON",children:[c.jsx(ma,{className:"w-4 h-4"}),"Import"]}),c.jsx("div",{className:"flex-1"}),S?c.jsxs(c.Fragment,{children:[c.jsxs(Ie,{variant:"secondary",onClick:ve,title:"Select all visible profiles",children:[c.jsx(jh,{className:"w-4 h-4"}),"Select All"]}),c.jsxs(Ie,{variant:"secondary",onClick:je,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[c.jsx(kn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),c.jsxs(Ie,{variant:"secondary",onClick:()=>{A(!1),P(new Set)},children:[c.jsx(Gt,{className:"w-4 h-4"}),"Cancel"]})]}):c.jsxs(Ie,{variant:"secondary",onClick:()=>A(!0),disabled:!ae.length,title:"Enter selection mode for bulk delete",children:[c.jsx(jh,{className:"w-4 h-4"}),"Select"]})]}),V?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):$?c.jsx(Nt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(SR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),c.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),c.jsxs(Ie,{variant:"secondary",onClick:()=>ne(),children:[c.jsx(qs,{className:"w-4 h-4"}),"Retry"]})]})}):ae.length>0?ue?c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),c.jsx("div",{className:"space-y-1",children:ae.filter(G=>G.extruder_id===1).map(G=>c.jsx(BN,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:S,isSelected:T.has(F(G)),onToggleSelect:()=>se(F(G)),note:re(G)},F(G)))})]}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),c.jsx("div",{className:"space-y-1",children:ae.filter(G=>G.extruder_id===0).map(G=>c.jsx(BN,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:S,isSelected:T.has(F(G)),onToggleSelect:()=>se(F(G)),note:re(G)},F(G)))})]})]}):c.jsx("div",{className:"space-y-1",children:ae.map(G=>c.jsx(BN,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:S,isSelected:T.has(F(G)),onToggleSelect:()=>se(F(G)),note:re(G)},F(G)))}):f||m!=="all"||y!=="all"?c.jsx(Nt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(Qu,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),c.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):c.jsx(Nt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(xR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),c.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),c.jsxs(Ie,{onClick:()=>l(!0),children:[c.jsx(fr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),s&&e&&(()=>{const{note:G,key:J}=z(s);return c.jsx(HN,{profile:s,printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:ue,initialNote:G,initialNoteKey:J,onSaveNote:H,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),a(null),ne()},onSave:()=>{a(null),ne()}})})(),o&&e&&c.jsx(HN,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:ue,onSaveNote:H,onClose:()=>{l(!1),ne()},onSave:()=>{l(!1),ne()}}),u&&e&&c.jsx(HN,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:ue,onSaveNote:H,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),ne()},onSave:()=>{d(null),ne()}}),C&&c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsx(Nt,{className:"w-full max-w-sm",children:c.jsxs(Dt,{className:"p-6",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:c.jsx(kn,{className:"w-5 h-5 text-red-500"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),c.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",c.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx(Ie,{variant:"secondary",onClick:()=>I(!1),disabled:N,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{onClick:de,disabled:N,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[N?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function Gj(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),a=s?(s[1]||s[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),l=o?o[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:a,layerHeight:l,filamentType:d}}function J0(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function W9e(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),s=Math.floor(r/36e5),a=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:s<24?`${s}h ago`:a<7?`${a}d ago`:e.toLocaleDateString()}function q9e({onSuccess:t}){const{showToast:e}=ri(),[n,r]=M.useState("email"),[i,s]=M.useState(""),[a,o]=M.useState(""),[l,u]=M.useState(""),[d,f]=M.useState(""),[g,m]=M.useState("global"),x=_t({mutationFn:()=>Pe.cloudLogin(i,a,g),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):S.needs_verification?(e("Verification code sent to your email"),r("code")):e(S.message,"error")},onError:S=>e(S.message,"error")}),y=_t({mutationFn:()=>Pe.cloudVerify(i,l),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):e(S.message,"error")},onError:S=>e(S.message,"error")}),v=_t({mutationFn:()=>Pe.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:S=>e(S.message,"error")}),b=S=>{S.preventDefault(),n==="email"?x.mutate():n==="code"?y.mutate():n==="token"&&v.mutate()},E=x.isPending||y.isPending||v.isPending;return c.jsx(Nt,{className:"max-w-md mx-auto",children:c.jsxs(Dt,{children:[c.jsxs("div",{className:"text-center mb-6",children:[c.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:c.jsx(gS,{className:"w-6 h-6 text-bambu-green"})}),c.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),c.jsxs("form",{onSubmit:b,className:"space-y-4",children:[n==="email"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),c.jsx("input",{type:"email",value:i,onChange:S=>s(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),c.jsx("input",{type:"password",value:a,onChange:S=>o(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),c.jsxs("select",{value:g,onChange:S=>m(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"global",children:"Global"}),c.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),c.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),c.jsx("input",{type:"text",value:l,onChange:S=>u(S.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),c.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),c.jsx("textarea",{value:d,onChange:S=>f(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),c.jsxs("div",{className:"flex gap-2",children:[n==="code"&&c.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),c.jsxs(Ie,{type:"submit",disabled:E,className:"flex-1",children:[E?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(E5,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&c.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:c.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[c.jsx(Op,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&c.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:c.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[c.jsx(E5,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Ap({label:t,value:e,options:n,onChange:r}){const[i,s]=M.useState(!1),a=n.find(o=>o.value===e);return c.jsxs("div",{className:"relative",children:[c.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[c.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),c.jsx("span",{children:a?.label||"All"}),c.jsx(ef,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),c.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(o=>c.jsxs("button",{onClick:()=>{r(o.value),s(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===o.value?"text-bambu-green":"text-white"}`,children:[c.jsx("span",{children:o.label}),o.count!==void 0&&c.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function K9e(){const[t,e]=M.useState(!1);M.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?c.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:c.jsx(nm,{className:"w-5 h-5"})}):null}function $N({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:a}){const o=Gj(t.name),l=J0(t.setting_id);return c.jsxs("div",{className:"flex items-center gap-2 group",children:[c.jsx("button",{onClick:e,disabled:a,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":a?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!a?"cursor-pointer":""}`,children:c.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&c.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!i&&l&&c.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),c.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&c.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&c.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&c.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),c.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:c.jsx(Dh,{className:"w-4 h-4"})})]})}function nR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(s=>n+" "+s).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+nR(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([s,a])=>n+" "+JSON.stringify(s)+": "+nR(a,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function X9e({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:s}=ri(),a=Sn(),[o,l]=M.useState(!1),{data:u,isLoading:d}=yt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>Pe.getCloudSettingDetail(t.setting_id)}),f=_t({mutationFn:()=>Pe.deleteCloudSetting(t.setting_id),onSuccess:()=>{s("Preset deleted"),a.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>s(x.message,"error")}),g=J0(t.setting_id),m=Gj(t.name,u?.setting?.inherits);return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsx(Nt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:c.jsxs(Dt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[c.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&c.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[c.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),m.printer&&c.jsxs(c.Fragment,{children:[c.jsx("span",{children:"•"}),c.jsx("span",{children:m.printer})]})]})]}),c.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?c.jsx("div",{className:"flex items-center justify-center py-16",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?c.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:nR(u)}):c.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),o?c.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[c.jsx(Qr,{className:"w-5 h-5"}),c.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),c.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{variant:"secondary",onClick:()=>l(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]}):c.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),c.jsxs(Ie,{variant:"secondary",onClick:r,children:[c.jsx(Dh,{className:"w-4 h-4"}),"Duplicate"]}),g&&c.jsxs(c.Fragment,{children:[c.jsxs(Ie,{variant:"secondary",onClick:i,disabled:d||!u,children:[c.jsx(Zu,{className:"w-4 h-4"}),"Edit"]}),c.jsx(Ie,{variant:"danger",onClick:()=>l(!0),children:c.jsx(kn,{className:"w-4 h-4"})})]})]})})]})})})}function Ree(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Dee(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function Y9e({onClose:t,onApply:e}){const{showToast:n}=ri(),[r,i]=M.useState(Ree),[s,a]=M.useState("all"),[o,l]=M.useState(null),[u,d]=M.useState(""),[f,g]=M.useState(""),[m,x]=M.useState("{}"),[y,v]=M.useState(null),[b,E]=M.useState(null),S=s==="all"?r:r.filter(L=>L.type===s),A=L=>{i(L),Dee(L)},T=L=>{const q=r.filter(R=>R.id!==L);A(q),E(null),n("Template deleted")},P=L=>{l(L.id),d(L.name),g(L.description),x(JSON.stringify(L.settings,null,2)),v(null)},C=()=>{if(!(!o||!u.trim()))try{const L=JSON.parse(m),q=r.map(R=>R.id===o?{...R,name:u.trim(),description:f.trim(),settings:L}:R);A(q),l(null),n("Template updated")}catch(L){v(L.message)}},I=()=>{l(null),d(""),g(""),x("{}"),v(null)},N=L=>{const q=r.map(R=>R.id===L?{...R,showInModal:!R.showInModal}:R);A(q)},D={filament:{label:"Filament",icon:pR,color:"text-amber-400"},print:{label:"Process",icon:vS,color:"text-blue-400"},printer:{label:"Printer",icon:jo,color:"text-purple-400"}},F=b?r.find(L=>L.id===b):null;return M.useEffect(()=>{const L=q=>{q.key==="Escape"&&(b?E(null):o?I():t())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[b,o,t]),c.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:c.jsx(Nt,{className:"w-full max-w-md",children:c.jsxs(Dt,{className:"p-6",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[c.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:c.jsx(Qr,{className:"w-6 h-6 text-red-400"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),c.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',c.jsx("span",{className:"font-medium",children:F.name}),'"?']}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{onClick:()=>T(b),className:"flex-1 bg-red-500 hover:bg-red-600",children:[c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),c.jsx(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:c.jsxs(Dt,{className:"p-0 flex flex-col h-full",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(h0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),c.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(L=>c.jsx("button",{onClick:()=>a(L),className:`px-3 py-1 text-sm rounded-lg transition-colors ${s===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:L==="all"?"All":D[L].label},L))]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:S.length===0?c.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[c.jsx(h0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),c.jsx("p",{children:"No templates yet"}),c.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):c.jsx("div",{className:"space-y-2",children:S.map(L=>{const q=D[L.type],R=q.icon;return o===L.id?c.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[c.jsx("input",{type:"text",value:u,onChange:V=>d(V.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),c.jsx("input",{type:"text",value:f,onChange:V=>g(V.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{className:"mb-3",children:[c.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),c.jsx("textarea",{value:m,onChange:V=>{x(V.target.value),v(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&c.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ie,{size:"sm",onClick:C,disabled:!u.trim(),children:[c.jsx(To,{className:"w-4 h-4"}),"Save"]}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:I,children:"Cancel"})]})]},L.id):c.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[c.jsx(R,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-sm font-medium text-white",children:L.name}),c.jsx("p",{className:"text-xs text-bambu-gray truncate",children:L.description})]}),c.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(L.settings).length," fields"]}),c.jsx("button",{onClick:()=>N(L.id),className:`p-1 transition-colors ${L.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:L.showInModal?"Shown in modals":"Hidden in modals",children:L.showInModal?c.jsx(o0,{className:"w-4 h-4"}):c.jsx(mR,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>e(L),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),c.jsx("button",{onClick:()=>P(L),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:c.jsx(Zu,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>E(L.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:c.jsx(kn,{className:"w-4 h-4"})})]},L.id)})})})]})})]})}function Oee({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[s,a]=M.useState("changes"),[o,l]=M.useState(""),u=M.useMemo(()=>{const m=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const y of m){if(y==="inherits"||y==="version")continue;const v=e[y],b=n[y],E=y in e,S=y in n;let A;!E&&S?A="added":E&&!S?A="removed":JSON.stringify(v)!==JSON.stringify(b)?A="changed":A="same",x.push({key:y,left:v,right:b,status:A})}return x.sort((y,v)=>{const b={changed:0,added:1,removed:2,same:3};return b[y.status]!==b[v.status]?b[y.status]-b[v.status]:y.key.localeCompare(v.key)})},[e,n]),d=M.useMemo(()=>{let m=[...u];if(s==="changes"&&(m=m.filter(x=>x.status!=="same")),o){const x=o.toLowerCase();m=m.filter(y=>y.key.toLowerCase().includes(x)||String(y.left).toLowerCase().includes(x)||String(y.right).toLowerCase().includes(x))}return m},[u,s,o]),f=M.useMemo(()=>({added:u.filter(m=>m.status==="added").length,removed:u.filter(m=>m.status==="removed").length,changed:u.filter(m=>m.status==="changed").length,same:u.filter(m=>m.status==="same").length}),[u]),g=m=>{if(m===void 0)return"—";if(m===null)return"null";if(Array.isArray(m))return m.length===0?"[]":m.length===1?String(m[0]):m.join(", ");if(typeof m=="object")return JSON.stringify(m);const x=String(m);if(x.includes("\\n")||x.length>100){const y=x.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return M.useEffect(()=>{const m=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]),c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:c.jsx(Nt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:c.jsxs(Dt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[c.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(Hp,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),c.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[c.jsxs("div",{className:"text-center",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),c.jsx("p",{className:"text-white font-medium truncate",children:r})]}),c.jsxs("div",{className:"text-center",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),c.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),c.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[c.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[c.jsx(fr,{className:"w-3.5 h-3.5"}),f.added," added"]}),c.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[c.jsx(M5,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),c.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[c.jsx(i3,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),c.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[c.jsx(oA,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"relative",children:[c.jsx(Qu,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:o,onChange:m=>l(m.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&c.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[c.jsx("button",{onClick:()=>a("changes"),className:`px-3 py-1.5 text-sm transition-colors ${s==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),c.jsx("button",{onClick:()=>a("all"),className:`px-3 py-1.5 text-sm transition-colors ${s==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?c.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[c.jsx(oA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),c.jsx("p",{children:s==="changes"?"No differences found":"No fields match the search"})]}):c.jsxs("table",{className:"w-full",children:[c.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:c.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[c.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),c.jsx("th",{className:"text-left p-3 w-1/3",children:r}),c.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),c.jsx("tbody",{children:d.map(m=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[m.status],y={added:c.jsx(fr,{className:"w-3.5 h-3.5 text-green-400"}),removed:c.jsx(M5,{className:"w-3.5 h-3.5 text-red-400"}),changed:c.jsx(i3,{className:"w-3.5 h-3.5 text-amber-400"}),same:c.jsx(oA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[m.status];return c.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[c.jsx("td",{className:"p-3",children:c.jsxs("div",{className:"flex items-center gap-2",children:[y,c.jsx("span",{className:"text-sm text-white font-mono",children:m.key})]})}),c.jsx("td",{className:"p-3",children:c.jsx("span",{className:`text-sm font-mono break-all ${m.status==="removed"?"text-red-300":m.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(m.left)})}),c.jsx("td",{className:"p-3",children:c.jsx("span",{className:`text-sm font-mono break-all ${m.status==="added"?"text-green-300":m.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(m.right)})})]},m.key)})})]})})]})})})}function Z9e({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=ri(),i=Sn(),s=!!e?.setting_id,[a,o]=M.useState("common"),[l,u]=M.useState(e?.type||"filament"),[d,f]=M.useState(e?.name?s?e.name:`${e.name} (Copy)`:""),[g,m]=M.useState(e?.base_id||""),[x,y]=M.useState(""),[v,b]=M.useState(e?.setting||{inherits:""}),[E,S]=M.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,T]=M.useState(null),[P,C]=M.useState(""),[I,N]=M.useState(!1),[D,F]=M.useState(""),[L,q]=M.useState(!1),[R,V]=M.useState(Ree),[K,W]=M.useState(!1),[ne,Y]=M.useState(""),[Z,U]=M.useState(""),[$,ee]=M.useState(!0),[ae,fe]=M.useState(null),[ue,xe]=M.useState(!1),Me=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[l]||[],[n,l]),se=M.useMemo(()=>Me.filter(ce=>J0(ce.setting_id)),[Me]),{data:ve}=yt({queryKey:["cloudFields",l],queryFn:()=>Pe.getCloudFields(l==="print"?"process":l),staleTime:1e3*60*60}),{data:je}=yt({queryKey:["allPresetDetails",l,se.map(ce=>ce.setting_id).join(",")],queryFn:async()=>{const ce={};for(let $e=0;$e<se.length;$e+=5){const Ze=se.slice($e,$e+5);(await Promise.all(Ze.map(async Q=>{try{const Fe=await Pe.getCloudSettingDetail(Q.setting_id);return{id:Q.setting_id,detail:Fe}}catch{return null}}))).forEach(Q=>{Q&&(ce[Q.id]=Q.detail)})}return ce},enabled:se.length>0,staleTime:1e3*60*10}),{data:de,isLoading:ut}=yt({queryKey:["cloudSettingDetail",g],queryFn:()=>Pe.getCloudSettingDetail(g),enabled:!!g});M.useEffect(()=>{a!=="json"&&S(JSON.stringify(v,null,2))},[v,a]);const H=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[l]||[]).filter(Ye=>!J0(Ye.setting_id)).sort((Ye,$e)=>Ye.name.localeCompare($e.name)),[n,l]);M.useEffect(()=>{if(!g)return;const ce=H.find(Ye=>Ye.setting_id===g);ce&&(y(ce.name),s||(b({inherits:ce.name}),S(JSON.stringify({inherits:ce.name},null,2))))},[g,H,s]);const z=M.useMemo(()=>{const ce=ve?.fields||[],Ye=new Set(ce.map(Q=>Q.key)),$e=new Set,Ze=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);je&&Object.values(je).forEach(Q=>{Q?.setting&&Object.keys(Q.setting).forEach(Fe=>{!Ye.has(Fe)&&!Ze.has(Fe)&&$e.add(Fe)})}),Object.keys(v).forEach(Q=>{!Ye.has(Q)&&!Ze.has(Q)&&$e.add(Q)});const at=Array.from($e).sort().map(Q=>({key:Q,label:Q.replace(/_/g," ").replace(/\b\w/g,Fe=>Fe.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ce,...at]},[ve,je,v]),re=z.filter(ce=>ce.label.toLowerCase().includes(P.toLowerCase())||ce.key.toLowerCase().includes(P.toLowerCase())),G=()=>{if(D.trim()){const ce=D.trim().toLowerCase().replace(/\s+/g,"_");J(ce,""),F(""),q(!1),r(`Field "${ce}" added`)}},J=(ce,Ye)=>{b($e=>{const Ze={...$e};return Ye===""||Ye===void 0?delete Ze[ce]:Ze[ce]=Ye,Ze})},le=ce=>{b(Ye=>({...Ye,...ce.settings})),fe(ce.name),r("Template applied")},ke=()=>{if(!ne.trim())return;const ce={...v};if(delete ce.inherits,Object.keys(ce).length===0){r("No overrides to save","error");return}const Ye={id:Date.now().toString(),name:ne.trim(),description:Z.trim()||"Custom template",type:l,settings:ce,showInModal:$},$e=[...R,Ye];V($e),Dee($e),W(!1),Y(""),U(""),ee(!0),r("Template saved")},Ne=M.useMemo(()=>R.filter(ce=>ce.type===l&&ce.showInModal),[l,R]),we=ce=>{S(ce);try{const Ye=JSON.parse(ce);b(Ye),T(null)}catch(Ye){T(Ye.message)}},B=ce=>{ce.preventDefault(),N(!1);const Ye=ce.dataTransfer.files[0];if(Ye&&Ye.name.endsWith(".json")){const $e=new FileReader;$e.onload=Ze=>{try{const at=Ze.target?.result,Q=JSON.parse(at),Fe=Q.setting||Q;b(pe=>({...pe,...Fe})),S(JSON.stringify({...v,...Fe},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},$e.readAsText(Ye)}},j=_t({mutationFn:()=>{const ce={...v},Ye=l==="filament"?"filament_settings_id":l==="print"?"print_settings_id":"printer_settings_id";ce[Ye]=`"${d}"`;const $e={type:l,name:d,base_id:g,setting:ce};return Pe.createCloudSetting($e)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ce=>r(ce.message,"error")}),te=_t({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return Pe.updateCloudSetting(e.setting_id,{name:d,setting:v})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ce=>r(ce.message,"error")}),be=s?te:j,_e=de?.setting?.inherits,ge=_e?H.find(ce=>ce.name===_e):void 0,{data:me}=yt({queryKey:["cloudSettingDetail",ge?.setting_id],queryFn:()=>Pe.getCloudSettingDetail(ge.setting_id),enabled:!!ge?.setting_id}),Ae=M.useMemo(()=>{const ce=me?.setting||{},Ye=de?.setting||{},$e=g&&je?.[g]?.setting?je[g].setting:{};return{...ce,...Ye,...$e}},[g,de,me,je]),ze=ce=>{if(ce==null)return"";if(Array.isArray(ce)){const Ye=[...new Set(ce.map($e=>String($e)))];return Ye.length===1?Ye[0]:ce.join(", ")}return String(ce)},st=ce=>{const Ye=v[ce.key],$e=Ae[ce.key],Ze=ze($e),at=ut?"Loading...":Ze||"",Q="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(ce.type==="boolean"){const Fe=Ye==="1"||Ye===void 0&&$e==="1";return c.jsx("button",{type:"button",onClick:()=>J(ce.key,Ye==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Fe?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:c.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Fe?"translate-x-3.5":"translate-x-0.5"}`})})}return ce.type==="select"?c.jsxs("select",{value:Ye||"",onChange:Fe=>J(ce.key,Fe.target.value),className:Q,children:[c.jsx("option",{value:"",children:at}),ce.options?.map(Fe=>c.jsx("option",{value:Fe.value,children:Fe.label},Fe.value))]}):c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:ce.type==="number"?"number":"text",value:Ye!==void 0?String(Ye):"",onChange:Fe=>J(ce.key,Fe.target.value),step:ce.step,min:ce.min,max:ce.max,placeholder:at,className:Q}),ce.unit&&c.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ce.unit})]})},Ve=M.useMemo(()=>de?.setting?de.setting:{},[de]);return c.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ce=>{ce.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:B,children:[ue&&g&&c.jsx(Oee,{onClose:()=>xe(!1),leftPreset:Ve,rightPreset:v,leftLabel:`Base: ${x||g}`,rightLabel:`Current: ${d||"New Preset"}`}),c.jsx(Nt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:c.jsxs(Dt,{className:"p-0 flex flex-col h-full",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-semibold text-white",children:s?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[g&&c.jsxs("button",{onClick:()=>xe(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Compare with base preset",children:[c.jsx(Hp,{className:"w-4 h-4"}),"Compare"]}),c.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]})]}),I&&c.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:c.jsxs("div",{className:"text-center",children:[c.jsx(ma,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),c.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),c.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[c.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),c.jsxs("select",{value:l,onChange:ce=>{u(ce.target.value),m("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"filament",children:"Filament"}),c.jsx("option",{value:"print",children:"Process"}),c.jsx("option",{value:"printer",children:"Printer"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),c.jsxs("select",{value:g,onChange:ce=>m(ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"",children:"Select base preset..."}),H.map(ce=>c.jsx("option",{value:ce.setting_id,children:ce.name},ce.setting_id))]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),c.jsx("input",{type:"text",value:d,onChange:ce=>f(ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&c.jsx("div",{className:"text-xs text-bambu-gray",children:c.jsxs("p",{className:"flex items-center gap-1",children:[c.jsx(Ph,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",c.jsx("span",{className:"text-white",children:x}),ut&&c.jsx(At,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),c.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[c.jsxs("button",{onClick:()=>o("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(A5,{className:"w-4 h-4"}),"Common"]}),c.jsxs("button",{onClick:()=>o("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(bR,{className:"w-4 h-4"}),"All Fields"]}),c.jsxs("button",{onClick:()=>o("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(CG,{className:"w-4 h-4"}),"JSON",A&&c.jsx(Oo,{className:"w-3 h-3 text-red-400"})]}),c.jsx("div",{className:"flex-1"}),c.jsxs("button",{onClick:()=>{const ce={name:d,type:l,base_id:g,setting:v},Ye=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),$e=URL.createObjectURL(Ye),Ze=document.createElement("a");Ze.href=$e,Ze.download=`${d||"preset"}.json`,document.body.appendChild(Ze),Ze.click(),document.body.removeChild(Ze),URL.revokeObjectURL($e),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[c.jsx(ya,{className:"w-4 h-4"}),"Export"]}),c.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Import settings from JSON file",children:[c.jsx(ma,{className:"w-4 h-4"}),"Import"]}),c.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ce=>{const Ye=ce.target.files?.[0];if(Ye){const $e=new FileReader;$e.onload=Ze=>{try{const at=JSON.parse(Ze.target?.result),Q=at.setting||at;b(Fe=>({...Fe,...Q})),r("File imported")}catch{r("Invalid JSON","error")}},$e.readAsText(Ye)}}})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[a==="common"&&c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[c.jsx(h0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(v).filter(ce=>ce!=="inherits").length>0&&c.jsxs("button",{onClick:()=>W(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[c.jsx(To,{className:"w-3 h-3"}),"Save as template"]})]}),K&&c.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[c.jsx("input",{type:"text",value:ne,onChange:ce=>Y(ce.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),c.jsx("input",{type:"text",value:Z,onChange:ce=>U(ce.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ie,{size:"sm",onClick:ke,disabled:!ne.trim(),children:[c.jsx(To,{className:"w-3 h-3"}),"Save"]}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>W(!1),children:"Cancel"})]}),c.jsxs("button",{onClick:()=>ee(!$),className:`flex items-center gap-1.5 text-xs transition-colors ${$?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[$?c.jsx(o0,{className:"w-3.5 h-3.5"}):c.jsx(mR,{className:"w-3.5 h-3.5"}),$?"Show in modals":"Hidden in modals"]})]})]}),ae&&c.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[c.jsx(Ph,{className:"w-4 h-4 text-bambu-green"}),c.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",c.jsx("span",{className:"font-medium",children:ae})]}),c.jsx("button",{onClick:()=>fe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:c.jsx(Gt,{className:"w-4 h-4"})})]}),c.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ne.map(ce=>c.jsxs("button",{onClick:()=>le(ce),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[c.jsx("p",{className:"text-sm font-medium text-white",children:ce.name}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ce.description})]},ce.id)),Ne.length===0&&c.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:"No templates selected. Use the Templates button to enable templates for quick access."})]}),c.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),c.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:z.slice(0,10).map(ce=>c.jsxs("div",{className:"flex items-center justify-between gap-4",children:[c.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:ce.label}),c.jsx("div",{className:"w-48",children:st(ce)})]},ce.key))})]}),Object.keys(v).length>1&&c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([ce])=>ce!=="inherits").map(([ce,Ye])=>c.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[ce,": ",String(Ye).slice(0,20),c.jsx("button",{onClick:()=>J(ce,void 0),className:"hover:text-white",children:c.jsx(Gt,{className:"w-3 h-3"})})]},ce))})]})]}),a==="fields"&&c.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[c.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[c.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),c.jsx("span",{className:"text-xs text-bambu-gray",children:je?`${z.length} fields`:"Loading..."})]}),c.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[c.jsx(Qu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:P,onChange:ce=>C(ce.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[re.filter(ce=>!(ce.key in v)).map(ce=>{const Ye=Ae[ce.key],$e=ze(Ye);return c.jsxs("div",{onClick:()=>{b(Ze=>({...Ze,[ce.key]:$e||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"text-sm text-white truncate",children:ce.label}),c.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ce.key})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[$e&&c.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:$e,children:[$e.slice(0,20),$e.length>20?"...":""]}),c.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:c.jsx(fr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ce.key)}),re.filter(ce=>!(ce.key in v)).length===0&&c.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:P?"No matching fields":"All fields added"})]}),c.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:L?c.jsxs("div",{className:"flex gap-2",children:[c.jsx("input",{type:"text",value:D,onChange:ce=>F(ce.target.value),onKeyDown:ce=>ce.key==="Enter"&&G(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),c.jsx(Ie,{size:"sm",onClick:G,disabled:!D.trim(),children:c.jsx(fr,{className:"w-4 h-4"})}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>{q(!1),F("")},children:c.jsx(Gt,{className:"w-4 h-4"})})]}):c.jsxs("button",{onClick:()=>q(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[c.jsx(fr,{className:"w-4 h-4"}),"Add custom field"]})})]}),c.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[c.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),c.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(v).filter(ce=>ce!=="inherits").length," fields"]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([ce])=>ce!=="inherits").map(([ce,Ye])=>{const $e=z.find(Ze=>Ze.key===ce);return c.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-white",children:$e?.label||ce}),c.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ce})]}),c.jsx("button",{onClick:()=>J(ce,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:c.jsx(Gt,{className:"w-4 h-4"})})]}),$e?st($e):c.jsx("input",{type:"text",value:String(Ye),onChange:Ze=>J(ce,Ze.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},ce)}),Object.keys(v).filter(ce=>ce!=="inherits").length===0&&c.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[c.jsx(A5,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),c.jsx("p",{className:"text-sm",children:"No overrides yet"}),c.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(v).filter(ce=>ce!=="inherits").length>0&&c.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:c.jsxs("button",{onClick:()=>{W(!0),o("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[c.jsx(To,{className:"w-4 h-4"}),"Save as template"]})})]})]}),a==="json"&&c.jsxs("div",{className:"space-y-2",children:[A&&c.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[c.jsx(Oo,{className:"w-4 h-4"}),A]}),c.jsx("textarea",{value:E,onChange:ce=>we(ce.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),c.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[c.jsx(Ie,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{onClick:()=>be.mutate(),disabled:be.isPending||!d.trim()||!s&&!g||!!A,className:"flex-1",children:[be.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):s?c.jsx(To,{className:"w-4 h-4"}):c.jsx(fr,{className:"w-4 h-4"}),s?"Save":e?"Duplicate":"Create"]})]})]})})]})}function Q9e({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[s,a]=M.useState(""),[o,l]=M.useState("all"),[u,d]=M.useState("all"),[f,g]=M.useState("all"),[m,x]=M.useState("all"),[y,v]=M.useState("all"),[b,E]=M.useState("all"),[S,A]=M.useState(null),[T,P]=M.useState(!1),[C,I]=M.useState(!1),[N,D]=M.useState(null),[F,L]=M.useState(null),[q,R]=M.useState(null),[V,K]=M.useState(!1),[W,ne]=M.useState([null,null]),[Y,Z]=M.useState(!1),[U,$]=M.useState(null),ee=Sn(),ae=M.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:Gj(re.name)})),[t]),fe=M.useMemo(()=>{const z=new Set,re=new Set,G=new Set;return ae.forEach(J=>{J.meta.nozzle&&z.add(J.meta.nozzle),J.meta.filamentType&&re.add(J.meta.filamentType),J.meta.layerHeight&&G.add(J.meta.layerHeight)}),{printers:i.map(J=>({id:J.id.toString(),name:J.name})),nozzles:Array.from(z).sort((J,le)=>parseFloat(J)-parseFloat(le)),filaments:Array.from(re).sort(),layerHeights:Array.from(G).sort((J,le)=>parseFloat(J)-parseFloat(le))}},[ae,i]),ue=M.useMemo(()=>f==="all"?null:i.find(re=>re.id.toString()===f)?.model||null,[f,i]),xe=M.useMemo(()=>ae.filter(z=>o==="all"||z.type===o).filter(z=>{if(u==="all")return!0;const re=J0(z.setting_id);return u==="custom"?re:!re}).filter(z=>{if(f==="all"||!ue)return!0;const re=z.meta.printer?.toLowerCase()||"",G=ue.toLowerCase();return re.includes(G)||G.includes(re)}).filter(z=>m==="all"||z.meta.nozzle===m).filter(z=>y==="all"||z.meta.filamentType===y).filter(z=>b==="all"||z.meta.layerHeight===b).filter(z=>s===""||z.name.toLowerCase().includes(s.toLowerCase())).sort((z,re)=>z.name.localeCompare(re.name)),[ae,o,u,f,ue,m,y,b,s]),Me=z=>{if(V){const re=W[0]?.setting_id===z.setting_id,G=W[1]?.setting_id===z.setting_id;if(re)ne([W[1],null]);else if(G)ne([W[0],null]);else if(!W[0])ne([z,null]);else if(W[1]){if(W[0].type!==z.type)return;ne([W[0],z])}else{if(W[0].type!==z.type)return;ne([W[0],z])}}else A(z)},se=z=>{if(W[0]?.setting_id===z.setting_id)return 0;if(W[1]?.setting_id===z.setting_id)return 1},ve=async z=>{try{const re=await Pe.getCloudSettingDetail(z.setting_id),G=z.type==="process"?"print":z.type;D({type:G,name:z.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 z=>{try{ee.removeQueries({queryKey:["cloudSettingDetail",z.setting_id]});const re=await Pe.getCloudSettingDetail(z.setting_id),G=z.type==="process"?"print":z.type;L({type:G,name:z.name,base_id:re.base_id||"GFSA00",setting:re.setting||{},setting_id:z.setting_id}),A(null)}catch(re){console.error("Failed to fetch preset details for editing:",re)}},de=()=>{l("all"),d("all"),g("all"),x("all"),v("all"),E("all"),a("")},ut=o!=="all"||u!=="all"||f!=="all"||m!=="all"||y!=="all"||b!=="all"||s!=="",H=t.filament.length+t.printer.length+t.process.length;return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-4 mb-6",children:[c.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(Qu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:s,onChange:z=>a(z.target.value),placeholder:"Search presets...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ie,{variant:V?"primary":"secondary",onClick:()=>{V?(K(!1),ne([null,null])):K(!0)},children:[c.jsx(Hp,{className:"w-4 h-4"}),V?"Cancel":"Compare"]}),c.jsxs(Ie,{variant:"secondary",onClick:()=>I(!0),children:[c.jsx(h0,{className:"w-4 h-4"}),"Templates"]}),c.jsxs(Ie,{variant:"secondary",onClick:n,disabled:r,children:[c.jsx(qs,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),c.jsxs(Ie,{onClick:()=>P(!0),children:[c.jsx(fr,{className:"w-4 h-4"}),"New Preset"]})]})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsx(gR,{className:"w-4 h-4 text-bambu-gray"}),c.jsx(Ap,{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:z=>l(z)}),c.jsx(Ap,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:z=>d(z)}),fe.printers.length>0&&c.jsx(Ap,{label:"Printer",value:f,options:[{value:"all",label:"All"},...fe.printers.map(z=>({value:z.id,label:z.name}))],onChange:g}),fe.nozzles.length>0&&c.jsx(Ap,{label:"Nozzle",value:m,options:[{value:"all",label:"All"},...fe.nozzles.map(z=>({value:z,label:z}))],onChange:x}),fe.filaments.length>0&&(o==="all"||o==="filament")&&c.jsx(Ap,{label:"Filament",value:y,options:[{value:"all",label:"All"},...fe.filaments.map(z=>({value:z,label:z}))],onChange:v}),fe.layerHeights.length>0&&(o==="all"||o==="process")&&c.jsx(Ap,{label:"Layer",value:b,options:[{value:"all",label:"All"},...fe.layerHeights.map(z=>({value:z,label:z}))],onChange:E}),ut&&c.jsx("button",{onClick:de,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),V&&c.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx(Hp,{className:"w-5 h-5 text-blue-400"}),c.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),c.jsx("span",{className:"text-bambu-gray",children:W[0]?`Select another ${W[0].type} preset`:"Click two presets of the same type to compare"})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${W[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:W[0]?W[0].name:"1. Select first"}),c.jsx(i3,{className:"w-4 h-4 text-bambu-gray"}),c.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${W[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:W[1]?W[1].name:"2. Select second"})]}),W[0]&&W[1]&&c.jsxs(Ie,{size:"sm",onClick:async()=>{try{const[z,re]=await Promise.all([Pe.getCloudSettingDetail(W[0].setting_id),Pe.getCloudSettingDetail(W[1].setting_id)]);$([z.setting||{},re.setting||{}]),Z(!0)}catch{}},children:[c.jsx(Hp,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),c.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(ti,{className:"w-3 h-3"}),"Last synced: ",W9e(e.toISOString())]}),c.jsxs("span",{children:["Showing ",xe.length," of ",H," presets"]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),c.jsx("span",{children:"= My preset (editable)"})]})]}),xe.length===0?c.jsxs("div",{className:"text-center py-16",children:[c.jsx(Oh,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),c.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),ut&&c.jsx("button",{onClick:de,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[c.jsx(pR,{className:"w-4 h-4 text-amber-400"}),c.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),c.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(z=>z.type==="filament").length,")"]})]}),c.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(z=>z.type==="filament").map(z=>c.jsx($N,{setting:z,onClick:()=>Me(z),onDuplicate:()=>ve(z),compareMode:V,isCompareSelected:se(z)!==void 0,compareIndex:se(z),compareDisabled:V&&!!W[0]&&W[0].type!==z.type},z.setting_id)),xe.filter(z=>z.type==="filament").length===0&&c.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[c.jsx(vS,{className:"w-4 h-4 text-blue-400"}),c.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),c.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(z=>z.type==="process").length,")"]})]}),c.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(z=>z.type==="process").map(z=>c.jsx($N,{setting:z,onClick:()=>Me(z),onDuplicate:()=>ve(z),compareMode:V,isCompareSelected:se(z)!==void 0,compareIndex:se(z),compareDisabled:V&&!!W[0]&&W[0].type!==z.type},z.setting_id)),xe.filter(z=>z.type==="process").length===0&&c.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[c.jsx(jo,{className:"w-4 h-4 text-purple-400"}),c.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),c.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(z=>z.type==="printer").length,")"]})]}),c.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(z=>z.type==="printer").map(z=>c.jsx($N,{setting:z,onClick:()=>Me(z),onDuplicate:()=>ve(z),compareMode:V,isCompareSelected:se(z)!==void 0,compareIndex:se(z),compareDisabled:V&&!!W[0]&&W[0].type!==z.type},z.setting_id)),xe.filter(z=>z.type==="printer").length===0&&c.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),S&&c.jsx(X9e,{setting:S,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>ve(S),onEdit:()=>je(S)}),(T||N||F||q)&&c.jsx(Z9e,{onClose:()=>{P(!1),D(null),L(null),R(null)},initialData:F||N||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),C&&c.jsx(Y9e,{onClose:()=>I(!1),onApply:z=>{R({type:z.type,setting:z.settings}),I(!1)}}),Y&&U&&W[0]&&W[1]&&c.jsx(Oee,{onClose:()=>{Z(!1),$(null)},leftPreset:U[0],rightPreset:U[1],leftLabel:W[0].name,rightLabel:W[1].name})]})}function J9e(){const t=Sn(),{showToast:e}=ri(),[n,r]=M.useState("cloud"),[i,s]=M.useState(),{data:a,isLoading:o}=yt({queryKey:["cloudStatus"],queryFn:Pe.getCloudStatus}),{data:l=[]}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=yt({queryKey:["cloudSettings"],queryFn:()=>Pe.getCloudSettings(),enabled:!!a?.is_authenticated,retry:!1,staleTime:1e3*60*5});M.useEffect(()=>{g&&s(new Date(g))},[g]);const m=_t({mutationFn:Pe.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return o?c.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c.jsxs("div",{className:"p-6 lg:p-8",children:[c.jsxs("div",{className:"mb-6",children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),c.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),c.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[c.jsxs("button",{onClick:()=>r("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(gS,{className:"w-4 h-4"}),"Cloud Profiles"]}),c.jsxs("button",{onClick:()=>r("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(xR,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&c.jsxs(c.Fragment,{children:[a?.is_authenticated&&c.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),c.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",c.jsx("span",{className:"text-white",children:a.email})]})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>m.mutate(),disabled:m.isPending,children:[c.jsx(hle,{className:"w-4 h-4"}),"Logout"]})]}),a?.is_authenticated?d?c.jsx("div",{className:"flex items-center justify-center py-16",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?c.jsx(Q9e,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:l}):c.jsxs("div",{className:"text-center py-16",children:[c.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),c.jsx(Ie,{onClick:()=>f(),children:"Retry"})]}):c.jsx(q9e,{onSuccess:x})]}),n==="kprofiles"&&c.jsx(G9e,{}),c.jsx(K9e,{})]})}const Px={Droplet:pR,Flame:Aoe,Ruler:Qle,Sparkles:h0,Square:im,Cable:Mae,Wrench:Ju,Calendar:qr,Timer:Ou,Cog:Jae,Fan:moe,Zap:am,Wind:Yce,Thermometer:$p,Layers:Oh,Box:rm,Target:IG,RefreshCw:qs,Settings:wR,Filter:gR,CircleDot:Bae};function t0(t){return t&&Px[t]||Ju}function Tp(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 VN(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 eGe({item:t,onPerform:e,onToggle:n}){const r=t0(t.maintenance_type_icon),i=t.interval_type||"hours",a=(()=>{if(i==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),o=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",l=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${Tp(Math.abs(f),"days")}`:t.is_warning?`Due in ${Tp(f,"days")}`:`${Tp(f,"days")} left`}else return t.is_due?`Overdue by ${Tp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Tp(t.hours_until_due,"hours")}`:`${Tp(t.hours_until_due,"hours")} left`};return c.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsxs("div",{className:`relative p-2.5 rounded-lg ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[c.jsx(r,{className:`w-5 h-5 ${o()}`}),t.enabled&&(t.is_due||t.is_warning)&&c.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&c.jsx("span",{title:"Time-based interval",children:c.jsx(qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})})]}),c.jsx("div",{className:"mt-2 mb-1.5",children:c.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:c.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${l()}`,style:{width:`${a}%`}})})}),c.jsxs("div",{className:`text-xs flex items-center gap-1 ${o()}`,children:[t.is_due&&c.jsx(Qr,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&c.jsx(ti,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&c.jsx(Ph,{className:"w-3 h-3"}),d()]})]}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[c.jsx(Zn,{checked:t.enabled,onChange:f=>n(t.id,f)}),c.jsxs(Ie,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[c.jsx(Im,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function tGe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,s]=M.useState(!0),[a,o]=M.useState(!1),[l,u]=M.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((m,x)=>m.is_due&&!x.is_due?-1:!m.is_due&&x.is_due?1:m.is_warning&&!x.is_warning?-1:!m.is_warning&&x.is_warning?1:m.maintenance_type_id-x.maintenance_type_id),f=d.find(m=>m.enabled&&(m.is_due||m.is_warning)),g=()=>{const m=parseFloat(l);!isNaN(m)&&m>=0&&(r(t.printer_id,m),o(!1))};return c.jsxs(Nt,{className:"overflow-hidden",children:[c.jsxs("div",{className:"p-5",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),c.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&c.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[c.jsx(Qr,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&c.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[c.jsx(ti,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&c.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[c.jsx(Ph,{className:"w-3 h-3"}),"All good"]})]})]}),c.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[i?c.jsx(mS,{className:"w-4 h-4"}):c.jsx(ef,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),c.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:c.jsx(Ou,{className:"w-4 h-4 text-bambu-gray"})}),a?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",value:l,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&g(),m.key==="Escape"&&o(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),c.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),c.jsx(Ie,{size:"sm",onClick:g,children:"Save"}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"Cancel"})]}):c.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),o(!0)},className:"group",children:[c.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.floor(t.total_print_hours)," hours",c.jsx(d0,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),c.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),c.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const m=t0(f.maintenance_type_icon);return c.jsx(m,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),c.jsxs("div",{children:[c.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),c.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&c.jsx(Dt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:c.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(m=>c.jsx(eGe,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function nGe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s}){const[a,o]=M.useState(null),[l,u]=M.useState(""),[d,f]=M.useState("hours"),[g,m]=M.useState(!1),[x,y]=M.useState(""),[v,b]=M.useState("100"),[E,S]=M.useState("hours"),[A,T]=M.useState("Wrench"),[P,C]=M.useState(null),[I,N]=M.useState(""),[D,F]=M.useState(""),[L,q]=M.useState("hours"),[R,V]=M.useState("Wrench"),K=ee=>{C(ee),N(ee.name),F(ee.default_interval_hours.toString()),q(ee.interval_type||"hours"),V(ee.icon||"Wrench")},W=()=>{P&&I.trim()&&parseFloat(D)>0&&(i(P.id,{name:I.trim(),default_interval_hours:parseFloat(D),interval_type:L,icon:R}),C(null))},ne=(ee,ae,fe)=>{const ue=parseFloat(l);if(!isNaN(ue)&&ue>0){const xe=Math.abs(ue-ae)<.01?null:ue;n(ee,{custom_interval_hours:xe,custom_interval_type:d!==fe?d:null})}o(null)},Y=ee=>{ee.preventDefault(),x.trim()&&parseFloat(v)>0&&(r({name:x.trim(),default_interval_hours:parseFloat(v),interval_type:E,icon:A}),y(""),b("100"),S("hours"),m(!1))},Z=t?.map(ee=>({printerId:ee.printer_id,printerName:ee.printer_name,items:ee.maintenance_items.sort((ae,fe)=>ae.maintenance_type_id-fe.maintenance_type_id)})).sort((ee,ae)=>ee.printerName.localeCompare(ae.printerName))||[],U=e.filter(ee=>ee.is_system),$=e.filter(ee=>!ee.is_system);return c.jsxs("div",{className:"space-y-8",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),c.jsxs(Ie,{onClick:()=>m(!g),children:[c.jsx(fr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),g&&c.jsx(Nt,{className:"mb-6",children:c.jsx(Dt,{className:"py-4",children:c.jsxs("form",{onSubmit:Y,children:[c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[c.jsxs("div",{className:"lg:col-span-2",children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),c.jsx("input",{type:"text",value:x,onChange:ee=>y(ee.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),c.jsxs("select",{value:E,onChange:ee=>{S(ee.target.value),ee.target.value==="days"?b("30"):b("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"hours",children:"Print Hours"}),c.jsx("option",{value:"days",children:"Calendar Days"})]})]}),c.jsxs("div",{children:[c.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",E==="days"?"days":"hours",")"]}),c.jsx("input",{type:"number",value:v,onChange:ee=>b(ee.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),c.jsxs("div",{className:"mt-4 flex items-end justify-between",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),c.jsx("div",{className:"flex gap-1",children:Object.keys(Px).map(ee=>{const ae=Px[ee];return c.jsx("button",{type:"button",onClick:()=>T(ee),className:`p-2 rounded-lg transition-colors ${A===ee?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:c.jsx(ae,{className:"w-4 h-4"})},ee)})})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),c.jsx(Ie,{type:"submit",disabled:!x.trim(),children:"Add Type"})]})]})]})})}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[U.map(ee=>{const ae=t0(ee.icon),fe=ee.interval_type||"hours";return c.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:c.jsx(ae,{className:"w-5 h-5 text-bambu-gray"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-sm font-medium text-white truncate",children:ee.name}),c.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[fe==="days"?c.jsx(qr,{className:"w-3 h-3"}):c.jsx(Ou,{className:"w-3 h-3"}),VN(ee.default_interval_hours,fe)]})]})]})},ee.id)}),$.map(ee=>{const ae=t0(ee.icon),fe=ee.interval_type||"hours";return P?.id===ee.id?c.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:c.jsxs("div",{className:"space-y-3",children:[c.jsx("input",{type:"text",value:I,onChange:xe=>N(xe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("select",{value:L,onChange:xe=>q(xe.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"hours",children:"Print Hours"}),c.jsx("option",{value:"days",children:"Calendar Days"})]}),c.jsx("input",{type:"number",value:D,onChange:xe=>F(xe.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),c.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Px).map(xe=>{const Me=Px[xe];return c.jsx("button",{type:"button",onClick:()=>V(xe),className:`p-1.5 rounded transition-colors ${R===xe?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:c.jsx(Me,{className:"w-3.5 h-3.5"})},xe)})}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{size:"sm",onClick:W,disabled:!I.trim(),children:"Save"}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>C(null),children:"Cancel"})]})]})},ee.id):c.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:c.jsx(ae,{className:"w-5 h-5 text-bambu-green"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-white truncate",children:ee.name}),c.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),c.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[fe==="days"?c.jsx(qr,{className:"w-3 h-3"}):c.jsx(Ou,{className:"w-3 h-3"}),VN(ee.default_interval_hours,fe)]})]}),c.jsx("button",{onClick:()=>K(ee),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:c.jsx(d0,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>{confirm(`Delete "${ee.name}"?`)&&s(ee.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:c.jsx(kn,{className:"w-4 h-4"})})]})},ee.id)})]})]}),Z.length>0&&c.jsxs("div",{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),c.jsx("div",{className:"space-y-4",children:Z.map(ee=>c.jsx(Nt,{children:c.jsxs(Dt,{className:"py-4",children:[c.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:ee.printerName}),c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:ee.items.map(ae=>{const fe=t0(ae.maintenance_type_icon),ue=e.find(je=>je.id===ae.maintenance_type_id),xe=ue?.default_interval_hours||ae.interval_hours,Me=ue?.interval_type||"hours",se=ae.interval_type||"hours",ve=a===ae.id;return c.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[c.jsx(fe,{className:"w-4 h-4 text-bambu-gray shrink-0"}),c.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:ae.maintenance_type_name}),ve?c.jsxs("div",{className:"flex items-center gap-1",children:[d==="days"?c.jsx(qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):c.jsx(Ou,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),c.jsxs("select",{value:d,onChange:je=>f(je.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[c.jsx("option",{value:"hours",children:"Print Hours"}),c.jsx("option",{value:"days",children:"Calendar Days"})]}),c.jsx("input",{type:"number",value:l,onChange:je=>u(je.target.value),onKeyDown:je=>{je.key==="Enter"&&ne(ae.id,xe,Me),je.key==="Escape"&&o(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),c.jsx(Ie,{size:"sm",onClick:()=>ne(ae.id,xe,Me),children:"OK"})]}):c.jsxs("button",{onClick:()=>{o(ae.id),u(ae.interval_hours.toString()),f(se)},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:[se==="days"?c.jsx(qr,{className:"w-3 h-3"}):c.jsx(Ou,{className:"w-3 h-3"}),VN(ae.interval_hours,se),c.jsx(d0,{className:"w-3 h-3 text-bambu-gray"})]})]},ae.id)})})]})},ee.printerId))})]}),Z.length===0&&c.jsx(Nt,{children:c.jsxs(Dt,{className:"text-center py-12",children:[c.jsx(ti,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),c.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),c.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function rGe(){const t=Sn(),{showToast:e}=ri(),[n,r]=M.useState("status"),{data:i,isLoading:s}=yt({queryKey:["maintenanceOverview"],queryFn:Pe.getMaintenanceOverview}),{data:a}=yt({queryKey:["maintenanceTypes"],queryFn:Pe.getMaintenanceTypes}),o=_t({mutationFn:({id:E,notes:S})=>Pe.performMaintenance(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:E=>{e(E.message,"error")}}),l=_t({mutationFn:({id:E,data:S})=>Pe.updateMaintenanceItem(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:E=>{e(E.message,"error")}}),u=_t({mutationFn:Pe.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:E=>{e(E.message,"error")}}),d=_t({mutationFn:({id:E,data:S})=>Pe.updateMaintenanceType(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:E=>{e(E.message,"error")}}),f=_t({mutationFn:Pe.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:E=>{e(E.message,"error")}}),g=_t({mutationFn:({printerId:E,hours:S})=>Pe.setPrinterHours(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:E=>{e(E.message,"error")}}),m=E=>{o.mutate({id:E})},x=(E,S)=>{l.mutate({id:E,data:{enabled:S}})},y=(E,S)=>{g.mutate({printerId:E,hours:S})};if(s)return c.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((E,S)=>E+S.due_count,0)||0,b=i?.reduce((E,S)=>E+S.warning_count,0)||0;return c.jsxs("div",{className:"p-4 md:p-8",children:[c.jsxs("div",{className:"mb-6",children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),c.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?c.jsxs(c.Fragment,{children:[v>0&&c.jsxs("span",{className:"text-red-400",children:[v," task",v!==1?"s":""," overdue"]}),v>0&&b>0&&" · ",b>0&&c.jsxs("span",{className:"text-amber-400",children:[b," due soon"]}),v===0&&b===0&&c.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),c.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[c.jsx("button",{onClick:()=>r("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Status"}),c.jsx("button",{onClick:()=>r("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Settings"})]}),n==="status"?c.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((E,S)=>{const A=E.due_count*10+E.warning_count,T=S.due_count*10+S.warning_count;return A!==T?T-A:E.printer_name.localeCompare(S.printer_name)}).map(E=>c.jsx(tGe,{overview:E,onPerform:m,onToggle:x,onSetHours:y},E.printer_id)):c.jsx(Nt,{children:c.jsxs(Dt,{className:"text-center py-16",children:[c.jsx(Ju,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),c.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),c.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):c.jsx(nGe,{overview:i,types:a||[],onUpdateInterval:(E,S)=>l.mutate({id:E,data:S}),onAddType:E=>u.mutate(E),onUpdateType:(E,S)=>d.mutate({id:E,data:S}),onDeleteType:E=>f.mutate(E)})]})}const B9=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function iGe({project:t,onClose:e,onSave:n,isLoading:r}){const[i,s]=M.useState(t?.name||""),[a,o]=M.useState(t?.description||""),[l,u]=M.useState(t?.color||B9[0]),[d,f]=M.useState(t?.target_count?.toString()||""),[g,m]=M.useState(t?.status||"active"),x=y=>{y.preventDefault(),n({name:i.trim(),description:a.trim()||void 0,color:l,target_count:d?parseInt(d,10):void 0,...t&&{status:g}})};return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[c.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),c.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),c.jsx("input",{type:"text",value:i,onChange:y=>s(y.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Voron 2.4 Build",required:!0})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),c.jsx("textarea",{value:a,onChange:y=>o(y.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:"Optional description...",rows:2})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),c.jsx("div",{className:"flex gap-2 flex-wrap",children:B9.map(y=>c.jsx("button",{type:"button",onClick:()=>u(y),className:`w-8 h-8 rounded-full transition-transform ${l===y?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:y}},y))})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Print Count (optional)"}),c.jsx("input",{type:"number",value:d,onChange:y=>f(y.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 50 parts to print",min:"1"})]}),t&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),c.jsxs("select",{value:g,onChange:y=>m(y.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[c.jsx("option",{value:"active",children:"Active"}),c.jsx("option",{value:"completed",children:"Completed"}),c.jsx("option",{value:"archived",children:"Archived"})]})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),c.jsx(Ie,{type:"submit",disabled:!i.trim()||r,children:r?c.jsx(At,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function sGe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.progress_percent??0,s=t.status==="completed",a=t.status==="archived";return c.jsx(Nt,{className:"hover:border-bambu-gray/30 transition-colors cursor-pointer",onClick:e,children:c.jsxs(Dt,{className:"p-4",children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:t.color||"#6b7280"}}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-white",children:t.name}),t.description&&c.jsx("p",{className:"text-sm text-bambu-gray/70 mt-0.5 line-clamp-1",children:t.description})]})]}),c.jsxs("div",{className:"flex items-center gap-1",onClick:o=>o.stopPropagation(),children:[s&&c.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded",children:"Completed"}),a&&c.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded",children:"Archived"}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,className:"p-1",children:c.jsx(d0,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:r,className:"p-1 text-red-400 hover:text-red-300",children:c.jsx(kn,{className:"w-4 h-4"})})]})]}),t.target_count&&c.jsxs("div",{className:"mb-3",children:[c.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[c.jsxs("span",{children:[t.archive_count," / ",t.target_count," prints"]}),c.jsxs("span",{children:[i.toFixed(0),"%"]})]}),c.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full transition-all duration-300",style:{width:`${Math.min(i,100)}%`,backgroundColor:i>=100?"#22c55e":t.color||"#6b7280"}})})]}),t.archives&&t.archives.length>0&&c.jsx("div",{className:"mb-3",children:c.jsxs("div",{className:"flex gap-2",children:[t.archives.slice(0,5).map(o=>c.jsxs("a",{href:`/archives?search=${encodeURIComponent(o.print_name||"")}`,onClick:l=>l.stopPropagation(),className:"relative w-14 h-14 rounded-lg bg-bambu-dark flex-shrink-0 overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:o.print_name||"Unknown",children:[o.thumbnail_path?c.jsx("img",{src:`/api/v1/archives/${o.id}/thumbnail`,alt:o.print_name||"",className:"w-full h-full object-cover"}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:c.jsx(u0,{className:"w-6 h-6"})}),o.status==="failed"&&c.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:c.jsx("span",{className:"text-white text-xs font-bold",children:"✗"})})]},o.id)),t.archive_count>5&&c.jsxs("div",{className:"w-14 h-14 rounded-lg bg-bambu-dark flex-shrink-0 flex items-center justify-center text-sm text-bambu-gray border border-bambu-dark-tertiary",children:["+",t.archive_count-5]})]})}),c.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[c.jsxs("div",{className:"flex items-center gap-1",title:"Archives",children:[c.jsx(pS,{className:"w-4 h-4"}),c.jsx("span",{children:t.archive_count})]}),c.jsxs("div",{className:"flex items-center gap-1",title:"Queued",children:[c.jsx(ole,{className:"w-4 h-4"}),c.jsx("span",{children:t.queue_count})]})]})]})})}function aGe(){const t=Sn(),{showToast:e}=ri(),[n,r]=M.useState(!1),[i,s]=M.useState(),[a,o]=M.useState("active"),[l,u]=M.useState(null),{data:d,isLoading:f}=yt({queryKey:["projects",a==="all"?void 0:a],queryFn:()=>Pe.getProjects(a==="all"?void 0:a)}),g=_t({mutationFn:A=>Pe.createProject(A),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),e("Project created","success")},onError:A=>{e(A.message,"error")}}),m=_t({mutationFn:({id:A,data:T})=>Pe.updateProject(A,T),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),s(void 0),e("Project updated","success")},onError:A=>{e(A.message,"error")}}),x=_t({mutationFn:A=>Pe.deleteProject(A),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),u(null),e("Project deleted","success")},onError:A=>{e(A.message,"error")}}),y=A=>{i?m.mutate({id:i.id,data:A}):g.mutate(A)},v=A=>{s(A),r(!0)},b=A=>{v(A)},E=A=>{u(A)},S=()=>{l!==null&&x.mutate(l)};return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(ph,{className:"w-6 h-6 text-bambu-green"}),c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Projects"})]}),c.jsxs(Ie,{onClick:()=>r(!0),children:[c.jsx(fr,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),c.jsx("div",{className:"flex gap-2",children:["active","completed","archived","all"].map(A=>c.jsx("button",{onClick:()=>o(A),className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${a===A?"bg-bambu-green text-white":"bg-bambu-card text-bambu-gray hover:bg-bambu-gray/20"}`,children:A.charAt(0).toUpperCase()+A.slice(1)},A))}),f?c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green"})}):d?.length===0?c.jsx(Nt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(ph,{className:"w-12 h-12 text-bambu-gray/50 mx-auto mb-4"}),c.jsx("p",{className:"text-bambu-gray",children:"No projects found"}),c.jsx("p",{className:"text-bambu-gray/70 text-sm mt-1",children:"Create a project to group related prints together"})]})}):c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:d?.map(A=>c.jsx(sGe,{project:A,onClick:()=>b(A),onEdit:()=>v(A),onDelete:()=>E(A.id)},A.id))}),l!==null&&c.jsx(Kr,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:S,onCancel:()=>u(null)}),n&&c.jsx(iGe,{project:i,onClose:()=>{r(!1),s(void 0)},onSave:y,isLoading:g.isPending||m.isPending})]})}function oGe(){const{printerId:t}=lG(),e=parseInt(t||"0",10),[n,r]=M.useState("stream"),[i,s]=M.useState(!1),[a,o]=M.useState(!0),[l,u]=M.useState(Date.now()),[d,f]=M.useState(!1),[g,m]=M.useState(!1),x=M.useRef(null),y=M.useRef(null),{data:v}=yt({queryKey:["printer",e],queryFn:()=>Pe.getPrinter(e),enabled:e>0});M.useEffect(()=>(v&&(document.title=`${v.name} - Camera`),()=>{document.title="Bambuddy"}),[v]),M.useEffect(()=>()=>{x.current&&(x.current.src="")},[]),M.useEffect(()=>{if(a&&!d){const N=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(N)}},[n,a,l,d]),M.useEffect(()=>{const I=()=>{m(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",I),()=>document.removeEventListener("fullscreenchange",I)},[]);const b=()=>{s(!0),o(!1)},E=()=>{o(!1),s(!1)},S=I=>{n===I||d||(f(!0),o(!0),s(!1),x.current&&(x.current.src=""),setTimeout(()=>{r(I),u(Date.now()),f(!1)},100))},A=()=>{d||(f(!0),o(!0),s(!1),x.current&&(x.current.src=""),setTimeout(()=>{u(Date.now()),f(!1)},100))},T=()=>{y.current&&(document.fullscreenElement?document.exitFullscreen():y.current.requestFullscreen())},P=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${l}`:`/api/v1/printers/${e}/camera/snapshot?t=${l}`,C=a||d;return e?c.jsxs("div",{ref:y,className:"min-h-screen bg-black flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[c.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[c.jsx(a0,{className:"w-4 h-4"}),v?.name||`Printer ${e}`]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[c.jsx("button",{onClick:()=>S("stream"),disabled:C,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),c.jsx("button",{onClick:()=>S("snapshot"),disabled:C,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),c.jsx("button",{onClick:A,disabled:C,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:c.jsx(qs,{className:`w-4 h-4 text-bambu-gray ${C?"animate-spin":""}`})}),c.jsx("button",{onClick:T,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?c.jsx(Ale,{className:"w-4 h-4 text-bambu-gray"}):c.jsx(yle,{className:"w-4 h-4 text-bambu-gray"})})]})]}),c.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:c.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(a||d)&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:c.jsxs("div",{className:"text-center",children:[c.jsx(qs,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),i&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:c.jsxs("div",{className:"text-center p-4",children:[c.jsx(Qr,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),c.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),c.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),c.jsx("button",{onClick:A,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),c.jsx("img",{ref:x,src:P,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:P?b:void 0,onLoad:P?E:void 0},l)]})})]}):c.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:c.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function lGe(){const{id:t}=lG(),{theme:e}=yS(),{data:n,isLoading:r,error:i}=yt({queryKey:["external-link",t],queryFn:()=>Pe.getExternalLink(Number(t)),enabled:!!t});return r?c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[c.jsx(Qr,{className:"w-12 h-12"}),c.jsx("p",{children:"Link not found"})]}):c.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function cGe(){const t=M.useRef(null),e=M.useRef(null),n=Sn(),[r,i]=M.useState(!1),s=M.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const u=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,d=new WebSocket(u);let f=null;d.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),f=window.setInterval(()=>{d.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"}))},3e4)},d.onmessage=g=>{try{const m=JSON.parse(g.data);a(m)}catch{}},d.onclose=g=>{console.log("[WebSocket] Closed",g.code,g.reason),f&&(clearInterval(f),f=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{s()},3e3)},d.onerror=g=>{console.error("[WebSocket] Error",g),d.close()},t.current=d},[]),a=M.useCallback(l=>{switch(l.type){case"printer_status":l.printer_id!==void 0&&n.setQueryData(["printerStatus",l.printer_id],u=>{const d={...u,...l.data};return d.wifi_signal==null&&u?.wifi_signal!=null&&(d.wifi_signal=u.wifi_signal),d});break;case"print_complete":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break;case"archive_created":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break}},[n]);M.useEffect(()=>(s(),()=>{e.current&&clearTimeout(e.current),t.current&&t.current.close()}),[s]);const o=M.useCallback(l=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(l))},[]);return{isConnected:r,sendMessage:o}}const uGe=new Wse({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function dGe({children:t}){return cGe(),c.jsx(c.Fragment,{children:t})}function hGe(){return c.jsx(iue,{children:c.jsx(pue,{children:c.jsx(qse,{client:uGe,children:c.jsx(dGe,{children:c.jsx(pse,{children:c.jsxs(Gie,{children:[c.jsx(La,{path:"/camera/:printerId",element:c.jsx(oGe,{})}),c.jsxs(La,{path:"/",element:c.jsx(due,{}),children:[c.jsx(La,{index:!0,element:c.jsx(Wue,{})}),c.jsx(La,{path:"archives",element:c.jsx(yNe,{})}),c.jsx(La,{path:"queue",element:c.jsx(ske,{})}),c.jsx(La,{path:"stats",element:c.jsx(E9e,{})}),c.jsx(La,{path:"profiles",element:c.jsx(J9e,{})}),c.jsx(La,{path:"maintenance",element:c.jsx(rGe,{})}),c.jsx(La,{path:"projects",element:c.jsx(aGe,{})}),c.jsx(La,{path:"settings",element:c.jsx(H9e,{})}),c.jsx(La,{path:"external/:id",element:c.jsx(lGe,{})})]})]})})})})})})}Xne.createRoot(document.getElementById("root")).render(c.jsx(M.StrictMode,{children:c.jsx(hGe,{})}));
|